live
OggFileParser.hh
Go to the documentation of this file.
1/**********
2This library is free software; you can redistribute it and/or modify it under
3the terms of the GNU Lesser General Public License as published by the
4Free Software Foundation; either version 3 of the License, or (at your
5option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
6
7This library is distributed in the hope that it will be useful, but WITHOUT
8ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
9FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
10more details.
11
12You should have received a copy of the GNU Lesser General Public License
13along with this library; if not, write to the Free Software Foundation, Inc.,
1451 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15**********/
16// "liveMedia"
17// Copyright (c) 1996-2024 Live Networks, Inc. All rights reserved.
18// A parser for an Ogg file
19// C++ header
20
21#ifndef _OGG_FILE_PARSER_HH
22
23#ifndef _STREAM_PARSER_HH
24#include "StreamParser.hh"
25#endif
26#ifndef _OGG_FILE_HH
27#include "OggFile.hh"
28#endif
29
30// An enum representing the current state of the parser:
35};
36
37// A structure that counts the sizes of 'packets' given by each page's "segment_table":
39public:
40 PacketSizeTable(unsigned number_page_segments);
42
43 unsigned numCompletedPackets; // will be <= "number_page_segments"
44 unsigned* size; // an array of sizes of each of the packets
45 unsigned totSizes;
47 Boolean lastPacketIsIncomplete; // iff the last segment's 'lacing' was 255
48};
49
51public:
52 OggFileParser(OggFile& ourFile, FramedSource* inputSource,
53 FramedSource::onCloseFunc* onEndFunc, void* onEndClientData,
54 OggDemux* ourDemux = NULL);
55 virtual ~OggFileParser();
56
57 // StreamParser 'client continue' function:
58 static void continueParsing(void* clientData, unsigned char* ptr, unsigned size, struct timeval presentationTime);
60
61private:
63
64 // Parsing functions:
65 Boolean parse(); // returns True iff we have finished parsing all BOS pages (on initialization)
66
68 u_int8_t parseInitialPage(); // returns the 'header_type_flag' byte
72 void parseStartOfPage(u_int8_t& header_type_flag, u_int32_t& bitstream_serial_number);
73
74 Boolean validateHeader(OggTrack* track, u_int8_t const* p, unsigned headerSize);
75
76private:
77 // General state for parsing:
84
88 u_int8_t* fSavedPacket; // used to temporarily save a copy of a 'packet' from a page
89};
90
91#endif
unsigned char Boolean
Definition: Boolean.hh:25
OggParseState
@ PARSING_START_OF_FILE
@ PARSING_AND_DELIVERING_PAGES
@ DELIVERING_PACKET_WITHIN_PAGE
#define NULL
void() onCloseFunc(void *clientData)
Definition: FramedSource.hh:40
FramedSource * fInputSource
OggFileParser(OggFile &ourFile, FramedSource *inputSource, FramedSource::onCloseFunc *onEndFunc, void *onEndClientData, OggDemux *ourDemux=NULL)
OggParseState fCurrentParseState
virtual ~OggFileParser()
void * fOnEndClientData
Boolean deliverPacketWithinPage()
OggDemux * fOurDemux
unsigned fNumUnfulfilledTracks
PacketSizeTable * fPacketSizeTable
Boolean needHeaders()
static void continueParsing(void *clientData, unsigned char *ptr, unsigned size, struct timeval presentationTime)
FramedSource::onCloseFunc * fOnEndFunc
u_int8_t parseInitialPage()
void parseAndDeliverPages()
Boolean parseAndDeliverPage()
void parseStartOfPage(u_int8_t &header_type_flag, u_int32_t &bitstream_serial_number)
Boolean parseStartOfFile()
OggFile & fOurFile
Boolean validateHeader(OggTrack *track, u_int8_t const *p, unsigned headerSize)
Boolean parse()
void continueParsing()
u_int8_t * fSavedPacket
u_int32_t fCurrentTrackNumber
unsigned * size
unsigned nextPacketNumToDeliver
unsigned numCompletedPackets
Boolean lastPacketIsIncomplete
PacketSizeTable(unsigned number_page_segments)