/* 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_UNBUFFERED_SINK_CONTROLLER_HPP_
#define _NMM_UNBUFFERED_SINK_CONTROLLER_HPP_

#include "nmm/nmm_prefix.hpp"

#include "SinkController.hpp"

namespace NMM {

  class GenericUSyncSinkNode;
  class AudioVideoSynchronizer;

  //! This class represents a synchronization controller for sink nodes.
  /*!
   *  In addition to the isBufferValid - method from controller, a 
   *  sinkcontroller has a waitToPresent - method which allows it to
   *  tell the sink node how long it should wait before presenting the 
   *  next buffer.
   */
  class USinkController : public SinkController {
  private:
    GenericUSyncSinkNode* node;
    
  public:
    //! Constructor that only sets the mode.
    /*!
     *  The name is "Controller" as default.
     */
    USinkController(const IController::Mode mode);

    //! The main constructor.
    /*!
     *  Sets the name and the mode, default values are "Controller" and
     *  DEFAULT_MODE (OFFLINE).
     */
    USinkController(GenericUSyncSinkNode* parent = 0, 
		    const IController::Mode mode = Controller::DEFAULT_MODE);

    //! The main destructor.
    virtual ~USinkController();

    //! This method is by a Controller::isBufferValid - call. 
    /*!
     *  It checks if the buffer should be prepared for presenatation or discarded. 
     */
    virtual bool checkBufferValid(const Timestamp timestamp);

    //! Tells the node how long it should wait until presenting the next buffer.
    /*!
     *  This method is called by the GenericSyncSinkNode to get to know how long
     *  it has to wait until the optimal time for presentation of this buffer 
     *  will be reached.
     *  \param timestamp The timestamp of the buffer that should be presented.
     *  \return An interval which represents the time to wait.
     */
    Interval waitToPresent(const Timestamp timestamp); 
  };

}

#include "nmm/nmm_suffix.hpp"

#endif // _NMM_UNBUFFERED_SINK_CONTROLLER_HPP_
