Provides an IContainerReader implementation for basic Ogg files.
Inheritance: IContainerReader
Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        public VorbisReader(Stream stream, bool closeStreamOnDispose)
            : this()
        {
            var bufferedStream = new BufferedReadStream(stream);

            bufferedStream.CloseBaseStream = closeStreamOnDispose;

            // try Ogg first
            var oggContainer = new Ogg.ContainerReader(bufferedStream, closeStreamOnDispose);

            if (!LoadContainer(oggContainer))
            {
                // oops, not Ogg!
                // we don't support any other container types yet, so error out
                // TODO: Add Matroska fallback
                bufferedStream.Close();
                throw new InvalidDataException("Could not determine container type!");
            }
            _containerReader = oggContainer;

            if (_decoders.Count == 0)
            {
                throw new InvalidDataException("No Vorbis data found!");
            }
        }
Ejemplo n.º 4
0
 internal Packet(ContainerReader containerReader, long streamOffset, int length)
     : base(length)
 {
     _containerReader = containerReader;
     _offset          = streamOffset;
     _length          = length;
     _curOfs          = 0;
 }
Ejemplo n.º 5
0
        Packet _prev; // IntPtr.Size

        #endregion Fields

        #region Constructors

        internal Packet(ContainerReader containerReader, long streamOffset, int length)
            : base(length)
        {
            _containerReader = containerReader;

            _offset = streamOffset;
            _length = length;
            _curOfs = 0;
        }
Ejemplo n.º 6
0
        public VorbisReader(Stream stream, bool closeStreamOnDispose)
            : this()
        {
            var bufferedStream = new BufferedReadStream(stream);
            bufferedStream.CloseBaseStream = closeStreamOnDispose;

            // try Ogg first
            var oggContainer = new Ogg.ContainerReader(bufferedStream, closeStreamOnDispose);
            if (!LoadContainer(oggContainer))
            {
                // oops, not Ogg!
                // we don't support any other container types yet, so error out
                bufferedStream.Close();
                throw new InvalidDataException("Could not determine container type!");
            }
            _containerReader = oggContainer;

            if (_decoders.Count == 0) throw new InvalidDataException("No Vorbis data found!");
        }
Ejemplo n.º 7
0
 public void Dispose()
 {
     _eosFound = true;
     _container.DisposePacketReader(this);
     _container = null;
     _current   = null;
     if (_first != null)
     {
         Packet packet = _first;
         _first = null;
         while (packet.Next != null)
         {
             Packet next = packet.Next;
             packet.Next = null;
             packet      = next;
             packet.Prev = null;
         }
         packet = null;
     }
     _last = null;
 }
Ejemplo n.º 8
0
        public VorbisReader(Stream stream, bool closeStreamOnDispose)
            : this()
        {
            var oggContainer = new Ogg.ContainerReader(stream, closeStreamOnDispose);

            if (!LoadContainer(oggContainer))
            {
                // oops, not Ogg!
                // we don't support any other container types here, so error out
                if (closeStreamOnDispose)
                {
                    stream.Close();
                }
                throw new InvalidDataException("Could not determine container type!");
            }
            _containerReader = oggContainer;

            if (_decoders.Count == 0)
            {
                throw new InvalidDataException("No Vorbis data found!");
            }
        }
Ejemplo n.º 9
0
 internal PacketReader(ContainerReader container, int streamSerial)
 {
     this._container    = container;
     this._streamSerial = streamSerial;
 }
Ejemplo n.º 10
0
 internal PacketReader(ContainerReader container, int streamSerial)
 {
     _container = container;
     _streamSerial = streamSerial;
 }
Ejemplo n.º 11
0
 internal void GatherNextPage(int streamSerial, ContainerReader.PageReaderLock pageLock)
 {
   if (pageLock == null)
     throw new ArgumentNullException("pageLock");
   if (!pageLock.Validate(this._pageLock))
     throw new ArgumentException("pageLock");
   if (!this._eosFlags.ContainsKey(streamSerial))
     throw new ArgumentOutOfRangeException("streamSerial");
   while (!this._eosFlags[streamSerial])
   {
     if (this.GatherNextPage("Could not find next page.") == streamSerial)
       return;
   }
   throw new EndOfStreamException();
 }
Ejemplo n.º 12
0
 private bool AddPage(ContainerReader.PageHeader hdr)
 {
   PacketReader packetReader;
   if (!this._packetReaders.TryGetValue(hdr.StreamSerial, out packetReader))
     packetReader = new PacketReader(this, hdr.StreamSerial);
   bool flag1 = false;
   bool flag2 = (hdr.Flags & PageFlags.ContinuesPacket) == PageFlags.ContinuesPacket;
   bool flag3 = (hdr.Flags & PageFlags.EndOfStream) == PageFlags.EndOfStream;
   bool flag4 = hdr.IsResync;
   int offset = 0;
   int length1 = hdr.PacketSizes.Length;
   foreach (int length2 in hdr.PacketSizes)
   {
     Packet packet1 = new Packet(this._stream, hdr.DataOffset + (long) offset, length2);
     packet1.PageGranulePosition = hdr.GranulePosition;
     packet1.IsEndOfStream = flag3;
     packet1.PageSequenceNumber = hdr.SequenceNumber;
     packet1.IsContinued = flag1;
     packet1.IsContinuation = flag2;
     packet1.IsResync = flag4;
     Packet packet2 = packet1;
     packet2.SetBuffer(hdr.SavedBuffer, offset);
     packetReader.AddPacket((DataPacket) packet2);
     offset += length2;
     flag2 = false;
     flag4 = false;
     if (--length1 == 1)
       flag1 = hdr.LastPacketContinues;
   }
   if (!this._packetReaders.ContainsKey(hdr.StreamSerial))
   {
     int streamSerial = hdr.StreamSerial;
     this._packetReaders.Add(streamSerial, packetReader);
     this._eosFlags.Add(streamSerial, flag3);
     this._streamSerials.Add(streamSerial);
     return true;
   }
   else
   {
     Dictionary<int, bool> dictionary;
     int streamSerial;
     (dictionary = this._eosFlags)[streamSerial = hdr.StreamSerial] = dictionary[streamSerial] | flag3;
     return false;
   }
 }