internal bool CheckSecondHeader(ogg.Packet p, ref bool needMoreData) { needMoreData = false; //We have all headers already, so just return if (headerCount == 3) { return(false); } int retVal = vorbisStreamState.packetout(p); if (retVal == 1) { if (vorbisInfo.synthesis_headerin(vorbisComment, p) != 0) { throw new Exception("Invalid stream"); } headerCount++; return(true); } else if (retVal < 0) //error { throw new Exception("Invalid stream"); } //Need more data needMoreData = true; return(true); }
internal bool CheckSecondHeader(ogg.Packet p, ref bool needMoreData) { needMoreData = false; if (headerCount == 3) { //Call to allow driver to setup any needed structures //OnInit( new Vec2i( (int)theoraInfo.width, (int)theoraInfo.height ) ); headerCount = 4; return(false); } else if (headerCount == 4) { return(false); } int retVal = theoraStreamState.packetout(p); if (retVal == 1) { if (theoraInfo.decode_header(theoraComment, p) != 0) { throw new Exception("invalid stream"); } headerCount++; return(true); } else if (retVal < 0) //error { throw new Exception("invalid stream"); } //Need more data, so return true needMoreData = true; return(true); }
/// <summary> /// internal method for parsing the main stream headers /// </summary> void ParsePrimaryHeaders() { ogg.Packet tempOggPacket = new ogg.Packet(); bool notDone = true; int vorbis_streams = 0; int theora_streams = 0; while (notDone) { if (BufferData() == 0) { tempOggPacket.Dispose(); throw new Exception("Invalid ogg file"); } //Check for page data while (oggSyncState.pageout(oggPage) > 0) { //is this an initial header? If not, stop if (oggPage.bos() == 0) { //This is done blindly, because stream only accept them selfs if (videoDriver != null && theora_streams > 0) { videoDriver.PageIn(oggPage); } if (audioDriver != null && vorbis_streams > 0) { audioDriver.PageIn(oggPage); } notDone = false; break; } ogg.StreamState oggStateTest = new ogg.StreamState(oggPage.serialno()); //oggStateTest.init( oggPage.serialno() ); oggStateTest.pagein(oggPage); oggStateTest.packetout(tempOggPacket); //identify the codec if (videoDriver != null && videoDriver.DecodePrimaryHeader(tempOggPacket, oggStateTest)) { theora_streams = 1; } else if (audioDriver != null && audioDriver.DecodePrimaryHeader(tempOggPacket, oggStateTest)) { vorbis_streams = 1; } else { oggStateTest.Dispose(); } } //end while ogg_sync_pageout } //end while notdone //if pri headers not found, then remove driver if (theora_streams == 0 && videoDriver != null) { videoDriver.Dispose(); videoDriver = null; } if (vorbis_streams == 0 && audioDriver != null) { audioDriver.Dispose(); audioDriver = null; } tempOggPacket.Dispose(); }