public override void Import(RawFrame rawFrame)
        {
            ImportRawFrameHeader(rawFrame);
            var payload = rawFrame.Payload;

            var ownerBytes = new List<byte>();
            var identifierBytes = new List<byte>();

            var zeroByteFound = false;
            foreach (var curByte in payload)
            {
                if (curByte == 0x00)
                {
                    zeroByteFound = true;
                }
                else
                {
                    if (zeroByteFound)
                    {
                        identifierBytes.Add(curByte);
                    }
                    else
                    {
                        ownerBytes.Add(curByte);
                    }
                }
            }

            var ownerChars = Converter.Extract(TextEncodingType.ISO_8859_1, ownerBytes.ToArray());
            Owner = new string(ownerChars);
            Identifier = identifierBytes.ToArray();
        }
        /// <summary>
        /// Converts a raw frame to PlayCounter frame.
        /// </summary>s
        /// <param name="rawFrame">the raw frame.</param>
        public override void Import(RawFrame rawFrame)
        {
            ImportRawFrameHeader(rawFrame);

            var payload = rawFrame.Payload;
            if (payload.Length == 0 )
            {
                Counter = 0;
            }
            else
            {
                /*
                 * This lib supports 8 bytes of the play counter values. The frames supports up to 8 bytes with a least 4 bytes.
                 * We must add zero bytes for the byte conversion.
                 */

                var counterBytes = new byte[8];
                if (payload.Length < 8)
                {
                    Array.Copy(payload,0,counterBytes,8-payload.Length,payload.Length);
                }
                else
                {
                    counterBytes = payload;
                }

                // Convert To LSB and decode!
                Array.Reverse(counterBytes);
                Counter = BitConverter.ToInt64(counterBytes, 0);
            }
        }
        /// <summary>
        /// Import the raw frame data.
        /// </summary>
        /// <param name="rawFrame">the raw frame.</param>
        public override void Import(RawFrame rawFrame)
        {
            ImportRawFrameHeader(rawFrame);

            // Simple ISO8859-1 coding in the payload!

            var chars = Converter.Extract(TextEncodingType.ISO_8859_1, rawFrame.Payload, true);
            URL = new string(chars);
        }
		/// <summary>
		/// Import the raw frame data.
		/// </summary>
		/// <param name="rawFrame">the raw frame.</param>
		/// <param name="codePage">Not used</param>
        public override void Import(RawFrame rawFrame, int codePage)
        {
            ImportRawFrameHeader(rawFrame);

			using (var reader = new FrameDataReader(rawFrame.Payload))
			{
				URL = reader.ReadVariableString(Encoding.ASCII);
			}
        }
Exemple #5
0
 /// <summary>
 /// Import the header flags from a raw frame.
 /// </summary>
 /// <param name="rawFrame"></param>
 protected void ImportRawFrameHeader(RawFrame rawFrame)
 {
     Descriptor.ID = rawFrame.ID;
     Descriptor.TagAlterPreservation = rawFrame.TagAlterPreservation;
     Descriptor.FileAlterPreservation = rawFrame.FileAlterPreservation;
     Descriptor.ReadOnly = rawFrame.ReadOnly;
     Descriptor.Compression = rawFrame.Compression;
     Descriptor.Encryption = rawFrame.Encryption;
     Descriptor.GroupingIdentify = rawFrame.GroupingIdentify;
 }
        public override void Import(RawFrame rawFrame, int codePage)
        {
            ImportRawFrameHeader(rawFrame);

            using (var reader = new FrameDataReader(rawFrame.Payload))
            {
                var encodingByte = reader.ReadByte();
                Language = reader.ReadFixedString(Encoding.ASCII, 3);
                TextEncoding = reader.ReadEncoding(encodingByte, codePage);
                ContentDescriptor = reader.ReadVariableString(TextEncoding);
                Lyrics = reader.ReadVariableString(TextEncoding);
            }
        }
		/// <summary>
		/// Converts a raw frame to PlayCounter frame.
		/// </summary>
		/// <param name="rawFrame">the raw frame.</param>
		/// <param name="codePage">Default code page for Ansi encoding. Pass 0 to use default system encoding code page.</param>
		/// s
        public override void Import(RawFrame rawFrame, int codePage)
        {
			/*
				ID = "PCNT"
				Counter         $xx xx xx xx (xx ...)
			*/

            ImportRawFrameHeader(rawFrame);

			using (var reader = new FrameDataReader(rawFrame.Payload))
			{
				Counter = reader.ReadUInt64();
			}
        }
		/// <summary>
		/// Import the raw frame.
		/// </summary>
		/// <param name="rawFrame">the raw frame.</param>
		/// <param name="codePage">Default code page for Ansi encoding. Pass 0 to use default system encoding code page.</param>
		public override void Import(RawFrame rawFrame, int codePage)
		{
			ImportRawFrameHeader(rawFrame);

			//
			//  <text> 00 <data>
			//

			using (var reader = new FrameDataReader(rawFrame.Payload))
			{
				Owner = reader.ReadVariableString(Encoding.GetEncoding(28591));
				Data = reader.ReadBytes();
			}
		}
