+FILE*mp3file;
+void handlesoundstream(TAG*tag)
+{
+ char*filename = "output.mp3";
+ if(numextracts==1) {
+ filename = destfilename;
+ if(!strcmp(filename,"output.swf"))
+ filename = "output.mp3";
+ }
+ switch(tag->id) {
+ case ST_SOUNDSTREAMHEAD:
+ if((tag->data[1]&0x30) == 0x20) { //mp3 compression
+ mp3file = fopen(filename, "wb");
+ logf("<notice> Writing mp3 data to %s",filename);
+ }
+ else
+ logf("<error> Soundstream is not mp3");
+ break;
+ case ST_SOUNDSTREAMHEAD2:
+ if((tag->data[1]&0x30) == 0x20) {//mp3 compression
+ mp3file = fopen("mainstream.mp3", "wb");
+ logf("<notice> Writing mp3 data to %s",filename);
+ }
+ else
+ logf("<error> Soundstream is not mp3 (2)");
+ break;
+ case ST_SOUNDSTREAMBLOCK:
+ if(mp3file)
+ fwrite(&tag->data[4],tag->len-4,1,mp3file);
+ break;
+ }
+}
+