Exemplo n.º 1
0
        public APE()
        {
            emptyFile    = "MP3/empty.mp3";
            notEmptyFile = "MP3/APE.mp3";
            tagType      = MetaDataIOFactory.TAG_APE;

            // Initialize specific test data (Publisher and Description fields not supported in APE tag)
            testData.Publisher          = null;
            testData.GeneralDescription = null;
            testData.RecordingDate      = null;

            // Initialize specific test data (Picture native codes are strings)
            testData.Pictures.Clear();
            PictureInfo pic = PictureInfo.fromBinaryData(
                File.ReadAllBytes(TestUtils.GetResourceLocationRoot() + "_Images/pic1.jpeg"),
                PIC_TYPE.Unsupported,
                MetaDataIOFactory.TAG_ANY,
                "COVER ART (FRONT)");

            pic.ComputePicHash();
            testData.Pictures.Add(pic);

            pic = PictureInfo.fromBinaryData(
                File.ReadAllBytes(TestUtils.GetResourceLocationRoot() + "_Images/pic1.png"),
                PIC_TYPE.Unsupported,
                MetaDataIOFactory.TAG_ANY,
                "COVER ART (BACK)");
            pic.ComputePicHash();
            testData.Pictures.Add(pic);
        }
Exemplo n.º 2
0
        public MP4()
        {
            emptyFile    = "AAC/empty.m4a"; // Has empty udta/meta tags
            notEmptyFile = "AAC/mp4.m4a";
            tagType      = MetaDataIOFactory.TAG_NATIVE;

            // MP4 does not support leading zeroes
            testData.TrackNumber   = "1";
            testData.TrackTotal    = "2";
            testData.DiscNumber    = "3";
            testData.DiscTotal     = "4";
            testData.RecordingDate = "1997-06-20T00:00:00"; // No timestamp in MP4 date format
            testData.Conductor     = null;                  // TODO - Should be supported; extended field makes it harder to manipulate by the generic test code
            testData.Publisher     = null;
            testData.Genre         = "Household";           // "House" was generating a 'gnre' numeric field whereas ATL standard way of tagging is '(c)gen' string field => Start with a non-standard Genre

            testData.AdditionalFields.Clear();
            testData.AdditionalFields.Add(new MetaFieldInfo(MetaDataIOFactory.TAG_ANY, "----:com.apple.iTunes:TEST", "xxx"));

            testData.Pictures.Clear();
            PictureInfo pic = PictureInfo.fromBinaryData(File.ReadAllBytes(TestUtils.GetResourceLocationRoot() + "_Images/pic1.jpeg"), PIC_TYPE.Unsupported, MetaDataIOFactory.TAG_ANY, 13);

            pic.ComputePicHash();
            testData.Pictures.Add(pic);

            supportsDateOrYear = true;
        }
Exemplo n.º 3
0
        public AA()
        {
            notEmptyFile = "AA/aa.aa";
            tagType      = MetaDataIOFactory.TAG_NATIVE;

            // Initialize specific test data
            testData = new TagData();

            testData.Title              = "The New York Times Audio Digest, July 10, 2015";
            testData.Artist             = "The New York Times";
            testData.Album              = "The New York Times Audio Digest";
            testData.Comment            = "It's the perfect listen for your morning commute! In the time it takes you to get to work, you'll hear a digest of the day's top stories, prepared by the editorial staff of The New York Times....";
            testData.PublishingDate     = DateTime.Parse("10-JUL-2015").ToString();
            testData.Publisher          = "The New York Times";
            testData.Composer           = "The New York Times";
            testData.GeneralDescription = "It's the perfect listen for your morning commute! In the time it takes you to get to work, you'll hear a digest of the day's top stories, prepared by the editorial staff of The New York Times. Each edition includes articles from the front page, as well as the paper's international, national, business, sports, and editorial sections.";
            testData.Copyright          = "(P) and ©2015 The New York Times News Services Division of The New York Times Company";

            // Initialize specific test data (Picture native codes are strings)
            testData.Pictures.Clear();
            PictureInfo pic = PictureInfo.fromBinaryData(
                File.ReadAllBytes(TestUtils.GetResourceLocationRoot() + "AA/aa.jpg"),
                PIC_TYPE.Generic,
                MetaDataIOFactory.TAG_ANY,
                11);

            pic.ComputePicHash();
            testData.Pictures.Add(pic);

            supportsInternationalChars = true;
        }
