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(); } }
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); } } }