FlacStreamMetadata { @Nullable public Metadata getMetadataCopyWithAppendedEntriesFrom(@Nullable Metadata other) { return metadata == null ? other : metadata.copyWithAppendedEntriesFrom(other); } FlacStreamMetadata(byte[] data, int offset);  FlacStreamMetadata(
      int minBlockSizeSamples,
      int maxBlockSizeSamples,
      int minFrameSize,
      int maxFrameSize,
      int sampleRate,
      int channels,
      int bitsPerSample,
      long totalSamples,
      ArrayList<String> vorbisComments,
      ArrayList<PictureFrame> pictureFrames); private  FlacStreamMetadata(
      int minBlockSizeSamples,
      int maxBlockSizeSamples,
      int minFrameSize,
      int maxFrameSize,
      int sampleRate,
      int channels,
      int bitsPerSample,
      long totalSamples,
      @Nullable SeekTable seekTable,
      @Nullable Metadata metadata); int getMaxDecodedFrameSize(); int getBitRate(); long getDurationUs(); long getSampleNumber(long timeUs); long getApproxBytesPerFrame(); Format getFormat(byte[] streamMarkerAndInfoBlock, @Nullable Metadata id3Metadata); @Nullable Metadata getMetadataCopyWithAppendedEntriesFrom(@Nullable Metadata other); FlacStreamMetadata copyWithSeekTable(@Nullable SeekTable seekTable); FlacStreamMetadata copyWithVorbisComments(List<String> vorbisComments); FlacStreamMetadata copyWithPictureFrames(List<PictureFrame> pictureFrames); static final int NOT_IN_LOOKUP_TABLE; final int minBlockSizeSamples; final int maxBlockSizeSamples; final int minFrameSize; final int maxFrameSize; final int sampleRate; final int sampleRateLookupKey; final int channels; final int bitsPerSample; final int bitsPerSampleLookupKey; final long totalSamples; @Nullable final SeekTable seekTable; }
@Test public void parseVorbisComments() { ArrayList<String> commentsList = new ArrayList<>(); commentsList.add("Title=Song"); commentsList.add("Artist=Singer"); Metadata metadata = new FlacStreamMetadata( 0, 0, 0, 0, 0, 0, 0, 0, commentsList, new ArrayList<>()) .getMetadataCopyWithAppendedEntriesFrom( null); assertThat(metadata.length()).isEqualTo(2); VorbisComment commentFrame = (VorbisComment) metadata.get(0); assertThat(commentFrame.key).isEqualTo("Title"); assertThat(commentFrame.value).isEqualTo("Song"); commentFrame = (VorbisComment) metadata.get(1); assertThat(commentFrame.key).isEqualTo("Artist"); assertThat(commentFrame.value).isEqualTo("Singer"); }
@Test public void parseEmptyVorbisComments() { ArrayList<String> commentsList = new ArrayList<>(); Metadata metadata = new FlacStreamMetadata( 0, 0, 0, 0, 0, 0, 0, 0, commentsList, new ArrayList<>()) .getMetadataCopyWithAppendedEntriesFrom( null); assertThat(metadata).isNull(); }
@Test public void parseVorbisCommentWithEqualsInValue() { ArrayList<String> commentsList = new ArrayList<>(); commentsList.add("Title=So=ng"); Metadata metadata = new FlacStreamMetadata( 0, 0, 0, 0, 0, 0, 0, 0, commentsList, new ArrayList<>()) .getMetadataCopyWithAppendedEntriesFrom( null); assertThat(metadata.length()).isEqualTo(1); VorbisComment commentFrame = (VorbisComment) metadata.get(0); assertThat(commentFrame.key).isEqualTo("Title"); assertThat(commentFrame.value).isEqualTo("So=ng"); }
@Test public void parseInvalidVorbisComment() { ArrayList<String> commentsList = new ArrayList<>(); commentsList.add("TitleSong"); commentsList.add("Artist=Singer"); Metadata metadata = new FlacStreamMetadata( 0, 0, 0, 0, 0, 0, 0, 0, commentsList, new ArrayList<>()) .getMetadataCopyWithAppendedEntriesFrom( null); assertThat(metadata.length()).isEqualTo(1); VorbisComment commentFrame = (VorbisComment) metadata.get(0); assertThat(commentFrame.key).isEqualTo("Artist"); assertThat(commentFrame.value).isEqualTo("Singer"); }