/// <summary>Reads an MP3Frame from a stream</summary> /// <remarks>http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm has some good info /// also see http://www.codeproject.com/KB/audio-video/mpegaudioinfo.aspx /// </remarks> /// <returns>A valid MP3 frame, or null if none found</returns> // Token: 0x060003A3 RID: 931 RVA: 0x0000CA4C File Offset: 0x0000AC4C public static Mp3Frame LoadFromStream(Stream input, bool readData) { Mp3Frame mp3Frame = new Mp3Frame(); mp3Frame.FileOffset = input.Position; byte[] array = new byte[4]; int num = input.Read(array, 0, array.Length); if (num < array.Length) { return(null); } while (!Mp3Frame.IsValidHeader(array, mp3Frame)) { array[0] = array[1]; array[1] = array[2]; array[2] = array[3]; num = input.Read(array, 3, 1); if (num < 1) { return(null); } mp3Frame.FileOffset += 1L; } int num2 = mp3Frame.FrameLength - 4; if (readData) { mp3Frame.RawData = new byte[mp3Frame.FrameLength]; Array.Copy(array, mp3Frame.RawData, 4); num = input.Read(mp3Frame.RawData, 4, num2); if (num < num2) { throw new EndOfStreamException("Unexpected end of stream before frame complete"); } } else { input.Position += (long)num2; } return(mp3Frame); }