1 // ------------------------------------------------
6 // (c) 2002-4 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 // ------------------------------------------------
26 // ------------------------------------------------
30 AtomStream(Stream &s) : io(s),numChildren(0),numData(0)
36 throw StreamException("Bad atom data");
39 void writeParent(ID4 id,int nc)
42 io.writeInt(nc|0x80000000);
45 void writeInt(ID4 id,int d)
52 void writeID4(ID4 id,ID4 d)
59 void writeShort(ID4 id,short d)
66 void writeChar(ID4 id,char d)
73 void writeBytes(ID4 id,const void *p,int l)
81 int writeStream(ID4 id,Stream &in,int l)
86 return (sizeof(int)*2)+l;
90 void writeString(ID4 id,const char *p)
92 writeBytes(id,p,strlen(p)+1);
95 ID4 read(int &numc,int &dlen)
97 ID4 id = io.readID4();
99 unsigned int v = io.readInt();
116 void skip(int c, int d)
121 for(int i=0; i<c; i++)
144 return io.readShort();
149 return io.readChar();
151 int readBytes(void *p,int l)
157 void readString(char *s,int max,int dlen)
160 readBytes(s,max,dlen);
165 void readBytes(void *s,int max,int dlen)
177 int writeAtoms(ID4 id, Stream &in, int cnt, int data)
184 total+=sizeof(int)*2;
186 for(int i=0; i<cnt; i++)
190 ID4 cid = ain.read(c,d);
191 total += writeAtoms(cid,in,c,d);
195 total += writeStream(id,in,data);
201 bool eof() {return io.eof();}
204 int numChildren,numData;