Exemple #9
0
		/// <summary>
		/// Import the header flags from a raw frame.
		/// </summary>
		/// <param name="rawFrame">The raw frame.</param>
        protected void ImportRawFrameHeader(RawFrame rawFrame)
        {
            Descriptor.ID = rawFrame.ID;
            Descriptor.TagAlterPreservation = rawFrame.Flag.TagAlterPreservation;
            Descriptor.FileAlterPreservation = rawFrame.Flag.FileAlterPreservation;
            Descriptor.ReadOnly = rawFrame.Flag.ReadOnly;
            Descriptor.Compression = rawFrame.Flag.Compression;
            Descriptor.Encryption = rawFrame.Flag.Encryption;
            Descriptor.GroupingIdentify = rawFrame.Flag.GroupingIdentify;
            //
            // ID3v2.4 only
            //
            Descriptor.Unsynchronisation = rawFrame.Flag.Unsynchronisation;
            Descriptor.DataLengthIndicator = rawFrame.Flag.DataLengthIndicator;
        }
Exemple #10
0
		/// <summary>
		/// Import the raw frame.
		/// </summary>
		/// <param name="rawFrame">the raw frame.</param>
		/// <param name="codePage">Default code page for Ansi encoding. Pass 0 to use default system encoding code page.</param>
		public override void Import(RawFrame rawFrame, int codePage)
		{
			ImportRawFrameHeader(rawFrame);

			//
			//  XX            - Encoding Byte
			//  Y1 Y2 ... Yn  - Text
			//

			using (var reader = new FrameDataReader(rawFrame.Payload))
			{
				byte encodingByte = reader.ReadByte();
				TextEncoding = reader.ReadEncoding(encodingByte, codePage);
				Content = reader.ReadVariableString(TextEncoding).TrimEnd(Char.MinValue);
			}
		}
		/// <summary>
		/// Import the raw frame.
		/// </summary>
		/// <param name="rawFrame">the raw frame.</param>
		/// <param name="codePage">Default code page for Ansi encoding. Pass 0 to use default system encoding code page.</param>
		public override void Import(RawFrame rawFrame, int codePage)
		{
			ImportRawFrameHeader(rawFrame);

			/*
             *  Text Encoding   xx
             *  Description     (xx xx .. xx) (00 / 00 00)
             *  URL             (xx xx ... xx)  als ISO8859-1 !
             */

			using (var reader = new FrameDataReader(rawFrame.Payload))
			{
				byte encodingByte = reader.ReadByte();
				TextEncoding = reader.ReadEncoding(encodingByte, codePage);
				Description = reader.ReadVariableString(TextEncoding);
				URL = reader.ReadVariableString(Encoding.GetEncoding(28591));
			}
		}
		/// <summary>
		/// Import the raw frame.
		/// </summary>
		/// <param name="rawFrame">the raw frame.</param>
		/// <param name="codePage">Default code page for Ansi encoding. Pass 0 to use default system encoding code page.</param>
		public override void Import(RawFrame rawFrame, int codePage)
		{
			ImportRawFrameHeader(rawFrame);

			/*
				<Header for 'User defined text information frame', ID: "TXXX"> 
				Text encoding : $xx
				Description   : <text string according to encoding> $00 (00)
				Value         : <text string according to encoding>
			*/

			using (var reader = new FrameDataReader(rawFrame.Payload))
			{
				byte encodingByte = reader.ReadByte();
				TextEncoding = reader.ReadEncoding(encodingByte, codePage);
				Description = reader.ReadVariableString(TextEncoding);
				Value = reader.ReadVariableString(TextEncoding);
			}
		}
