use of com.google.android.exoplayer2.decoder.DecoderReuseEvaluation in project ExoPlayer by google.
the class DecoderAudioRenderer method onInputFormatChanged.
private void onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException {
Format newFormat = Assertions.checkNotNull(formatHolder.format);
setSourceDrmSession(formatHolder.drmSession);
Format oldFormat = inputFormat;
inputFormat = newFormat;
encoderDelay = newFormat.encoderDelay;
encoderPadding = newFormat.encoderPadding;
if (decoder == null) {
maybeInitDecoder();
eventDispatcher.inputFormatChanged(inputFormat, /* decoderReuseEvaluation= */
null);
return;
}
DecoderReuseEvaluation evaluation;
if (sourceDrmSession != decoderDrmSession) {
evaluation = new DecoderReuseEvaluation(decoder.getName(), oldFormat, newFormat, REUSE_RESULT_NO, DISCARD_REASON_DRM_SESSION_CHANGED);
} else {
evaluation = canReuseDecoder(decoder.getName(), oldFormat, newFormat);
}
if (evaluation.result == REUSE_RESULT_NO) {
if (decoderReceivedBuffers) {
// Signal end of stream and wait for any final output buffers before re-initialization.
decoderReinitializationState = REINITIALIZATION_STATE_SIGNAL_END_OF_STREAM;
} else {
// There aren't any final output buffers, so release the decoder immediately.
releaseDecoder();
maybeInitDecoder();
audioTrackNeedsConfigure = true;
}
}
eventDispatcher.inputFormatChanged(inputFormat, evaluation);
}
use of com.google.android.exoplayer2.decoder.DecoderReuseEvaluation in project ExoPlayer by google.
the class MediaCodecAudioRenderer method canReuseCodec.
@Override
protected DecoderReuseEvaluation canReuseCodec(MediaCodecInfo codecInfo, Format oldFormat, Format newFormat) {
DecoderReuseEvaluation evaluation = codecInfo.canReuseCodec(oldFormat, newFormat);
@DecoderDiscardReasons int discardReasons = evaluation.discardReasons;
if (getCodecMaxInputSize(codecInfo, newFormat) > codecMaxInputSize) {
discardReasons |= DISCARD_REASON_MAX_INPUT_SIZE_EXCEEDED;
}
return new DecoderReuseEvaluation(codecInfo.name, oldFormat, newFormat, discardReasons != 0 ? REUSE_RESULT_NO : evaluation.result, discardReasons);
}
use of com.google.android.exoplayer2.decoder.DecoderReuseEvaluation in project ExoPlayer by google.
the class MediaCodecAudioRenderer method onInputFormatChanged.
@Override
@Nullable
protected DecoderReuseEvaluation onInputFormatChanged(FormatHolder formatHolder) throws ExoPlaybackException {
@Nullable DecoderReuseEvaluation evaluation = super.onInputFormatChanged(formatHolder);
eventDispatcher.inputFormatChanged(formatHolder.format, evaluation);
return evaluation;
}
use of com.google.android.exoplayer2.decoder.DecoderReuseEvaluation in project ExoPlayer by google.
the class MediaCodecInfoTest method canKeepCodec_audioWithDifferentChannelCounts_returnsNo.
@Test
public void canKeepCodec_audioWithDifferentChannelCounts_returnsNo() {
MediaCodecInfo codecInfo = buildAacCodecInfo();
assertThat(codecInfo.canReuseCodec(FORMAT_AAC_STEREO, FORMAT_AAC_SURROUND)).isEqualTo(new DecoderReuseEvaluation(codecInfo.name, FORMAT_AAC_STEREO, FORMAT_AAC_SURROUND, REUSE_RESULT_NO, DISCARD_REASON_AUDIO_CHANNEL_COUNT_CHANGED));
}
use of com.google.android.exoplayer2.decoder.DecoderReuseEvaluation in project ExoPlayer by google.
the class MediaCodecInfoTest method canKeepCodec_withRotation_returnsNo.
@Test
public void canKeepCodec_withRotation_returnsNo() {
MediaCodecInfo codecInfo = buildH264CodecInfo(/* adaptive= */
true);
Format hdRotatedFormat = FORMAT_H264_HD.buildUpon().setRotationDegrees(90).build();
assertThat(codecInfo.canReuseCodec(FORMAT_H264_HD, hdRotatedFormat)).isEqualTo(new DecoderReuseEvaluation(codecInfo.name, FORMAT_H264_HD, hdRotatedFormat, REUSE_RESULT_NO, DISCARD_REASON_VIDEO_ROTATION_CHANGED));
}
Aggregations