com.google.android.exoplayer2.util.FlacStreamMetadata Java Examples
The following examples show how to use
com.google.android.exoplayer2.util.FlacStreamMetadata.
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 |
/** * 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: FlacExtractor.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
private static void outputFormat( FlacStreamMetadata streamMetadata, @Nullable Metadata metadata, TrackOutput output) { Format mediaFormat = Format.createAudioSampleFormat( /* id= */ null, MimeTypes.AUDIO_RAW, /* codecs= */ null, streamMetadata.bitRate(), streamMetadata.maxDecodedFrameSize(), streamMetadata.channels, streamMetadata.sampleRate, getPcmEncoding(streamMetadata.bitsPerSample), /* encoderDelay= */ 0, /* encoderPadding= */ 0, /* initializationData= */ null, /* drmInitData= */ null, /* selectionFlags= */ 0, /* language= */ null, metadata); output.format(mediaFormat); }
Example #3
Source File: FlacBinarySearchSeeker.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
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 #4
Source File: FlacExtractor.java From Telegram with GNU General Public License v2.0 | 6 votes |
/** * 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 #5
Source File: FlacExtractor.java From Telegram with GNU General Public License v2.0 | 6 votes |
private static void outputFormat( FlacStreamMetadata streamMetadata, @Nullable Metadata metadata, TrackOutput output) { Format mediaFormat = Format.createAudioSampleFormat( /* id= */ null, MimeTypes.AUDIO_RAW, /* codecs= */ null, streamMetadata.bitRate(), streamMetadata.maxDecodedFrameSize(), streamMetadata.channels, streamMetadata.sampleRate, getPcmEncoding(streamMetadata.bitsPerSample), /* encoderDelay= */ 0, /* encoderPadding= */ 0, /* initializationData= */ null, /* drmInitData= */ null, /* selectionFlags= */ 0, /* language= */ null, metadata); output.format(mediaFormat); }
Example #6
Source File: FlacBinarySearchSeeker.java From Telegram with GNU General Public License v2.0 | 6 votes |
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 #7
Source File: FlacExtractor.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@RequiresNonNull({"decoderJni", "extractorOutput", "trackOutput"}) // Requires initialized. @EnsuresNonNull({"streamMetadata", "outputFrameHolder"}) // Ensures stream metadata decoded. @SuppressWarnings({"contracts.postcondition.not.satisfied"}) private void decodeStreamMetadata(ExtractorInput input) throws InterruptedException, IOException { if (streamMetadataDecoded) { return; } FlacStreamMetadata streamMetadata; try { streamMetadata = decoderJni.decodeStreamMetadata(); } catch (IOException e) { decoderJni.reset(/* newPosition= */ 0); input.setRetryPosition(/* position= */ 0, e); throw e; } streamMetadataDecoded = true; if (this.streamMetadata == null) { this.streamMetadata = streamMetadata; binarySearchSeeker = outputSeekMap(decoderJni, streamMetadata, input.getLength(), extractorOutput); Metadata metadata = id3MetadataDisabled ? null : id3Metadata; if (streamMetadata.metadata != null) { metadata = streamMetadata.metadata.copyWithAppendedEntriesFrom(metadata); } outputFormat(streamMetadata, metadata, trackOutput); outputBuffer.reset(streamMetadata.maxDecodedFrameSize()); outputFrameHolder = new OutputFrameHolder(ByteBuffer.wrap(outputBuffer.data)); } }
Example #8
Source File: FlacDecoderJni.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
/** Decodes and consumes the metadata from the FLAC stream. */ public FlacStreamMetadata decodeStreamMetadata() throws IOException, InterruptedException { FlacStreamMetadata streamMetadata = flacDecodeMetadata(nativeDecoderContext); if (streamMetadata == null) { throw new ParserException("Failed to decode stream metadata"); } return streamMetadata; }
Example #9
Source File: FlacExtractor.java From Telegram with GNU General Public License v2.0 | 5 votes |
@RequiresNonNull({"decoderJni", "extractorOutput", "trackOutput"}) // Requires initialized. @EnsuresNonNull({"streamMetadata", "outputFrameHolder"}) // Ensures stream metadata decoded. @SuppressWarnings({"contracts.postcondition.not.satisfied"}) private void decodeStreamMetadata(ExtractorInput input) throws InterruptedException, IOException { if (streamMetadataDecoded) { return; } FlacStreamMetadata streamMetadata; try { streamMetadata = decoderJni.decodeStreamMetadata(); } catch (IOException e) { decoderJni.reset(/* newPosition= */ 0); input.setRetryPosition(/* position= */ 0, e); throw e; } streamMetadataDecoded = true; if (this.streamMetadata == null) { this.streamMetadata = streamMetadata; binarySearchSeeker = outputSeekMap(decoderJni, streamMetadata, input.getLength(), extractorOutput); Metadata metadata = id3MetadataDisabled ? null : id3Metadata; if (streamMetadata.metadata != null) { metadata = streamMetadata.metadata.copyWithAppendedEntriesFrom(metadata); } outputFormat(streamMetadata, metadata, trackOutput); outputBuffer.reset(streamMetadata.maxDecodedFrameSize()); outputFrameHolder = new OutputFrameHolder(ByteBuffer.wrap(outputBuffer.data)); } }
Example #10
Source File: FlacDecoderJni.java From Telegram with GNU General Public License v2.0 | 5 votes |
/** Decodes and consumes the metadata from the FLAC stream. */ public FlacStreamMetadata decodeStreamMetadata() throws IOException, InterruptedException { FlacStreamMetadata streamMetadata = flacDecodeMetadata(nativeDecoderContext); if (streamMetadata == null) { throw new ParserException("Failed to decode stream metadata"); } return streamMetadata; }
Example #11
Source File: FlacBinarySearchSeeker.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public FlacSeekTimestampConverter(FlacStreamMetadata streamMetadata) { this.streamMetadata = streamMetadata; }
Example #12
Source File: FlacDecoderJni.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private native FlacStreamMetadata flacDecodeMetadata(long context) throws IOException, InterruptedException;
Example #13
Source File: FlacBinarySearchSeeker.java From Telegram with GNU General Public License v2.0 | 4 votes |
public FlacSeekTimestampConverter(FlacStreamMetadata streamMetadata) { this.streamMetadata = streamMetadata; }
Example #14
Source File: FlacDecoderJni.java From Telegram with GNU General Public License v2.0 | 4 votes |
private native FlacStreamMetadata flacDecodeMetadata(long context) throws IOException, InterruptedException;