Exemple #13
0
        /// <summary>
        /// Import the raw frame.
        /// </summary>
        /// <param name="rawFrame">the raw frame.</param>
        public override void Import(RawFrame rawFrame)
        {
            ImportRawFrameHeader(rawFrame);

            //
            //  <text> 00 <data>
            //
            var payload = rawFrame.Payload;
            var items = Converter.SplitByteArray(payload);

            if (items.Count < 2)
            {
                throw new ID3TagException("Could not decode PrivateFrame : Payload decoding failed.");
            }

            var ownerBytes = items[0];
            var ownerChars = Converter.Extract(TextEncodingType.ISO_8859_1, ownerBytes, false);
            Owner = new string(ownerChars);

            Data = items[1];
        }
Exemple #14
0
        /// <summary>
        /// Import the raw frame.
        /// </summary>
        /// <param name="rawFrame">the raw frame.</param>
        public override void Import(RawFrame rawFrame)
        {
            ImportRawFrameHeader(rawFrame);

            if (rawFrame.Payload.Length > 0)
            {
                TextEncoding = (TextEncodingType) rawFrame.Payload[0];
            }

            if (rawFrame.Payload.Length > 1)
            {
                var contentLength = rawFrame.Payload.Length - 1;
                var content = new byte[contentLength];
                Array.Copy(rawFrame.Payload, 1, content, 0, contentLength);

                var chars = Converter.Extract(TextEncoding, content, true);
                Content = new string(chars);
            }
            else
            {
                Content = String.Empty;
            }
        }
        /// <summary>
        /// Import the raw frame.
        /// </summary>
        /// <param name="rawFrame">the raw frame.</param>
        public override void Import(RawFrame rawFrame)
        {
            ImportRawFrameHeader(rawFrame);
            var payloadBytes = rawFrame.Payload;

            // Read the text bytes.
            var textBytes = new List<byte>();
            var curPos = 0;
            for (curPos = 0; curPos < payloadBytes.Length; curPos++)
            {
                var curByte = payloadBytes[curPos];
                if (curByte == 0)
                {
                    // Termination found. Abort.
                    break;
                }

                textBytes.Add(payloadBytes[curPos]);
            }

            curPos++;

            var chars = Converter.Extract(TextEncodingType.ISO_8859_1, textBytes.ToArray());
            Owner = new string(chars);

            var startBytes = new byte[2];
            var lengthBytes = new byte[2];

            Array.Copy(payloadBytes, curPos, startBytes, 0, 2);
            Array.Copy(payloadBytes, curPos + 2, lengthBytes, 0, 2);
            Array.Reverse(startBytes);
            Array.Reverse(lengthBytes);

            PreviewStart = BitConverter.ToUInt16(startBytes, 0);
            PreviewLength = BitConverter.ToUInt16(lengthBytes, 0);

            var encryptionPos = curPos + 4;
            var encryptionSize = payloadBytes.Length - encryptionPos;
            Encryption = new byte[encryptionSize];
            Array.Copy(payloadBytes, encryptionPos, Encryption, 0, Encryption.Length);
        }
Exemple #16
0
		/*
           <Header for 'Attached picture', ID: "APIC"> 
           Text encoding   $xx
           MIME type       <text string> $00
           Picture type    $xx
           Description     <text string according to encoding> $00 (00)
           Picture data    <binary data>
        */

		/// <summary>
		/// Import a raw frame
		/// </summary>
		/// <param name="rawFrame">the raw frame</param>
		/// <param name="codePage">Default code page for Ansi encoding. Pass 0 to use default system encoding code page.</param>
		public override void Import(RawFrame rawFrame, int codePage)
		{
			ImportRawFrameHeader(rawFrame);

			if (rawFrame.Payload.Length == 0)
			{
				throw new ID3TagException("Frame has no payload.");
			}

			using (var reader = new FrameDataReader(rawFrame.Payload))
			{
				var encodingByte = reader.ReadByte();
				MimeType = reader.ReadVariableString(Encoding.ASCII);
				PictureCoding = (PictureType)reader.ReadByte();
				TextEncoding = reader.ReadEncoding(encodingByte, codePage);
				Description = reader.ReadVariableString(TextEncoding);
				PictureData = reader.ReadBytes();
			}
		}