Exemplo n.º 4
0
        public APE()
        {
            emptyFile    = "MP3/empty.mp3";
            notEmptyFile = "MP3/APE.mp3";
            tagType      = MetaDataIOFactory.TAG_APE;

            // Initialize specific test data (Publisher and Description fields not supported in APE tag)
            testData.Publisher          = null;
            testData.GeneralDescription = null;

            // Initialize specific test data (Picture native codes are strings)
            testData.Pictures.Clear();
            PictureInfo pic = new PictureInfo(Commons.ImageFormat.Jpeg, MetaDataIOFactory.TAG_ANY, "COVER ART (FRONT)");

            byte[] data = System.IO.File.ReadAllBytes(TestUtils.GetResourceLocationRoot() + "_Images/pic1.jpeg");
            pic.PictureData = data;
            pic.ComputePicHash();
            testData.Pictures.Add(pic);

            pic             = new PictureInfo(Commons.ImageFormat.Png, MetaDataIOFactory.TAG_ANY, "COVER ART (BACK)");
            data            = System.IO.File.ReadAllBytes(TestUtils.GetResourceLocationRoot() + "_Images/pic1.png");
            pic.PictureData = data;
            pic.ComputePicHash();
            testData.Pictures.Add(pic);
        }
Exemplo n.º 5
0
        public MP4()
        {
            emptyFile    = "AAC/empty.m4a";
            notEmptyFile = "AAC/mp4.m4a";
            tagType      = MetaDataIOFactory.TAG_NATIVE;

            // MP4 does not support leading zeroes
            testData.TrackNumber = "1";
            testData.TrackTotal  = "2";
            testData.DiscNumber  = "3";
            testData.DiscTotal   = "4";
            testData.Conductor   = null; // TODO - Should be supported; extended field makes it harder to manipulate by the generic test code
            testData.Publisher   = null;

            testData.AdditionalFields.Clear();
            testData.AdditionalFields.Add(new MetaFieldInfo(MetaDataIOFactory.TAG_ANY, "----:com.apple.iTunes:TEST", "xxx"));

            testData.Pictures.Clear();
            PictureInfo pic = new PictureInfo(Commons.ImageFormat.Jpeg, MetaDataIOFactory.TAG_ANY, 13);

            byte[] data = System.IO.File.ReadAllBytes(TestUtils.GetResourceLocationRoot() + "_Images/pic1.jpeg");
            pic.PictureData = data;
            pic.ComputePicHash();
            testData.Pictures.Add(pic);
        }
