Commit eff82e92 by andrewlewis Committed by Oliver Woodman

Fix DASH multi-period transitions and manifest updates.

Period transitions can either be to new windows (in which case the default
position for the new window should be loaded) or to the next period of the
current window (in which case the the new period should be played from zero).
Fix the logic for calculating the new period index to load to implement this.

In processManifest, periodsById may contain periods that have been removed from
the manifest, which are still being used by the player (it releases periods on
receiving the source info refresh after processManifest returns). Ignore
periods that have been removed from the manifest when calling updateManifest.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=130626441
parent c009028d
......@@ -906,7 +906,9 @@ import java.io.IOException;
mediaSource.maybeThrowSourceInfoRefreshError();
} else {
Window window = timeline.getPeriodWindow(newLoadingPeriodIndex);
long startPositionUs = loadingPeriod == null ? playbackInfo.positionUs : C.UNSET_TIME_US;
long startPositionUs = loadingPeriod == null ? playbackInfo.positionUs
: newLoadingPeriodIndex == window.startPeriodIndex ? C.UNSET_TIME_US
: 0;
if (startPositionUs == C.UNSET_TIME_US) {
// This is the first period of a new window or we don't have a start position, so seek to
// the default position for the window.
......
......@@ -184,10 +184,7 @@ public final class DashMediaSource implements MediaSource {
@Override
public void releasePeriod(MediaPeriod mediaPeriod) {
int id = ((DashMediaPeriod) mediaPeriod).id;
if (id >= firstPeriodId) {
periodsById.remove(id);
}
periodsById.remove(((DashMediaPeriod) mediaPeriod).id);
}
@Override
......@@ -348,7 +345,12 @@ public final class DashMediaSource implements MediaSource {
private void processManifest() {
// Update any periods.
for (int i = 0; i < periodsById.size(); i++) {
periodsById.valueAt(i).updateManifest(manifest, periodsById.keyAt(i) - firstPeriodId);
int id = periodsById.keyAt(i);
if (id >= firstPeriodId) {
periodsById.valueAt(i).updateManifest(manifest, id - firstPeriodId);
} else {
// This period has been removed from the manifest so it doesn't need to be updated.
}
}
// Remove any pending simulated updates.
handler.removeCallbacks(simulateManifestRefreshRunnable);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment