live
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Private Member Functions | Private Attributes
MatroskaFileParser Class Reference

#include <MatroskaFileParser.hh>

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

Public Member Functions

 MatroskaFileParser (MatroskaFile &ourFile, FramedSource *inputSource, FramedSource::onCloseFunc *onEndFunc, void *onEndClientData, MatroskaDemux *ourDemux=NULL)
 
virtual ~MatroskaFileParser ()
 
void seekToTime (double &seekNPT)
 
void continueParsing ()
 
virtual void flushInput ()
 

Static Public Member Functions

static void continueParsing (void *clientData, unsigned char *ptr, unsigned size, struct timeval presentationTime)
 

Protected Types

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

Protected Member Functions

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
 

Private Member Functions

Boolean parse ()
 
Boolean parseStartOfFile ()
 
void lookForNextTrack ()
 
Boolean parseTrack ()
 
Boolean parseCues ()
 
void lookForNextBlock ()
 
void parseBlock ()
 
Boolean deliverFrameWithinBlock ()
 
void deliverFrameBytes ()
 
void getCommonFrameBytes (MatroskaTrack *track, u_int8_t *to, unsigned numBytesToGet, unsigned numBytesToSkip)
 
Boolean parseEBMLNumber (EBMLNumber &num)
 
Boolean parseEBMLIdAndSize (EBMLId &id, EBMLDataSize &size)
 
Boolean parseEBMLVal_unsigned64 (EBMLDataSize &size, u_int64_t &result)
 
Boolean parseEBMLVal_unsigned (EBMLDataSize &size, unsigned &result)
 
Boolean parseEBMLVal_float (EBMLDataSize &size, float &result)
 
Boolean parseEBMLVal_string (EBMLDataSize &size, char *&result)
 
Boolean parseEBMLVal_binary (EBMLDataSize &size, u_int8_t *&result)
 
void skipHeader (EBMLDataSize const &size)
 
void skipRemainingHeaderBytes (Boolean isContinuation)
 
void setParseState ()
 
void seekToFilePosition (u_int64_t offsetInFile)
 
void seekToEndOfFile ()
 
void resetStateAfterSeeking ()
 
virtual void restoreSavedParserState ()
 

Private Attributes

MatroskaFilefOurFile
 
FramedSourcefInputSource
 
FramedSource::onCloseFuncfOnEndFunc
 
void * fOnEndClientData
 
MatroskaDemuxfOurDemux
 
MatroskaParseState fCurrentParseState
 
u_int64_t fCurOffsetInFile
 
u_int64_t fSavedCurOffsetInFile
 
u_int64_t fLimitOffsetInFile
 
u_int64_t fNumHeaderBytesToSkip
 
EBMLId fLastSeekId
 
unsigned fClusterTimecode
 
unsigned fBlockSize
 
unsigned fBlockTrackNumber
 
short fBlockTimecode
 
unsigned fNumFramesInBlock
 
unsigned * fFrameSizesWithinBlock
 
double fPresentationTimeOffset
 
unsigned fNextFrameNumberToDeliver
 
unsigned fCurOffsetWithinFrame
 
unsigned fSavedCurOffsetWithinFrame
 
u_int8_t * fCurFrameTo
 
unsigned fCurFrameNumBytesToGet
 
unsigned fCurFrameNumBytesToSkip
 

Detailed Description

Definition at line 46 of file MatroskaFileParser.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

MatroskaFileParser::MatroskaFileParser ( MatroskaFile ourFile,
FramedSource inputSource,
FramedSource::onCloseFunc onEndFunc,
void *  onEndClientData,
MatroskaDemux ourDemux = NULL 
)
virtual MatroskaFileParser::~MatroskaFileParser ( )
virtual

Member Function Documentation

unsigned StreamParser::bankSize ( ) const
protectedinherited
static void MatroskaFileParser::continueParsing ( void *  clientData,
unsigned char *  ptr,
unsigned  size,
struct timeval  presentationTime 
)
static
void MatroskaFileParser::continueParsing ( )
unsigned StreamParser::curOffset ( ) const
inlineprotectedinherited

Definition at line 100 of file StreamParser.hh.

References StreamParser::fCurParserIndex.

100 { return fCurParserIndex; }
unsigned fCurParserIndex
void MatroskaFileParser::deliverFrameBytes ( )
private
Boolean MatroskaFileParser::deliverFrameWithinBlock ( )
private
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 MPEGVideoStreamParser::saveToNextCode(), and MPEGVideoStreamParser::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 MPEGVideoStreamParser::saveToNextCode(), and MPEGVideoStreamParser::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
void MatroskaFileParser::getCommonFrameBytes ( MatroskaTrack track,
u_int8_t *  to,
unsigned  numBytesToGet,
unsigned  numBytesToSkip 
)
private
Boolean StreamParser::haveSeenEOF ( ) const
inlineprotectedinherited

Definition at line 104 of file StreamParser.hh.

References StreamParser::fHaveSeenEOF.

