private void readHeader ( RandomAccessInputStream raf , long location ) throws IOException { byte [ ] head = new byte [ HEADER_SIZE ] ; raf . seek ( location ) ; if ( raf . read ( head ) != HEADER_SIZE ) { throw new IOException ( "Error reading MPEG frame header." ) ; } version = ( head [ 1 ] & 0x18 ) >> 3 ; layer = ( head [ 1 ] & 0x06 ) >> 1 ; crced = ( head [ 1 ] & 0x01 ) == 0 ; bitRate = findBitRate ( ( head [ 2 ] & 0xF0 ) >> 4 , version , layer ) ; sampleRate = findSampleRate ( ( head [ 2 ] & 0x0C ) >> 2 , version ) ; channelMode = ( head [ 3 ] & 0xC0 ) >> 6 ; copyrighted = ( head [ 3 ] & 0x08 ) != 0 ; original = ( head [ 3 ] & 0x04 ) != 0 ; emphasis = head [ 3 ] & 0x03 ; }
Read in all the information found in the mpeg header .