Exemple #17
0
 internal static RawFrame CreateFrame(string frameID, byte[] flags, byte[] payload)
 {
     var f = new RawFrame(frameID, flags, payload);
     return f;
 }
        /// <summary>
        /// Import the raw frame.
        /// </summary>
        /// <param name="rawFrame">the raw frame.</param>
        public override void Import(RawFrame rawFrame)
        {
            ImportRawFrameHeader(rawFrame);
            TextEncoding = (TextEncodingType) rawFrame.Payload[0];

            var contentLength = rawFrame.Payload.Length - 1;
            var content = new byte[contentLength];
            Array.Copy(rawFrame.Payload, 1, content, 0, contentLength);

            /*
             *  TextEncoding        XX
             *  Desc                Data (00 | 0000)
             *  Value               Data
             * 
             */

            var chars = Converter.Extract(TextEncoding, content);

            string descriptionText;
            string valueText;
            Converter.DecodeDescriptionValuePairs(chars, out descriptionText, out valueText);

            Description = descriptionText;
            Value = valueText;
        }
Exemple #19
0
 /// <summary>
 /// Import the raw content to a high level frame.
 /// </summary>
 /// <param name="rawFrame">the raw frame.</param>
 public abstract void Import(RawFrame rawFrame);
Exemple #20
0
        /*
         * <Header for 'Attached picture', ID: "APIC"> 
            Text encoding   $xx
            MIME type       <text string> $00
            Picture type    $xx
            Description     <text string according to encoding> $00 (00)
            Picture data    <binary data>
         */

        public override void Import(RawFrame rawFrame)
        {
            ImportRawFrameHeader(rawFrame);

            var payload = rawFrame.Payload;
            if (payload.Length == 0)
            {
                throw new ID3TagException("Frame does not have a payload.");
            }

            //
            //  Get the TextEncoding.
            //
            var encodingByte = payload[0];
            TextEncoding = (TextEncodingType) encodingByte;

            //
            //  Get the Mime.
            //
            var mimeBytes = new List<byte>();
            var curPos = 0;
            for (curPos = 1; curPos < payload.Length; curPos++)
            {
                var curByte = payload[curPos];
                if (curByte == 0x00)
                {
                    break;
                }

                mimeBytes.Add(curByte);
            }

            var charBytes = Converter.Extract(TextEncodingType.ISO_8859_1, mimeBytes);
            MimeType = new string(charBytes);

            //
            //  Get the PictureType.
            //
            var pictureTypeByte = payload[curPos + 1];
            PictureCoding = (PictureType) pictureTypeByte;

            //
            //  Get the description
            //
            curPos += 2;
            var descriptionBytes = new List<byte>();
            var increment = Converter.GetTerminationCharLength(TextEncoding);
            for (; curPos < payload.Length; curPos += increment)
            {
                var isTerminatedSymbol = Converter.DetermineTerminateSymbol(payload, curPos, increment);
                if (isTerminatedSymbol)
                {
                    curPos += increment;
                    break;
                }

                var values = new byte[increment];
                Array.Copy(payload, curPos, values, 0, increment);
                descriptionBytes.AddRange(values);
            }

            var descriptionChars = Converter.Extract(TextEncoding, descriptionBytes.ToArray());
            Description = new string(descriptionChars);

            //
            //  Get the payload.
            //
            var pictureDataLength = payload.Length - curPos;
            var pictureDataBytes = new byte[pictureDataLength];

            Array.Copy(payload, curPos, pictureDataBytes, 0, pictureDataLength);
            PictureData = pictureDataBytes;
        }
 private static IFrame AnalyseFrameId(RawFrame rawFrame)
 {
     IFrame frame;
     if (rawFrame.ID[0] == 'T' || rawFrame.ID[0] == 'W')
     {
         switch (rawFrame.ID[0])
         {
             case 'T':
                 if (rawFrame.ID != "TXXX")
                 {
                     frame = new TextFrame();
                 }
                 else
                 {
                     frame = new UserDefinedTextFrame();
                 }
                 break;
             case 'W':
                 if (rawFrame.ID != "WXXX")
                 {
                     frame = new UrlLinkFrame();
                 }
                 else
                 {
                     frame = new UserDefinedURLLinkFrame();
                 }
                 break;
             default:
                 throw new ID3TagException("Unknown Text or URL frame!");
         }
     }
     else
     {
         // Other frames
         switch (rawFrame.ID)
         {
             case "AENC":
                 frame = new AudioEncryptionFrame();
                 break;
             case "PRIV":
                 frame = new PrivateFrame();
                 break;
             case "MCDI":
                 frame = new MusicCdIdentifierFrame();
                 break;
             case "COMM":
                 frame = new CommentFrame();
                 break;
             case "APIC":
                 frame = new PictureFrame();
                 break;
             case "PCNT":
                 frame = new PlayCounterFrame();
                 break;
             case "POPM":
                 frame = new PopularimeterFrame();
                 break;
             case "UFID":
                 frame = new UniqueFileIdentifierFrame();
                 break;
             default:
                 frame = new UnknownFrame();
                 break;
         }
     }
     return frame;
 }
