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 pause ()
 
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_int16_t test2Bytes ()
 
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 ()
 
void resetPresentationTimes ()
 
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

◆ clientContinueFunc

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::MatroskaFileParser ( MatroskaFile ourFile,
FramedSource inputSource,
FramedSource::onCloseFunc onEndFunc,
void *  onEndClientData,
MatroskaDemux ourDemux = NULL 
)

◆ ~MatroskaFileParser()

virtual MatroskaFileParser::~MatroskaFileParser ( )
virtual

Member Function Documentation

◆ bankSize()

unsigned StreamParser::bankSize ( ) const
protectedinherited

◆ continueParsing() [1/2]

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

◆ continueParsing() [2/2]

void MatroskaFileParser::continueParsing ( )

◆ curOffset()

unsigned StreamParser::curOffset ( ) const
inlineprotectedinherited

Definition at line 107 of file StreamParser.hh.

107 { return fCurParserIndex; }
unsigned fCurParserIndex

References StreamParser::fCurParserIndex.

◆ deliverFrameBytes()

void MatroskaFileParser::deliverFrameBytes ( )
private

◆ deliverFrameWithinBlock()

Boolean MatroskaFileParser::deliverFrameWithinBlock ( )
private

◆ flushInput()

virtual void StreamParser::flushInput ( )
virtualinherited

◆ get1Byte()

u_int8_t StreamParser::get1Byte ( )
inlineprotectedinherited

Definition at line 79 of file StreamParser.hh.

79  { // byte-aligned
82  return curBank()[fCurParserIndex++];
83  }
unsigned fCurParserIndex
unsigned char fRemainingUnparsedBits
void ensureValidBytes(unsigned numBytesNeeded)
unsigned char * curBank()

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

Referenced by MPEGVideoStreamParser::saveToNextCode(), and MPEGVideoStreamParser::skipToNextCode().

◆ get2Bytes()

u_int16_t StreamParser::get2Bytes ( )
inlineprotectedinherited

Definition at line 60 of file StreamParser.hh.

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()

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

◆ get4Bytes()

u_int32_t StreamParser::get4Bytes ( )
inlineprotectedinherited

Definition at line 46 of file StreamParser.hh.

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

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

Referenced by MPEGVideoStreamParser::saveToNextCode(), and MPEGVideoStreamParser::skipToNextCode().

◆ getBits()

unsigned StreamParser::getBits ( unsigned  numBits)
protectedinherited

◆ getBytes()

void StreamParser::getBytes ( u_int8_t *  to,
unsigned  numBytes 
)
inlineprotectedinherited

Definition at line 89 of file StreamParser.hh.

89  {
90  testBytes(to, numBytes);
91  fCurParserIndex += numBytes;
93  }
void testBytes(u_int8_t *to, unsigned numBytes)
Definition: StreamParser.hh:94
unsigned fCurParserIndex
unsigned char fRemainingUnparsedBits

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

◆ getCommonFrameBytes()

void MatroskaFileParser::getCommonFrameBytes ( MatroskaTrack track,
u_int8_t *  to,
unsigned  numBytesToGet,
unsigned  numBytesToSkip 
)
private

◆ haveSeenEOF()

Boolean StreamParser::haveSeenEOF ( ) const
inlineprotectedinherited

Definition at line 111 of file StreamParser.hh.

111 { return fHaveSeenEOF; }
Boolean fHaveSeenEOF

References StreamParser::fHaveSeenEOF.

◆ lookForNextBlock()

void MatroskaFileParser::lookForNextBlock ( )
private

◆ lookForNextTrack()

void MatroskaFileParser::lookForNextTrack ( )
private

◆ parse()

Boolean MatroskaFileParser::parse ( )
private

◆ parseBlock()

void MatroskaFileParser::parseBlock ( )
private

◆ parseCues()

Boolean MatroskaFileParser::parseCues ( )
private

◆ parseEBMLIdAndSize()

Boolean MatroskaFileParser::parseEBMLIdAndSize ( EBMLId id,
EBMLDataSize size 
)
private

◆ parseEBMLNumber()

Boolean MatroskaFileParser::parseEBMLNumber ( EBMLNumber num)
private

◆ parseEBMLVal_binary()

