Skip to content

Commit

Permalink
SUP-42513: (PPF CZ) 3201: NG STB Videolibrary (VOD) error
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-bondarenko85 committed Oct 28, 2024
1 parent ac22a85 commit 66e8f2c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public class KDefaultRenderersFactory {

public static DefaultRenderersFactory createDecoderInitErrorRetryFactory(
Context context,
PlayerSettings playerSettings
PlayerSettings playerSettings,
boolean skipFirstCodecReusage
) {
final MediaCodecSupportFormatHelper mediaCodecSupportFormatHelper = new MediaCodecSupportFormatHelper(context);
return new DefaultRenderersFactory(context) {
Expand Down Expand Up @@ -59,6 +60,9 @@ protected void buildVideoRenderers(@NonNull Context context,
eventHandler,
eventListener,
MAX_DROPPED_VIDEO_FRAME_COUNT_TO_NOTIFY) {

private boolean firstCodecReusageSkipped = false;

@Override
public void render(long positionUs, long elapsedRealtimeUs) throws ExoPlaybackException {
try {
Expand Down Expand Up @@ -101,9 +105,12 @@ protected int supportsFormat(MediaCodecSelector mediaCodecSelector, Format forma
@NonNull
@Override
protected DecoderReuseEvaluation canReuseCodec(@NonNull MediaCodecInfo codecInfo, @NonNull Format oldFormat, @NonNull Format newFormat) {
if (playerSettings.canReuseCodec()) {
if (playerSettings.canReuseCodec() && (!skipFirstCodecReusage || firstCodecReusageSkipped)) {
return super.canReuseCodec(codecInfo, oldFormat, newFormat);
} else {
if (skipFirstCodecReusage) {
firstCodecReusageSkipped = true;
}
return new DecoderReuseEvaluation(codecInfo.name,
oldFormat, newFormat,
DecoderReuseEvaluation.REUSE_RESULT_NO,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,17 @@ public void onBandwidthSample(int elapsedMs, long bytes, long bitrate) {
}

private void initializePlayer() {
initializePlayer(false);
}

private void initializePlayer(boolean skipFirstCodecReusage) {
DefaultTrackSelector trackSelector = initializeTrackSelector();
if (exoPlayerView instanceof ExoPlayerView) {
((ExoPlayerView)exoPlayerView).setUsingSpeedAdjustedRenderer(this.useSpeedAdjustingRenderer);
}
DefaultRenderersFactory renderersFactory = this.useSpeedAdjustingRenderer
? SpeedAdjustedRenderersFactory.createSpeedAdjustedRenderersFactory(context, playerSettings, exoPlayerView)
: KDefaultRenderersFactory.createDecoderInitErrorRetryFactory(context, playerSettings);
: KDefaultRenderersFactory.createDecoderInitErrorRetryFactory(context, playerSettings, skipFirstCodecReusage);
renderersFactory.setAllowedVideoJoiningTimeMs(playerSettings.getLoadControlBuffers().getAllowedVideoJoiningTimeMs());
renderersFactory.setEnableDecoderFallback(playerSettings.enableDecoderFallback());

Expand Down Expand Up @@ -1161,9 +1165,11 @@ private void maybeChangePlayerRenderView() {
private void maybeReInitPlayerOnSpeedAdjustmentChange(PKMediaFormat format) {
boolean useSpeedAdjustingRenderer = shouldUseSpeedAdjustingRenderer(format);
if (useSpeedAdjustingRenderer != this.useSpeedAdjustingRenderer) {
// Do not reuse codec first time after switching from multicast to dash content
boolean skipFirstCodecReusage = !useSpeedAdjustingRenderer;
this.useSpeedAdjustingRenderer = useSpeedAdjustingRenderer;
destroyPlayer(false);
initializePlayer();
initializePlayer(skipFirstCodecReusage);
}
}

Expand Down

0 comments on commit 66e8f2c

Please sign in to comment.