Exemple #22
0
		/// <summary>
		/// Import the the raw frame data.
		/// </summary>
		/// <param name="rawFrame">the raw frame.</param>
		/// <param name="codePage">Default code page for Ansi encoding. Pass 0 to use default system encoding code page.</param>
		public override void Import(RawFrame rawFrame, int codePage)
		{
			ImportRawFrameHeader(rawFrame);
			Content = rawFrame.Payload;
		}
        private static IFrame AnalyseFrameId(RawFrame rawFrame, IFrameCreationService frameService)
        {
            var id = rawFrame.ID;
            IFrame frame = null;

            if (frameService.Search(id))
            {
                //
                //  Get the specific frame instance
                //
                frame = frameService.GetFrameInstance(id);
            }
            else
            {
                if (id[0] == 'T' && id[1] != 'X')
                {
                    //
                    // Handle Textfames
                    //
                    frame = frameService.GetTextFrame();
                }

                if (id[0] == 'W' && id[1] != 'X')
                {
                    //
                    // Handle Web Frames
                    //
                    frame = frameService.GetUrlLinkFrame();
                }
            }

            if (frame == null)
            {
                //
                //  If all is failed then create an Unknown frame instance
                //
                frame = new UnknownFrame();
            }

            return frame;
        }
Exemple #24
0
		/// <summary>
		/// Import the raw content to a high level frame.
		/// </summary>
		/// <param name="rawFrame">the raw frame.</param>
		/// <param name="codePage">Default code page for Ansi encoding. Pass 0 to use default system encoding code page.</param>
        public abstract void Import(RawFrame rawFrame, int codePage);
		/// <summary>
		/// Import the raw frame.
		/// </summary>
		/// <param name="rawFrame">the raw frame.</param>
		/// <param name="codePage">Default code page for Ansi encoding. Pass 0 to use default system encoding code page.</param>
        public override void Import(RawFrame rawFrame, int codePage)
        {
            ImportRawFrameHeader(rawFrame);

			using (var reader = new FrameDataReader(rawFrame.Payload))
			{
				Owner = reader.ReadVariableString(Encoding.GetEncoding(28591));
				PreviewStart = reader.ReadUInt16();
				PreviewLength = reader.ReadUInt16();
				Encryption = reader.ReadBytes();
			}
        }
Exemple #26
0
		/// <summary>
		/// Import the raw frame.
		/// </summary>
		/// <param name="rawFrame">the raw frame.</param>
		/// <param name="codePage">Default code page for Ansi encoding. Pass 0 to use default system encoding code page.</param>
		public override void Import(RawFrame rawFrame, int codePage)
		{
			ImportRawFrameHeader(rawFrame);

			/*
				ID = "COMM"
				TextEncoding    xx
				Language        xx xx xx
				Short Content   (xx xx ... xx) (00 / 00 00)
				Text            (xx xx ... xx)
            */

			using (var reader = new FrameDataReader(rawFrame.Payload))
			{
				byte encodingByte = reader.ReadByte();
				Language = reader.ReadFixedString(Encoding.ASCII, 3);
				TextEncoding = reader.ReadEncoding(encodingByte, codePage);
				ContentDescriptor = reader.ReadVariableString(TextEncoding);
				Text = reader.ReadVariableString(TextEncoding);
			}
		}
