1 // ------------------------------------------------
6 // (c) 2002-3 peercast.org
7 // ------------------------------------------------
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 // ------------------------------------------------
24 // ----------------------------------------------
27 // ----------------------------------
33 MAX_BODYLEN = 65536, // probably too small
34 MAX_PACKETS = 256 // prolly too small too, but realloc?!?!?!
37 void addLacing(OggPage &);
40 unsigned char body[MAX_BODYLEN];
44 unsigned int packetSizes[MAX_PACKETS];
47 // ----------------------------------------------
52 :maxHeaders(0),serialNo(0),bitrate(0)
57 return maxHeaders && (pack.numPackets < maxHeaders);
66 void bos(unsigned int ser)
70 pack.packetSizes[0]=0;
76 bool isActive() {return serialNo!=0;}
78 void readHeader(Channel *,OggPage &);
80 virtual void procHeaders(Channel *) = 0;
86 unsigned int serialNo;
88 // ----------------------------------------------
89 class OggVorbisSubStream : public OggSubStream
96 virtual void procHeaders(Channel *);
98 void readIdent(Stream &, ChanInfo &);
99 void readSetup(Stream &);
100 void readComment(Stream &, ChanInfo &);
102 double getTime(OggPage &);
107 // ----------------------------------------------
108 class OggTheoraSubStream : public OggSubStream
111 OggTheoraSubStream() : granposShift(0), frameTime(0) {}
113 virtual void procHeaders(Channel *);
115 void readInfo(Stream &, ChanInfo &);
117 double getTime(OggPage &);
123 // ----------------------------------------------
124 class OGGStream : public ChannelStream
131 virtual void readHeader(Stream &,Channel *);
132 virtual int readPacket(Stream &,Channel *);
133 virtual void readEnd(Stream &,Channel *);
136 void readHeaders(Stream &,Channel *, OggPage &);
138 OggVorbisSubStream vorbis;
139 OggTheoraSubStream theora;
142 // ----------------------------------
149 MAX_HEADERLEN = 27+256
157 unsigned int getSerialNo();
165 unsigned char data[MAX_HEADERLEN+MAX_BODYLEN];