Boolean MatroskaFileParser::parseEBMLVal_binary ( EBMLDataSize size,
u_int8_t *&  result 
)
private

◆ parseEBMLVal_float()

Boolean MatroskaFileParser::parseEBMLVal_float ( EBMLDataSize size,
float &  result 
)
private

◆ parseEBMLVal_string()

Boolean MatroskaFileParser::parseEBMLVal_string ( EBMLDataSize size,
char *&  result 
)
private

◆ parseEBMLVal_unsigned()

Boolean MatroskaFileParser::parseEBMLVal_unsigned ( EBMLDataSize size,
unsigned &  result 
)
private

◆ parseEBMLVal_unsigned64()

Boolean MatroskaFileParser::parseEBMLVal_unsigned64 ( EBMLDataSize size,
u_int64_t &  result 
)
private

◆ parseStartOfFile()

Boolean MatroskaFileParser::parseStartOfFile ( )
private

◆ parseTrack()

Boolean MatroskaFileParser::parseTrack ( )
private

◆ pause()

void MatroskaFileParser::pause ( )

◆ resetPresentationTimes()

void MatroskaFileParser::resetPresentationTimes ( )
private

◆ resetStateAfterSeeking()

void MatroskaFileParser::resetStateAfterSeeking ( )
private

◆ restoreSavedParserState()

virtual void MatroskaFileParser::restoreSavedParserState ( )
privatevirtual

Reimplemented from StreamParser.

◆ saveParserState()

void StreamParser::saveParserState ( )
protectedinherited

◆ seekToEndOfFile()

void MatroskaFileParser::seekToEndOfFile ( )
private

◆ seekToFilePosition()

void MatroskaFileParser::seekToFilePosition ( u_int64_t  offsetInFile)
private

◆ seekToTime()

void MatroskaFileParser::seekToTime ( double &  seekNPT)

◆ setParseState()

void MatroskaFileParser::setParseState ( )
private

◆ skipBits()

void StreamParser::skipBits ( unsigned  numBits)
protectedinherited

◆ skipBytes()

void StreamParser::skipBytes ( unsigned  numBytes)
inlineprotectedinherited

Definition at line 98 of file StreamParser.hh.

98  {
99  ensureValidBytes(numBytes);
100  fCurParserIndex += numBytes;
101  }
unsigned fCurParserIndex
void ensureValidBytes(unsigned numBytesNeeded)

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

◆ skipHeader()

void MatroskaFileParser::skipHeader ( EBMLDataSize const &  size)
private

◆ skipRemainingHeaderBytes()

void MatroskaFileParser::skipRemainingHeaderBytes ( Boolean  isContinuation)
private

◆ test1Byte()

u_int8_t StreamParser::test1Byte ( )
inlineprotectedinherited

Definition at line 84 of file StreamParser.hh.

84  { // as above, but doesn't advance ptr
86  return nextToParse()[0];
87  }
void ensureValidBytes(unsigned numBytesNeeded)
unsigned char * nextToParse()

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

◆ test2Bytes()

u_int16_t StreamParser::test2Bytes ( )
inlineprotectedinherited

Definition at line 71 of file StreamParser.hh.

71  {
73 
74  unsigned char const* ptr = nextToParse();
75  return (ptr[0]<<8)|ptr[1];
76  }
void ensureValidBytes(unsigned numBytesNeeded)
unsigned char * nextToParse()

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

◆ test4Bytes()

u_int32_t StreamParser::test4Bytes ( )
inlineprotectedinherited

Definition at line 53 of file StreamParser.hh.

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()

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

Referenced by StreamParser::get4Bytes().

◆ testBytes()

void StreamParser::testBytes ( u_int8_t *  to,
unsigned  numBytes 
)
inlineprotectedinherited

Definition at line 94 of file StreamParser.hh.

94  { // as above, but doesn't advance ptr
95  ensureValidBytes(numBytes);
96  memmove(to, nextToParse(), numBytes);
97  }
void ensureValidBytes(unsigned numBytesNeeded)
unsigned char * nextToParse()

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

Referenced by StreamParser::getBytes().

◆ totNumValidBytes()

unsigned& StreamParser::totNumValidBytes ( )
inlineprotectedinherited

