FlacMetadataReader { public static int getFrameStartMarker(ExtractorInput input) throws IOException, InterruptedException { input.resetPeekPosition(); ParsableByteArray scratch = new ParsableByteArray(2); input.peekFully(scratch.data, 0, 2); int frameStartMarker = scratch.readUnsignedShort(); int syncCode = frameStartMarker >> 2; if (syncCode != SYNC_CODE) { input.resetPeekPosition(); throw new ParserException("First frame does not start with sync code."); } input.resetPeekPosition(); return frameStartMarker; } private  FlacMetadataReader(); @Nullable static Metadata peekId3Metadata(ExtractorInput input, boolean parseData); static boolean checkAndPeekStreamMarker(ExtractorInput input); @Nullable static Metadata readId3Metadata(ExtractorInput input, boolean parseData); static void readStreamMarker(ExtractorInput input); static boolean readMetadataBlock(
      ExtractorInput input, FlacStreamMetadataHolder metadataHolder); static FlacStreamMetadata.SeekTable readSeekTableMetadataBlock(ParsableByteArray data); static int getFrameStartMarker(ExtractorInput input);  }
@Test public void getFrameStartMarker_doesNotUpdateReadPositionAndAlignsPeekPosition() throws Exception { ExtractorInput input = buildExtractorInput("flac/bear.flac"); int firstFramePosition = 8880; input.skipFully(firstFramePosition); input.advancePeekPosition(3); FlacMetadataReader.getFrameStartMarker(input); assertThat(input.getPosition()).isEqualTo(firstFramePosition); assertThat(input.getPeekPosition()).isEqualTo(input.getPosition()); }
@Test public void getFrameStartMarker_returnsCorrectFrameStartMarker() throws Exception { ExtractorInput input = buildExtractorInput("flac/bear.flac"); input.skipFully(8880); int result = FlacMetadataReader.getFrameStartMarker(input); assertThat(result).isEqualTo(0xFFF8); }
@Test(expected = ParserException.class) public void getFrameStartMarker_invalidData_throwsException() throws Exception { ExtractorInput input = buildExtractorInput("flac/bear.flac"); FlacMetadataReader.getFrameStartMarker(input); }