public static GaplessInfo parseId3(ExtractorInput input) throws IOException, InterruptedException {
  ParsableByteArray scratch=new ParsableByteArray(10);
  int peekedId3Bytes=0;
  GaplessInfo metadata=null;
  while (true) {
    input.peekFully(scratch.data,0,10);
    scratch.setPosition(0);
    if (scratch.readUnsignedInt24() != ID3_TAG) {
      break;
    }
    int majorVersion=scratch.readUnsignedByte();
    int minorVersion=scratch.readUnsignedByte();
    int flags=scratch.readUnsignedByte();
    int length=scratch.readSynchSafeInt();
    if (metadata == null && canParseMetadata(majorVersion,minorVersion,flags,length)) {
      byte[] frame=new byte[length];
      input.peekFully(frame,0,length);
      metadata=parseGaplessInfo(new ParsableByteArray(frame),majorVersion,flags);
    }
 else {
      input.advancePeekPosition(length);
    }
    peekedId3Bytes+=10 + length;
  }
  input.resetPeekPosition();
  input.advancePeekPosition(peekedId3Bytes);
  return metadata;
}

public static GaplessInfo parseId3 ( ExtractorInput input ) throws IOException , InterruptedException { ParsableByteArray scratch = new ParsableByteArray ( 10 ) ; int peekedId3Bytes = 0 ; GaplessInfo metadata = null ; while ( true ) { input . peekFully ( scratch . data , 0 , 10 ) ; scratch . setPosition ( 0 ) ; if ( scratch . readUnsignedInt24 ( ) != ID3_TAG ) { break ; } int majorVersion = scratch . readUnsignedByte ( ) ; int minorVersion = scratch . readUnsignedByte ( ) ; int flags = scratch . readUnsignedByte ( ) ; int length = scratch . readSynchSafeInt ( ) ; if ( metadata == null && canParseMetadata ( majorVersion , minorVersion , flags , length ) ) { byte [ ] frame = new byte [ length ] ; input . peekFully ( frame , 0 , length ) ; metadata = parseGaplessInfo ( new ParsableByteArray ( frame ) , majorVersion , flags ) ; } else { input . advancePeekPosition ( length ) ; } peekedId3Bytes += 10 + length ; } input . resetPeekPosition ( ) ; input . advancePeekPosition ( peekedId3Bytes ) ; return metadata ; }
peeks data from the input and parses id3 metadata .
