public static ID3v2Footer FromStream(Stream stream) { if (stream == null) { throw new ArgumentNullException("stream"); } if (!stream.CanRead) { throw new ArgumentException("stream not readable"); } if (!stream.CanSeek) { throw new ArgumentException("stream not seekable"); } BinaryReader reader = new BinaryReader(stream); ID3v2Footer footer; byte[] buffer = new byte[FooterLength]; int read = stream.Read(buffer, 0, buffer.Length); if (read < 10) { throw new EndOfStreamException(); } if (buffer[0] == 0x49 && //I buffer[1] == 0x44 && //D buffer[2] == 0x33) { footer = new ID3v2Footer(); footer.Version = (ID3Version)buffer[3]; footer.RawVersion = new byte[] { buffer[3], buffer[4] }; footer.Flags = (ID3v2HeaderFlags)buffer[5]; /*footer.DataLength = buffer[6] * (1 << 21); * footer.DataLength += buffer[7] * (1 << 14); * footer.DataLength += buffer[8] * (1 << 7); * footer.DataLength += buffer[9];*/ footer.DataLength = ID3Utils.ReadInt32(buffer, 6, true); return(footer); } stream.Position -= read; return(null); }
private bool Parse4(Stream stream) { if ((_header.Flags & ID3v2HeaderFlags.ExtendedHeader) == ID3v2HeaderFlags.ExtendedHeader) { _extendedHeader = new ID3v2ExtendedHeader(stream, ID3Version.ID3v2_4); } if ((_header.Flags & ID3v2HeaderFlags.FooterPresent) == ID3v2HeaderFlags.FooterPresent) { //footer vom orginal stream lesen - da im neuen stream kein footer vorhanden ist _footer = ID3v2Footer.FromStream(_stream); if (_footer == null) { throw new ID3Exception("Invalid Id3Footer."); } } if (((int)_header.Flags & 0x0F) != 0) { throw new ID3Exception("Invalid headerflags: 0x{0}.", ((int)_header.Flags).ToString("x")); } return(true); }
public static ID3v2Footer FromStream(Stream stream) { if (stream == null) throw new ArgumentNullException("stream"); if (!stream.CanRead) throw new ArgumentException("stream not readable"); if (!stream.CanSeek) throw new ArgumentException("stream not seekable"); BinaryReader reader = new BinaryReader(stream); ID3v2Footer footer; byte[] buffer = new byte[FooterLength]; int read = stream.Read(buffer, 0, buffer.Length); if (read < 10) throw new EndOfStreamException(); if (buffer[0] == 0x49 && //I buffer[1] == 0x44 && //D buffer[2] == 0x33) { footer = new ID3v2Footer(); footer.Version = (ID3Version)buffer[3]; footer.RawVersion = new byte[] { buffer[3], buffer[4] }; footer.Flags = (ID3v2HeaderFlags)buffer[5]; /*footer.DataLength = buffer[6] * (1 << 21); footer.DataLength += buffer[7] * (1 << 14); footer.DataLength += buffer[8] * (1 << 7); footer.DataLength += buffer[9];*/ footer.DataLength = ID3Utils.ReadInt32(buffer, 6, true); return footer; } stream.Position -= read; return null; }