Ejemplo n.º 1
0
 public Bitstream (Page page)
 {
    if (page == null)
       throw new ArgumentNullException ("page");
    
    // Assume that the first packet is completely enclosed. This should be
    // sufficient for codec recognition.
    _codec = Codec.GetCodec (page.Packets [0]);
    
    _first_absolute_granular_position = page.Header.AbsoluteGranularPosition;
 }
Ejemplo n.º 2
0
 public bool ReadPage (Page page)
 {
    if (page == null)
       throw new ArgumentNullException ("page");
    
    ByteVector[] packets = page.Packets;
    for (int i = 0; i < packets.Length; i ++)
    {
       if ((page.Header.Flags & PageFlags.FirstPacketContinued) == 0 && _previous_packet != null)
       {
          if (ReadPacket (_previous_packet))
             return true;
          _previous_packet = null;
       }
       
       
       ByteVector packet = packets [i];
       
       // If we're at the first packet of the page, and we're continuing an
       // old packet, combine the old with the new.
       if (i == 0 && (page.Header.Flags & PageFlags.FirstPacketContinued) != 0 && _previous_packet != null)
       {
          _previous_packet.Add (packet);
          packet = _previous_packet;
       }
       _previous_packet = null;
       
       // If we're at the last packet of the page, store it.
       if (i == packets.Length - 1)
          _previous_packet = new ByteVector (packet);
       
       // Otherwise, we need to process it.
       else if (ReadPacket (packet))
          return true;
    }
    
    return false;
 }
Ejemplo n.º 3
0
 private Dictionary<uint, Bitstream> ReadStreams (List<Page> pages, out long end)
 {
    Dictionary<uint, Bitstream> streams = new Dictionary<uint, Bitstream> ();
    List<Bitstream> active_streams = new List<Bitstream> ();
    
    long position = 0;
    
    do
    {
       Bitstream stream = null;
       Page page = new Page (this, position);
       
       if ((page.Header.Flags & PageFlags.FirstPageOfStream) != 0)
       {
          stream = new Bitstream (page);
          streams.Add (page.Header.StreamSerialNumber, stream);
          active_streams.Add (stream);
       }
       
       if (stream == null)
          stream = streams [page.Header.StreamSerialNumber];
       
       if (active_streams.Contains (stream) && stream.ReadPage (page))
          active_streams.Remove (stream);
       
       if (pages != null)
          pages.Add (page);
       
       position += page.Size;
    }
    while (active_streams.Count > 0);
    
    end = position;
    
    return streams;
 }