live
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions
MPEGVideoStreamParser Class Referenceabstract

#include <MPEGVideoStreamParser.hh>

Inheritance diagram for MPEGVideoStreamParser:
Inheritance graph
[legend]
Collaboration diagram for MPEGVideoStreamParser:
Collaboration graph
[legend]

Public Member Functions

 MPEGVideoStreamParser (MPEGVideoStreamFramer *usingSource, FramedSource *inputSource)
 
virtual ~MPEGVideoStreamParser ()
 
void registerReadInterest (unsigned char *to, unsigned maxSize)
 
virtual unsigned parse ()=0
 
unsigned numTruncatedBytes () const
 
virtual void flushInput ()
 

Protected Types

typedef void( clientContinueFunc )(void *clientData, unsigned char *ptr, unsigned size, struct timeval presentationTime)
 

Protected Member Functions

void setParseState ()
 
void saveByte (u_int8_t byte)
 
void save4Bytes (u_int32_t word)
 
void saveToNextCode (u_int32_t &curWord)
 
void skipToNextCode (u_int32_t &curWord)
 
unsigned curFrameSize ()
 
void saveParserState ()
 
u_int32_t get4Bytes ()
 
u_int32_t test4Bytes ()
 
u_int16_t get2Bytes ()
 
u_int8_t get1Byte ()
 
u_int8_t test1Byte ()
 
void getBytes (u_int8_t *to, unsigned numBytes)
 
void testBytes (u_int8_t *to, unsigned numBytes)
 
void skipBytes (unsigned numBytes)
 
void skipBits (unsigned numBits)
 
unsigned getBits (unsigned numBits)
 
unsigned curOffset () const
 
unsigned & totNumValidBytes ()
 
Boolean haveSeenEOF () const
 
unsigned bankSize () const
 

Protected Attributes

MPEGVideoStreamFramerfUsingSource
 
unsigned char * fStartOfFrame
 
unsigned char * fTo
 
unsigned char * fLimit
 
unsigned fNumTruncatedBytes
 
unsigned char * fSavedTo
 
unsigned fSavedNumTruncatedBytes
 

Private Member Functions

virtual void restoreSavedParserState ()
 

Detailed Description

Definition at line 33 of file MPEGVideoStreamParser.hh.

Member Typedef Documentation

typedef void( StreamParser::clientContinueFunc)(void *clientData, unsigned char *ptr, unsigned size, struct timeval presentationTime)
protectedinherited

Definition at line 33 of file StreamParser.hh.

Constructor & Destructor Documentation

MPEGVideoStreamParser::MPEGVideoStreamParser ( MPEGVideoStreamFramer usingSource,
FramedSource inputSource 
)
virtual MPEGVideoStreamParser::~MPEGVideoStreamParser ( )
virtual

Member Function Documentation

unsigned StreamParser::bankSize ( ) const
protectedinherited
unsigned MPEGVideoStreamParser::curFrameSize ( )
inlineprotected

Definition at line 114 of file MPEGVideoStreamParser.hh.

References fStartOfFrame, and fTo.

114 { return fTo - fStartOfFrame; }
unsigned StreamParser::curOffset ( ) const
inlineprotectedinherited

Definition at line 100 of file StreamParser.hh.

References StreamParser::fCurParserIndex.

100 { return fCurParserIndex; }
unsigned fCurParserIndex
virtual void StreamParser::flushInput ( )
virtualinherited
u_int8_t StreamParser::get1Byte ( )
inlineprotectedinherited

Definition at line 72 of file StreamParser.hh.

References StreamParser::curBank(), StreamParser::ensureValidBytes(), StreamParser::fCurParserIndex, and StreamParser::fRemainingUnparsedBits.

Referenced by saveToNextCode(), and skipToNextCode().

72  { // byte-aligned
75  return curBank()[fCurParserIndex++];
76  }
unsigned fCurParserIndex
unsigned char fRemainingUnparsedBits
void ensureValidBytes(unsigned numBytesNeeded)
unsigned char * curBank()
u_int16_t StreamParser::get2Bytes ( )
inlineprotectedinherited

Definition at line 60 of file StreamParser.hh.

References StreamParser::ensureValidBytes(), StreamParser::fCurParserIndex, StreamParser::fRemainingUnparsedBits, and StreamParser::nextToParse().

60  {
62 
63  unsigned char const* ptr = nextToParse();
64  u_int16_t result = (ptr[0]<<8)|ptr[1];
65 
66  fCurParserIndex += 2;
68 
69  return result;
70  }
unsigned fCurParserIndex
unsigned char fRemainingUnparsedBits
void ensureValidBytes(unsigned numBytesNeeded)
unsigned char * nextToParse()
u_int32_t StreamParser::get4Bytes ( )
inlineprotectedinherited

Definition at line 46 of file StreamParser.hh.

References StreamParser::fCurParserIndex, StreamParser::fRemainingUnparsedBits, and StreamParser::test4Bytes().

Referenced by saveToNextCode(), and skipToNextCode().

46  { // byte-aligned; returned in big-endian order
47  u_int32_t result = test4Bytes();
48  fCurParserIndex += 4;
50 
51  return result;
52  }
unsigned fCurParserIndex
unsigned char fRemainingUnparsedBits
u_int32_t test4Bytes()
Definition: StreamParser.hh:53
unsigned StreamParser::getBits ( unsigned  numBits)
protectedinherited
void StreamParser::getBytes ( u_int8_t *  to,
unsigned  numBytes 
)
inlineprotectedinherited

Definition at line 82 of file StreamParser.hh.

References StreamParser::fCurParserIndex, StreamParser::fRemainingUnparsedBits, and StreamParser::testBytes().

82  {
83  testBytes(to, numBytes);
84  fCurParserIndex += numBytes;
86  }
void testBytes(u_int8_t *to, unsigned numBytes)
Definition: StreamParser.hh:87
unsigned fCurParserIndex
unsigned char fRemainingUnparsedBits
Boolean StreamParser::haveSeenEOF ( ) const
inlineprotectedinherited

Definition at line 104 of file StreamParser.hh.

References StreamParser::fHaveSeenEOF.

104 { return fHaveSeenEOF; }
Boolean fHaveSeenEOF
unsigned MPEGVideoStreamParser::numTruncatedBytes ( ) const
inline

Definition at line 45 of file MPEGVideoStreamParser.hh.

References fNumTruncatedBytes.

45 { return fNumTruncatedBytes; }
virtual unsigned MPEGVideoStreamParser::parse ( )
pure virtual
void MPEGVideoStreamParser::registerReadInterest ( unsigned char *  to,
unsigned  maxSize 
)
virtual void MPEGVideoStreamParser::restoreSavedParserState ( )
privatevirtual

Reimplemented from StreamParser.

void MPEGVideoStreamParser::save4Bytes ( u_int32_t  word)
inlineprotected

Definition at line 64 of file MPEGVideoStreamParser.hh.

References fLimit, fNumTruncatedBytes, and fTo.

Referenced by saveToNextCode().

64  {
65  if (fTo+4 > fLimit) { // there's no space left
66  fNumTruncatedBytes += 4;
67  return;
68  }
69 
70  *fTo++ = word>>24; *fTo++ = word>>16; *fTo++ = word>>8; *fTo++ = word;
71  }
void MPEGVideoStreamParser::saveByte ( u_int8_t  byte)
inlineprotected

Definition at line 55 of file MPEGVideoStreamParser.hh.

References fLimit, fNumTruncatedBytes, and fTo.

Referenced by saveToNextCode().

55  {
56  if (fTo >= fLimit) { // there's no space left
58  return;
59  }
60 
61  *fTo++ = byte;
62  }
void StreamParser::saveParserState ( )
protectedinherited

Referenced by setParseState().

void MPEGVideoStreamParser::saveToNextCode ( u_int32_t &  curWord)
inlineprotected

Definition at line 74 of file MPEGVideoStreamParser.hh.

References StreamParser::get1Byte(), StreamParser::get4Bytes(), save4Bytes(), and saveByte().

74  {
75  saveByte(curWord>>24);
76  curWord = (curWord<<8)|get1Byte();
77  while ((curWord&0xFFFFFF00) != 0x00000100) {
78  if ((unsigned)(curWord&0xFF) > 1) {
79  // a sync word definitely doesn't begin anywhere in "curWord"
80  save4Bytes(curWord);
81  curWord = get4Bytes();
82  } else {
83  // a sync word might begin in "curWord", although not at its start
84  saveByte(curWord>>24);
85  unsigned char newByte = get1Byte();
86  curWord = (curWord<<8)|newByte;
87  }
88  }
89  }
void saveByte(u_int8_t byte)
u_int32_t get4Bytes()
Definition: StreamParser.hh:46
u_int8_t get1Byte()
Definition: StreamParser.hh:72
void save4Bytes(u_int32_t word)
void MPEGVideoStreamParser::setParseState ( )
inlineprotected
void StreamParser::skipBits ( unsigned  numBits)
protectedinherited
void StreamParser::skipBytes ( unsigned  numBytes)
inlineprotectedinherited

