public static void ParseStream(Stream stream)
        {
            AudioTags audioTags = new AudioTags();
            audioTags.AudioTagParse += AudioTagParse;
            try
            {
                audioTags.ReadTags(stream);
            }
            catch (Exception ex)
            {
                Console.WriteLine("[-] Exception thrown: {0}", ex);
                return;
            }

            // Display all found iTunes normalization frames.
            foreach (Id3v2iTunesNormalizationFrame normalizationFrame in
                audioTags.OfType<Id3v2Tag>().Select(audioTag => audioTag.GetFrame<Id3v2iTunesNormalizationFrame>()))
            {
                Console.WriteLine("[+] iTunes normalization frame found in an Id3v2 tag.");
                Console.WriteLine("[+] Volume adjustment1 left: {0}", normalizationFrame.VolumeAdjustment1Left);
                Console.WriteLine("[+] Volume adjustment1 right: {0}", normalizationFrame.VolumeAdjustment1Right);
                Console.WriteLine("[+] Volume adjustment2 left: {0}", normalizationFrame.VolumeAdjustment2Left);
                Console.WriteLine("[+] Volume adjustment2 right: {0}", normalizationFrame.VolumeAdjustment2Right);
                Console.WriteLine("[+] Unknown1 left: {0}", normalizationFrame.Unknown1Left);
                Console.WriteLine("[+] Unknown1 right: {0}", normalizationFrame.Unknown1Right);
                Console.WriteLine("[+] Peak value left: {0}", normalizationFrame.PeakValueLeft);
                Console.WriteLine("[+] Peak value right: {0}", normalizationFrame.PeakValueRight);
                Console.WriteLine("[+] Unknown2 left: {0}", normalizationFrame.Unknown2Left);
                Console.WriteLine("[+] Unknown2 right: {0}", normalizationFrame.Unknown2Right);
                Console.WriteLine();
            }
        }
Esempio n. 2
0
        private void ScanTags()
        {
            try
            {
                var tagFile = TagLib.File.Create(FullPath);
                if (tagFile != null)
                {
                    MimeType = tagFile.MimeType;
                }
                if (!tagFile.Tag.IsEmpty)
                {
                    _isAudio = tagFile.Properties.MediaTypes == MediaTypes.Audio;
                    _tags    = new AudioTags(tagFile.Tag);
                }
                else
                {
                    _tags = null;
                }
            }
            catch (UnsupportedFormatException)
            {
                _tags = null;
            }
            catch (Exception ex)
            {
                //todo: logging
                Console.Error.WriteLine($"Error parsing audio tag: {ex.Message}; {ex.StackTrace}");
                _tags = null;
            }

            _scannedTags = true;
        }
Esempio n. 3
0
        ////------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="AudioInfo" /> class.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <exception cref="System.ArgumentNullException">Thrown if stream is null.</exception>
        private AudioInfo(Stream stream)
        {
            if (stream == null)
                throw new ArgumentNullException("stream");

            _stream = stream;
            AudioTags = new AudioTags();
            AudioStreams = new AudioStreams();
        }
        public static void ParseStream(Stream stream)
        {
            AudioTags audioTags = new AudioTags();
            audioTags.AudioTagParse += AudioTagParse;
            try
            {
                audioTags.ReadTags(stream);
            }
            catch (Exception ex)
            {
                Console.WriteLine("[-] Exception thrown: {0}", ex);
                return;
            }

            // For each Id3v2 tag found
            foreach (IAudioTagOffset tagOffset in audioTags.Where(t => t.AudioTag is Id3v2Tag))
            {
                Id3v2Tag tag = tagOffset.AudioTag as Id3v2Tag;
                if (tag == null)
                    continue;

                // For each frame in the Id3v2 tag
                foreach (Id3v2Frame frame in tag.Frames)
                {
                    // Set encryption
                    frame.UseEncryption = true;

                    // Set the cryptor
                    frame.Cryptor = new Id3v2FrameCryption();
                }

                // Write the tag to a byte array into a memory stream (this will trigger encrypting each frame).
                MemoryStream ms = new MemoryStream(tag.ToByteArray());

                // Read the tag again from the memory stream (this will trigger decrypting each frame).
                Id3v2TagReader tagReader = new Id3v2TagReader();
                IAudioTagOffset decryptedTagOffset = tagReader.ReadFromStream(ms, tagOffset.TagOrigin);
                if (decryptedTagOffset != null)
                {
                    Id3v2Tag decryptedTag = decryptedTagOffset.AudioTag as Id3v2Tag;
                    if (decryptedTag != null)
                        Console.WriteLine("[*] Frames use encryption: {0}", decryptedTag.Frames.All(f => f.UseEncryption));
                }
            }
        }
        public static void ParseStream(Stream stream)
        {
            AudioTags audioTags = new AudioTags();
            audioTags.AudioTagParse += AudioTagParse;
            try
            {
                audioTags.ReadTags(stream);
            }
            catch (Exception ex)
            {
                Console.WriteLine("[-] Exception thrown: {0}", ex);
                return;
            }

            foreach (IAudioTagOffset tagOffset in audioTags.Where(t => t.AudioTag is Id3v2Tag))
            {
                Id3v2Tag tag = tagOffset.AudioTag as Id3v2Tag;
                if (tag == null)
                    continue;

                Id3v2ExperimentalTestFrame testFrame = tag.GetFrame<Id3v2ExperimentalTestFrame>();
                if (testFrame == null)
                {
                    testFrame = new Id3v2ExperimentalTestFrame(tag.Version)
                                    {
                                        TextEncodingType = Id3v2FrameEncodingType.UTF16BigEndian,
                                        TaggingLibraryUsed = "This one",
                                        TaggingLibraryAuthor = "Me",
                                        TaggingLibraryWebsite = "http://www.google.com/",
                                        TaggingLibrarySupportsFrame = true,
                                        DateOfTag = DateTime.MaxValue
                                    };
                    tag.SetFrame(testFrame);
                }
            }
        }
Esempio n. 6
0
 public void WriteAudioTags(AudioTags audioTags)
 {
     WriteArray(audioTags.ToArray());
 }