Beispiel #1
0
        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 ParseUniqueFields(ByteVector data)
        {
            ByteVectorCollection fields = ByteVectorCollection.Split(data, (byte)0);

            if (fields.Count != 2)
            {
                return;
            }

            owner      = fields[0].ToString(StringType.Latin1);
            identifier = fields[1];
        }
Beispiel #3
0
        private void ParsePrivateFields(ByteVector data)
        {
            if (data.Count < 1)
            {
                TagLibDebugger.Debug("A private frame must contain at least 1 byte.");
                return;
            }

            ByteVectorCollection list = ByteVectorCollection.Split(data, TextDelimiter(StringType.Latin1), 1, 2);

            if (list.Count == 2)
            {
                owner = list[0].ToString(StringType.Latin1);
                data  = list[1];
            }
        }
        private void ParseTextIdentifierFields(ByteVector data)
        {
            // read the string data type (the first byte of the field data)

            textEncoding = (StringType)data[0];

            // split the byte numbers into chunks based on the string type (two byte delimiter
            // for unicode encodings)

            int byteAlign = textEncoding == StringType.Latin1 || textEncoding == StringType.UTF8 ? 1 : 2;

            ByteVectorCollection list = ByteVectorCollection.Split(data.Mid(1), TextDelimiter(textEncoding), byteAlign);

            fieldList.Clear();

            // append those split values to the text and make sure that the new string'field
            // type is the same specified for this frame

            foreach (ByteVector vector in list)
            {
                fieldList.Add(vector.ToString(textEncoding));
            }
        }
Beispiel #5
0
        private void ParseCommentsFields(ByteVector data)
        {
            if (data.Count < 5)
            {
                TagLibDebugger.Debug("A comment frame must contain at least 5 bytes.");
                return;
            }

            textEncoding = (StringType)data[0];
            language     = data.Mid(1, 3);

            int byte_align = textEncoding == StringType.Latin1 || textEncoding == StringType.UTF8 ? 1 : 2;

            ByteVectorCollection l = ByteVectorCollection.Split(data.Mid(4), TextDelimiter(textEncoding), byte_align, 2);

            if (l.Count == 2)
            {
                if (l[0].Data != null && l[0].Data.Count > 0)
                {
                    description = l[0].ToString(textEncoding);
                }
                else
                {
                    description = string.Empty;
                }

                if (l[1].Data != null && l[1].Data.Count > 0)
                {
                    text = l[1].ToString(textEncoding);
                }
                else
                {
                    text = string.Empty;
                }
            }
        }