/* 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_IMasterSlaveSourceSynchronizer_HPP
#define NMM_IMasterSlaveSourceSynchronizer_HPP

#include "nmm/nmm_prefix.hpp"

#include "nmm/comm/Interface.hpp"
#include "nmm/comm/messaging/Event.hpp"
#include "nmm/comm/messaging/IllegalStateException.hpp"
#include <memory>

#include "ISourceSynchronizer.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 IMasterSlaveSourceSynchronizer : virtual public ISourceSynchronizer { 
  public:
    IMasterSlaveSourceSynchronizer() : NMM::Interface(IMasterSlaveSourceSynchronizer::IMasterSlaveSourceSynchronizer_type, "NMM") { };

    IMasterSlaveSourceSynchronizer(NMM::NMMObject& parent) : NMM::Interface (parent, IMasterSlaveSourceSynchronizer::IMasterSlaveSourceSynchronizer_type, "NMM") { };

    virtual ~IMasterSlaveSourceSynchronizer() {};

    static const char* IMasterSlaveSourceSynchronizer_type;

    virtual  string getInterfaceType() const { return IMasterSlaveSourceSynchronizer_type; }

    NMM::Interface* copy() const { return new IMasterSlaveSourceSynchronizer(*this); }
    static void used(); 
    static const char* setStartDelay_event;
    static const char* setMasterController_event;
    static const char* addSlaveController_event;
    static const char* removeSlaveController_event;
    static const char* resetAll_event;
    /** 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)
      throw(const NMM::SerializedException&);
    /** Set the master audio source controller.
     *
     * @param value Interface of the master audio source controller
     * @return SUCCESS
     */

    virtual Result setMasterController(const ISourceController* value)
      throw(const NMM::SerializedException&);
    /** Add a slave source controller.
     *
     * @param value Interface of the slave source controller
     * @return SUCCESS
     */

    virtual Result addSlaveController(const ISourceController* value)
      throw(const NMM::SerializedException&);
    /** Remove a slave source controller.
     *
     * @param value Interface of the slave source controller
     * @return SUCCESS
     */

    virtual Result removeSlaveController(const ISourceController* value)
      throw(const NMM::SerializedException&);
    /** Reset the synchronizer.
     *
     * @return SUCCESS
     */

    virtual Result resetAll()
      throw(const NMM::SerializedException&);


  };

  typedef auto_ptr<IMasterSlaveSourceSynchronizer> IMasterSlaveSourceSynchronizer_var;




}

#include "nmm/nmm_suffix.hpp"

#endif
