private void ParseRelativeVolumeFields(ByteVector data) { int pos = data.Find(TextDelimiter(StringType.Latin1)); if (pos < 0) { return; } identification = data.Mid(0, pos).ToString(StringType.Latin1); pos += 1; // Each channel is at least 4 buffer. while (pos <= data.Count - 4) { Id3v2ChannelType type = (Id3v2ChannelType)data[pos]; pos += 1; SetVolumeAdjustmentIndex(data.Mid(pos, 2).ToShort(), type); pos += 2; int bytes = BitsToBytes(data[pos]); pos += 1; SetPeakVolumeIndex(ParsePeakVolume(data.Mid(pos, bytes)), type); pos += bytes; } }
public void Parse(ByteVector data) { if (data != null) { // 11 buffer is the minimum size for an APE item if (data.Count < 11) { TagLibDebugger.Debug("APE.Item.Parse() -- no data in item"); return; } uint value_length = data.Mid(0, 4).ToUInt(false); uint flags = data.Mid(4, 4).ToUInt(false); int pos = data.Find(new ByteVector(1), 8); key = data.Mid(8, pos - 8).ToString(StringType.UTF8); value = data.Mid(pos + 1, (int)value_length); ReadOnly = (flags & 1) == 1; Type = (ApeItemType)((flags >> 1) & 3); if (Type != ApeItemType.Binary) { text.Clear(); text = new StringCollection(ByteVectorCollection.Split(value, (byte)0), StringType.UTF8); } } else { throw new ArgumentNullException("data"); } }
private void ParseAttachedPictureFields(ByteVector data) { if (data != null) { if (data.Count < 5) { TagLibDebugger.Debug("A picture frame must contain at least 5 bytes."); return; } int pos = 0; textEncoding = (StringType)data[pos]; pos += 1; int offset; if (Header.Version > 2) { offset = data.Find(TextDelimiter(StringType.Latin1), pos); if (offset < pos) { return; } mimeType = data.Mid(pos, offset - pos).ToString(StringType.Latin1); pos = offset + 1; } else { ByteVector ext = data.Mid(pos, 3); if (ext == "JPG") { mimeType = "image/jpeg"; } else if (ext == "PNG") { mimeType = "image/png"; } else { mimeType = "image/unknown"; } pos += 3; } type = (PictureType)data[pos]; pos += 1; offset = data.Find(TextDelimiter(textEncoding), pos); if (offset < pos) { return; } description = data.Mid(pos, offset - pos).ToString(textEncoding); pos = offset + 1; this.data = data.Mid(pos); } else { throw new ArgumentNullException("data"); } }