Пример #1
0
        public void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            this.m_FrameHeader.Read(tagReadingInfo, ref stream);
            int num1 = this.m_FrameHeader.FrameSizeExcludingAdditions;

            if (num1 > 0)
            {
                this.UserEmail = Utils.ReadString(EncodingType.ISO88591, stream, ref num1);
                if (num1 > 0)
                {
                    this.Rating = Utils.ReadByte(stream, ref num1);
                    if (num1 > 0)
                    {
                        byte[] buffer1 = Utils.Read(stream, num1);
                        this.PlayCount = Utils.ConvertToInt64(buffer1);
                    }
                    else
                    {
                        this.PlayCount = 0;
                    }
                }
                else
                {
                    this.Rating    = 0;
                    this.PlayCount = 0;
                }
            }
            else
            {
                this.UserEmail = null;
                this.Rating    = 0;
                this.PlayCount = 0;
            }
        }
Пример #2
0
        public void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            this.m_FrameHeader.Read(tagReadingInfo, ref stream);
            int num1 = this.m_FrameHeader.FrameSizeExcludingAdditions;

            if (num1 >= 4)
            {
                this.TextEncoding = (EncodingType)Utils.ReadByte(stream, ref num1);
                this.MimeType     = Utils.ReadString(EncodingType.ISO88591, stream, ref num1);
                if (num1 > 0)
                {
                    this.FileName = Utils.ReadString(this.TextEncoding, stream, ref num1);
                    if (num1 > 0)
                    {
                        this.Description = Utils.ReadString(this.TextEncoding, stream, ref num1);
                        if (num1 > 0)
                        {
                            this.EncapsulatedObject = Utils.Read(stream, num1);
                            num1 = 0;
                        }
                    }
                }
            }
            if (num1 > 0)
            {
                stream.Seek((long)num1, SeekOrigin.Current);
            }
        }
Пример #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;
            }
        }
Пример #4
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);
            }
        }
Пример #5
0
        public void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            this.Reset();
            this.m_FrameHeader.Read(tagReadingInfo, ref stream);
            int num1 = this.m_FrameHeader.FrameSizeExcludingAdditions;

            if (num1 > 1)
            {
                this.TextEncoding = (EncodingType)Utils.ReadByte(stream, ref num1);
                string text1 = Utils.ReadString(EncodingType.ISO88591, stream, ref num1);
                if (!string.IsNullOrEmpty(text1))
                {
                    foreach (string text2 in text1.Split(new char[] { '/' }))
                    {
                        if (text2.Length > 3)
                        {
                            double num2;
                            string text3 = text2.Substring(3, text2.Length - 3);
                            if (double.TryParse(text3, NumberStyles.Any, NumberFormatInfo.InvariantInfo, out num2))
                            {
                                IPriceInformation information1 = new PriceInformation();
                                information1.CurrencyCode = text2.Substring(0, 3);
                                information1.Price        = num2;
                                this.m_PriceList.Add(information1);
                            }
                        }
                    }
                }
                if (num1 > 0)
                {
                    string text4 = Utils.ReadString(EncodingType.ISO88591, stream, 8);
                    num1 -= 8;
                    if (text4.Length == 8)
                    {
                        text4 = string.Format("{0}-{1}-{2}", text4.Substring(0, 4), text4.Substring(4, 2), text4.Substring(6, 2));
                        DateTime.TryParse(text4, out this.m_ValidUntil);
                    }
                    if (num1 > 0)
                    {
                        this.ContactUrl = Utils.ReadString(EncodingType.ISO88591, stream, ref num1);
                        if (num1 > 0)
                        {
                            this.ReceivedAs         = (IdSharp.Tagging.ID3v2.ReceivedAs)Utils.ReadByte(stream, ref num1);
                            this.NameOfSeller       = Utils.ReadString(this.TextEncoding, stream, ref num1);
                            this.Description        = Utils.ReadString(this.TextEncoding, stream, ref num1);
                            this.SellerLogoMimeType = Utils.ReadString(EncodingType.ISO88591, stream, ref num1);
                            if (num1 > 0)
                            {
                                this.SellerLogo = Utils.Read(stream, num1);
                                num1            = 0;
                            }
                        }
                    }
                }
            }
            if (num1 != 0)
            {
                stream.Seek((long)num1, SeekOrigin.Current);
            }
        }
Пример #6
0
        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);
            }
        }
Пример #7
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);
            }
        }
Пример #8
0
        public void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            this.m_FrameHeader.Read(tagReadingInfo, ref stream);
            int num1 = this.m_FrameHeader.FrameSizeExcludingAdditions;

            if (num1 >= 1)
            {
                this.TextEncoding = (EncodingType)Utils.ReadByte(stream, ref num1);
                if (num1 >= 3)
                {
                    this.LanguageCode = Utils.ReadString(EncodingType.ISO88591, stream, 3);
                    num1 -= 3;
                    if (num1 > 0)
                    {
                        this.Value = Utils.ReadString(this.TextEncoding, stream, num1);
                        num1       = 0;
                    }
                }
                else
                {
                    this.LanguageCode = "eng";
                }
            }
            else
            {
                this.TextEncoding = EncodingType.ISO88591;
                this.LanguageCode = "eng";
            }
            if (num1 > 0)
            {
                stream.Seek((long)num1, SeekOrigin.Current);
            }
        }
Пример #9
0
 public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
 {
     _frameHeader.Read(tagReadingInfo, ref stream);
     if (_frameHeader.FrameSizeExcludingAdditions > 0)
         TOC = stream.Read(_frameHeader.FrameSizeExcludingAdditions);
     else
         TOC = null;
 }
Пример #10
0
        public void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            this.m_FrameHeader.Read(tagReadingInfo, ref stream);
            int num1 = this.m_FrameHeader.FrameSizeExcludingAdditions;

            if (num1 != 0)
            {
                stream.Seek((long)num1, SeekOrigin.Current);
            }
            throw new NotImplementedException();
        }
Пример #11
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            while (bytesLeft > 0)
            {
                stream.Read1(ref bytesLeft);
            }
            Value = true;
        }
Пример #12
0
 public void Read(TagReadingInfo tagReadingInfo, Stream stream)
 {
     this.m_FrameHeader.Read(tagReadingInfo, ref stream);
     if (this.m_FrameHeader.FrameSizeExcludingAdditions > 0)
     {
         this.TOC = Utils.Read(stream, this.m_FrameHeader.FrameSizeExcludingAdditions);
     }
     else
     {
         this.TOC = null;
     }
 }
Пример #13
0
 public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
 {
     _frameHeader.Read(tagReadingInfo, ref stream);
     if (_frameHeader.FrameSizeExcludingAdditions > 0)
     {
         TOC = stream.Read(_frameHeader.FrameSizeExcludingAdditions);
     }
     else
     {
         TOC = null;
     }
 }
Пример #14
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            while (bytesLeft > 0)
            {
                stream.Read1(ref bytesLeft);
            }
            Value = true;
        }
Пример #15
0
        public void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            this.m_FrameHeader.Read(tagReadingInfo, ref stream);
            int  num1 = this.m_FrameHeader.FrameSizeExcludingAdditions;
            long num2 = 0;

            while (num1 > 0)
            {
                num2  = num2 << 8;
                num2 += Utils.ReadByte(stream, ref num1);
            }
            this.Value = new Nullable <long>(num2);
        }
Пример #16
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

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

            throw new NotImplementedException();
        }
Пример #17
0
        public void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            this.m_FrameHeader.Read(tagReadingInfo, ref stream);
            int num1 = this.m_FrameHeader.FrameSizeExcludingAdditions;

            if (num1 >= 6)
            {
                this.TextEncoding = (EncodingType)Utils.ReadByte(stream, ref num1);
                if (tagReadingInfo.TagVersion == ID3v2TagVersion.ID3v22)
                {
                    Utils.ReadString(EncodingType.ISO88591, stream, 3);
                    num1 -= 3;
                }
                else
                {
                    this.MimeType = Utils.ReadString(EncodingType.ISO88591, stream, ref num1);
                }
                this.PictureType = (IdSharp.Tagging.ID3v2.PictureType)Utils.ReadByte(stream, ref num1);
                this.Description = Utils.ReadString(this.TextEncoding, stream, ref num1);
                if (num1 > 0)
                {
                    byte[] buffer1 = Utils.Read(stream, num1);
                    num1 = 0;
                    this.m_ReadingTag = true;
                    try
                    {
                        this.m_PictureCached = false;
                        this.PictureData     = buffer1;
                        goto Label_00D1;
                    }
                    finally
                    {
                        this.m_ReadingTag = false;
                    }
                }
                this.PictureData = null;
            }
            else
            {
                this.TextEncoding = EncodingType.ISO88591;
                this.Description  = null;
                this.MimeType     = null;
                this.PictureType  = IdSharp.Tagging.ID3v2.PictureType.CoverFront;
                this.PictureData  = null;
            }
Label_00D1:
            if (num1 > 0)
            {
                stream.Seek((long)num1, SeekOrigin.Current);
            }
        }
Пример #18
0
 public void Read(TagReadingInfo tagReadingInfo, Stream stream)
 {
     this.m_FrameHeader.Read(tagReadingInfo, ref stream);
     if (this.m_FrameHeader.FrameSizeExcludingAdditions >= 1)
     {
         this.TextEncoding = (EncodingType)Utils.ReadByte(stream);
         this.Value        = Utils.ReadString(this.m_TextEncoding, stream, this.m_FrameHeader.FrameSizeExcludingAdditions - 1);
     }
     else
     {
         this.TextEncoding = EncodingType.ISO88591;
         this.Value        = "";
     }
 }
Пример #19
0
        public void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            this.m_FrameHeader.Read(tagReadingInfo, ref stream);
            int num1 = this.m_FrameHeader.FrameSizeExcludingAdditions;

            if (num1 > 0)
            {
                this.OwnerIdentifier = Utils.ReadString(EncodingType.ISO88591, stream, ref num1);
                if (num1 > 0)
                {
                    this.PrivateData = Utils.Read(stream, num1);
                }
            }
        }
Пример #20
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);
                }
            }
        }
Пример #21
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            long playCount = 0;
            while (bytesLeft > 0)
            {
                playCount <<= 8;
                playCount += stream.Read1(ref bytesLeft);
            }

            Value = playCount;
        }
Пример #22
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);
                }
            }
        }
Пример #23
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);
            }
        }
Пример #24
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);
            }
        }
Пример #25
0
 public void Read(TagReadingInfo tagReadingInfo, Stream stream)
 {
     this.m_FrameHeader.Read(tagReadingInfo, ref stream);
     if (this.m_FrameHeader.FrameSizeExcludingAdditions > 0)
     {
         this.TextEncoding = (EncodingType)Utils.ReadByte(stream);
         int num1 = this.m_FrameHeader.FrameSizeExcludingAdditions - 1;
         this.Description = Utils.ReadString(this.TextEncoding, stream, ref num1);
         this.Value       = Utils.ReadString(EncodingType.ISO88591, stream, num1);
     }
     else
     {
         this.Description = "";
         this.Value       = "";
     }
 }
Пример #26
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

            long playCount = 0;

            while (bytesLeft > 0)
            {
                playCount <<= 8;
                playCount  += stream.Read1(ref bytesLeft);
            }

            Value = playCount;
        }
Пример #27
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);
            }
        }
Пример #28
0
        public void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            this.m_FrameHeader.Read(tagReadingInfo, ref stream);
            int num1 = this.m_FrameHeader.FrameSizeExcludingAdditions;

            if (num1 > 0)
            {
                this.TextEncoding = (EncodingType)Utils.ReadByte(stream, ref num1);
                if (num1 > 0)
                {
                    this.MimeType = Utils.ReadString(EncodingType.ISO88591, stream, ref num1);
                    if (num1 > 1)
                    {
                        byte num2 = Utils.ReadByte(stream, ref num1);
                        this.m_IsMpegOrAac  = (num2 & 1) == 0;
                        this.EquivalentText = Utils.ReadString(this.TextEncoding, stream, ref num1);
                        if (num1 > 0)
                        {
                            this.m_AudioData = Utils.Read(stream, num1);
                            num1             = 0;
                        }
                    }
                    else
                    {
                        this.EquivalentText = null;
                        this.m_AudioData    = null;
                    }
                }
                else
                {
                    this.MimeType       = null;
                    this.EquivalentText = null;
                    this.m_AudioData    = null;
                }
            }
            else
            {
                this.TextEncoding   = EncodingType.ISO88591;
                this.MimeType       = null;
                this.EquivalentText = null;
                this.m_AudioData    = null;
            }
            if (num1 > 0)
            {
                stream.Seek((long)num1, SeekOrigin.Current);
            }
        }
Пример #29
0
        private static void TestFrame(IFrame frame, ID3v2TagVersion tagVersion, byte[] data)
        {
            TagReadingInfo tagReadingInfo = new TagReadingInfo(tagVersion);
            Stream         stream         = GetFrame(tagVersion, data);

            frame.Read(tagReadingInfo, stream);

            byte[] data2  = frame.GetBytes(tagVersion);
            int    offset = (tagVersion == ID3v2TagVersion.ID3v22 ? 6 : 10);

            Assert.AreEqual(data.Length, data2.Length - offset, "Frame sizes are different");

            for (int i = 0; i < data.Length; i++)
            {
                Assert.AreEqual(data[i], data2[i + offset], string.Format("Byte offset {0}", i + offset));
            }
        }
Пример #30
0
        public void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            this.m_FrameHeader.Read(tagReadingInfo, ref stream);
            int num1 = this.m_FrameHeader.FrameSizeExcludingAdditions;
            int num2 = (tagReadingInfo.TagVersion == ID3v2TagVersion.ID3v22) ? 3 : 4;

            if (num1 > num2)
            {
                this.FrameIdentifier = Utils.ReadString(EncodingType.ISO88591, stream, num2);
                num1               -= num2;
                this.Url            = Utils.ReadString(EncodingType.ISO88591, stream, ref num1);
                this.AdditionalData = Utils.Read(stream, num1);
            }
            else
            {
                stream.Seek((long)num1, SeekOrigin.Current);
            }
        }
Пример #31
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        = "";
            }
        }
Пример #32
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;
            }
        }
Пример #33
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);
            }
        }
Пример #34
0
 public void Read(TagReadingInfo tagReadingInfo, Stream stream)
 {
     this.m_FrameHeader.Read(tagReadingInfo, ref stream);
     if (this.m_FrameHeader.FrameSizeExcludingAdditions >= 4)
     {
         this.TextEncoding = (EncodingType)Utils.ReadByte(stream);
         this.LanguageCode = Utils.ReadString(EncodingType.ISO88591, stream, 3);
         int num1 = (this.m_FrameHeader.FrameSizeExcludingAdditions - 1) - 3;
         this.ContentDescriptor = Utils.ReadString(this.TextEncoding, stream, ref num1);
         this.Text = Utils.ReadString(this.m_TextEncoding, stream, num1);
     }
     else
     {
         string text1 = string.Format("Under-sized ({0} bytes) unsynchronized text frame at position {1}", this.m_FrameHeader.FrameSizeExcludingAdditions, stream.Position);
         Trace.WriteLine(text1);
         this.LanguageCode      = "eng";
         this.ContentDescriptor = "";
         this.Text = "";
     }
 }
Пример #35
0
        public void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            this.m_FrameHeader.Read(tagReadingInfo, ref stream);
            int num1 = this.m_FrameHeader.FrameSizeExcludingAdditions;

            if (num1 > 0)
            {
                this.OwnerIdentifier = Utils.ReadString(EncodingType.ISO88591, stream, ref num1);
                if (num1 >= 4)
                {
                    this.PreviewStart  = Utils.ReadInt16(stream, ref num1);
                    this.PreviewLength = Utils.ReadInt16(stream, ref num1);
                    if (num1 > 0)
                    {
                        this.EncryptionInfo = Utils.Read(stream, num1);
                        num1 = 0;
                    }
                    else
                    {
                        this.EncryptionInfo = null;
                    }
                }
                else
                {
                    this.PreviewStart   = 0;
                    this.PreviewLength  = 0;
                    this.EncryptionInfo = null;
                }
            }
            else
            {
                this.OwnerIdentifier = null;
                this.PreviewStart    = 0;
                this.PreviewLength   = 0;
                this.EncryptionInfo  = null;
            }
            if (num1 != 0)
            {
                stream.Seek((long)num1, SeekOrigin.Current);
            }
        }
Пример #36
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);
            }
        }
Пример #37
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 = "";
            }
        }
Пример #38
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);
            }
        }
Пример #39
0
 public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
 {
     _mpegLookupTableItemBindingList.Clear();
     throw new NotImplementedException();
 }
Пример #40
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);
            }
        }
        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);
            }
        }
Пример #42
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 = "";
            }
        }
Пример #43
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);
            }
        }
Пример #44
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 = "";
            }
        }
Пример #45
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;
            }
        }
Пример #46
0
        public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
        {
            _frameHeader.Read(tagReadingInfo, ref stream);

            int bytesLeft = _frameHeader.FrameSizeExcludingAdditions;

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

            throw new NotImplementedException();
        }
Пример #47
0
 public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
 {
     _frameHeader.Read(tagReadingInfo, ref stream);
     _frameData = stream.Read(_frameHeader.FrameSizeExcludingAdditions);
 }
Пример #48
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);
            }
        }
Пример #49
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);
            }
        }
Пример #50
0
 public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
 {
     _fractionAtIndex.Clear();
     throw new NotImplementedException();
 }
Пример #51
0
 public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
 {
     _eventTimingItemBindingList.Clear();
     throw new NotImplementedException();
 }
Пример #52
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;
                    }
                }
            }
        }
Пример #53
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);
            }
        }
Пример #54
0
 public UnknownFrame(string frameID, TagReadingInfo tagReadingInfo, Stream stream)
 {
     _frameID = frameID;
     Read(tagReadingInfo, stream);
 }
Пример #55
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;
            }
        }
Пример #56
0
 public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
 {
     _musicianCreditsItemBindingList.Clear();
     throw new NotImplementedException();
 }
        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;
                }
            }
        }
Пример #58
0
 public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
 {
     _frameHeader.Read(tagReadingInfo, ref stream);
     Value = ID3v2Utils.ReadString(EncodingType.ISO88591, stream, _frameHeader.FrameSizeExcludingAdditions);
 }
Пример #59
0
 public override void Read(TagReadingInfo tagReadingInfo, Stream stream)
 {
     throw new NotImplementedException();
 }
Пример #60
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);
            }
        }