public void Init(VirtualFileStream stream, VideoDriver videoDriver, AudioDriver audioDriver, bool sound3D) { this.stream = stream; this.audioDriver = audioDriver; this.videoDriver = videoDriver; this.sound3D = sound3D; if (videoDriver != null) { videoDriver.oggFile = this; } if (audioDriver != null) { audioDriver.oggFile = this; } oggSyncState = new ogg.SyncState(); oggPage = new ogg.Page(); ParsePrimaryHeaders(); ParseSecondaryHeaders(); if (this.audioDriver != null) { this.audioDriver.InitDSP(); } if (this.videoDriver != null) { this.videoDriver.InitTheora(); } //Update first frame Update(0); }
public void Dispose() { try { if (criticalSection != null) { criticalSection.Enter(); } Pause = true; if (videoDriver != null) { videoDriver.Dispose(); videoDriver = null; } if (audioDriver != null) { audioDriver.Dispose(); audioDriver = null; } if (oggSyncState != null) { oggSyncState.Dispose(); oggSyncState = null; } if (oggPage != null) { oggPage.Dispose(); oggPage = null; } if (stream != null) { stream.Dispose(); stream = null; } } catch (Exception ex) { Log.Error("OggFile: Exception: " + ex.ToString()); } finally { if (criticalSection != null) { criticalSection.Leave(); } } if (criticalSection != null) { criticalSection.Dispose(); criticalSection = null; } GC.SuppressFinalize(this); }
/// <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(); }