public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            if (bytesLeft >= 4)
            {
                TextEncoding = (EncodingType)stream.Read1(ref bytesLeft);
                MimeType     = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                if (bytesLeft > 0)
                {
                    FileName = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);
                    if (bytesLeft > 0)
                    {
                        Description = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);
                        if (bytesLeft > 0)
                        {
                            EncapsulatedObject = stream.Read(bytesLeft);
                            bytesLeft          = 0;
                        }
                    }
                }
            }

            // Seek to end of frame
            if (bytesLeft > 0)
            {
                stream.Seek(bytesLeft, SeekOrigin.Current);
            }
        }
Beispiel #2
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            Reset();

            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            if (bytesLeft > 0)
            {
                OwnerIdentifier = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                if (bytesLeft > 0)
                {
                    MethodSymbol = stream.Read1(ref bytesLeft);
                    if (bytesLeft > 0)
                    {
                        EncryptionData = stream.Read(bytesLeft);
                        bytesLeft      = 0;
                    }
                }
            }

            if (bytesLeft != 0)
            {
                stream.Seek(bytesLeft, SeekOrigin.Current);
            }
        }
Beispiel #3
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            if (bytesLeft > 0)
            {
                UserEmail = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                if (bytesLeft > 0)
                {
                    Rating = stream.Read1(ref bytesLeft);
                    if (bytesLeft > 0)
                    {
                        byte[] playCount = stream.Read(bytesLeft);
                        PlayCount = ByteUtils.ConvertToInt64(playCount);
                    }
                    else
                    {
                        PlayCount = 0;
                    }
                }
                else
                {
                    Rating    = 0;
                    PlayCount = 0;
                }
            }
            else
            {
                UserEmail = null;
                Rating    = 0;
                PlayCount = 0;
            }
        }
Beispiel #4
0
        public static bool RequiresFix(this ITextEncoding frame, ID3v2TagVersion tagVersion, string value, byte[] data)
        {
            if (frame.TextEncoding != EncodingType.ISO88591)
            {
                return(false);
            }

            if (value != null && value != ID3v2Utils.ReadString(frame.TextEncoding, data, data.Length))
            {
                frame.TextEncoding = tagVersion == ID3v2TagVersion.ID3v24 ? EncodingType.UTF8 : EncodingType.Unicode;
                return(true);
            }

            return(false);
        }
Beispiel #5
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            if (bytesLeft > 0)
            {
                OwnerIdentifier = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                if (bytesLeft > 0)
                {
                    PrivateData = stream.Read(bytesLeft);
                }
            }
        }
Beispiel #6
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);
            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            if (bytesLeft > 0)
            {
                TextEncoding = (EncodingType)stream.Read1(ref bytesLeft);
                if (bytesLeft > 0)
                {
                    MimeType = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                    if (bytesLeft > 1)
                    {
                        byte flags = stream.Read1(ref bytesLeft);
                        _isMpegOrAac   = ((flags & 0x01) == 0x00);
                        EquivalentText = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);
                        if (bytesLeft > 0)
                        {
                            _audioData = stream.Read(bytesLeft);
                            bytesLeft  = 0;
                        }
                    }
                    else
                    {
                        EquivalentText = null;
                        _audioData     = null;
                    }
                }
                else
                {
                    MimeType       = null;
                    EquivalentText = null;
                    _audioData     = null;
                }
            }
            else
            {
                TextEncoding   = EncodingType.ISO88591;
                MimeType       = null;
                EquivalentText = null;
                _audioData     = null;
            }

            if (bytesLeft > 0)
            {
                stream.Seek(bytesLeft, SeekOrigin.Current);
            }
        }
