FilteredIO Class Reference

<class description="" goes="" here=""> <short description=""> More...

#include <FilteredIO.hpp>

Inheritance diagram for FilteredIO:

IO VThread List of all members.

Public Member Functions

 FilteredIO (IO *io, BitField *filter)
 Note that the get-/writeFrame() functions of this class will only return the frames from the underlying io class where the corresponding entry in BitField is 1!
FramegetFrame ()
 returns a frame if one complete frame is available, otherwise null is returned.
int writeFrame (Frame *frm, ESInfo *out_es=NULL)
 returns the number of packets sent.
bool open ()
 opens the IO connection.
bool close (bool immediate=false)
 closes the IO class.
bool destroy ()
 deletes the data source for this IO class.
State getState () const
State setState (State s)
 returns the newly set state
int getBufferFillLevel () const
 returns a value from 0..100 indicating buffer usage
int flushBuffer (long from_ts=0, long to_ts=-1)
 flushes the buffer from starting TimeStamp to end TS
const char * getURL () const
 returns a pointer to the local file name or an URL
bool setToFrameNumber (u32 frameNumber)
 repositions the IO class to the given frame.
virtual u32 getCurrentFrameNumber () const
 Returns the current frame number of the associated IO object.
virtual bool setEndFrameNumber (u32 stopNumber)
 Sets the end frame number of the associated IO object.
virtual u32 getEndFrameNumber () const
 Returns the end frame number of the associated IO object.
void setResendFrameHeader (bool set)
 indicates if the next call to getFrame will send the frame header.
void run ()
void setESInfo (ESInfo *es)
ESInfogetESInfo ()
long setToClosestIFrame (u32 frameNumber, bool backwards)
 repositions the IO class to
bool setBitField (BitField *b)
 deletes the old BitField and sets a new one, returns false if the old and new BitField differ in size
virtual u32 getFramesSeen () const
 returns the number of frames received or sent.
void setRtxInfo (const rtx_info *rtx)
 sets a shallow copy of
State play (double prefetchTime=0.0)
State pause ()
State mute ()

Protected Attributes

IOio
BitFieldfilter

Detailed Description

<class description="" goes="" here=""> <short description="">

Author:
Michael Kropfberger and Peter Schojer
Version:
Id
FilteredIO.hpp,v 1.14 2006/01/26 11:42:00 mkropfbe Exp

Definition at line 62 of file FilteredIO.hpp.


Member Function Documentation

bool FilteredIO::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 136 of file FilteredIO.cpp.

References IO::close().

00137 { 00138 return io->close(immediate); 00139 };

bool FilteredIO::destroy  )  [virtual]
 

deletes the data source for this IO class.

Will only work with local files, remote files can not be deleted and will always return true.

Implements IO.

Definition at line 150 of file FilteredIO.cpp.

References IO::destroy().

00151 { 00152 return io->destroy(); 00153 };

int FilteredIO::flushBuffer long  from_ts = 0,
long  to_ts = -1
[virtual]
 

flushes the buffer from starting TimeStamp to end TS

Parameters:
from_ts: 0 is beginning, everything else is somewhere in the stream
to_ts: -1 is ending, everything else is somewhere in the stream
Returns:
the number of freed bytes

Reimplemented from IO.

Definition at line 177 of file FilteredIO.cpp.

References IO::flushBuffer().

00178 { 00179 return io->flushBuffer(from_ts,to_ts); 00180 };

Frame * FilteredIO::getFrame  )  [virtual]
 

returns a frame if one complete frame is available, otherwise null is returned.

This function is typically blocking. Don't use a NULL return value to conclude STREAMEOF, always check with getState()!

Implements IO.

Definition at line 72 of file FilteredIO.cpp.

References Frame::getAU(), BitField::getBit(), IO::getESInfo(), IO::getFrame(), IO::getState(), and ESInfo::getVOPTimeIncrement().

