live
MPEG2TransportStreamParser Class Reference

#include <MPEG2TransportStreamParser.hh>

Inheritance diagram for MPEG2TransportStreamParser:
Collaboration diagram for MPEG2TransportStreamParser:

Public Member Functions

 MPEG2TransportStreamParser (FramedSource *inputSource, FramedSource::onCloseFunc *onEndFunc, void *onEndClientData)
virtual ~MPEG2TransportStreamParser ()
UsageEnvironmentenvir ()
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 ()
u_int8_t parseAdaptationField ()
Boolean processDataBytes (u_int16_t PID, Boolean pusi, unsigned numDataBytes)
void parsePAT (Boolean pusi, unsigned numDataBytes)
void parsePMT (PIDState_PMT *pidState, Boolean pusi, unsigned numDataBytes)
void parseStreamDescriptors (unsigned numDescriptorBytes)
Boolean processStreamPacket (PIDState_STREAM *pidState, Boolean pusi, unsigned numDataBytes)
unsigned parsePESHeader (PIDState_STREAM *pidState, unsigned numDataBytes)
virtual void restoreSavedParserState ()
unsigned char * curBank ()
unsigned char * nextToParse ()
unsigned char * lastParsed ()
void ensureValidBytes (unsigned numBytesNeeded)
void ensureValidBytes1 (unsigned numBytesNeeded)
void afterGettingBytes1 (unsigned numBytesRead, struct timeval presentationTime)
void onInputClosure1 ()

Static Private Member Functions

static void afterGettingBytes (void *clientData, unsigned numBytesRead, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds)
static void onInputClosure (void *clientData)

Private Attributes

FramedSourcefInputSource
Boolean fAmCurrentlyParsing
FramedSource::onCloseFuncfOnEndFunc
void * fOnEndClientData
PIDState ** fPIDState
double fLastSeenPCR
FramedSource::onCloseFuncfClientOnInputCloseFunc
void * fClientOnInputCloseClientData
clientContinueFuncfClientContinueFunc
void * fClientContinueClientData
unsigned char * fBank [2]
unsigned char fCurBankNum
unsigned char * fCurBank
unsigned fSavedParserIndex
unsigned char fSavedRemainingUnparsedBits
unsigned fCurParserIndex
unsigned char fRemainingUnparsedBits
unsigned fTotNumValidBytes
Boolean fHaveSeenEOF
struct timeval fLastSeenPresentationTime

Friends

class MPEG2TransportStreamDemuxedTrack

Detailed Description

Definition at line 93 of file MPEG2TransportStreamParser.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

◆ MPEG2TransportStreamParser()

MPEG2TransportStreamParser::MPEG2TransportStreamParser ( FramedSource * inputSource,
FramedSource::onCloseFunc * onEndFunc,
void * onEndClientData )

◆ ~MPEG2TransportStreamParser()

virtual MPEG2TransportStreamParser::~MPEG2TransportStreamParser ( )
virtual

Member Function Documentation

◆ afterGettingBytes()

void StreamParser::afterGettingBytes ( void * clientData,
unsigned numBytesRead,
unsigned numTruncatedBytes,
struct timeval presentationTime,
unsigned durationInMicroseconds )
staticprivateinherited

◆ afterGettingBytes1()

void StreamParser::afterGettingBytes1 ( unsigned numBytesRead,
struct timeval presentationTime )
privateinherited

◆ bankSize()

unsigned StreamParser::bankSize ( ) const
protectedinherited

◆ continueParsing() [1/2]

void MPEG2TransportStreamParser::continueParsing ( )

◆ continueParsing() [2/2]

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

◆ curBank()

unsigned char * StreamParser::curBank ( )
inlineprivateinherited

Definition at line 116 of file StreamParser.hh.

116{ return fCurBank; }
unsigned char * fCurBank

References fCurBank.

Referenced by get1Byte(), lastParsed(), and nextToParse().

◆ curOffset()

unsigned StreamParser::curOffset ( ) const
inlineprotectedinherited

Definition at line 107 of file StreamParser.hh.

107{ return fCurParserIndex; }
unsigned fCurParserIndex

References fCurParserIndex.

◆ ensureValidBytes()

void StreamParser::ensureValidBytes ( unsigned numBytesNeeded)
inlineprivateinherited

Definition at line 121 of file StreamParser.hh.

121 {
122 // common case: inlined:
123 if (fCurParserIndex + numBytesNeeded <= fTotNumValidBytes) return;
124
125 ensureValidBytes1(numBytesNeeded);
126 }
unsigned fTotNumValidBytes
void ensureValidBytes1(unsigned numBytesNeeded)

References ensureValidBytes1(), fCurParserIndex, and fTotNumValidBytes.

Referenced by get1Byte(), get2Bytes(), skipBytes(), test1Byte(), test2Bytes(), test4Bytes(), and testBytes().

◆ ensureValidBytes1()

void StreamParser::ensureValidBytes1 ( unsigned numBytesNeeded)
privateinherited

Referenced by ensureValidBytes().

◆ envir()

UsageEnvironment & MPEG2TransportStreamParser::envir ( )

◆ 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 }
void ensureValidBytes(unsigned numBytesNeeded)
unsigned char fRemainingUnparsedBits
unsigned char * curBank()

References curBank(), ensureValidBytes(), fCurParserIndex, and 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 char * nextToParse()

References ensureValidBytes(), fCurParserIndex, fRemainingUnparsedBits, and 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 }
u_int32_t test4Bytes()

References fCurParserIndex, fRemainingUnparsedBits, and 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)

References fCurParserIndex, fRemainingUnparsedBits, and testBytes().

◆ haveSeenEOF()

Boolean StreamParser::haveSeenEOF ( ) const
inlineprotectedinherited

Definition at line 111 of file StreamParser.hh.

111{ return fHaveSeenEOF; }
Boolean fHaveSeenEOF

References fHaveSeenEOF.

◆ lastParsed()

unsigned char * StreamParser::lastParsed ( )
inlineprivateinherited

Definition at line 118 of file StreamParser.hh.

118{ return &curBank()[fCurParserIndex-1]; }

References curBank(), and fCurParserIndex.

◆ nextToParse()

unsigned char * StreamParser::nextToParse ( )
inlineprivateinherited

Definition at line 117 of file StreamParser.hh.

117{ return &curBank()[fCurParserIndex]; }

References curBank(), and fCurParserIndex.

Referenced by get2Bytes(), test1Byte(), test2Bytes(), test4Bytes(), and testBytes().

◆ onInputClosure()

void StreamParser::onInputClosure ( void * clientData)
staticprivateinherited

◆ onInputClosure1()

void StreamParser::onInputClosure1 ( )
privateinherited

◆ parse()

Boolean MPEG2TransportStreamParser::parse ( )
private

◆ parseAdaptationField()

u_int8_t MPEG2TransportStreamParser::parseAdaptationField ( )
private

◆ parsePAT()

void MPEG2TransportStreamParser::parsePAT ( Boolean pusi,
unsigned numDataBytes )
private

◆ parsePESHeader()

unsigned MPEG2TransportStreamParser::parsePESHeader ( PIDState_STREAM * pidState,
unsigned numDataBytes )
private

◆ parsePMT()

void MPEG2TransportStreamParser::parsePMT ( PIDState_PMT * pidState,
Boolean pusi,
unsigned numDataBytes )
private

◆ parseStreamDescriptors()

void MPEG2TransportStreamParser::parseStreamDescriptors ( unsigned numDescriptorBytes)
private

◆ processDataBytes()

Boolean MPEG2TransportStreamParser::processDataBytes ( u_int16_t PID,
Boolean pusi,
unsigned numDataBytes )
private

◆ processStreamPacket()

Boolean MPEG2TransportStreamParser::processStreamPacket ( PIDState_STREAM * pidState,
Boolean pusi,
unsigned numDataBytes )
private

◆ restoreSavedParserState()

virtual void MPEG2TransportStreamParser::restoreSavedParserState ( )
privatevirtual

Reimplemented from StreamParser.

◆ saveParserState()

