Example #1
0
		/// <summary>
		///    Reads the file until all streams have finished their
		///    property and tagging data.
		/// </summary>
		/// <param name="pages">
		///    A <see cref="T:System.Collections.Generic.List`1"/>
		///    object to be filled with <see cref="Page" /> objects as
		///    they are read, or <see langword="null"/> if the pages
		///    are not to be stored.
		/// </param>
		/// <param name="end">
		///    A <see cref="long" /> value reference to be updated to
		///    the postion of the first page not read by the current
		///    instance.
		/// </param>
		/// <returns>
		///    A <see cref="T:System.Collections.Generic.Dictionary`2"
		///    /> object containing stream serial numbers as the keys
		///    <see cref="Bitstream" /> objects as the values.
		/// </returns>
		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;
		}
Example #2
0
 private Dictionary<uint, Bitstream> ReadStreams(List<Page> pages, out long end)
 {
     Dictionary<uint, Bitstream> dictionary = new Dictionary<uint, Bitstream>();
     List<Bitstream> list = new List<Bitstream>();
     long position = 0L;
     do
     {
         Bitstream bitstream = null;
         Page page = new Page(this, position);
         if (((byte) (page.Header.Flags & PageFlags.FirstPageOfStream)) != 0)
         {
             bitstream = new Bitstream(page);
             dictionary.Add(page.Header.StreamSerialNumber, bitstream);
             list.Add(bitstream);
         }
         if (bitstream == null)
         {
             bitstream = dictionary[page.Header.StreamSerialNumber];
         }
         if (list.Contains(bitstream) && bitstream.ReadPage(page))
         {
             list.Remove(bitstream);
         }
         if (pages != null)
         {
             pages.Add(page);
         }
         position += page.Size;
     }
     while (list.Count > 0);
     end = position;
     return dictionary;
 }