Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TagContainerV4"/> class.
 /// </summary>
 public TagContainerV4() : base(TagVersion.Id3V24)
 {
     m_Descriptor = new TagDescriptorV4();
 }
Example #2
0
        private static byte[] GetExtendedHeaderV4(TagDescriptorV4 descriptor)
        {
            if (!descriptor.ExtendedHeader)
            {
                return new byte[0];
            }

            //
            //  Create a list with dummy bytes for length and flags...
            //

            var bytes = new List<byte> {0x00, 0x00, 0x00, 0x00, 0x01, 0x00};

            byte flagByte = 0x00;
            if (descriptor.UpdateTag)
            {
                flagByte |= 0x40;
                bytes.Add(0x00);
            }

            if (descriptor.CrcDataPresent)
            {
                flagByte |= 0x20;
                bytes.Add(0x05);

                //TODO: Check byte array here...
                bytes.AddRange(descriptor.Crc);
            }

            if (descriptor.RestrictionPresent)
            {
                flagByte |= 0x10;
                bytes.Add(0x01);
                bytes.Add(descriptor.Restriction);
            }

            bytes[5] = flagByte;

            byte[] byteArray = bytes.ToArray();
            List<int> bits = GetBitCoding(byteArray.Length);
            var lengthBytes = new byte[4];

            EncodeLength(bits, lengthBytes);
            Array.Copy(lengthBytes, 0, byteArray, 0, 4);

            return byteArray;
        }