FlacMetadataReader { @Nullable public static Metadata peekId3Metadata(ExtractorInput input, boolean parseData) throws IOException, InterruptedException { @Nullable Id3Decoder.FramePredicate id3FramePredicate = parseData ? null : Id3Decoder.NO_FRAMES_PREDICATE; @Nullable Metadata id3Metadata = new Id3Peeker().peekId3Data(input, id3FramePredicate); return id3Metadata == null || id3Metadata.length() == 0 ? null : id3Metadata; } 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 peekId3Metadata_updatesPeekPosition() throws Exception { ExtractorInput input = buildExtractorInput("flac/bear_with_id3_enabled.flac"); FlacMetadataReader.peekId3Metadata(input, false); assertThat(input.getPosition()).isEqualTo(0); assertThat(input.getPeekPosition()).isNotEqualTo(0); }
@Test public void peekId3Metadata_parseData_returnsNonEmptyMetadata() throws Exception { ExtractorInput input = buildExtractorInput("flac/bear_with_id3_enabled.flac"); Metadata metadata = FlacMetadataReader.peekId3Metadata(input, true); assertThat(metadata).isNotNull(); assertThat(metadata.length()).isNotEqualTo(0); }
@Test public void peekId3Metadata_doNotParseData_returnsNull() throws Exception { ExtractorInput input = buildExtractorInput("flac/bear_with_id3_enabled.flac"); Metadata metadata = FlacMetadataReader.peekId3Metadata(input, false); assertThat(metadata).isNull(); }
@Test public void peekId3Metadata_noId3Metadata_returnsNull() throws Exception { String fileWithoutId3Metadata = "flac/bear.flac"; ExtractorInput input = buildExtractorInput(fileWithoutId3Metadata); Metadata metadata = FlacMetadataReader.peekId3Metadata(input, true); assertThat(metadata).isNull(); }