Logo Search packages:      
Sourcecode: f-spot version File versions  Download package

TagLib::Ogg::PageHeader::PageHeader ( File  file,
long  position 
) [inline]

Constructs and initializes a new instance of PageHeader by reading a raw Ogg page header from a specified position in a specified file.

fileA File object containing the file from which the contents of the new instance are to be read.
positionA long value specify at what position to read.
ArgumentNullExceptionfile is .
ArgumentOutOfRangeExceptionposition is less than zero or greater than the size of the file.
CorruptFileExceptionThe Ogg identifier could not be found at the correct location.

Definition at line 174 of file PageHeader.cs.

References TagLib::ByteVector::Add(), TagLib::ByteVector::Count, TagLib::File::Length, TagLib::ByteVector::Mid(), TagLib::File::ReadBlock(), TagLib::File::Seek(), TagLib::ByteVector::StartsWith(), TagLib::ByteVector::ToUInt(), and TagLib::ByteVector::ToULong().

                  if (file == null)
                        throw new ArgumentNullException ("file");
                  if (position < 0 || position > file.Length - 27)
                        throw new ArgumentOutOfRangeException (
                  file.Seek (position);
                  // An Ogg page header is at least 27 bytes, so we'll go
                  // ahead and read that much and then get the rest when
                  // we're ready for it.
                  ByteVector data = file.ReadBlock (27);
                  if (data.Count < 27 || !data.StartsWith ("OggS"))
                        throw new CorruptFileException (
                              "Error reading page header");
                  version = data [4];
                  this.flags = (PageFlags) data [5];
                  absolute_granular_position = data.Mid(6, 8).ToULong (
                  stream_serial_number = data.Mid(14, 4).ToUInt (false);
                  page_sequence_number = data.Mid(18, 4).ToUInt (false);

                  // Byte number 27 is the number of page segments, which
                  // is the only variable length portion of the page
                  // header. After reading the number of page segments
                  // we'll then read in the coresponding data for this
                  // count.
                  int page_segment_count = data [26];
                  ByteVector page_segments =
                        file.ReadBlock (page_segment_count);
                  // Another sanity check.
                  if (page_segment_count < 1 ||
                        page_segments.Count != page_segment_count)
                        throw new CorruptFileException (
                              "Incorrect number of page segments");
                  // The base size of an Ogg page 27 bytes plus the number
                  // of lacing values.
                  size = (uint)(27 + page_segment_count);
                  packet_sizes = new List<int> ();
                  int packet_size = 0;
                  data_size = 0;
                  for (int i = 0; i < page_segment_count; i++) {
                        data_size += page_segments [i];
                        packet_size += page_segments [i];
                        if (page_segments [i] < 255) {
                              packet_sizes.Add (packet_size);
                              packet_size = 0;
                  if (packet_size > 0)
                        packet_sizes.Add (packet_size);

Here is the call graph for this function:

Generated by  Doxygen 1.6.0   Back to index