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 // ------------------------------------------------
25 // -----------------------------------
32 data1 = in.readLong();
33 data2 = in.readShort();
34 data3 = in.readShort();
38 void write(Stream &out)
41 out.writeShort(data2);
42 out.writeShort(data3);
47 void toString(String &s)
49 sprintf(s.data,"%X-%X-%X-%02X%02X%02X%02X%02X%02X%02X%02X",
51 data4[0],data4[1],data4[2],data4[3],
52 data4[4],data4[5],data4[6],data4[7]);
55 int operator==(const MSID& msid) const{return !memcmp(this, &msid, sizeof(MSID));}
58 unsigned short data2,data3;
59 unsigned char data4[8];
66 // -----------------------------------
68 {0x75B22630, 0x668E, 0x11CF, 0xA6,0xD9,0x00,0xAA,0x00,0x62,0xCE,0x6C};
70 {0x75B22636, 0x668E, 0x11CF, 0xA6,0xD9,0x00,0xAA,0x00,0x62,0xCE,0x6C};
71 const MSID filePropObjID=
72 {0x8CABDCA1, 0xA947, 0x11CF, 0x8E,0xE4,0x00,0xC0,0x0C,0x20,0x53,0x65};
73 const MSID streamPropObjID=
74 {0xB7DC0791, 0xA9B7, 0x11CF, 0x8E,0xE6,0x00,0xC0,0x0C,0x20,0x53,0x65};
76 const MSID audioStreamObjID=
77 {0xF8699E40, 0x5B4D, 0x11CF, 0xA8,0xFD,0x00,0x80,0x5F,0x5C,0x44,0x2B};
78 const MSID videoStreamObjID=
79 {0xBC19EFC0, 0x5B4D, 0x11CF, 0xA8,0xFD,0x00,0x80,0x5F,0x5C,0x44,0x2B};
81 const MSID streamBitrateObjID=
82 {0x7BF875CE, 0x468D, 0x11D1, 0x8D,0x82,0x00,0x60,0x97,0xC9,0xA2,0xB2};
85 // -----------------------------------
105 unsigned int readHead(Stream &in)
109 lenLo = in.readLong();
110 lenHi = in.readLong();
114 type = T_HEAD_OBJECT;
115 else if (id == dataObjID)
116 type = T_DATA_OBJECT;
117 else if (id == filePropObjID)
119 else if (id == streamPropObjID)
120 type = T_STREAM_PROP;
121 else if (id == streamBitrateObjID)
122 type = T_STREAM_BITRATE;
126 LOG_DEBUG("ASF: %s (%s)= %d : %d\n",str.data,getTypeName(),lenLo,lenHi);
134 void readData(Stream &in,int len)
138 if ((dataLen > sizeof(data)) || (lenHi))
139 throw StreamException("ASF object too big");
141 in.read(data,dataLen);
145 void write(Stream &out)
148 out.writeLong(lenLo);
149 out.writeLong(lenHi);
151 out.write(data,dataLen);
154 const char *getTypeName()
159 return "ASF_Header_Object";
161 return "ASF_Data_Object";
163 return "ASF_File_Properties_Object";
165 return "ASF_Stream_Properties_Object";
166 case T_STREAM_BITRATE:
167 return "ASF_Stream_Bitrate_Properties_Object";
169 return "Unknown_Object";
175 unsigned int lenLo,lenHi,dataLen;
178 // -----------------------------------
189 void read(Stream &in)
194 if (sid == videoStreamObjID)
196 else if (sid == audioStreamObjID)
202 id = in.readShort()&0x7f;
206 const char *getTypeName()
230 // -----------------------------------
245 for(int i=0; i<MAX_STREAMS; i++)
249 unsigned int packetSize,numPackets,flags,bitrate;
251 ASFStream streams[MAX_STREAMS];
254 // -----------------------------------
259 void read(Stream &in)
261 type = in.readShort();
262 len = in.readShort();
268 if (dataLen > sizeof(data))
269 throw StreamException("ASF chunk too big");
270 in.read(data,dataLen);
273 void write(Stream &out)
275 out.writeShort(type);
280 out.write(data,dataLen);
283 unsigned int seq,dataLen;
284 unsigned short type,len,v1,v2;
285 unsigned char data[8192];