Beispiel #1
0
        /// <summary>
        /// Creates a new SeekTable base on the provided binary data.
        /// </summary>
        /// <param name="data"></param>
        public override void LoadBlockData(byte[] data)
        {
            UInt32    numberOfSeekpoints;
            SeekPoint newSeekPoint;

            numberOfSeekpoints = this.Header.MetaDataBlockLength / SEEKPOINT_SIZE;
            for (int i = 0; i < numberOfSeekpoints; i++)
            {
                newSeekPoint = new SeekPoint(BinaryDataHelper.GetDataSubset(data, i * (int)SEEKPOINT_SIZE, (int)SEEKPOINT_SIZE));
                // We should keep in mind that the placeholder seekpoints aren't actually added to the list but are kept only as a
                // count in this.SeekPoints.Placeholders
                this.SeekPoints.Add(newSeekPoint);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Loads the picture data from a Metadata block.
        /// </summary>
        /// <param name="data"></param>
        public override void LoadBlockData(byte[] data)
        {
            // First 32-bit: picture type according to the ID3v2 APIC frame
            pictureType = (PictureType)(int)BinaryDataHelper.GetUInt32(data, 0);

            // Then the length of the MIME type text (32-bit) and the mime type
            int mimeTypeLength = (int)BinaryDataHelper.GetUInt32(data, 4);

            byte[] mimeData = BinaryDataHelper.GetDataSubset(data, 8, mimeTypeLength);
            this.mimeType = Encoding.ASCII.GetString(mimeData);

            int byteOffset = 8 + mimeTypeLength;

            // Then the description (in UTF-8)
            int descriptionLength = (int)BinaryDataHelper.GetUInt32(data, byteOffset);

            byte[] descriptionData = BinaryDataHelper.GetDataSubset(data, byteOffset + 4, descriptionLength);
            this.description = Encoding.UTF8.GetString(descriptionData);

            byteOffset += 4 + descriptionLength;

            this.width      = BinaryDataHelper.GetUInt32(data, byteOffset);
            this.height     = BinaryDataHelper.GetUInt32(data, byteOffset + 4);
            this.colorDepth = BinaryDataHelper.GetUInt32(data, byteOffset + 8);
            this.colors     = BinaryDataHelper.GetUInt32(data, byteOffset + 12);

            byteOffset += 16;

            int dataLength = (int)BinaryDataHelper.GetUInt32(data, byteOffset);

            this.data = BinaryDataHelper.GetDataSubset(data, byteOffset + 4, dataLength);

            // According to the FLAC format, if the mimeType is the string -->, the data contains
            // a URL, pointing to the image. A URL should be ASCII encoded, but using UTF-8 seems
            // more sensible.
            if (mimeType == "-->")
            {
                this.url = Encoding.UTF8.GetString(this.data);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Loads the Vorbis from a block of data.
        /// </summary>
        /// <param name="data"></param>
        public override void LoadBlockData(byte[] data)
        {
            UInt32 vendorLength = BinaryDataHelper.GetUInt32(BinaryDataHelper.SwitchEndianness(data, 0, 4), 0);

            this.vendor = Encoding.UTF8.GetString(BinaryDataHelper.GetDataSubset(data, 4, (int)vendorLength));

            int    startOfComments       = 4 + (int)vendorLength;
            UInt32 userCommentListLength = BinaryDataHelper.GetUInt32(BinaryDataHelper.SwitchEndianness(data, startOfComments, 4), 0);

            // Start of comments actually four bytes further (first piece is the count of items in the list)
            startOfComments += 4;
            for (UInt32 i = 0; i < userCommentListLength; i++)
            {
                UInt32 commentLength = BinaryDataHelper.GetUInt32(BinaryDataHelper.SwitchEndianness(data, startOfComments, 4), 0);
                string comment       = Encoding.UTF8.GetString(BinaryDataHelper.GetDataSubset(data, startOfComments + 4, (int)commentLength));
                // We're moving on in the array ...
                startOfComments += 4 + (int)commentLength;

                AddComment(comment);
            }

            // All done, note that FLAC doesn't have the "fraiming bit" for vorbis ...
        }