BufferedIO Class Reference
stores
writeFrame() written frames in an internal list-buffer, to be fetchted FIFO-style with
getFrame() <short description="">
More...
#include <BufferedIO.hpp>
Inheritance diagram for BufferedIO:
List of all members.
|
Public Member Functions |
| BufferedIO (ESInfo *es, MuxDemuxIO *muxio, bool writeOnly) |
virtual Frame * | getFrame () |
| returns a frame if one complete frame is available, otherwise null is returned.
|
virtual 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 elementary stream and its extra hint-file
|
int | getBufferFillLevel () const |
| returns the number of elems in the buffer
|
IO * | clone () const |
const char * | getURL () const |
| not implemented/needed
|
void | setESInfo (ESInfo *esi) |
ESInfo * | getESInfo () |
void | addToBuffer (Frame *frm) |
s64 | nextCTSinBuf () |
Protected Attributes |
bool | writeOnly |
ESInfo * | es |
MuxDemuxIO * | muxio |
bool | atFileStart |
long | lastCTSSeen |
list< Frame * > | buffer |
Detailed Description
stores
writeFrame() written frames in an internal list-buffer, to be fetchted FIFO-style with
getFrame() <short description="">
- Author:
- Michael Kropfberger
- Version:
- Id
- BufferedIO.hpp,v 1.7 2006/02/11 16:35:26 klschoef Exp
Definition at line 66 of file BufferedIO.hpp.
Member Function Documentation
bool BufferedIO::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 105 of file BufferedIO.cpp.
References ESInfo::getStreamId(), MuxDemuxIO::processFrame(), and MuxDemuxIO::removeBufferedIO().
Referenced by destroy(). 00105 {
00106 dprintf_full( "BufferedIO::close ES-ID %lli, immediate=%i, %i frames left in buffer\n",es-> getStreamId(), immediate, buffer.size());
00107
00108 if (state == CLOSED)
00109 return true;
00110
00111 state = CLOSING;
00112 if (!immediate)
00113 while(!buffer.empty()) {
00114 dprintf_full( "BufferedIO::close ES-ID %lli, %i frames left in buffer\n",es-> getStreamId(), buffer.size());
00115
00116 muxio-> processFrame();
00117
00118
00119 }
00120 else
00121 buffer.clear();
00122
00123 muxio-> removeBufferedIO(es-> getStreamId(), this);
00124 state = CLOSED;
00125 return true;
00126 }
|
Frame * BufferedIO::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 182 of file BufferedIO.cpp.
References Frame::getAU(), IO::getState(), ESInfo::getStreamId(), and MuxDemuxIO::processFrame(). 00182 {
00183 Frame *frm = NULL;
00184
00185 dprintf_full( "BufferedIO::getFrame: ES-ID %lli state %i, buffer: %i frames\n",es-> getStreamId(), state, buffer.size());
00186
00187 if ( (state != OPEN) && (state != CLOSING))
00188 return NULL;
00189
00190 if (atFileStart) {
00191 atFileStart = false;
00192
00193 }
00194
00195 if (!writeOnly && muxio-> getState() != STREAMEOF)
00196 muxio-> processFrame();
00197
00198 if (!buffer.empty()) {
00199 frm = buffer.front();
00200 buffer.pop_front();
00201
00202 lastCTSSeen = frm-> getAU()->cts;
00203 framesSeen++;
00204 currentFrameNumber++;
00205 dprintf_full( "BufferedIO::getFrame: %p AU %p ES-ID %lli cts %i size %i, %i frames left in buffer\n", frm, frm-> getAU(),
00206 es-> getStreamId(), frm-> getAU()->cts, frm-> getAU()->size, buffer.size());
00207
00208 } else {
00209 if (muxio-> getState() == OPEN) {
00210 dprintf_full( "BufferedIO::getFrame: ES-ID %lli no frame in buffer right now!\n",es-> getStreamId());
00211 } else
00212 state = muxio-> getState();
00213 }
00214
00215 #ifdef _POSIX_PRIORITY_SCHEDULING
00216 sched_yield();
00217 #endif
00218
00219 return frm;
00220 }
|
bool BufferedIO::open |
( |
|
) |
[virtual] |
|
int BufferedIO::writeFrame |
( |
Frame * |
frm, |
|
|
ESInfo * |
out_es = NULL |
|
) |
[virtual] |
|
|
returns the number of packets sent.
Returns 0 on error
Implements IO.
Definition at line 130 of file BufferedIO.cpp.
References Frame::getAU(), ESInfo::getFrameStatistic(), ESInfo::getStreamId(), ESInfo::getVOPTimeIncrement(), Frame::markForDelete(), MuxDemuxIO::processFrame(), and BitField::setBit(). 00130 {
00131
00132 dprintf_full( "BufferedIO::writeFrame %p, AU %p, ES-ID %lli\n",frm, frm-> getAU(),es-> getStreamId());
00133
00134 if ( (lastCTSSeen >= ( signed)frm-> getAU()->cts) && (lastCTSSeen != 0) ) {
00135 dprintf_small( "BufferedIO::writeFrame WARNING: CTS %u already seen (lastCTSSeen %li) still writing to file!\n",
00136 frm-> getAU()->cts,lastCTSSeen);
00137 } else
00138 lastCTSSeen = frm-> getAU()->cts;
00139
00140 if (!writeOnly || state != OPEN) {
00141 dprintf_small( "BufferedIO::writeFrame esID %llu Warning: Output is readonly or not open\n", es-> getStreamId());
00142 return -1;
00143 }
00144 if (frm-> getAU()->size == 0) {
00145 dprintf_small( "BufferedIO::writeFrame esID %llu: Cannot write zero sized frames\n", es-> getStreamId());
00146 return 0;
00147 }
00148
00149 dprintf_full( "BufferedIO::writeFrame: Storing %i bytes of CTS %i into buffer (already holds %i frames)\n",
00150 frm-> getAU()->size, frm-> getAU()->cts, buffer.size());
00151
00152 es-> getFrameStatistic()-> setBit(frm-> getAU()->cts/es-> getVOPTimeIncrement());
00153
00154
00155 addToBuffer(frm);
00156 frm-> markForDelete( false);
00157
00158 muxio-> processFrame();
00159
00160 framesSeen++;
00161
00162 #ifdef _POSIX_PRIORITY_SCHEDULING
00163 sched_yield();
00164 #endif
00165
00166 return true;
00167 }
|
The documentation for this class was generated from the following files: