protected override void Decode(byte[] content)
        {
            if (content.Length == 0)
            {
                throw new ID3Exception("Contentlength is zero");
            }

            var  info = Header.GetFrameInformation();
            bool url  = false;

            url = (info != null) && info.ID == NAudio.Flac.FrameID.UserURLLinkFrame;

            var      encoding0 = ID3Utils.GetEncoding(content, 0, 1);
            Encoding encoding1 = encoding0;

            if (url)
            {
                encoding1 = ID3Utils.Iso88591;
            }

            int read;

            Description = ID3Utils.ReadString(content, 1, -1, encoding0, out read);

            if (content.Length < read + 1)
            {
                throw new ID3Exception("Frame does not contain any text");
            }

            base.Decode(content, read + 1, -1, encoding1, out read);
        }
        protected override void Decode(byte[] content)
        {
            int      read;
            Encoding encoding = ID3Utils.GetEncoding(content, 0, 4);

            Language    = ID3Utils.ReadString(content, 1, 3, ID3Utils.Iso88591);
            Description = ID3Utils.ReadString(content, 4, -1, encoding, out read);
            Text        = ID3Utils.ReadString(content, read + 4, -1, encoding);
        }
Example #3
0
        private void Parse2(Stream stream)
        {
            byte[] buffer = ID3Utils.Read(stream, 6);
            FrameID   = ID3Utils.ReadString(buffer, 0, 3, ID3Utils.Iso88591);
            FrameSize = ID3Utils.ReadInt32(buffer, 3, false, 3);

            //Flags not supported
            Flags = FrameFlags.None;
        }
Example #4
0
        protected void Decode(byte[] content, int offset, int count, Encoding encoding, out int read)
        {
            if (content.Length == 0)
            {
                throw new ID3Exception("Contentlength is zero");
            }

            Text = ID3Utils.ReadString(content, 0, content.Length - 1, ID3Utils.Iso88591, out read);
        }
Example #5
0
        public static string GetURL(byte[] RawData, string MimeType)
        {
            if (RawData == null)
            {
                throw new InvalidOperationException("Decode the frame first");
            }
            if (MimeType != MimeURL)
            {
                throw new InvalidOperationException("MimeType != " + MimeURL);
            }

            return(ID3Utils.ReadString(RawData, 0, -1, ID3Utils.Iso88591));
        }
Example #6
0
        private void Parse4(Stream stream)
        {
            byte[] buffer = ID3Utils.Read(stream, 10);
            FrameID   = ID3Utils.ReadString(buffer, 0, 4, ID3Utils.Iso88591);
            FrameSize = ID3Utils.ReadInt32(buffer, 4, true, 4);

            byte[] flags = new byte[] { buffer[8], buffer[9] };

            //%0abc0000 Framestatusflags
            if ((flags[0] & 0x40) == 0)
            {
                Flags |= FrameFlags.PreserveTagAltered;
            }
            if ((flags[0] & 0x20) == 0)
            {
                Flags |= FrameFlags.PreserveFileAltered;
            }
            if ((flags[0] & 0x10) != 0)
            {
                Flags |= FrameFlags.ReadOnly;
            }
            //%0h00kmnp Frameformatflags
            if ((flags[1] & 0x40) != 0)
            {
                Flags          |= FrameFlags.GroupIdentified;
                GroupIdentifier = ID3Utils.Read(stream, 1)[0];
                FrameSize      -= 1;
            }
            if ((flags[1] & 0x8) != 0)
            {
                Flags |= FrameFlags.Compressed;
            }
            if ((flags[1] & 0x4) != 0)
            {
                Flags            |= FrameFlags.Encrypted;
                _encryptionMethod = ID3Utils.Read(stream, 1)[0];
                FrameSize        -= 1;
            }
            if ((flags[1] & 0x2) != 0)
            {
                Flags |= FrameFlags.UnsyncApplied; //todo: tag allgemein benachrichtigen?
            }
            if ((flags[1] & 0x1) != 0)
            {
                Flags |= FrameFlags.DataLengthIndicatorPresent;
                _dataLengthIndicator = ID3Utils.ReadInt32(stream, true);
                FrameSize           -= 4;
            }
        }
Example #7
0
        protected override void Decode(byte[] content)
        {
            int offset = 1;

            if (content.Length < 3)
            {
                throw new ID3Exception("Invalid contentlength id=0.");//id -> for debugging
            }
            int read;

            if (_version == ID3Version.ID3v2_2)
            {
                //MimeType = ID3Utils.ReadString(content, offset, 3, ID3Utils.Iso88591, out read);
                MimeType = ID3Utils.ReadString(content, offset, 3, ID3Utils.Iso88591, out read);
                offset  += 3;
            }
            else
            {
                MimeType = ID3Utils.ReadString(content, 1, -1, ID3Utils.Iso88591, out read);
                offset  += read;
            }

            if (content.Length < offset)
            {
                throw new ID3Exception("Invalid contentlength id=1.");
            }

            if (!Enum.IsDefined(typeof(PictureFormat), content[offset]))
            {
                throw new ID3Exception("Invalid pictureformat: 0x{0}", content[offset].ToString("x"));
            }
            Format = (PictureFormat)content[offset++];

            if (content.Length < offset)
            {
                throw new ID3Exception("Invalid contentlength id=2.");
            }
            var descenc = ID3Utils.GetEncoding(content, 0, 2);

            Description = ID3Utils.ReadString(content, offset, -1, descenc, out read);
            offset     += read;

            if (content.Length < offset)
            {
                throw new ID3Exception("Invalid contentlength id=3.");
            }
            RawData = new byte[content.Length - offset];
            Array.Copy(content, offset, RawData, 0, RawData.Length);
        }
Example #8
0
        protected override void Decode(byte[] content)
        {
            if (content.Length == 0)
            {
                throw new ID3Exception("Contentlength is zero");
            }

            int read;

            OwnerIdentifier = ID3Utils.ReadString(content, 0, content.Length, ID3Utils.Iso88591, out read);
            Data            = new byte[content.Length - read];
            if (Data.Length > 0)
            {
                Array.Copy(content, read, Data, 0, Data.Length);
            }
        }
Example #9
0
        private void Parse3(Stream stream)
        {
            byte[] buffer = ID3Utils.Read(stream, 10);
            FrameID   = ID3Utils.ReadString(buffer, 0, 4, ID3Utils.Iso88591);
            FrameSize = ID3Utils.ReadInt32(buffer, 4, false, 4);

            byte[] flags = new byte[] { buffer[8], buffer[9] };

            //%abc00000
            if ((flags[0] & 0x80) == 0)
            {
                Flags |= FrameFlags.PreserveTagAltered;
            }
            if ((flags[0] & 0x40) == 0)
            {
                Flags |= FrameFlags.PreserveFileAltered;
            }
            if ((flags[0] & 0x20) != 0)
            {
                Flags |= FrameFlags.ReadOnly;
            }
            //%ijk00000
            if ((flags[1] & 0x80) != 0)
            {
                Flags            |= FrameFlags.Compressed;
                _uncompressedSize = ID3Utils.ReadInt32(stream, false);
                FrameSize        -= 4;
            }
            if ((flags[1] & 0x40) != 0)
            {
                Flags            |= FrameFlags.Encrypted;
                _encryptionMethod = ID3Utils.Read(stream, 1)[0];
                FrameSize        -= 1;
            }
            if ((flags[1] & 0x20) != 0)
            {
                Flags          |= FrameFlags.GroupIdentified;
                GroupIdentifier = ID3Utils.Read(stream, 1)[0];
                FrameSize      -= 1;
            }
        }
Example #10
0
        protected override void Decode(byte[] content)
        {
            int offset = 1;
            int read;

            Price   = ID3Utils.ReadString(content, offset, -1, ID3Utils.Iso88591, out read);
            offset += read;

            IsValidUntil = ID3Utils.ReadString(content, offset, -1, ID3Utils.Iso88591, out read);
            offset      += read;

            ContactURL = ID3Utils.ReadString(content, offset, -1, ID3Utils.Iso88591, out read);
            offset    += read;

            ReceivedType = (ReceivedType)content[offset];
            offset++;

            var encoding = ID3Utils.GetEncoding(content, 0, offset);

            offset++;

            SellerName = ID3Utils.ReadString(content, offset, -1, encoding, out read);
            offset    += read;

            Description = ID3Utils.ReadString(content, offset, -1, encoding, out read);
            offset     += read;

            if (offset < content.Length)
            {
                //we've got a attached logo
                LogoMimeType = ID3Utils.ReadString(content, offset, -1, ID3Utils.Iso88591, out read);
                offset      += read;

                var logoData = new byte[content.Length - offset];
                Array.Copy(content, offset, logoData, 0, logoData.Length);

                Image = ID3Utils.DecodeImage(logoData, LogoMimeType);
            }
        }
        protected override void Decode(byte[] content)
        {
            Encoding e;
            int      index = 1;

            Strings.Clear();

            e = ID3Utils.GetEncoding(content, 0, 1);
            //int read = 0;
            //e = ID3Utils.GetEncoding2(content, 0, out read);
            //index = read;
            while (index < content.Length)
            {
                int r = 0;
                Strings.Add(ID3Utils.ReadString(content, index, -1, e, out r));
                index += r;
            }

            if (Strings.Count == 0)
            {
                Strings.Add(String.Empty);
            }
        }