Exemple #27
0
        /// <summary>
        /// Import the raw frame.
        /// </summary>
        /// <param name="rawFrame">the raw frame.</param>
        public override void Import(RawFrame rawFrame)
        {
            ImportRawFrameHeader(rawFrame);

            /*
             *  ID = "COMM"
             *  TextEncoding    xx
             *  Language        xx xx xx
             *  Short Content   (xx xx ... xx) (00 / 00 00)
             *  Text            (xx xx ... xx)
             */

            var payload = rawFrame.Payload;
            var languageBytes = new byte[3];
            var textBytes = new byte[payload.Length - 4];

            TextEncoding = (TextEncodingType) payload[0];
            Array.Copy(payload, 1, languageBytes, 0, 3);
            var languageChars = Converter.Extract(TextEncodingType.ISO_8859_1, languageBytes, false);
            Language = new string(languageChars);

            Array.Copy(payload, 4, textBytes, 0, textBytes.Length);
            var chars = Converter.Extract(TextEncoding, textBytes);

            string descriptor;
            string text;
            Converter.DecodeDescriptionValuePairs(chars, out descriptor, out text);
            ContentDescriptor = descriptor;
            Text = text;
        }
        /// <summary>
        /// Import the raw frame.
        /// </summary>
        /// <param name="rawFrame">the raw frame.</param>
        public override void Import(RawFrame rawFrame)
        {
            ImportRawFrameHeader(rawFrame);

            TOC = rawFrame.Payload;
        }
        /// <summary>
        /// Import the raw frame.
        /// </summary>
        /// <param name="rawFrame">the raw frame.</param>
        public override void Import(RawFrame rawFrame)
        {
            ImportRawFrameHeader(rawFrame);

            /*
             *  Text Encoding   xx
             *  Description     (xx xx .. xx) (00 / 00 00)
             *  URL             (xx xx ... xx)  als ISO8859-1 !
             */

            TextEncoding = (TextEncodingType) rawFrame.Payload[0];
            var dataBytes = new byte[rawFrame.Payload.Length - 1];
            Array.Copy(rawFrame.Payload, 1, dataBytes, 0, dataBytes.Length);

            int increment;
            switch (TextEncoding)
            {
                case TextEncodingType.ISO_8859_1:
                    increment = 1;
                    break;
                case TextEncodingType.UTF16:
                    increment = 2;
                    break;
                case TextEncodingType.UTF16_BE:
                    increment = 2;
                    break;
                case TextEncodingType.UTF8:
                    increment = 1;
                    break;
                default:
                    throw new ID3TagException("Unknown TextEncoding format (" + (byte) TextEncoding + ".)");
            }

            var descrBytes = new List<byte>();
            var urlBytes = new List<byte>();
            var urlPos = 0;

            //
            //  Determine the description bytes first
            //
            for (var i = 0; i < dataBytes.Length; i += increment)
            {
                var isTerminatedSymbol = Converter.DetermineTerminateSymbol(dataBytes, i, increment);
                if (isTerminatedSymbol)
                {
                    urlPos = i + increment;
                    break;
                }

                var values = new byte[increment];
                Array.Copy(dataBytes, i, values, 0, increment);
                descrBytes.AddRange(values);
            }

            //
            //  Get the URL bytes
            //
            for (var j = urlPos; j < dataBytes.Length; j++)
            {
                urlBytes.Add(dataBytes[j]);
            }

            var descrChars = Converter.Extract(TextEncoding, descrBytes.ToArray());
            Description = new string(descrChars);

            var urlChars = Converter.Extract(TextEncodingType.ISO_8859_1, urlBytes.ToArray(), false);
            URL = new string(urlChars);
        }
        ///<summary>
        /// 
        /// </summary>
        /// <param name="rawFrame">the raw frame.</param>
        public override void Import(RawFrame rawFrame)
        {
            /*
             * ID = "POPM"
            * Email to user   <text string> $00
             * Rating          $xx
             * Counter         $xx xx xx xx (xx ...)
             */
            ImportRawFrameHeader(rawFrame);

            var payload = rawFrame.Payload;
            if (payload.Length > 0)
            {
                var chars = Converter.Extract(TextEncodingType.ISO_8859_1, payload, true);
                var pointer = chars.Length;
                eMail = new string(chars);

                if (payload.Length > pointer)
                {
                    Rating = payload[++pointer]; //email-characters + 00 Termination (+ 1 because Length is 1-based)
                    if (payload.Length > ++pointer) //Playcounter present?
                    {
                        var bytesleft = payload.Length - pointer;
                        pointer += (bytesleft > 4) ? bytesleft - 4 : 0;
                            // only read the last 4 bytes (come on who listens to a song mor than Int32.Max times??
                        var readlength = (bytesleft < 4) ? bytesleft : 4;
                        var counterbytes = new byte[4] {0, 0, 0, 0};
                        Array.Copy(payload, pointer, counterbytes, 0, readlength);
                        Array.Reverse(counterbytes);
                        PlayCounter = BitConverter.ToInt32(counterbytes, 0);
                    }
                }
            }
        }