Definition at line 91 of file StreamParser.hh.

References StreamParser::ensureValidBytes(), and StreamParser::fCurParserIndex.

91  {
92  ensureValidBytes(numBytes);
93  fCurParserIndex += numBytes;
94  }
unsigned fCurParserIndex
void ensureValidBytes(unsigned numBytesNeeded)
void MPEGVideoStreamParser::skipToNextCode ( u_int32_t &  curWord)
inlineprotected

Definition at line 92 of file MPEGVideoStreamParser.hh.

References StreamParser::get1Byte(), and StreamParser::get4Bytes().

92  {
93  curWord = (curWord<<8)|get1Byte();
94  while ((curWord&0xFFFFFF00) != 0x00000100) {
95  if ((unsigned)(curWord&0xFF) > 1) {
96  // a sync word definitely doesn't begin anywhere in "curWord"
97  curWord = get4Bytes();
98  } else {
99  // a sync word might begin in "curWord", although not at its start
100  unsigned char newByte = get1Byte();
101  curWord = (curWord<<8)|newByte;
102  }
103  }
104  }
u_int32_t get4Bytes()
Definition: StreamParser.hh:46
u_int8_t get1Byte()
Definition: StreamParser.hh:72
u_int8_t StreamParser::test1Byte ( )
inlineprotectedinherited

Definition at line 77 of file StreamParser.hh.

References StreamParser::ensureValidBytes(), and StreamParser::nextToParse().

77  { // as above, but doesn't advance ptr
79  return nextToParse()[0];
80  }
void ensureValidBytes(unsigned numBytesNeeded)
unsigned char * nextToParse()
u_int32_t StreamParser::test4Bytes ( )
inlineprotectedinherited

Definition at line 53 of file StreamParser.hh.

References StreamParser::ensureValidBytes(), and StreamParser::nextToParse().

Referenced by StreamParser::get4Bytes().

53  { // as above, but doesn't advance ptr
55 
56  unsigned char const* ptr = nextToParse();
57  return (ptr[0]<<24)|(ptr[1]<<16)|(ptr[2]<<8)|ptr[3];
58  }
void ensureValidBytes(unsigned numBytesNeeded)
unsigned char * nextToParse()
void StreamParser::testBytes ( u_int8_t *  to,
unsigned  numBytes 
)
inlineprotectedinherited

Definition at line 87 of file StreamParser.hh.

References StreamParser::ensureValidBytes(), and StreamParser::nextToParse().

Referenced by StreamParser::getBytes().

87  { // as above, but doesn't advance ptr
88  ensureValidBytes(numBytes);
89  memmove(to, nextToParse(), numBytes);
90  }
void ensureValidBytes(unsigned numBytesNeeded)
unsigned char * nextToParse()
unsigned& StreamParser::totNumValidBytes ( )
inlineprotectedinherited

Definition at line 102 of file StreamParser.hh.

References StreamParser::fTotNumValidBytes.

102 { return fTotNumValidBytes; }
unsigned fTotNumValidBytes

Field Documentation

unsigned char* MPEGVideoStreamParser::fLimit
protected

Definition at line 112 of file MPEGVideoStreamParser.hh.

Referenced by save4Bytes(), and saveByte().

unsigned MPEGVideoStreamParser::fNumTruncatedBytes
protected

Definition at line 113 of file MPEGVideoStreamParser.hh.

Referenced by numTruncatedBytes(), save4Bytes(), saveByte(), and setParseState().

unsigned MPEGVideoStreamParser::fSavedNumTruncatedBytes
protected

Definition at line 116 of file MPEGVideoStreamParser.hh.

Referenced by setParseState().

unsigned char* MPEGVideoStreamParser::fSavedTo
protected

Definition at line 115 of file MPEGVideoStreamParser.hh.

Referenced by setParseState().

unsigned char* MPEGVideoStreamParser::fStartOfFrame
protected

Definition at line 110 of file MPEGVideoStreamParser.hh.

Referenced by curFrameSize().

unsigned char* MPEGVideoStreamParser::fTo
protected

Definition at line 111 of file MPEGVideoStreamParser.hh.

Referenced by curFrameSize(), save4Bytes(), saveByte(), and setParseState().

MPEGVideoStreamFramer* MPEGVideoStreamParser::fUsingSource
protected

Definition at line 107 of file MPEGVideoStreamParser.hh.


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