Beispiel #7
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _languageItems.Clear();

            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            if (bytesLeft >= 4)
            {
                TextEncoding = (EncodingType)stream.Read1(ref bytesLeft);
                // This could be implemented many ways
                // engfraspa etc
                // eng 0x00 fra 0x00 spa 0x00 etc
                // English
                // English 0x00 French 0x00 Spanish 0x00

                // TODO: Finish implementation
                string languageCode = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);
                if (languageCode.Length != 3)
                {
                    if (languageCode.ToLower() == "english" || languageCode.ToLower() == "en")
                    {
                        Items.AddNew().LanguageCode = "eng";
                    }
                    else
                    {
                        foreach (KeyValuePair <string, string> kvp in LanguageHelper.Languages)
                        {
                            if (kvp.Value.ToLower() == languageCode.ToLower())
                            {
                                Items.AddNew().LanguageCode = kvp.Key;
                                break;
                            }
                        }
                    }
                }
                else
                {
                    Items.AddNew().LanguageCode = languageCode;
                }
            }

            if (bytesLeft > 0)
            {
                stream.Seek(bytesLeft, SeekOrigin.Current);
            }
        }
Beispiel #8
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            if (bytesLeft > 0)
            {
                OwnerIdentifier = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                if (bytesLeft >= 4)
                {
                    PreviewStart  = stream.ReadInt16(ref bytesLeft);
                    PreviewLength = stream.ReadInt16(ref bytesLeft);
                    if (bytesLeft > 0)
                    {
                        EncryptionInfo = stream.Read(bytesLeft);
                        bytesLeft      = 0;
                    }
                    else
                    {
                        // Incomplete frame
                        EncryptionInfo = null;
                    }
                }
                else
                {
                    // Incomplete frame
                    PreviewStart   = 0;
                    PreviewLength  = 0;
                    EncryptionInfo = null;
                }
            }
            else
            {
                // Incomplete frame
                OwnerIdentifier = null;
                PreviewStart    = 0;
                PreviewLength   = 0;
                EncryptionInfo  = null;
            }

            // Seek to end of frame
            if (bytesLeft != 0)
            {
                stream.Seek(bytesLeft, SeekOrigin.Current);
            }
        }
Beispiel #9
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);
            if (_frameHeader.FrameSizeExcludingAdditions > 0)
            {
                TextEncoding = (EncodingType)stream.Read1();
                int bytesLeft = _frameHeader.FrameSizeExcludingAdditions - 1;
                Description = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);
                Value       = ID3v2Utils.ReadString(TextEncoding, stream, bytesLeft);
            }
            else
            {
                /*String msg = String.Format("0 length frame '{0}' at position {1}", "TXXX", stream.Position);
                 * Trace.WriteLine(msg);*/

                Description = string.Empty;
                Value       = string.Empty;
            }
        }
Beispiel #10
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            // Some taggers write 0 byte sized frames (which is explicitly forbidden by the spec)
            if (_frameHeader.FrameSizeExcludingAdditions >= 1)
            {
                TextEncoding = (EncodingType)stream.Read1();
                Value        = ID3v2Utils.ReadString(_textEncoding, stream, _frameHeader.FrameSizeExcludingAdditions - 1);
            }
            else
            {
                //String msg = String.Format("Under-sized ({0} bytes) text frame at position {1}", m_FrameHeader.FrameSizeExcludingAdditions, stream.Position);
                //Trace.WriteLine(msg);

                TextEncoding = EncodingType.ISO88591;
                Value        = "";
            }
        }
Beispiel #11
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft   = _frameHeader.FrameSizeExcludingAdditions;
            int frameIDSize = (tagReadingInfo.TagVersion == ID3v2TagVersion.ID3v22 ? 3 : 4);

            if (bytesLeft > frameIDSize)
            {
                FrameIdentifier = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, frameIDSize);
                bytesLeft      -= frameIDSize;
                Url             = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                AdditionalData  = stream.Read(bytesLeft);
            }
            else
            {
                stream.Seek(bytesLeft, SeekOrigin.Current);
            }
        }
