mirror of
https://github.com/androidx/media.git
synced 2025-05-15 19:49:50 +08:00
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
This commit is contained in:
parent
c009028dad
commit
eff82e920e
@ -906,7 +906,9 @@ import java.io.IOException;
|
|||||||
mediaSource.maybeThrowSourceInfoRefreshError();
|
mediaSource.maybeThrowSourceInfoRefreshError();
|
||||||
} else {
|
} else {
|
||||||
Window window = timeline.getPeriodWindow(newLoadingPeriodIndex);
|
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) {
|
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
|
// 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.
|
// the default position for the window.
|
||||||
|
@ -184,10 +184,7 @@ public final class DashMediaSource implements MediaSource {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void releasePeriod(MediaPeriod mediaPeriod) {
|
public void releasePeriod(MediaPeriod mediaPeriod) {
|
||||||
int id = ((DashMediaPeriod) mediaPeriod).id;
|
periodsById.remove(((DashMediaPeriod) mediaPeriod).id);
|
||||||
if (id >= firstPeriodId) {
|
|
||||||
periodsById.remove(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -348,7 +345,12 @@ public final class DashMediaSource implements MediaSource {
|
|||||||
private void processManifest() {
|
private void processManifest() {
|
||||||
// Update any periods.
|
// Update any periods.
|
||||||
for (int i = 0; i < periodsById.size(); i++) {
|
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.
|
// Remove any pending simulated updates.
|
||||||
handler.removeCallbacks(simulateManifestRefreshRunnable);
|
handler.removeCallbacks(simulateManifestRefreshRunnable);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user