/* 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_AVDEMUXNODE_HPP
#define NMM_AVDEMUXNODE_HPP NMM_AVDEMUXNODE_HPP

#include "nmm/nmm_prefix.hpp"

#include "nmm/plugins/interfaces/ISetBufferLabelImpl.hpp"
#include "nmm/multimedia/GenericDemultiplexerNode.hpp"

#include "visibility.hpp"

namespace NMM {
  
  /**
   * Audio/Video Demultiplexer.
   * This node receives muxed audio and video buffers and events and sends each to the proper
   * output stream ("video" or "audio"). Labels are used to tell to which output stream a
   * message belongs. These labels are defined by the predecessor node by sending setBufferLabel events.
   */
  class AVDemuxNode :
    public GenericDemultiplexerNode,
    public ISetBufferLabelImpl
  {
  private:
    int buf_count;
    unsigned int labelnum_video;
    unsigned int labelnum_audio;
    
    // ISetBufferLabel interface
    virtual Result setBufferLabel(const string& label_name, const nmm_int32& label_num);

  protected:
    virtual Result doInit();
    virtual Result doDeinit();
    virtual Result doInitOutput();
    virtual Result doDeinitOutput();
    
  public:

    AVDemuxNode(const char *name = "AVDemuxNode", StreamQueue::Mode = StreamQueue::MODE_SUSPEND, int = 20);
    ~AVDemuxNode() {};

    virtual Message *processBuffer (Buffer *);
    
    virtual Result processCEvent (CEvent *);
  };

}

#include "nmm/nmm_suffix.hpp"

#endif //NMM_AVDEMUXNODE_HPP



