Search in sources :

Example 1 with DecoderReuseEvaluation

use of androidx.media3.exoplayer.DecoderReuseEvaluation in project media by androidx.

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(androidx.media3.exoplayer.DecoderReuseEvaluation) DecoderDiscardReasons(androidx.media3.exoplayer.DecoderReuseEvaluation.DecoderDiscardReasons) SuppressLint(android.annotation.SuppressLint)

Example 2 with DecoderReuseEvaluation

use of androidx.media3.exoplayer.DecoderReuseEvaluation in project media by androidx.

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(androidx.media3.exoplayer.DecoderReuseEvaluation) Nullable(androidx.annotation.Nullable) Nullable(androidx.annotation.Nullable)

Example 3 with DecoderReuseEvaluation

use of androidx.media3.exoplayer.DecoderReuseEvaluation in project media by androidx.

the class DefaultAnalyticsCollector method onVideoInputFormatChanged.

@Override
// Calling deprecated listener method.
@SuppressWarnings("deprecation")
public final void onVideoInputFormatChanged(Format format, @Nullable DecoderReuseEvaluation decoderReuseEvaluation) {
    EventTime eventTime = generateReadingMediaPeriodEventTime();
    sendEvent(eventTime, AnalyticsListener.EVENT_VIDEO_INPUT_FORMAT_CHANGED, listener -> {
        listener.onVideoInputFormatChanged(eventTime, format);
        listener.onVideoInputFormatChanged(eventTime, format, decoderReuseEvaluation);
        listener.onDecoderInputFormatChanged(eventTime, C.TRACK_TYPE_VIDEO, format);
    });
}
Also used : EventTime(androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime)

Example 4 with DecoderReuseEvaluation

use of androidx.media3.exoplayer.DecoderReuseEvaluation in project media by androidx.

the class MediaCodecInfoTest method canKeepCodec_colorInfoChange_returnsNo.

@Test
public void canKeepCodec_colorInfoChange_returnsNo() {
    MediaCodecInfo codecInfo = buildH264CodecInfo(/* adaptive= */
    false);
    Format hdrVariantFormat1 = FORMAT_H264_4K.buildUpon().setColorInfo(buildColorInfo(C.COLOR_SPACE_BT601)).build();
    Format hdrVariantFormat2 = FORMAT_H264_4K.buildUpon().setColorInfo(buildColorInfo(C.COLOR_SPACE_BT709)).build();
    assertThat(codecInfo.canReuseCodec(hdrVariantFormat1, hdrVariantFormat2)).isEqualTo(new DecoderReuseEvaluation(codecInfo.name, hdrVariantFormat1, hdrVariantFormat2, REUSE_RESULT_NO, DISCARD_REASON_VIDEO_COLOR_INFO_CHANGED));
}
Also used : Format(androidx.media3.common.Format) DecoderReuseEvaluation(androidx.media3.exoplayer.DecoderReuseEvaluation) Test(org.junit.Test)

Example 5 with DecoderReuseEvaluation

use of androidx.media3.exoplayer.DecoderReuseEvaluation in project media by androidx.

the class MediaCodecInfoTest method canKeepCodec_withResolutionChange_adaptiveCodec_returnsYesWithReconfiguration.

@Test
public void canKeepCodec_withResolutionChange_adaptiveCodec_returnsYesWithReconfiguration() {
    MediaCodecInfo codecInfo = buildH264CodecInfo(/* adaptive= */
    true);
    assertThat(codecInfo.canReuseCodec(FORMAT_H264_HD, FORMAT_H264_4K)).isEqualTo(new DecoderReuseEvaluation(codecInfo.name, FORMAT_H264_HD, FORMAT_H264_4K, REUSE_RESULT_YES_WITH_RECONFIGURATION, /* discardReasons= */
    0));
}
Also used : DecoderReuseEvaluation(androidx.media3.exoplayer.DecoderReuseEvaluation) Test(org.junit.Test)

Aggregations

DecoderReuseEvaluation (androidx.media3.exoplayer.DecoderReuseEvaluation)19 Format (androidx.media3.common.Format)11 Test (org.junit.Test)11 Nullable (androidx.annotation.Nullable)4 DecoderDiscardReasons (androidx.media3.exoplayer.DecoderReuseEvaluation.DecoderDiscardReasons)4 SuppressLint (android.annotation.SuppressLint)2 Point (android.graphics.Point)2 CallSuper (androidx.annotation.CallSuper)2 EventTime (androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime)2 MediaFormat (android.media.MediaFormat)1