Definition at line 109 of file StreamParser.hh.

109 { return fTotNumValidBytes; }
unsigned fTotNumValidBytes

References StreamParser::fTotNumValidBytes.

Field Documentation

◆ fBlockSize

unsigned MatroskaFileParser::fBlockSize
private

Definition at line 122 of file MatroskaFileParser.hh.

◆ fBlockTimecode

short MatroskaFileParser::fBlockTimecode
private

Definition at line 124 of file MatroskaFileParser.hh.

◆ fBlockTrackNumber

unsigned MatroskaFileParser::fBlockTrackNumber
private

Definition at line 123 of file MatroskaFileParser.hh.

◆ fClusterTimecode

unsigned MatroskaFileParser::fClusterTimecode
private

Definition at line 119 of file MatroskaFileParser.hh.

◆ fCurFrameNumBytesToGet

unsigned MatroskaFileParser::fCurFrameNumBytesToGet
private

Definition at line 135 of file MatroskaFileParser.hh.

◆ fCurFrameNumBytesToSkip

unsigned MatroskaFileParser::fCurFrameNumBytesToSkip
private

Definition at line 136 of file MatroskaFileParser.hh.

◆ fCurFrameTo

u_int8_t* MatroskaFileParser::fCurFrameTo
private

Definition at line 134 of file MatroskaFileParser.hh.

◆ fCurOffsetInFile

u_int64_t MatroskaFileParser::fCurOffsetInFile
private

Definition at line 110 of file MatroskaFileParser.hh.

◆ fCurOffsetWithinFrame

unsigned MatroskaFileParser::fCurOffsetWithinFrame
private

Definition at line 131 of file MatroskaFileParser.hh.

◆ fCurrentParseState

MatroskaParseState MatroskaFileParser::fCurrentParseState
private

Definition at line 109 of file MatroskaFileParser.hh.

◆ fFrameSizesWithinBlock

unsigned* MatroskaFileParser::fFrameSizesWithinBlock
private

Definition at line 126 of file MatroskaFileParser.hh.

◆ fInputSource

FramedSource* MatroskaFileParser::fInputSource
private

Definition at line 105 of file MatroskaFileParser.hh.

◆ fLastSeekId

EBMLId MatroskaFileParser::fLastSeekId
private

Definition at line 116 of file MatroskaFileParser.hh.

◆ fLimitOffsetInFile

u_int64_t MatroskaFileParser::fLimitOffsetInFile
private

Definition at line 110 of file MatroskaFileParser.hh.

◆ fNextFrameNumberToDeliver

unsigned MatroskaFileParser::fNextFrameNumberToDeliver
private

Definition at line 130 of file MatroskaFileParser.hh.

◆ fNumFramesInBlock

unsigned MatroskaFileParser::fNumFramesInBlock
private

Definition at line 125 of file MatroskaFileParser.hh.

◆ fNumHeaderBytesToSkip

u_int64_t MatroskaFileParser::fNumHeaderBytesToSkip
private

Definition at line 113 of file MatroskaFileParser.hh.

◆ fOnEndClientData

void* MatroskaFileParser::fOnEndClientData
private

Definition at line 107 of file MatroskaFileParser.hh.

◆ fOnEndFunc

FramedSource::onCloseFunc* MatroskaFileParser::fOnEndFunc
private

Definition at line 106 of file MatroskaFileParser.hh.

◆ fOurDemux

MatroskaDemux* MatroskaFileParser::fOurDemux
private

Definition at line 108 of file MatroskaFileParser.hh.

◆ fOurFile

MatroskaFile& MatroskaFileParser::fOurFile
private

Definition at line 104 of file MatroskaFileParser.hh.

◆ fPresentationTimeOffset

double MatroskaFileParser::fPresentationTimeOffset
private

Definition at line 129 of file MatroskaFileParser.hh.

◆ fSavedCurOffsetInFile

u_int64_t MatroskaFileParser::fSavedCurOffsetInFile
private

Definition at line 110 of file MatroskaFileParser.hh.

◆ fSavedCurOffsetWithinFrame

unsigned MatroskaFileParser::fSavedCurOffsetWithinFrame
private

Definition at line 131 of file MatroskaFileParser.hh.


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