/// <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 { OggContainerReader reader = new OggContainerReader(_inputStream, true); if (!reader.Init()) { _lastError = "Could not initialize stream"; return(false); } //if (!reader.FindNextStream()) //{ // _lastError = "Could not find elementary stream"; // return false; //} if (reader.StreamSerials.Length == 0) { _lastError = "Initialization failed: No elementary streams found in input file"; return(false); } int streamSerial = reader.StreamSerials[0]; _packetProvider = reader.GetStream(streamSerial); QueueNextPacket(); return(true); } catch (Exception e) { _lastError = "Unknown initialization error: " + e.Message; return(false); } }
public void Dispose() { _eosFound = true; _container.DisposePacketReader(this); _container = null; _current = null; if (_first != null) { var node = _first; _first = null; while (node.Next != null) { var temp = node.Next; node.Next = null; node = temp; node.Prev = null; } node = null; } _last = null; }
internal Packet(OggContainerReader containerReader, long streamOffset, int length) : base(length) { _containerReader = containerReader; _offset = streamOffset; _length = length; _curOfs = 0; }
/// <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); } }
internal PacketReader(OggContainerReader container, int streamSerial) { _container = container; _streamSerial = streamSerial; }