protected OggPage(ByteVectorCollection packets, uint stream_serial_number, int page_number, bool first_packet_continued, bool last_packet_completed, bool contains_last_packet) { //file = null; fileOffset = -1; //packetOffset = 0; //dataSize = 0; header = new OggPageHeader(); firstPacketIndex = -1; this.packets = packets; ByteVector data = new ByteVector(); ArrayList packet_sizes = new ArrayList(); header.FirstPageOfStream = (page_number == 0 && !first_packet_continued); header.LastPageOfStream = contains_last_packet; header.FirstPacketContinued = first_packet_continued; header.LastPacketCompleted = last_packet_completed; header.StreamSerialNumber = stream_serial_number; header.PageSequenceNumber = page_number; // Build a page from the text of packets. foreach (ByteVector v in packets) { packet_sizes.Add(v.Count); data.Add(v); } header.SetPacketSizes((int[])packet_sizes.ToArray(typeof(int))); }
protected void ClearPageData() { streamSerialNumber = 0; pages = new List <OggPage>(); //new ArrayList (); firstPageHeader = null; lastPageHeader = null; packetToPageMap = new List <IntCollection>(); //new ArrayList(); dirtyPackets = new Dictionary <uint, ByteVector>(); //new Hashtable (); dirtyPages = new IntCollection(); currentPage = null; currentPacketPage = null; currentPackets = null; }
////////////////////////////////////////////////////////////////////////// // 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; } }
//private void Read(OggVorbisFile file, ReadStyle style) private void Read(OggVorbisFile file) { // Get the identification header from the Ogg implementation. ByteVector data = file.GetPacket(0); int pos = 0; if (data.Mid(pos, 7) != vorbisCommentHeaderId) { TagLibDebugger.Debug("Vorbis.Properties.Read() -- invalid Vorbis identification header"); return; } pos += 7; vorbisVersion = (int)data.Mid(pos, 4).ToUInt(false); pos += 4; channels = data[pos]; pos += 1; sampleRate = (int)data.Mid(pos, 4).ToUInt(false); pos += 4; bitrateMaximum = (int)data.Mid(pos, 4).ToUInt(false); pos += 4; bitrateNominal = (int)data.Mid(pos, 4).ToUInt(false); pos += 4; bitrateMinimum = (int)data.Mid(pos, 4).ToUInt(false); // TODO: Later this should be only the "fast" mode. bitrate = bitrateNominal; // Find the length of the file. See http://wiki.xiph.org/VorbisStreamLength/ // for my notes on the topic. OggPageHeader first = file.FirstPageHeader; OggPageHeader last = file.LastPageHeader; if (first != null && last != null) { long start = first.AbsoluteGranularPosition; long end = last.AbsoluteGranularPosition; if (start >= 0 && end >= 0 && sampleRate > 0) { duration = TimeSpan.FromSeconds(((double)(end - start) / (double)sampleRate)); } else { TagLibDebugger.Debug("Vorbis.Properties.Read() -- Either the PCM " + "values for the start or end of this file was " + "incorrect or the sample rate is zero."); } } else { TagLibDebugger.Debug("Vorbis.Properties.Read() -- Could not find valid first and last Ogg pages."); } }
protected OggPage (ByteVectorCollection packets, uint stream_serial_number, int page_number, bool first_packet_continued, bool last_packet_completed, bool contains_last_packet) { //file = null; fileOffset = -1; //packetOffset = 0; //dataSize = 0; header = new OggPageHeader(); firstPacketIndex = -1; this.packets = packets; ByteVector data = new ByteVector(); ArrayList packet_sizes = new ArrayList(); header.FirstPageOfStream = (page_number == 0 && !first_packet_continued); header.LastPageOfStream = contains_last_packet; header.FirstPacketContinued = first_packet_continued; header.LastPacketCompleted = last_packet_completed; header.StreamSerialNumber = stream_serial_number; header.PageSequenceNumber = page_number; // Build a page from the text of packets. foreach (ByteVector v in packets) { packet_sizes.Add (v.Count); data.Add (v); } header.SetPacketSizes((int[]) packet_sizes.ToArray(typeof(int))); }
protected void ClearPageData() { streamSerialNumber = 0; pages = new List<OggPage>(); //new ArrayList (); firstPageHeader = null; lastPageHeader = null; packetToPageMap = new List<IntCollection>(); //new ArrayList(); dirtyPackets = new Dictionary<uint, ByteVector>(); //new Hashtable (); dirtyPages = new IntCollection(); currentPage = null; currentPacketPage = null; currentPackets = null; }