Exemplo n.º 6
0
        public MetaIOTest()
        {
            // Initialize default test data
            testData = new TagData();

            testData.Title              = "aa父bb";
            testData.Artist             = "֎FATHER֎";
            testData.Album              = "Papa֍rules";
            testData.AlbumArtist        = "aaᱬbb";
            testData.Comment            = "父父!";
            testData.RecordingYear      = "1997";
            testData.RecordingDate      = "1997-06-20T04:04:04";
            testData.Genre              = "House";
            testData.Rating             = "0";
            testData.TrackNumber        = "01";
            testData.TrackTotal         = "02";
            testData.Composer           = "ccᱬdd";
            testData.Conductor          = ""; // Empty string means "supported, but not valued in test sample"
            testData.Publisher          = "";
            testData.DiscNumber         = "03";
            testData.DiscTotal          = "04";
            testData.Copyright          = "";
            testData.GeneralDescription = "";

            testData.AdditionalFields = new List <MetaFieldInfo>();
            testData.AdditionalFields.Add(new MetaFieldInfo(MetaDataIOFactory.TAG_ANY, "TEST", "xxx"));

            testData.Pictures = new List <PictureInfo>();
            PictureInfo pic = PictureInfo.fromBinaryData(File.ReadAllBytes(TestUtils.GetResourceLocationRoot() + "_Images/pic1.jpeg"), PIC_TYPE.Unsupported, MetaDataIOFactory.TAG_ANY, 0x03);

            pic.ComputePicHash();
            testData.Pictures.Add(pic);

            pic = PictureInfo.fromBinaryData(File.ReadAllBytes(TestUtils.GetResourceLocationRoot() + "_Images/pic1.png"), PIC_TYPE.Unsupported, MetaDataIOFactory.TAG_ANY, 0x02);
            pic.ComputePicHash();
            testData.Pictures.Add(pic);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Process picture block at the index 'targetPictureIndex'
        /// Three outcomes :
        ///     1/ Target picture cannot be written => block is marked for deletion
        ///     2/ Target picture can be written and is identical to existing picture at the same position => block is left as it is
        ///     3/ Target picture can be written and is different to existing picture at the same position => target picture is written
        /// </summary>
        /// <param name="w">Writer to be used</param>
        /// <param name="existingPictures">List of existing pictures on the file</param>
        /// <param name="picturesToWrite">List of pictures to write</param>
        /// <param name="existingPictureIndex">Current index of existing pictures in use in the main write loop</param>
        /// <param name="targetPictureIndex">Current index of target pictures in use in the main write loop</param>
        /// <returns></returns>
        private WriteResult processPictureBlock(BinaryWriter w, IList <PictureInfo> existingPictures, IList <PictureInfo> picturesToWrite, ref int existingPictureIndex, ref int targetPictureIndex)
        {
            bool        doWritePicture = false;
            PictureInfo pictureToWrite = null;

            while (!doWritePicture && picturesToWrite.Count > targetPictureIndex)
            {
                pictureToWrite = picturesToWrite[targetPictureIndex++];

                // Picture has either to be supported, or to come from the right tag standard
                doWritePicture = !pictureToWrite.PicType.Equals(PictureInfo.PIC_TYPE.Unsupported);
                if (!doWritePicture)
                {
                    doWritePicture = (MetaDataIOFactory.TAG_NATIVE == pictureToWrite.TagType);
                }
                // It also has not to be marked for deletion
                doWritePicture = doWritePicture && (!pictureToWrite.MarkedForDeletion);
            }

            if (doWritePicture)
            {
                bool pictureExists = false;
                // Check if the picture to write is already there ('neutral update' use case)
                if (existingPictures.Count > existingPictureIndex)
                {
                    PictureInfo existingPic = existingPictures[existingPictureIndex++];
                    pictureExists = existingPic.ComputePicHash() == pictureToWrite.ComputePicHash(); // No need to rewrite an identical pic
                }
                if (!pictureExists)
                {
                    return(new WriteResult(WriteMode.REPLACE, writePictureBlock(w, pictureToWrite)));
                }
                else
                {
                    w.Write(META_PICTURE);
                    return(new WriteResult(WriteMode.OVERWRITE, 1));
                }
            }
            else
            {
                return(new WriteResult(WriteMode.REPLACE, 0)); // Nothing else to write; existing picture blocks are erased
            }
        }
Exemplo n.º 8
0
        public MetaIOTest()
        {
            // Initialize default test data
            testData = new TagData();

            testData.Title              = "Title";
            testData.Album              = "父";
            testData.Artist             = "Artist";
            testData.AlbumArtist        = "Bob";
            testData.Comment            = "Test!";
            testData.RecordingYear      = "2017";
            testData.RecordingDate      = ""; // Empty string means "supported, but not valued in test sample"
            testData.Genre              = "Test";
            testData.Rating             = "0";
            testData.TrackNumber        = "22";
            testData.Composer           = "Me";
            testData.Conductor          = "";
            testData.Publisher          = "";
            testData.DiscNumber         = "2";
            testData.Copyright          = "";
            testData.GeneralDescription = "";

            testData.AdditionalFields = new List <MetaFieldInfo>();
            testData.AdditionalFields.Add(new MetaFieldInfo(MetaDataIOFactory.TAG_ANY, "TEST", "xxx"));

            testData.Pictures = new List <PictureInfo>();
            PictureInfo pic = new PictureInfo(Commons.ImageFormat.Jpeg, MetaDataIOFactory.TAG_ANY, 0x03);

            byte[] data = System.IO.File.ReadAllBytes(TestUtils.GetResourceLocationRoot() + "_Images/pic1.jpeg");
            pic.PictureData = data;
            pic.ComputePicHash();
            testData.Pictures.Add(pic);

            pic             = new PictureInfo(Commons.ImageFormat.Png, MetaDataIOFactory.TAG_ANY, 0x02);
            data            = System.IO.File.ReadAllBytes(TestUtils.GetResourceLocationRoot() + "_Images/pic1.png");
            pic.PictureData = data;
            pic.ComputePicHash();
            testData.Pictures.Add(pic);
        }