Beispiel #12
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);
            if (_frameHeader.FrameSizeExcludingAdditions >= 4)
            {
                TextEncoding = (EncodingType)stream.Read1();
                LanguageCode = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, 3);

                int tmpBytesLeft = _frameHeader.FrameSizeExcludingAdditions - 1 /*encoding*/ - 3 /*language code*/;
                ContentDescriptor = ID3v2Utils.ReadString(TextEncoding, stream, ref tmpBytesLeft);

                Text = ID3v2Utils.ReadString(_textEncoding, stream, tmpBytesLeft);
            }
            else
            {
                string msg = string.Format("Under-sized ({0} bytes) unsynchronized text frame at position {1}", _frameHeader.FrameSizeExcludingAdditions, stream.Position);
                Trace.WriteLine(msg);

                LanguageCode      = "eng";
                ContentDescriptor = "";
                Text = "";
            }
        }
Beispiel #13
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            if (bytesLeft >= 1)
            {
                TextEncoding = (EncodingType)stream.Read1(ref bytesLeft);
                if (bytesLeft >= 3)
                {
                    LanguageCode = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, 3);
                    bytesLeft   -= 3;
                    if (bytesLeft > 0)
                    {
                        Value     = ID3v2Utils.ReadString(TextEncoding, stream, bytesLeft);
                        bytesLeft = 0;
                    }
                }
                else
                {
                    LanguageCode = "eng";
                }
            }
            else
            {
                TextEncoding = EncodingType.ISO88591;
                LanguageCode = "eng";
            }

            // Seek past any unread bytes
            if (bytesLeft > 0)
            {
                stream.Seek(bytesLeft, SeekOrigin.Current);
            }
        }
Beispiel #14
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);
            _involvedPersons.Clear();

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            if (bytesLeft > 0)
            {
                TextEncoding = (EncodingType)stream.Read1(ref bytesLeft);
                while (bytesLeft > 0)
                {
                    string involvement = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);
                    string name        = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);

                    if (!string.IsNullOrEmpty(involvement) || !string.IsNullOrEmpty(name))
                    {
                        IInvolvedPerson involvedPerson = _involvedPersons.AddNew();
                        involvedPerson.Involvement = involvement;
                        involvedPerson.Name        = name;
                    }
                }
            }
        }
Beispiel #15
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            Reset();

            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            if (bytesLeft > 1)
            {
                TextEncoding = (EncodingType)stream.Read1(ref bytesLeft);
                string priceString = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);

                if (!string.IsNullOrEmpty(priceString))
                {
                    foreach (string priceItem in priceString.Split('/'))
                    {
                        if (priceItem.Length > 3)
                        {
                            decimal price;
                            string  pricePart = priceItem.Substring(3, priceItem.Length - 3);
                            if (decimal.TryParse(pricePart, System.Globalization.NumberStyles.Any, System.Globalization.NumberFormatInfo.InvariantInfo, out price))
                            {
                                IPriceInformation priceInfo = new PriceInformation();
                                priceInfo.CurrencyCode = priceItem.Substring(0, 3);
                                priceInfo.Price        = price;
                                _priceList.Add(priceInfo);
                            }
                        }
                    }
                }

                if (bytesLeft > 0)
                {
                    string validUntil = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, 8);
                    bytesLeft -= 8;

                    if (validUntil.Length == 8)
                    {
                        validUntil = string.Format("{0}-{1}-{2}", validUntil.Substring(0, 4),
                                                   validUntil.Substring(4, 2), validUntil.Substring(6, 2));
                        DateTime.TryParse(validUntil, out _validUntil);
                    }

                    if (bytesLeft > 0)
                    {
                        ContactUrl = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);

                        if (bytesLeft > 0)
                        {
                            ReceivedAs         = (ReceivedAs)stream.Read1(ref bytesLeft);
                            NameOfSeller       = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);
                            Description        = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);
                            SellerLogoMimeType = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                            if (bytesLeft > 0)
                            {
                                SellerLogo = stream.Read(bytesLeft);
                                bytesLeft  = 0;
                            }
                        }
                    }
                }
            }

            if (bytesLeft != 0)
            {
                stream.Seek(bytesLeft, SeekOrigin.Current);
            }
        }
Beispiel #16
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            // Sometimes a frame size of "0" comes through (which is explicitly forbidden in spec)
            if (_frameHeader.FrameSizeExcludingAdditions >= 1)
            {
                TextEncoding = (EncodingType)stream.Read1();

                // TODO: A common mis-implementation is to exclude the language code and description
                // Haven't decided how to handle this yet.  Maybe if a lookup to the language table fails,
                // the rest of the frame should be treated as suspicious.

                if (_frameHeader.FrameSizeExcludingAdditions >= 4)
                {
                    string languageCode = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, 3);
                    int    bytesLeft    = _frameHeader.FrameSizeExcludingAdditions - 1 - 3;
                    string description  = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);

                    bool invalidFrame = false;
                    if (LanguageHelper.Languages.ContainsKey(languageCode.ToLower()) == false && languageCode.ToLower() != "xxx")
                    {
                        // most likely, it's en\0, or some other funk
                        if (languageCode.StartsWith("en"))
                        {
                            languageCode = "";
                        }

                        invalidFrame = true;

                        if (bytesLeft == 0)
                        {
                            Description = "";
                        }
                        else
                        {
                            Description = languageCode + description;
                        }
                        LanguageCode = "eng";
                    }
                    else
                    {
                        LanguageCode = languageCode;
                        Description  = description;
                    }

                    if (bytesLeft > 0)
                    {
                        Value = ID3v2Utils.ReadString(TextEncoding, stream, bytesLeft);
                    }
                    else
                    {
                        if (invalidFrame)
                        {
                            if (languageCode.Contains("\0"))
                            {
                                // forget it, too messed up.
                                Value = "";
                            }
                            else
                            {
                                Value = languageCode + description;
                            }
                        }
                        else
                        {
                            Value = "";
                        }
                    }
                }
                else
                {
                    string msg = string.Format("Under-sized ({0} bytes) COMM frame at position {1}", _frameHeader.FrameSizeExcludingAdditions, stream.Position);
                    Trace.WriteLine(msg);

                    LanguageCode = "eng";
                    Value        = "";
                }
            }
            else
            {
                string msg = string.Format("Under-sized ({0} bytes) COMM frame at position {1}", _frameHeader.FrameSizeExcludingAdditions, stream.Position);
                Trace.WriteLine(msg);

                LanguageCode = "eng";
                Value        = "";
            }
        }
Beispiel #17
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            // Read header
            _frameHeader.Read(tagReadingInfo, ref stream);

            // Read frame data
            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            if (bytesLeft >= 6) // note: 6 was chosen arbitrarily
            {
                // Read text encoding
                TextEncoding = (EncodingType)stream.Read1(ref bytesLeft);

                if (tagReadingInfo.TagVersion == ID3v2TagVersion.ID3v22)
                {
                    // TODO: Do something with this?
                    string imageFormat = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, 3);
                    bytesLeft -= 3;
                }
                else
                {
                    // Read MIME type
                    MimeType = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                }

                // Read picture type
                PictureType = (PictureType)stream.Read1(ref bytesLeft);

                // Short description
                Description = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);

                // Picture data
                if (bytesLeft > 0)
                {
                    byte[] pictureData = stream.Read(bytesLeft);
                    bytesLeft   = 0;
                    _readingTag = true;
                    try
                    {
                        _pictureCached = false;
                        PictureData    = pictureData;
                    }
                    finally
                    {
                        _readingTag = false;
                    }
                }
                else
                {
                    // Incomplete frame
                    PictureData = null;
                }
            }
            else
            {
                // Incomplete frame
                TextEncoding = EncodingType.ISO88591;
                Description  = null;
                MimeType     = null;
                PictureType  = PictureType.CoverFront;
                PictureData  = null;
            }

            // Seek to end of frame
            if (bytesLeft > 0)
            {
                stream.Seek(bytesLeft, SeekOrigin.Current);
            }
        }
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            // RVAD/RVA2

            /*Double original = -65534;
             * Double newVal = Math.Log10(1 + original/65535.0)*20.0*512.0;
             * Double original2 = Math.Pow(10, newVal/(20.0*512.0));
             * original2 = original2 - 1;
             * original2 *= 65535.0;*/

            /*Double original = 10000;
             * Double newVal = Math.Log10(1 + original / 65535.0);
             * Double original2 = Math.Pow(10, newVal);
             * original2 = original2 - 1;
             * original2 *= 65535.0;*/

            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            if (bytesLeft > 0)
            {
                // todo: there needs to be some kind of a test to see if this is RVAD/RVA2 format, too
                // much varying implementation in 2.3 and 2.4

                bool isRVA2 = (_frameHeader.TagVersion == ID3v2TagVersion.ID3v24);

                if (isRVA2)
                {
                    // sometimes "identification" is completely ommitted... grr
                    Identification = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, ref bytesLeft);
                    while (bytesLeft >= 3)
                    {
                        // TODO: Implementation not complete
                        byte channelType = stream.Read1(ref bytesLeft);
                        //if (channelType == 16) break; // Invalid, probably stored as an ID3v2.3 RVAD frame
                        // TODO: some kind of switch.. maybe a new internal enum
                        short volumeAdjustment = stream.ReadInt16(ref bytesLeft);
                        if (bytesLeft > 0)
                        {
                            // sometimes represented as BITS representing peak.. seriously.
                            byte bytesRepresentingPeak = stream.Read1(ref bytesLeft);
                            if (bytesRepresentingPeak == 0)
                            {
                                break;
                            }
                            if (bytesLeft >= bytesRepresentingPeak)
                            {
                                // TODO: Finish implementation
                                byte[] peakVolume = stream.Read(bytesRepresentingPeak);
                                bytesLeft -= peakVolume.Length;
                            }
                            else
                            {
                                break;
                            }
                        }
                    }

                    if (bytesLeft > 0)
                    {
                        //Trace.WriteLine("Invalid RVA2 frame");
                        //stream.Seek(bytesLeft, SeekOrigin.Current);
                        //bytesLeft = 0;
                        // Try to read it like an ID3v2.3 RVAD frame
                        stream.Seek(bytesLeft - _frameHeader.FrameSizeExcludingAdditions, SeekOrigin.Current);
                        bytesLeft = _frameHeader.FrameSizeExcludingAdditions;
                        isRVA2    = false;
                    }
                    else
                    {
                        // TODO
                        //MessageBox.Show("valid RVA2 frame, omg!");
                    }
                }

                // ID3v2.2, ID3v2.3, or mal-formed ID3v2.4
                if (isRVA2 == false)
                {
                    byte incrementDecrement = stream.Read1(ref bytesLeft);
                    if (bytesLeft > 0)
                    {
                        byte bitsUsedForVolumeDescription  = stream.Read1(ref bytesLeft);
                        int  bytesUsedForVolumeDescription = bitsUsedForVolumeDescription / 8;

                        // TODO: (may be useful for testing which implementation)
                        // if bits used for volume description is > 64, don't bother

                        // Relative volume change, right
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            FrontRightAdjustment = ByteUtils.ConvertToInt64(byteArray) * (ByteUtils.IsBitSet(incrementDecrement, 0) ? 1 : -1);
                        }
                        // Relative volume change, left
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            FrontLeftAdjustment = ByteUtils.ConvertToInt64(byteArray) * (ByteUtils.IsBitSet(incrementDecrement, 1) ? 1 : -1);
                        }
                        // Peak volume right
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            FrontRightPeak = ByteUtils.ConvertToInt64(byteArray);
                        }
                        // Peak volume left
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            FrontLeftPeak = ByteUtils.ConvertToInt64(byteArray);
                        }
                        // Relative volume change, right back
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            BackRightAdjustment = ByteUtils.ConvertToInt64(byteArray) * (ByteUtils.IsBitSet(incrementDecrement, 2) ? 1 : -1);
                        }
                        // Relative volume change, left back
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            BackLeftAdjustment = ByteUtils.ConvertToInt64(byteArray) * (ByteUtils.IsBitSet(incrementDecrement, 3) ? 1 : -1);
                        }
                        // Peak volume right back
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            BackRightPeak = ByteUtils.ConvertToInt64(byteArray);
                        }
                        // Peak volume left back
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            BackLeftPeak = ByteUtils.ConvertToInt64(byteArray);
                        }
                        // Relative volume change, center
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            FrontCenterAdjustment = ByteUtils.ConvertToInt64(byteArray) * (ByteUtils.IsBitSet(incrementDecrement, 4) ? 1 : -1);
                        }
                        // Peak volume center
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            FrontCenterPeak = ByteUtils.ConvertToInt64(byteArray);
                        }
                        // Relative volume change, bass
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            SubwooferAdjustment = ByteUtils.ConvertToInt64(byteArray) * (ByteUtils.IsBitSet(incrementDecrement, 5) ? 1 : -1);
                        }
                        // Peak volume bass
                        if (bytesLeft >= bytesUsedForVolumeDescription)
                        {
                            byte[] byteArray = stream.Read(bytesUsedForVolumeDescription, ref bytesLeft);
                            SubwooferPeak = ByteUtils.ConvertToInt64(byteArray);
                        }
                    }
                }

                // Skip past the rest of the frame
                if (bytesLeft > 0)
                {
                    Trace.WriteLine("Invalid RVA2/RVAD/RVA frame");
                    stream.Seek(bytesLeft, SeekOrigin.Current);
                    //bytesLeft = 0;
                }
            }
        }