void StreamParser::saveParserState ( )
protectedinherited

◆ 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 }

References ensureValidBytes(), and fCurParserIndex.

◆ 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 }

References ensureValidBytes(), and 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 }

References ensureValidBytes(), and 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 }

References ensureValidBytes(), and nextToParse().

Referenced by 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 }

References ensureValidBytes(), and nextToParse().

Referenced by getBytes().

◆ totNumValidBytes()

unsigned & StreamParser::totNumValidBytes ( )
inlineprotectedinherited

Definition at line 109 of file StreamParser.hh.

109{ return fTotNumValidBytes; }

References fTotNumValidBytes.

◆ MPEG2TransportStreamDemuxedTrack

Field Documentation

◆ fAmCurrentlyParsing

Boolean MPEG2TransportStreamParser::fAmCurrentlyParsing
private

Definition at line 125 of file MPEG2TransportStreamParser.hh.

◆ fBank

unsigned char* StreamParser::fBank[2]
privateinherited

Definition at line 146 of file StreamParser.hh.

◆ fClientContinueClientData

void* StreamParser::fClientContinueClientData
privateinherited

Definition at line 143 of file StreamParser.hh.

◆ fClientContinueFunc

clientContinueFunc* StreamParser::fClientContinueFunc
privateinherited

Definition at line 142 of file StreamParser.hh.

◆ fClientOnInputCloseClientData

void* StreamParser::fClientOnInputCloseClientData
privateinherited

Definition at line 141 of file StreamParser.hh.

◆ fClientOnInputCloseFunc

FramedSource::onCloseFunc* StreamParser::fClientOnInputCloseFunc
privateinherited

Definition at line 140 of file StreamParser.hh.

◆ fCurBank

unsigned char* StreamParser::fCurBank
privateinherited

Definition at line 148 of file StreamParser.hh.

Referenced by curBank().

◆ fCurBankNum

unsigned char StreamParser::fCurBankNum
privateinherited

Definition at line 147 of file StreamParser.hh.

◆ fCurParserIndex

unsigned StreamParser::fCurParserIndex
privateinherited

◆ fHaveSeenEOF

Boolean StreamParser::fHaveSeenEOF
privateinherited

Definition at line 162 of file StreamParser.hh.

Referenced by haveSeenEOF().

◆ fInputSource

FramedSource* MPEG2TransportStreamParser::fInputSource
private

Definition at line 124 of file MPEG2TransportStreamParser.hh.

◆ fLastSeenPCR

double MPEG2TransportStreamParser::fLastSeenPCR
private

Definition at line 129 of file MPEG2TransportStreamParser.hh.

◆ fLastSeenPresentationTime

struct timeval StreamParser::fLastSeenPresentationTime
privateinherited

Definition at line 164 of file StreamParser.hh.

◆ fOnEndClientData

void* MPEG2TransportStreamParser::fOnEndClientData
private

Definition at line 127 of file MPEG2TransportStreamParser.hh.

◆ fOnEndFunc

FramedSource::onCloseFunc* MPEG2TransportStreamParser::fOnEndFunc
private

Definition at line 126 of file MPEG2TransportStreamParser.hh.

◆ fPIDState

PIDState** MPEG2TransportStreamParser::fPIDState
private

Definition at line 128 of file MPEG2TransportStreamParser.hh.

◆ fRemainingUnparsedBits

unsigned char StreamParser::fRemainingUnparsedBits
privateinherited

Definition at line 156 of file StreamParser.hh.

Referenced by get1Byte(), get2Bytes(), get4Bytes(), and getBytes().

◆ fSavedParserIndex

unsigned StreamParser::fSavedParserIndex
privateinherited

Definition at line 151 of file StreamParser.hh.

◆ fSavedRemainingUnparsedBits

unsigned char StreamParser::fSavedRemainingUnparsedBits
privateinherited

Definition at line 152 of file StreamParser.hh.

◆ fTotNumValidBytes

unsigned StreamParser::fTotNumValidBytes
privateinherited

Definition at line 159 of file StreamParser.hh.

Referenced by ensureValidBytes(), and totNumValidBytes().


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