Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes early transiton to Player.STATE_ENDED with MPD transition dy… #1451

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3030,6 +3030,11 @@ private static PositionUpdateForPlaylistChange resolvePositionForPlaylistChange(
}
}

long periodPositionDeltaUs = checkPlayingPeriodPositionChanged(timeline, playbackInfo, period.windowIndex);
if (periodPositionDeltaUs > 0) {
periodPositionUs = periodPositionUs - periodPositionDeltaUs;
}

return new PositionUpdateForPlaylistChange(
newPeriodId,
periodPositionUs,
Expand All @@ -3039,6 +3044,26 @@ private static PositionUpdateForPlaylistChange resolvePositionForPlaylistChange(
setTargetLiveOffset);
}

private static long checkPlayingPeriodPositionChanged(Timeline timeline, PlaybackInfo playbackInfo, int currentWindowIndex) {
long periodPositionDeltaUs = C.TIME_UNSET;
if (!playbackInfo.timeline.isEmpty()
&& !timeline.isEmpty()
&& !playbackInfo.periodId.isAd()
&& playbackInfo.timeline.getWindowCount() == timeline.getWindowCount()
&& currentWindowIndex < playbackInfo.timeline.getWindowCount()) {
Timeline.Window newWindow = timeline.getWindow(currentWindowIndex, new Timeline.Window());
Timeline.Window oldWindow = playbackInfo.timeline.getWindow(currentWindowIndex, new Timeline.Window());
if (oldWindow.isDynamic && ! newWindow.isDynamic) {
Timeline.Period newPeriod = timeline.getPeriodByUid(playbackInfo.periodId.periodUid, new Timeline.Period());
int windowIndex = newPeriod.windowIndex;
Pair<Object, Long> oldPositionZero = playbackInfo.timeline.getPeriodPosition(oldWindow, new Timeline.Period(), windowIndex, 0);
Pair<Object, Long> newPositionZero = timeline.getPeriodPosition(newWindow, new Timeline.Period(), windowIndex, 0);
periodPositionDeltaUs = oldPositionZero.second - newPositionZero.second;
}
}
return periodPositionDeltaUs;
}

private static boolean isIgnorableServerSideAdInsertionPeriodChange(
boolean isUsingPlaceholderPeriod,
MediaPeriodId oldPeriodId,
Expand Down