bool LoadComments(DataPacket packet) { if (!packet.ReadBytes(7).SequenceEqual(new byte[] { 0x03, 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73 })) { return(false); } if (!_pagesSeen.Contains((_lastPageSeen = packet.PageSequenceNumber))) { _pagesSeen.Add(_lastPageSeen); } _glueBits += 56; _vendor = Encoding.UTF8.GetString(packet.ReadBytes(packet.ReadInt32())); _comments = new string[packet.ReadInt32()]; for (int i = 0; i < _comments.Length; i++) { _comments[i] = Encoding.UTF8.GetString(packet.ReadBytes(packet.ReadInt32())); } _metaBits += packet.BitsRead - 56; _wasteHdrBits += 8 * packet.Length - packet.BitsRead; return(true); }
bool ProcessStreamHeader(DataPacket packet) { if (!packet.ReadBytes(7).SequenceEqual(new byte[] { 0x01, 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73 })) { // don't mark the packet as done... it might be used elsewhere _glueBits += packet.Length * 8; return(false); } if (!_pagesSeen.Contains((_lastPageSeen = packet.PageSequenceNumber))) { _pagesSeen.Add(_lastPageSeen); } _glueBits += 56; var startPos = packet.BitsRead; if (packet.ReadInt32() != 0) { throw new InvalidDataException("Only Vorbis stream version 0 is supported."); } _channels = packet.ReadByte(); _sampleRate = packet.ReadInt32(); _upperBitrate = packet.ReadInt32(); _nominalBitrate = packet.ReadInt32(); _lowerBitrate = packet.ReadInt32(); Block0Size = 1 << (int)packet.ReadBits(4); Block1Size = 1 << (int)packet.ReadBits(4); if (_nominalBitrate == 0) { if (_upperBitrate > 0 && _lowerBitrate > 0) { _nominalBitrate = (_upperBitrate + _lowerBitrate) / 2; } } _metaBits += packet.BitsRead - startPos + 8; _wasteHdrBits += 8 * packet.Length - packet.BitsRead; return(true); }
bool ProcessStreamHeader(DataPacket packet) { if (!packet.ReadBytes(7).SequenceEqual(new byte[] { 0x01, 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73 })) { // don't mark the packet as done... it might be used elsewhere _glueBits += packet.Length * 8; return false; } if (!_pagesSeen.Contains((_lastPageSeen = packet.PageSequenceNumber))) _pagesSeen.Add(_lastPageSeen); _glueBits += 56; var startPos = packet.BitsRead; if (packet.ReadInt32() != 0) throw new InvalidDataException("Only Vorbis stream version 0 is supported."); _channels = packet.ReadByte(); _sampleRate = packet.ReadInt32(); _upperBitrate = packet.ReadInt32(); _nominalBitrate = packet.ReadInt32(); _lowerBitrate = packet.ReadInt32(); Block0Size = 1 << (int)packet.ReadBits(4); Block1Size = 1 << (int)packet.ReadBits(4); if (_nominalBitrate == 0) { if (_upperBitrate > 0 && _lowerBitrate > 0) { _nominalBitrate = (_upperBitrate + _lowerBitrate) / 2; } } _metaBits += packet.BitsRead - startPos + 8; _wasteHdrBits += 8 * packet.Length - packet.BitsRead; return true; }
bool LoadComments(DataPacket packet) { if (!packet.ReadBytes(7).SequenceEqual(new byte[] { 0x03, 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73 })) { return false; } if (!_pagesSeen.Contains((_lastPageSeen = packet.PageSequenceNumber))) _pagesSeen.Add(_lastPageSeen); _glueBits += 56; _vendor = Encoding.UTF8.GetString(packet.ReadBytes(packet.ReadInt32())); _comments = new string[packet.ReadInt32()]; for (int i = 0; i < _comments.Length; i++) { _comments[i] = Encoding.UTF8.GetString(packet.ReadBytes(packet.ReadInt32())); } _metaBits += packet.BitsRead - 56; _wasteHdrBits += 8 * packet.Length - packet.BitsRead; return true; }