Java Code Examples for com.google.android.exoplayer2.util.FlacStreamMetadata#durationUs()

The following examples show how to use com.google.android.exoplayer2.util.FlacStreamMetadata#durationUs() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlacExtractor.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Outputs a {@link SeekMap} and returns a {@link FlacBinarySearchSeeker} if one is required to
 * handle seeks.
 */
@Nullable
private static FlacBinarySearchSeeker outputSeekMap(
    FlacDecoderJni decoderJni,
    FlacStreamMetadata streamMetadata,
    long streamLength,
    ExtractorOutput output) {
  boolean haveSeekTable = decoderJni.getSeekPoints(/* timeUs= */ 0) != null;
  FlacBinarySearchSeeker binarySearchSeeker = null;
  SeekMap seekMap;
  if (haveSeekTable) {
    seekMap = new FlacSeekMap(streamMetadata.durationUs(), decoderJni);
  } else if (streamLength != C.LENGTH_UNSET) {
    long firstFramePosition = decoderJni.getDecodePosition();
    binarySearchSeeker =
        new FlacBinarySearchSeeker(streamMetadata, firstFramePosition, streamLength, decoderJni);
    seekMap = binarySearchSeeker.getSeekMap();
  } else {
    seekMap = new SeekMap.Unseekable(streamMetadata.durationUs());
  }
  output.seekMap(seekMap);
  return binarySearchSeeker;
}
 
Example 2
Source File: FlacBinarySearchSeeker.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public FlacBinarySearchSeeker(
    FlacStreamMetadata streamMetadata,
    long firstFramePosition,
    long inputLength,
    FlacDecoderJni decoderJni) {
  super(
      new FlacSeekTimestampConverter(streamMetadata),
      new FlacTimestampSeeker(decoderJni),
      streamMetadata.durationUs(),
      /* floorTimePosition= */ 0,
      /* ceilingTimePosition= */ streamMetadata.totalSamples,
      /* floorBytePosition= */ firstFramePosition,
      /* ceilingBytePosition= */ inputLength,
      /* approxBytesPerFrame= */ streamMetadata.getApproxBytesPerFrame(),
      /* minimumSearchRange= */ Math.max(1, streamMetadata.minFrameSize));
  this.decoderJni = Assertions.checkNotNull(decoderJni);
}
 
Example 3
Source File: FlacExtractor.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Outputs a {@link SeekMap} and returns a {@link FlacBinarySearchSeeker} if one is required to
 * handle seeks.
 */
@Nullable
private static FlacBinarySearchSeeker outputSeekMap(
    FlacDecoderJni decoderJni,
    FlacStreamMetadata streamMetadata,
    long streamLength,
    ExtractorOutput output) {
  boolean haveSeekTable = decoderJni.getSeekPoints(/* timeUs= */ 0) != null;
  FlacBinarySearchSeeker binarySearchSeeker = null;
  SeekMap seekMap;
  if (haveSeekTable) {
    seekMap = new FlacSeekMap(streamMetadata.durationUs(), decoderJni);
  } else if (streamLength != C.LENGTH_UNSET) {
    long firstFramePosition = decoderJni.getDecodePosition();
    binarySearchSeeker =
        new FlacBinarySearchSeeker(streamMetadata, firstFramePosition, streamLength, decoderJni);
    seekMap = binarySearchSeeker.getSeekMap();
  } else {
    seekMap = new SeekMap.Unseekable(streamMetadata.durationUs());
  }
  output.seekMap(seekMap);
  return binarySearchSeeker;
}
 
Example 4
Source File: FlacBinarySearchSeeker.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public FlacBinarySearchSeeker(
    FlacStreamMetadata streamMetadata,
    long firstFramePosition,
    long inputLength,
    FlacDecoderJni decoderJni) {
  super(
      new FlacSeekTimestampConverter(streamMetadata),
      new FlacTimestampSeeker(decoderJni),
      streamMetadata.durationUs(),
      /* floorTimePosition= */ 0,
      /* ceilingTimePosition= */ streamMetadata.totalSamples,
      /* floorBytePosition= */ firstFramePosition,
      /* ceilingBytePosition= */ inputLength,
      /* approxBytesPerFrame= */ streamMetadata.getApproxBytesPerFrame(),
      /* minimumSearchRange= */ Math.max(1, streamMetadata.minFrameSize));
  this.decoderJni = Assertions.checkNotNull(decoderJni);
}