Esempio n. 1
0
        public void ValidationOKTest()
        {
            /*
             *  T___
             *  TXXX
             *  WXXX
             *  APIC
             */

            var tagContainer = new TagContainerV3();
            tagContainer.Tag.SetExtendedHeader(0, false);
            tagContainer.Tag.SetHeaderOptions(false, false, false);

            var textFrame = new TextFrame("TALB", "My Albun", Encoding.Default);
            var userDefineTextFrame = new UserDefinedTextFrame("my comment", "so", Encoding.Default);
            var linkFrame = new UserDefinedUrlLinkFrame("Id3Tag", "Id3Tag.codeplex.com", Encoding.Default);
            var pictureFrame = new PictureFrame(
                Encoding.Default,
                "image/jpeg",
                "la",
                PictureType.Other,
                new byte[] {0x11, 0x12, 0x13, 0x14});

            tagContainer.Add(textFrame);
            tagContainer.Add(userDefineTextFrame);
            tagContainer.Add(linkFrame);
            tagContainer.Add(pictureFrame);

            WriteTagContainer(tagContainer);

            // OK... passed!
        }
Esempio n. 2
0
        public void ExtendedHeaderEncoderTest()
        {
            var crc = new byte[] {0x20, 0x21, 0x22, 0x23};

            var tagContainer = new TagContainerV3();
            tagContainer.Tag.SetHeaderOptions(true, true, true);
            tagContainer.Tag.SetExtendedHeader(10, true);
            tagContainer.Tag.SetCrc32(crc);

            var titleFrame = new TextFrame();
            titleFrame.TextEncoding = Encoding.Unicode;
            titleFrame.Descriptor.Id = "TIT2";
            titleFrame.Content = "ABCD";

            tagContainer.Add(titleFrame);

            Id3TagInfo Id3Tag = m_TagController.Encode(tagContainer);

            Assert.AreEqual(Id3Tag.MajorVersion, 3);
            Assert.AreEqual(Id3Tag.Revision, 0);
            Assert.IsTrue(Id3Tag.Unsynchronised);
            Assert.IsTrue(Id3Tag.Unsynchronised);
            Assert.IsTrue(Id3Tag.ExtendedHeaderAvailable);

            ExtendedTagHeaderV3 extendedHeader = Id3Tag.ExtendedHeader.ConvertToV23();
            Assert.IsNotNull(extendedHeader);
            Assert.IsTrue(ComparePayload(extendedHeader.Crc32, crc));
            Assert.AreEqual(Id3Tag.Frames.Count, 1);
        }
Esempio n. 3
0
        public void EncodeWithExtendedHeaderTest2()
        {
            //
            // Configure the tag
            //
            var tagContainer1 = new TagContainerV3();
            tagContainer1.Tag.SetHeaderOptions(true, true, true);
            tagContainer1.Tag.SetExtendedHeader(10, true);
            tagContainer1.Tag.SetCrc32(new byte[] {0x10, 0x20, 0x30, 0x40});

            var titleFrame = new TextFrame
                                 {
                                     Descriptor = {Id = "TIT2"},
                                     TextEncoding = Encoding.Unicode,
                                     Content = "Title1"
                                 };

            tagContainer1.Add(titleFrame);

            //
            // Write and read the tag again. 
            //
            TagContainer tagContainer2 = WriteAndRead(tagContainer1);

            //
            // Compare both container!
            //
            CompareContainer(tagContainer1, tagContainer2);
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a new ID3 Tag representation. 
        /// </summary>
        /// <param name="version">the ID3 Tag version.</param>
        /// <returns>the representation instance.</returns>
        public static TagContainer CreateId3Tag(TagVersion version)
        {
            Logger.LogInfo(string.Format("Create ID3Tag with TagVersion {0}", version));
            TagContainer container;

            switch (version)
            {
                case TagVersion.Id3V23:
                    container = new TagContainerV3();
                    break;
                case TagVersion.Id3V24:
                    container = new TagContainerV4();
                    break;
                default:
                    throw new Id3TagException("Invalid tag version!");
            }

            return container;
        }
Esempio n. 5
0
        public void SimpleEncoderTest()
        {
            var tagContainer = new TagContainerV3();
            tagContainer.Tag.SetHeaderOptions(false, false, false);

            var titleFrame = new TextFrame();
            titleFrame.TextEncoding = Encoding.Unicode;
            titleFrame.Descriptor.Id = "TIT2";
            titleFrame.Content = "ABCD";

            tagContainer.Add(titleFrame);

            Id3TagInfo Id3Tag = m_TagController.Encode(tagContainer);

            Assert.AreEqual(Id3Tag.MajorVersion, 3);
            Assert.AreEqual(Id3Tag.Revision, 0);
            Assert.IsFalse(Id3Tag.Unsynchronised);
            Assert.IsFalse(Id3Tag.Unsynchronised);
            Assert.IsFalse(Id3Tag.ExtendedHeaderAvailable);
            Assert.IsNull(Id3Tag.ExtendedHeader);
            Assert.AreEqual(Id3Tag.Frames.Count, 1);
        }
Esempio n. 6
0
        private static TagContainer DecodeV3Tag(Id3TagInfo info)
        {
            var container = new TagContainerV3();
            TagDescriptorV3 descriptor = container.Tag;

            descriptor.SetHeaderOptions(info.Unsynchronised, info.ExtendedHeaderAvailable, info.Experimental);

            if (info.ExtendedHeaderAvailable)
            {
                ExtendedTagHeaderV3 extendedHeader = info.ExtendedHeader.ConvertToV23();
                descriptor.SetExtendedHeader(extendedHeader.PaddingSize, extendedHeader.CrcDataPresent);
                if (extendedHeader.CrcDataPresent)
                {
                    descriptor.SetCrc32(extendedHeader.Crc32);
                }
            }

            return container;
        }
Esempio n. 7
0
        public void SynchronizedTest5()
        {
            var tagContainer1 = new TagContainerV3();
            tagContainer1.Tag.SetHeaderOptions(true, false, false);

            const long counter = 0x12FF;
            var playCounter = new PlayCounterFrame(counter);
            tagContainer1.Add(playCounter);

            TagContainer tagContainer2 = WriteAndRead(tagContainer1);
            CompareContainer(tagContainer1, tagContainer2);

            PlayCounterFrame playCounter2 = FrameUtilities.ConvertToPlayCounterFrame(tagContainer2[0]);
            Assert.AreEqual(playCounter2.Counter, counter);
        }
Esempio n. 8
0
        public void EncodeWithoutExtendedHeaderTest()
        {
            //
            // Configure the tag
            //
            var tagContainer1 = new TagContainerV3();
            tagContainer1.Tag.SetHeaderOptions(false, false, false);

            var titleFrame = new TextFrame
                                 {
                                     Descriptor = {Id = "TIT2"},
                                     TextEncoding = Encoding.Unicode,
                                     Content = "Title1"
                                 };

            tagContainer1.Add(titleFrame);

            //
            // Write and read the tag again. 
            //
            TagContainer tagContainer2 = WriteAndRead(tagContainer1);

            //
            // Compare both container!
            //
            CompareContainer(tagContainer1, tagContainer2);
        }