Exemplo n.º 1
0
        //////////////////////////////////////////////////////////////////////////
        // public methods
        //////////////////////////////////////////////////////////////////////////
        public OggPage(OggFile file, long pageOffset)
        {
            this.file       = file;
            this.fileOffset = pageOffset;
            //packetOffset = 0;
            //dataSize = 0;
            header           = new OggPageHeader(file, pageOffset);
            firstPacketIndex = -1;
            packets          = new ByteVectorCollection();

            if (file != null)
            {
                packetOffset = fileOffset + header.Size;
                dataSize     = header.DataSize;
            }
        }
Exemplo n.º 2
0
      //////////////////////////////////////////////////////////////////////////
      // public methods
      //////////////////////////////////////////////////////////////////////////
		public OggPage(OggFile file, long pageOffset)
		{
			this.file = file;
			this.fileOffset = pageOffset;
			//packetOffset = 0;
			//dataSize = 0;
			header = new OggPageHeader(file, pageOffset);
			firstPacketIndex = -1;
			packets = new ByteVectorCollection();
         
			if (file != null)
			{
				packetOffset = fileOffset + header.Size;
				dataSize = header.DataSize;
			}
		}
Exemplo n.º 3
0
		public OggPageHeader(OggFile file, long pageOffset)
		{
			//isValid                   = false;
			//packetSizes = new ArrayList();
			//firstPacketContinued     = false;
			//lastPacketCompleted      = false;
			//first_page_of_stream       = false;
			//last_page_of_stream        = false;
			//absolute_granular_position = 0;
			//streamSerialNumber       = 0;
			//pageSequenceNumber = -1;
			//size                       = 0;
			//data_size                  = 0;

			if (file != null && pageOffset >= 0)
				Read(file, pageOffset);
		}
Exemplo n.º 4
0
        public OggPageHeader(OggFile file, long pageOffset)
        {
            //isValid                   = false;
            //packetSizes = new ArrayList();
            //firstPacketContinued     = false;
            //lastPacketCompleted      = false;
            //first_page_of_stream       = false;
            //last_page_of_stream        = false;
            //absolute_granular_position = 0;
            //streamSerialNumber       = 0;
            //pageSequenceNumber = -1;
            //size                       = 0;
            //data_size                  = 0;

            if (file != null && pageOffset >= 0)
            {
                Read(file, pageOffset);
            }
        }
Exemplo n.º 5
0
        private void Read(OggFile file, long file_offset)
        {
            file.Seek(file_offset);

            // An Ogg page header is at least 27 buffer, 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);

            // Sanity check -- make sure that we were in fact able to read as much data as
            // we asked for and that the page begins with "OggS".

            if (data.Count != 27 || !data.StartsWith("OggS"))
            {
                TagLibDebugger.Debug("Ogg.PageHeader.Read() -- error reading page header");
                return;
            }

            byte flags = data[5];

            firstPacketContinued = (flags & 1) != 0;
            firstPageOfStream    = ((flags >> 1) & 1) != 0;
            lastPageOfStream     = ((flags >> 2) & 1) != 0;

            absoluteGranularPosition = data.Mid(6, 8).ToLong(false);
            streamSerialNumber       = data.Mid(14, 4).ToUInt(false);
            pageSequenceNumber       = (int)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 pageSegmentCount = data[26];

            ByteVector page_segments = file.ReadBlock(pageSegmentCount);

            // Another sanity check.

            if (pageSegmentCount < 1 || page_segments.Count != pageSegmentCount)
            {
                return;
            }

            // The base size of an Ogg page 27 buffer plus the number of lacing values.

            size = 27 + pageSegmentCount;

            int packetSize = 0;

            for (int i = 0; i < pageSegmentCount; i++)
            {
                dataSize   += page_segments[i];
                packetSize += page_segments[i];

                if (page_segments[i] < 255)
                {
                    packetSizes.Add(packetSize);
                    packetSize = 0;
                }
            }

            if (packetSize > 0)
            {
                packetSizes.Add(packetSize);
                lastPacketCompleted = false;
            }
            else
            {
                lastPacketCompleted = true;
            }

            isValid = true;
        }
Exemplo n.º 6
0
		private void Read(OggFile file, long file_offset)
		{
			file.Seek(file_offset);

			// An Ogg page header is at least 27 buffer, 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);

			// Sanity check -- make sure that we were in fact able to read as much data as
			// we asked for and that the page begins with "OggS".

			if (data.Count != 27 || !data.StartsWith("OggS"))
			{
				TagLibDebugger.Debug("Ogg.PageHeader.Read() -- error reading page header");
				return;
			}

			byte flags = data[5];

			firstPacketContinued = (flags & 1) != 0;
			firstPageOfStream = ((flags >> 1) & 1) != 0;
			lastPageOfStream = ((flags >> 2) & 1) != 0;

			absoluteGranularPosition = data.Mid(6, 8).ToLong(false);
			streamSerialNumber = data.Mid(14, 4).ToUInt(false);
			pageSequenceNumber = (int)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 pageSegmentCount = data[26];

			ByteVector page_segments = file.ReadBlock(pageSegmentCount);

			// Another sanity check.

			if (pageSegmentCount < 1 || page_segments.Count != pageSegmentCount)
				return;

			// The base size of an Ogg page 27 buffer plus the number of lacing values.

			size = 27 + pageSegmentCount;

			int packetSize = 0;

			for (int i = 0; i < pageSegmentCount; i++)
			{
				dataSize += page_segments[i];
				packetSize += page_segments[i];

				if (page_segments[i] < 255)
				{
					packetSizes.Add(packetSize);
					packetSize = 0;
				}
			}

			if (packetSize > 0)
			{
				packetSizes.Add(packetSize);
				lastPacketCompleted = false;
			}
			else
				lastPacketCompleted = true;

			isValid = true;
		}