104 { return fHaveSeenEOF; }
Boolean fHaveSeenEOF
void MatroskaFileParser::lookForNextBlock ( )
private
void MatroskaFileParser::lookForNextTrack ( )
private
Boolean MatroskaFileParser::parse ( )
private
void MatroskaFileParser::parseBlock ( )
private
Boolean MatroskaFileParser::parseCues ( )
private
Boolean MatroskaFileParser::parseEBMLIdAndSize ( EBMLId id,
EBMLDataSize size 
)
private
Boolean MatroskaFileParser::parseEBMLNumber ( EBMLNumber num)
private
Boolean MatroskaFileParser::parseEBMLVal_binary ( EBMLDataSize size,
u_int8_t *&  result 
)
private
Boolean MatroskaFileParser::parseEBMLVal_float ( EBMLDataSize size,
float &  result 
)
private
Boolean MatroskaFileParser::parseEBMLVal_string ( EBMLDataSize size,
char *&  result 
)
private
Boolean MatroskaFileParser::parseEBMLVal_unsigned ( EBMLDataSize size,
unsigned &  result 
)
private
Boolean MatroskaFileParser::parseEBMLVal_unsigned64 ( EBMLDataSize size,
u_int64_t &  result 
)
private
Boolean MatroskaFileParser::parseStartOfFile ( )
private
Boolean MatroskaFileParser::parseTrack ( )
private
void MatroskaFileParser::resetStateAfterSeeking ( )
private
virtual void MatroskaFileParser::restoreSavedParserState ( )
privatevirtual

Reimplemented from StreamParser.

void StreamParser::saveParserState ( )
protectedinherited
void MatroskaFileParser::seekToEndOfFile ( )
private
void MatroskaFileParser::seekToFilePosition ( u_int64_t  offsetInFile)
private
void MatroskaFileParser::seekToTime ( double &  seekNPT)
void MatroskaFileParser::setParseState ( )
private
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 MatroskaFileParser::skipHeader ( EBMLDataSize const &  size)
private
void MatroskaFileParser::skipRemainingHeaderBytes ( Boolean  isContinuation)
private
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 MatroskaFileParser::fBlockSize
private

Definition at line 117 of file MatroskaFileParser.hh.

short MatroskaFileParser::fBlockTimecode
private

Definition at line 119 of file MatroskaFileParser.hh.

unsigned MatroskaFileParser::fBlockTrackNumber
private

Definition at line 118 of file MatroskaFileParser.hh.

unsigned MatroskaFileParser::fClusterTimecode
private

Definition at line 114 of file MatroskaFileParser.hh.

unsigned MatroskaFileParser::fCurFrameNumBytesToGet
private

Definition at line 130 of file MatroskaFileParser.hh.

unsigned MatroskaFileParser::fCurFrameNumBytesToSkip
private

Definition at line 131 of file MatroskaFileParser.hh.

u_int8_t* MatroskaFileParser::fCurFrameTo
private

Definition at line 129 of file MatroskaFileParser.hh.

u_int64_t MatroskaFileParser::fCurOffsetInFile
private

Definition at line 105 of file MatroskaFileParser.hh.

unsigned MatroskaFileParser::fCurOffsetWithinFrame
private

Definition at line 126 of file MatroskaFileParser.hh.

MatroskaParseState MatroskaFileParser::fCurrentParseState
private

Definition at line 104 of file MatroskaFileParser.hh.

unsigned* MatroskaFileParser::fFrameSizesWithinBlock
private

Definition at line 121 of file MatroskaFileParser.hh.

FramedSource* MatroskaFileParser::fInputSource
private

Definition at line 100 of file MatroskaFileParser.hh.

EBMLId MatroskaFileParser::fLastSeekId
private

Definition at line 111 of file MatroskaFileParser.hh.

u_int64_t MatroskaFileParser::fLimitOffsetInFile
private

Definition at line 105 of file MatroskaFileParser.hh.

unsigned MatroskaFileParser::fNextFrameNumberToDeliver
private

Definition at line 125 of file MatroskaFileParser.hh.

unsigned MatroskaFileParser::fNumFramesInBlock
private

Definition at line 120 of file MatroskaFileParser.hh.

u_int64_t MatroskaFileParser::fNumHeaderBytesToSkip
private

Definition at line 108 of file MatroskaFileParser.hh.

void* MatroskaFileParser::fOnEndClientData
private

Definition at line 102 of file MatroskaFileParser.hh.

FramedSource::onCloseFunc* MatroskaFileParser::fOnEndFunc
private

Definition at line 101 of file MatroskaFileParser.hh.

MatroskaDemux* MatroskaFileParser::fOurDemux
private

Definition at line 103 of file MatroskaFileParser.hh.

MatroskaFile& MatroskaFileParser::fOurFile
private

Definition at line 99 of file MatroskaFileParser.hh.

double MatroskaFileParser::fPresentationTimeOffset
private

Definition at line 124 of file MatroskaFileParser.hh.

u_int64_t MatroskaFileParser::fSavedCurOffsetInFile
private

Definition at line 105 of file MatroskaFileParser.hh.

unsigned MatroskaFileParser::fSavedCurOffsetWithinFrame
private

Definition at line 126 of file MatroskaFileParser.hh.


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