Beispiel #19
0
 public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
 {
     _frameHeader.Read(tagReadingInfo, ref stream);
     Value = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, _frameHeader.FrameSizeExcludingAdditions);
 }
Beispiel #20
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            Items.Clear();

            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            if (bytesLeft >= 1)
            {
                TextEncoding = (EncodingType)stream.Read1(ref bytesLeft);
                if (bytesLeft >= 3)
                {
                    LanguageCode = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, 3);
                    bytesLeft   -= 3;
                    if (bytesLeft >= 2)
                    {
                        TimestampFormat = (TimestampFormat)stream.Read1(ref bytesLeft);
                        ContentType     = (TextContentType)stream.Read1(ref bytesLeft);
                        if (bytesLeft > 0)
                        {
                            ContentDescriptor = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);

                            while (bytesLeft > 0)
                            {
                                string lyrics = ID3v2Utils.ReadString(TextEncoding, stream, ref bytesLeft);
                                if (bytesLeft >= 4)
                                {
                                    SynchronizedTextItem textItem = new SynchronizedTextItem();
                                    textItem.Text      = lyrics;
                                    textItem.Timestamp = stream.ReadInt32();
                                    bytesLeft         -= 4;
                                    Items.Add(textItem);
                                }
                            }
                        }
                        else
                        {
                            // Incomplete frame
                            ContentDescriptor = "";
                        }
                    }
                    else
                    {
                        // Incomplete frame
                        TimestampFormat   = TimestampFormat.Milliseconds;
                        ContentType       = TextContentType.Other;
                        ContentDescriptor = "";
                    }
                }
                else
                {
                    // Incomplete frame
                    LanguageCode      = "eng";
                    TimestampFormat   = TimestampFormat.Milliseconds;
                    ContentType       = TextContentType.Other;
                    ContentDescriptor = "";
                }
            }
            else
            {
                // Incomplete frame
                TextEncoding      = EncodingType.ISO88591;
                LanguageCode      = "eng";
                TimestampFormat   = TimestampFormat.Milliseconds;
                ContentType       = TextContentType.Other;
                ContentDescriptor = "";
            }

            if (bytesLeft > 0)
            {
                stream.Seek(bytesLeft, SeekOrigin.Current);
            }
        }