/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *
 * This file is part of NMM. 
 * 
 * NMM is free software; you can redistribute it and/or modify it    
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; only version 2 of the License.      
 * 
 * NMM is distributed in the hope that it will be useful, but WITHOUT 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 
 * License for more details.  
 * 
 * You should have received a copy of the GNU General Public License 
 * along with NMM; if not, write to the Free Software Foundation,    
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

#ifndef NMM_IMasterSlaveSourceSynchronizerImpl_HPP
#define NMM_IMasterSlaveSourceSynchronizerImpl_HPP

#include "nmm/nmm_prefix.hpp"

#include "nmm/comm/NMMObject.hpp"
#include "IMasterSlaveSourceSynchronizer.hpp"

#include "ISourceSynchronizerImpl.hpp"

#include "visibility.hpp"

namespace NMM
{
  /** Interface of a master-slave source synchronizer.
   * This the interface of a synchronizer which performs inter-stream synchronization between
   * one master and multiple slave sources.
   *
   * Source synchronizers are needed in recording applications where audio and video need to be
   * recorded synchronously. It is not used for synchronizing sources with sinks.
   */

  class DLLEXPORT IMasterSlaveSourceSynchronizerImpl  : virtual public ISourceSynchronizerImpl { 
  public:
    IMasterSlaveSourceSynchronizerImpl() { addInterface(new IMasterSlaveSourceSynchronizer(*this)); registerEvents(); };

    virtual ~IMasterSlaveSourceSynchronizerImpl() {};

  protected:
    /** Set the start delay.
     * This method sets the time interval to wait before starting after start() is called.
     * This allows the MasterSlaveSourceSynchronizer to tell its controllers the
     * delay time.
     * With the help of a start delay, the nodes
     * are told to start at the current time + delay to avoid scheduling
     * problems (as one node would always be started some time after the other).
     * This is done by calling the setStartTime() method of the controllers
     * with (current_time + delay).
     *
     * @param interval Start delay
     * @return SUCCESS
     */

    virtual Result setStartDelay(const Interval& interval) = 0;
    /** Set the master audio source controller.
     *
     * @param value Interface of the master audio source controller
     * @return SUCCESS
     */

    virtual Result setMasterController(const ISourceController* value) = 0;
    /** Add a slave source controller.
     *
     * @param value Interface of the slave source controller
     * @return SUCCESS
     */

    virtual Result addSlaveController(const ISourceController* value) = 0;
    /** Remove a slave source controller.
     *
     * @param value Interface of the slave source controller
     * @return SUCCESS
     */

    virtual Result removeSlaveController(const ISourceController* value) = 0;
    /** Reset the synchronizer.
     *
     * @return SUCCESS
     */

    virtual Result resetAll() = 0;


  private:
    void registerEvents();
  };

}

#include "nmm/nmm_suffix.hpp"

#endif
