private void Read(bool read_tags, ReadStyle style, out uint aiff_size, out long tag_start, out long tag_end) { base.Seek(0L); if (base.ReadBlock(4) != FileIdentifier) { throw new CorruptFileException("File does not begin with AIFF identifier"); } aiff_size = base.ReadBlock(4).ToUInt(true); tag_start = -1L; tag_end = -1L; if ((this.header_block == null) && (style != ReadStyle.None)) { long offset = base.Find(CommIdentifier, 0L); if (offset == -1L) { throw new CorruptFileException("No Common chunk available in AIFF file."); } base.Seek(offset); this.header_block = base.ReadBlock(0x1a); StreamHeader header = new StreamHeader(this.header_block, (long) ((ulong) aiff_size)); ICodec[] codecs = new ICodec[] { header }; this.properties = new TagLib.Properties(TimeSpan.Zero, codecs); } long num2 = -1L; if (base.Find(SoundIdentifier, 0L, ID3Identifier) == -1L) { num2 = base.Find(ID3Identifier, 0L); } long num3 = base.Find(SoundIdentifier, 0L); if (num3 == -1L) { throw new CorruptFileException("No Sound chunk available in AIFF file."); } base.Seek(num3 + 4L); long startPosition = (((long) base.ReadBlock(4).ToULong(true)) + num3) + 4L; if (num2 == -1L) { num2 = base.Find(ID3Identifier, startPosition); } if (num2 > -1L) { if (read_tags && (this.tag == null)) { this.tag = new TagLib.Id3v2.Tag(this, num2 + 8L); } base.Seek(num2 + 4L); uint num6 = base.ReadBlock(4).ToUInt(true) + 8; long num7 = num2; base.InvariantStartPosition = num7; tag_start = num7; num7 = tag_start + num6; base.InvariantEndPosition = num7; tag_end = num7; } }
private void Read(bool read_tags, ReadStyle style, out uint aiff_size, out long tag_start, out long tag_end) { Seek(0); if (ReadBlock(4) != FileIdentifier) { throw new CorruptFileException("File does not begin with AIFF identifier"); } aiff_size = ReadBlock(4).ToUInt(true); tag_start = -1; tag_end = -1; if (header_block == null && style != ReadStyle.None) { long common_chunk_pos = Find(CommIdentifier, 0); if (common_chunk_pos == -1) { throw new CorruptFileException("No Common chunk available in AIFF file."); } Seek(common_chunk_pos); header_block = ReadBlock((int)StreamHeader.Size); StreamHeader header = new StreamHeader(header_block, aiff_size); properties = new Properties(TimeSpan.Zero, header); } long id3_chunk_pos = -1; long sound_chunk_pos = Find(SoundIdentifier, 0, ID3Identifier); if (sound_chunk_pos == -1) { id3_chunk_pos = Find(ID3Identifier, 0); } sound_chunk_pos = Find(SoundIdentifier, 0); if (sound_chunk_pos == -1) { throw new CorruptFileException("No Sound chunk available in AIFF file."); } Seek(sound_chunk_pos + 4); ulong sound_chunk_length = ReadBlock(4).ToULong(true); long start_search_pos = (long)sound_chunk_length + sound_chunk_pos + 4; if (id3_chunk_pos == -1) { id3_chunk_pos = Find(ID3Identifier, start_search_pos); } if (id3_chunk_pos > -1) { if (read_tags && tag == null) { tag = new Id3v2.Tag(this, id3_chunk_pos + 8); } Seek(id3_chunk_pos + 4); uint tag_size = ReadBlock(4).ToUInt(true) + 8; tag_start = InvariantStartPosition = id3_chunk_pos; tag_end = InvariantEndPosition = tag_start + tag_size; } }
/// <summary> /// Reads the contents of the current instance determining /// the size of the riff data, the area the tagging is in, /// and optionally reading in the tags and media properties. /// </summary> /// <param name="read_tags"> /// If <see langword="true" />, any tags found will be read /// into the current instance. /// </param> /// <param name="style"> /// A <see cref="ReadStyle"/> value specifying how the media /// data is to be read into the current instance. /// </param> /// <param name="aiff_size"> /// A <see cref="uint"/> value reference to be filled with /// the size of the RIFF data as read from the file. /// </param> /// <param name="tag_start"> /// A <see cref="long" /> value reference to be filled with /// the absolute seek position at which the tagging data /// starts. /// </param> /// <param name="tag_end"> /// A <see cref="long" /> value reference to be filled with /// the absolute seek position at which the tagging data /// ends. /// </param> /// <exception cref="CorruptFileException"> /// The file does not begin with <see cref="FileIdentifier" /// />. /// </exception> private void Read(bool read_tags, ReadStyle style, out uint aiff_size, out long tag_start, out long tag_end) { Seek(0); if (ReadBlock(4) != FileIdentifier) throw new CorruptFileException( "File does not begin with AIFF identifier"); aiff_size = ReadBlock(4).ToUInt(true); tag_start = -1; tag_end = -1; // Get the properties of the file if (header_block == null && style != ReadStyle.None) { long common_chunk_pos = Find(CommIdentifier, 0); if (common_chunk_pos == -1) { throw new CorruptFileException( "No Common chunk available in AIFF file."); } Seek(common_chunk_pos); header_block = ReadBlock((int) StreamHeader.Size); StreamHeader header = new StreamHeader(header_block, aiff_size); properties = new Properties(TimeSpan.Zero, header); } // Now we search for the ID3 chunk. // Normally it appears after the Sound data chunk. But as the order of // chunks is free, it might be the case that the ID3 chunk appears before // the sound data chunk. // So we search first for the Sound data chunk and see, if an ID3 chunk appears before long id3_chunk_pos = -1; long sound_chunk_pos = Find(SoundIdentifier, 0, ID3Identifier); if (sound_chunk_pos == -1) { // The ID3 chunk appears before the Sound chunk id3_chunk_pos = Find(ID3Identifier, 0); } // Now let's look for the Sound chunk again // Since a previous return value of -1 does mean, that the ID3 chunk was found first sound_chunk_pos = Find(SoundIdentifier, 0); if (sound_chunk_pos == -1) { throw new CorruptFileException( "No Sound chunk available in AIFF file."); } // Get the length of the Sound chunk and use this as a start value to look for the ID3 chunk Seek(sound_chunk_pos + 4); ulong sound_chunk_length = ReadBlock(4).ToULong(true); long start_search_pos = (long) sound_chunk_length + sound_chunk_pos + 4; if (id3_chunk_pos == -1) { id3_chunk_pos = Find(ID3Identifier, start_search_pos); } if (id3_chunk_pos > -1) { if (read_tags && tag == null) { tag = new Id3v2.Tag(this, id3_chunk_pos + 8); } // Get the length of the tag out of the ID3 chunk Seek(id3_chunk_pos + 4); uint tag_size = ReadBlock(4).ToUInt(true) + 8; tag_start = InvariantStartPosition = id3_chunk_pos; tag_end = InvariantEndPosition = tag_start + tag_size; } }
/// <summary> /// Reads the contents of the current instance determining /// the size of the riff data, the area the tagging is in, /// and optionally reading in the tags and media properties. /// </summary> /// <param name="read_tags"> /// If <see langword="true" />, any tags found will be read /// into the current instance. /// </param> /// <param name="style"> /// A <see cref="ReadStyle"/> value specifying how the media /// data is to be read into the current instance. /// </param> /// <param name="aiff_size"> /// A <see cref="uint"/> value reference to be filled with /// the size of the RIFF data as read from the file. /// </param> /// <param name="tag_start"> /// A <see cref="long" /> value reference to be filled with /// the absolute seek position at which the tagging data /// starts. /// </param> /// <param name="tag_end"> /// A <see cref="long" /> value reference to be filled with /// the absolute seek position at which the tagging data /// ends. /// </param> /// <exception cref="CorruptFileException"> /// The file does not begin with <see cref="FileIdentifier" /// />. /// </exception> private void Read(bool read_tags, ReadStyle style, out uint aiff_size, out long tag_start, out long tag_end) { Seek(0); if (ReadBlock(4) != FileIdentifier) { throw new CorruptFileException( "File does not begin with AIFF identifier"); } aiff_size = ReadBlock(4).ToUInt(true); tag_start = -1; tag_end = -1; // Get the properties of the file if (header_block == null && style != ReadStyle.None) { long common_chunk_pos = Find(CommIdentifier, 0); if (common_chunk_pos == -1) { throw new CorruptFileException( "No Common chunk available in AIFF file."); } Seek(common_chunk_pos); header_block = ReadBlock((int)StreamHeader.Size); StreamHeader header = new StreamHeader(header_block, aiff_size); properties = new Properties(TimeSpan.Zero, header); } // Now we search for the ID3 chunk. // Normally it appears after the Sound data chunk. But as the order of // chunks is free, it might be the case that the ID3 chunk appears before // the sound data chunk. // So we search first for the Sound data chunk and see, if an ID3 chunk appears before long id3_chunk_pos = -1; long sound_chunk_pos = Find(SoundIdentifier, 0, ID3Identifier); if (sound_chunk_pos == -1) { // The ID3 chunk appears before the Sound chunk id3_chunk_pos = Find(ID3Identifier, 0); } // Now let's look for the Sound chunk again // Since a previous return value of -1 does mean, that the ID3 chunk was found first sound_chunk_pos = Find(SoundIdentifier, 0); if (sound_chunk_pos == -1) { throw new CorruptFileException( "No Sound chunk available in AIFF file."); } // Get the length of the Sound chunk and use this as a start value to look for the ID3 chunk Seek(sound_chunk_pos + 4); ulong sound_chunk_length = ReadBlock(4).ToULong(true); long start_search_pos = (long)sound_chunk_length + sound_chunk_pos + 4; if (id3_chunk_pos == -1) { id3_chunk_pos = Find(ID3Identifier, start_search_pos); } if (id3_chunk_pos > -1) { if (read_tags && tag == null) { tag = new Id3v2.Tag(this, id3_chunk_pos + 8); } // Get the length of the tag out of the ID3 chunk Seek(id3_chunk_pos + 4); uint tag_size = ReadBlock(4).ToUInt(true) + 8; tag_start = InvariantStartPosition = id3_chunk_pos; tag_end = InvariantEndPosition = tag_start + tag_size; } }
/// <summary> /// Reads the contents of the current instance determining /// the size of the riff data, the area the tagging is in, /// and optionally reading in the tags and media properties. /// </summary> /// <param name="read_tags"> /// If <see langword="true" />, any tags found will be read /// into the current instance. /// </param> /// <param name="style"> /// A <see cref="ReadStyle"/> value specifying how the media /// data is to be read into the current instance. /// </param> /// <param name="aiff_size"> /// A <see cref="uint"/> value reference to be filled with /// the size of the RIFF data as read from the file. /// </param> /// <param name="tag_start"> /// A <see cref="long" /> value reference to be filled with /// the absolute seek position at which the tagging data /// starts. /// </param> /// <param name="tag_end"> /// A <see cref="long" /> value reference to be filled with /// the absolute seek position at which the tagging data /// ends. /// </param> /// <exception cref="CorruptFileException"> /// The file does not begin with <see cref="FileIdentifier" /// />. /// </exception> private void Read(bool read_tags, ReadStyle style, out uint aiff_size, out long tag_start, out long tag_end) { Seek(0); if (ReadBlock(4) != FileIdentifier) { throw new CorruptFileException( "File does not begin with AIFF identifier"); } aiff_size = ReadBlock(4).ToUInt(true); tag_start = -1; tag_end = -1; // Check formType if (ReadBlock(4) != AIFFFormType) { throw new CorruptFileException( "File form type is not AIFF"); } long formBlockChunksPosition = Tell; // Get the properties of the file if (header_block == null && style != ReadStyle.None) { long common_chunk_pos = FindChunk(CommIdentifier, formBlockChunksPosition); if (common_chunk_pos == -1) { throw new CorruptFileException( "No Common chunk available in AIFF file."); } Seek(common_chunk_pos); header_block = ReadBlock((int)StreamHeader.Size); StreamHeader header = new StreamHeader(header_block, aiff_size); properties = new Properties(TimeSpan.Zero, header); } // Search for the ID3 chunk long id3_chunk_pos = FindChunk(ID3Identifier, formBlockChunksPosition); // Search for the sound chunk long sound_chunk_pos = FindChunk(SoundIdentifier, formBlockChunksPosition); // Ensure there is a sound chunk for the file to be valid if (sound_chunk_pos == -1) { throw new CorruptFileException( "No Sound chunk available in AIFF file."); } // Get the length of the Sound chunk and use this as a start value to look for the ID3 chunk Seek(sound_chunk_pos + 4); // Read the id3 chunk if (id3_chunk_pos > -1) { if (read_tags && tag == null) { tag = new Id3v2.Tag(this, id3_chunk_pos + 8, style); } // Get the length of the tag out of the ID3 chunk Seek(id3_chunk_pos + 4); uint tag_size = ReadBlock(4).ToUInt(true) + 8; tag_start = InvariantStartPosition = id3_chunk_pos; tag_end = InvariantEndPosition = tag_start + tag_size; } }