00072 { 00073 Frame* frm = NULL; 00074 bool stop = false; 00075 u32 vopTimeIncrement = io->getESInfo()->getVOPTimeIncrement(); 00076 do { 00077 frm=io->getFrame(); 00078 if(frm) { 00079 if(filter->getBit(frm->getAU()->cts/vopTimeIncrement) || (frm->getAU()->cts==0)) 00080 stop=true; 00081 else { 00082 dprintf_full("FilteredIO::getFrame: throwing away CTS %i VopIncr %i\n",frm->getAU()->cts,vopTimeIncrement); 00083 delete frm; 00084 frm=NULL; 00085 } 00086 } 00087 } while(!stop && io->getState()!=IO::STREAMEOF && io->getState()!=IO::CLOSED && 00088 io->getState()!=IO::CLOSING && io->getState()!=IO::STREAMERR); 00089 framesSeen++; 00090 00091 #ifdef _POSIX_PRIORITY_SCHEDULING 00092 sched_yield(); 00093 #else 00094 // for windows pthread lib! 00095 #ifdef WIN32 00096 #ifndef WINCE 00097 sched_yield(); 00098 #else 00099 Sleep(0); 00100 #endif 00101 #endif 00102 #endif 00103 dprintf_full("FilteredIO::getFrame() CTS %u\n",frm?frm->getAU()->cts:0); 00104 return frm; 00105 };

virtual u32 FilteredIO::getFramesSeen  )  const [inline, virtual]
 

returns the number of frames received or sent.

counter will be resetted when open is called

Reimplemented from IO.

Definition at line 169 of file FilteredIO.hpp.

00169 { return framesSeen;};

bool FilteredIO::open  )  [virtual]
 

opens the IO connection.

State is set to OPENING. Depending on the underlying QIODevice, a network connection or a file connection is established. When the connection is ready for use, State is OPEN

Implements IO.

Definition at line 126 of file FilteredIO.cpp.

References IO::open().

00127 { 00128 framesSeen=0; 00129 return io->open(); 00130 };

virtual bool FilteredIO::setEndFrameNumber u32  stopNumber  )  [inline, virtual]
 

Sets the end frame number of the associated IO object.

Returns:
true on success.
See also:
IO::setEndFrameNumber(u32)

Reimplemented from IO.

Definition at line 134 of file FilteredIO.hpp.

References IO::setEndFrameNumber().

00134 { 00135 return io ? io->setEndFrameNumber(stopNumber) : false; 00136 }

void FilteredIO::setRtxInfo const rtx_info *  rtx  )  [virtual]
 

sets a shallow copy of

Parameters:
rtx at the ESInfo object

Reimplemented from IO.

Definition at line 211 of file FilteredIO.cpp.

References IO::setRtxInfo().

00212 { 00213 io->setRtxInfo(rtx); 00214 };

long FilteredIO::setToClosestIFrame u32  frameNumber,
bool  backwards
[virtual]
 

repositions the IO class to

Parameters:
frameNumber,if this Frame is an I-frame. Otherwise a frameNumber lower than frameNumber is searched and returned.
return contains the chosen frameNumber. Will return -1 in case of an error, will only work with IO classes opened for reading.

Reimplemented from IO.

Definition at line 141 of file FilteredIO.cpp.

References IO::setToClosestIFrame().

00142 { 00143 dprintf_full("FilteredIO::setToClosestIFrame\n"); 00144 return io->setToClosestIFrame(frameNumber, backwards); 00145 };

bool FilteredIO::setToFrameNumber u32  frameNumber  )  [virtual]
 

repositions the IO class to the given frame.

Will return false in the following cases:

  • an illegal frame number (too large) was specified
  • the stream is not seekable, because the underlying device is a network device and the requested frame is already out of range: FIXME: implement

Reimplemented from IO.

Definition at line 188 of file FilteredIO.cpp.

References IO::setToFrameNumber().

00189 { 00190 dprintf_full("FilteredIO::setToFrameNumber\n"); 00191 return io->setToFrameNumber(frameNumber); 00192 };

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

returns the number of packets sent.

Returns 0 on error

Implements IO.

Definition at line 108 of file FilteredIO.cpp.

References Frame::getAU(), BitField::getBit(), IO::getESInfo(), ESInfo::getVOPTimeIncrement(), and IO::writeFrame().

00109 { 00110 assert(frm); 00111 framesSeen++; 00112 if(filter->getBit(frm->getAU()->cts/io->getESInfo()->getVOPTimeIncrement())) { 00113 return io->writeFrame(frm); 00114 } 00115 00116 #ifdef _POSIX_PRIORITY_SCHEDULING 00117 sched_yield(); //this is necessary to give parallel getFrames a chance 00118 #endif 00119 00120 return 1; 00121 };


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