Search in sources :

Example 1 with DecoderReuseEvaluation

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);
}
Also used : Format(com.google.android.exoplayer2.Format) DecoderReuseEvaluation(com.google.android.exoplayer2.decoder.DecoderReuseEvaluation)

Example 2 with DecoderReuseEvaluation

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);
}
Also used : DecoderReuseEvaluation(com.google.android.exoplayer2.decoder.DecoderReuseEvaluation) DecoderDiscardReasons(com.google.android.exoplayer2.decoder.DecoderReuseEvaluation.DecoderDiscardReasons) SuppressLint(android.annotation.SuppressLint)

Example 3 with DecoderReuseEvaluation

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;
}
Also used : DecoderReuseEvaluation(com.google.android.exoplayer2.decoder.DecoderReuseEvaluation) Nullable(androidx.annotation.Nullable) Nullable(androidx.annotation.Nullable)

Example 4 with DecoderReuseEvaluation

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));
}
Also used : DecoderReuseEvaluation(com.google.android.exoplayer2.decoder.DecoderReuseEvaluation) Test(org.junit.Test)

Example 5 with DecoderReuseEvaluation

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));
}
Also used : Format(com.google.android.exoplayer2.Format) DecoderReuseEvaluation(com.google.android.exoplayer2.decoder.DecoderReuseEvaluation) Test(org.junit.Test)

Aggregations

DecoderReuseEvaluation (com.google.android.exoplayer2.decoder.DecoderReuseEvaluation)19 Format (com.google.android.exoplayer2.Format)11 Test (org.junit.Test)11 Nullable (androidx.annotation.Nullable)4 DecoderDiscardReasons (com.google.android.exoplayer2.decoder.DecoderReuseEvaluation.DecoderDiscardReasons)4 SuppressLint (android.annotation.SuppressLint)2 Point (android.graphics.Point)2 CallSuper (androidx.annotation.CallSuper)2 EventTime (com.google.android.exoplayer2.analytics.AnalyticsListener.EventTime)2 MediaFormat (android.media.MediaFormat)1