public override DemuxPacketWrapper Read()
    {
      DemuxPacketWrapper EOS = new DemuxPacketWrapper(new DemuxPacket { StreamId = 0 }, IntPtr.Zero);

      byte[] bytes = new byte[1000000];
      if (_fileStream.Read(bytes, 0, 2) != 2) // 0xAF, 0xFE
        return EOS;

      if (bytes[0] != 0xAF || bytes[1] != 0xFE)
        throw new InvalidDataException("No valid header bytes found!");

      // Packet size
      if (_fileStream.Read(bytes, 0, sizeof(int)) != sizeof(int))
        return EOS; // int Size
      int size = BitConverter.ToInt32(bytes, 0);

      // noPadding = true, because padding was originally applied from source filter, avoid doing it again
      var packet = new DemuxPacket { Data = Marshal.AllocCoTaskMem(size) };

      // Packet data
      if (_fileStream.Read(bytes, 0, size) != size)
        return EOS;
      Marshal.Copy(bytes, 0, packet.Data, size);

      if (_fileStream.Read(bytes, 0, sizeof(int)) != sizeof(int))
        return EOS;
      packet.StreamId = BitConverter.ToInt32(bytes, 0);

      if (_fileStream.Read(bytes, 0, sizeof(long)) != sizeof(long))
        return EOS;
      packet.DemuxerId = BitConverter.ToInt32(bytes, 0);

      if (_fileStream.Read(bytes, 0, sizeof(int)) != sizeof(int))
        return EOS;
      packet.DispTime = BitConverter.ToInt32(bytes, 0);

      if (_fileStream.Read(bytes, 0, sizeof(double)) != sizeof(double))
        return EOS;
      packet.Dts = BitConverter.ToDouble(bytes, 0);

      if (_fileStream.Read(bytes, 0, sizeof(double)) != sizeof(double))
        return EOS;
      packet.Pts = BitConverter.ToDouble(bytes, 0);

      if (_fileStream.Read(bytes, 0, sizeof(double)) != sizeof(double))
        return EOS;
      packet.Duration = BitConverter.ToDouble(bytes, 0);

      if (_fileStream.Read(bytes, 0, sizeof(int)) != sizeof(int))
        return EOS;
      packet.GroupId = BitConverter.ToInt32(bytes, 0);

      return new DemuxPacketWrapper(packet, IntPtr.Zero);
    }
        public override DemuxPacketWrapper Read()
        {
            DemuxPacketWrapper EOS = new DemuxPacketWrapper(new DemuxPacket {
                StreamId = 0
            }, IntPtr.Zero);

            byte[] bytes = new byte[1000000];
            if (_fileStream.Read(bytes, 0, 2) != 2) // 0xAF, 0xFE
            {
                return(EOS);
            }

            if (bytes[0] != 0xAF || bytes[1] != 0xFE)
            {
                throw new InvalidDataException("No valid header bytes found!");
            }

            // Packet size
            if (_fileStream.Read(bytes, 0, sizeof(int)) != sizeof(int))
            {
                return(EOS); // int Size
            }
            int size = BitConverter.ToInt32(bytes, 0);

            // noPadding = true, because padding was originally applied from source filter, avoid doing it again
            var packet = new DemuxPacket {
                Data = Marshal.AllocCoTaskMem(size)
            };

            // Packet data
            if (_fileStream.Read(bytes, 0, size) != size)
            {
                return(EOS);
            }
            Marshal.Copy(bytes, 0, packet.Data, size);

            if (_fileStream.Read(bytes, 0, sizeof(int)) != sizeof(int))
            {
                return(EOS);
            }
            packet.StreamId = BitConverter.ToInt32(bytes, 0);

            if (_fileStream.Read(bytes, 0, sizeof(long)) != sizeof(long))
            {
                return(EOS);
            }
            packet.DemuxerId = BitConverter.ToInt32(bytes, 0);

            if (_fileStream.Read(bytes, 0, sizeof(int)) != sizeof(int))
            {
                return(EOS);
            }
            packet.DispTime = BitConverter.ToInt32(bytes, 0);

            if (_fileStream.Read(bytes, 0, sizeof(double)) != sizeof(double))
            {
                return(EOS);
            }
            packet.Dts = BitConverter.ToDouble(bytes, 0);

            if (_fileStream.Read(bytes, 0, sizeof(double)) != sizeof(double))
            {
                return(EOS);
            }
            packet.Pts = BitConverter.ToDouble(bytes, 0);

            if (_fileStream.Read(bytes, 0, sizeof(double)) != sizeof(double))
            {
                return(EOS);
            }
            packet.Duration = BitConverter.ToDouble(bytes, 0);

            if (_fileStream.Read(bytes, 0, sizeof(int)) != sizeof(int))
            {
                return(EOS);
            }
            packet.GroupId = BitConverter.ToInt32(bytes, 0);

            return(new DemuxPacketWrapper(packet, IntPtr.Zero));
        }
Esempio n. 3
0
 public virtual void Free(DemuxPacketWrapper packet)
 {
 }
Esempio n. 4
0
 public virtual void Free(DemuxPacketWrapper packet)
 {
 
 }