MuxDemuxIO Class Reference

muxes/demuxes from/to containers to elementary-stream BufferIOs <short description=""> More...

#include <MuxDemuxIO.hpp>

Inheritance diagram for MuxDemuxIO:

IO VThread VITMuxDemuxIO List of all members.

Public Member Functions

 MuxDemuxIO (ByteStream *stream)
virtual bool addBufferedIO (int streamID, BufferedIO *bufIO)
 used by writeFrame to add the correct streamID for each frame
virtual bool removeBufferedIO (int streamID, BufferedIO *bufIO)
 used by BufferedIO::close to remove the correct streamID when finishing
virtual int getNumberOfConnectedBufferedIO ()
virtual FramegetFrame ()
 returns a frame and forwards it to the correct BufferIO This function is typically blocking.
virtual int writeFrame (Frame *frm, ESInfo *out_es=NULL)
 muxes a frame to the container
virtual void processFrame ()
 give the MuxDemuxIO the chance to do mux/demux (called by fferedIOs)
bool open ()
 opens the IO connection.
bool close (bool immediate=false)
 closes the IO class.
bool destroy ()
 deletes the elementary stream and its extra hint-file
int getBufferFillLevel () const
 returns a value from 0..100 indicating buffer usage.
IOclone () const
const char * getURL () const
 returns a local file name or an URL
void setESInfo (ESInfo *esi)
ESInfogetESInfo ()

Protected Member Functions

virtual void processWriteFrame ()
 give the MuxDemuxIO the chance to query the BufferIOs for new muxing data
virtual void processReadFrame ()
 let the MuxDemuxIO read frames and demux/pass them to the correct BufferIOs

Protected Attributes

bool readOnly
map< int, BufferedIO * > ioList
VMutexmutex
bool firstFrame
ByteStreamstream

Detailed Description

muxes/demuxes from/to containers to elementary-stream BufferIOs <short description="">

Author:
Michael Kropfberger
Version:
Id
MuxDemuxIO.hpp,v 1.9 2006/02/24 13:47:42 mkropfbe Exp

Definition at line 67 of file MuxDemuxIO.hpp.


Member Function Documentation

bool MuxDemuxIO::close bool  immediate = false  )  [virtual]
 

closes the IO class.

Parameters:
immediate specifies, if (optional) buffered data should be read/sent to the client (==false), or immediately dumped (==true)

Implements IO.

Definition at line 102 of file MuxDemuxIO.cpp.

References ByteStream::close().

Referenced by destroy().

00102 { 00103 state = CLOSING; 00104 stream->close(); 00105 state = CLOSED; 00106 return true; 00107 }

int MuxDemuxIO::getBufferFillLevel  )  const [inline, virtual]
 

returns a value from 0..100 indicating buffer usage.

Fixme: returns a constant value of 50

Implements IO.

Definition at line 106 of file MuxDemuxIO.hpp.

00106 { return 50; };

Frame * MuxDemuxIO::getFrame  )  [virtual]
 

returns a frame and forwards it to the correct BufferIO This function is typically blocking.

Don't use a NULL return valuse to conclude STREAMEOF, always check with getState()!

Implements IO.

Reimplemented in VITMuxDemuxIO.

Definition at line 154 of file MuxDemuxIO.cpp.

Referenced by processReadFrame().

00154 { 00155 if (!readOnly || state != OPEN) 00156 return NULL; 00157 00158 #ifdef _POSIX_PRIORITY_SCHEDULING 00159 sched_yield(); //this is necessary to give parallel getFrames a chance 00160 #endif 00161 00162 return NULL; 00163 }

bool MuxDemuxIO::open  )  [virtual]
 

opens the IO connection.

State is set to OPENING. When the connection is ready for use, State is OPEN

Implements IO.

Definition at line 79 of file MuxDemuxIO.cpp.

References ByteStream::open().

Referenced by VITMuxDemuxIO::getFrame(), BufferedIO::open(), VITMuxDemuxIO::writeFrame(), and writeFrame().

00079 { 00080 dprintf_full("MuxDemuxIO::open(), working with %i BufferedIOs \n",ioList.size()); 00081 assert(stream); 00082 if(state==OPEN) 00083 return true; 00084 00085 bool ret = false; 00086 state = OPENING; 00087 00088 ret = stream->open(); 00089 00090 if (ret) 00091 state = OPEN; 00092 else 00093 state = CLOSED; 00094 00095 currentFrameNumber=0; 00096 framesSeen=0; 00097 00098 return ret; 00099 }

int MuxDemuxIO::writeFrame Frame frm,
ESInfo out_es = NULL
[virtual]
 

muxes a frame to the container

Returns -1 on error

Implements IO.

Reimplemented in VITMuxDemuxIO.

Definition at line 117 of file MuxDemuxIO.cpp.

References Frame::getAU(), ESInfo::getStreamId(), and open().

Referenced by processWriteFrame().

00117 { 00118 dprintf_full("MuxDemuxIO::writeFrame %p\n",frm); 00119 00120 if (state != OPEN) 00121 this->open(); 00122 00123 if (state != OPEN) { 00124 dprintf_err("MuxDemuxIO::writeFrame: Stream not open!\n"); 00125 return 0; 00126 } 00127 00128 if (firstFrame) { 00129 firstFrame=false; 00130 //write Container Header to file 00131 } 00132 00133 dprintf_full("MuxDemuxIO::writeFrame: writing frame CTS %i size %i from streamID %lli to container\n", 00134 frm->getAU()->cts, frm->getAU()->size, out_es->getStreamId()); 00135 00136 // forwarding the frame to container file 00137 00138 00139 framesSeen++; 00140 00141 #ifdef _POSIX_PRIORITY_SCHEDULING 00142 sched_yield(); //this is necessary to give parallel getFrames a chance 00143 #endif 00144 00145 return true; 00146 }


The documentation for this class was generated from the following files: