private void NewStream(int streamSerial) { DataPacket nextPacket = this._packetProvider.GetNextPacket(streamSerial); if ((int)nextPacket.PeekByte() != (int)VorbisStreamDecoder.InitialPacketMarker) { return; } VorbisStreamDecoder vorbisStreamDecoder = new VorbisStreamDecoder((Func <DataPacket>)(() => { IPacketProvider local_0 = this._packetProvider; if (local_0 != null) { return(local_0.GetNextPacket(streamSerial)); } else { return((DataPacket)null); } }), (Func <int>)(() => { IPacketProvider local_0 = this._packetProvider; if (local_0 != null) { return(local_0.GetTotalPageCount(streamSerial)); } else { return(0); } })); try { if (!vorbisStreamDecoder.TryInit(nextPacket)) { return; } this._decoders.Add(vorbisStreamDecoder); this._serials.Add(streamSerial); } catch (InvalidDataException ex) { } }
/// <summary> /// Creates an opus decoder and reads from the ogg stream until a data packet is encountered, /// queuing it up for future decoding. Tags are also parsed if they are encountered. /// </summary> /// <returns>True if the stream is valid and ready to be decoded</returns> private bool Initialize() { try { var oggContainerReader = new OggContainerReader(_stream, true); if (!oggContainerReader.Init()) { LastError = "Could not initialize stream"; return(false); } if (oggContainerReader.StreamSerials.Length == 0) { LastError = "Initialization failed: No elementary streams found in input file"; return(false); } int firstStreamSerial = oggContainerReader.StreamSerials[0]; _packetProvider = oggContainerReader.GetStream(firstStreamSerial); if (CanSeek) { GranuleCount = _packetProvider.GetGranuleCount(); PageCount = _packetProvider.GetTotalPageCount(); } QueueNextPacket(); return(true); } catch (Exception e) { LastError = "Unknown initialization error: " + e.Message; return(false); } }