Commit d62688cf by bachinger Committed by Oliver Woodman

Mask periodId and loadingPeriodId

This change masks playbackInfo.periodId and playbackInfo.loadingPeriodId for operations which change these periods (set/add/remove sources and seeks).

Because this masking is reflected in the playbackInfo object, player attributes can be retrieved without the maskingXyz variables in EPI. This has the advantage that the playbackInfo object always reflects the public state of the player even when operations are still pending. The maskingXyz variables in EPI are only required for the deprecated use case of an initial seek in an empty timeline.

PiperOrigin-RevId: 321160092
parent 683d630e
...@@ -421,7 +421,7 @@ public final class AnalyticsCollectorTest { ...@@ -421,7 +421,7 @@ public final class AnalyticsCollectorTest {
assertThat(loadingEvents).hasSize(4); assertThat(loadingEvents).hasSize(4);
assertThat(loadingEvents).containsAtLeast(period0, period0).inOrder(); assertThat(loadingEvents).containsAtLeast(period0, period0).inOrder();
assertThat(listener.getEvents(EVENT_TRACKS_CHANGED)) assertThat(listener.getEvents(EVENT_TRACKS_CHANGED))
.containsExactly(period0, period1) .containsExactly(period0, period1, period1)
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_LOAD_STARTED)) assertThat(listener.getEvents(EVENT_LOAD_STARTED))
.containsExactly( .containsExactly(
...@@ -887,7 +887,7 @@ public final class AnalyticsCollectorTest { ...@@ -887,7 +887,7 @@ public final class AnalyticsCollectorTest {
assertThat(listener.getEvents(EVENT_LOADING_CHANGED)) assertThat(listener.getEvents(EVENT_LOADING_CHANGED))
.containsExactly(period0Seq0, period0Seq0, period0Seq0, period0Seq0); .containsExactly(period0Seq0, period0Seq0, period0Seq0, period0Seq0);
assertThat(listener.getEvents(EVENT_TRACKS_CHANGED)) assertThat(listener.getEvents(EVENT_TRACKS_CHANGED))
.containsExactly(period0Seq0, period0Seq1) .containsExactly(period0Seq0, period0Seq1, period0Seq1)
.inOrder(); .inOrder();
assertThat(listener.getEvents(EVENT_LOAD_STARTED)) assertThat(listener.getEvents(EVENT_LOAD_STARTED))
.containsExactly(WINDOW_0 /* manifest */, period0Seq0 /* media */, period1Seq1 /* media */) .containsExactly(WINDOW_0 /* manifest */, period0Seq0 /* media */, period1Seq1 /* media */)
......
...@@ -72,6 +72,7 @@ public class FakeMediaPeriod implements MediaPeriod { ...@@ -72,6 +72,7 @@ public class FakeMediaPeriod implements MediaPeriod {
private boolean prepared; private boolean prepared;
private long seekOffsetUs; private long seekOffsetUs;
private long discontinuityPositionUs; private long discontinuityPositionUs;
private long bufferedPositionUs;
/** /**
* Constructs a FakeMediaPeriod with a single sample for each track in {@code trackGroupArray}. * Constructs a FakeMediaPeriod with a single sample for each track in {@code trackGroupArray}.
...@@ -149,6 +150,7 @@ public class FakeMediaPeriod implements MediaPeriod { ...@@ -149,6 +150,7 @@ public class FakeMediaPeriod implements MediaPeriod {
this.drmEventDispatcher = drmEventDispatcher; this.drmEventDispatcher = drmEventDispatcher;
this.deferOnPrepared = deferOnPrepared; this.deferOnPrepared = deferOnPrepared;
this.trackDataFactory = trackDataFactory; this.trackDataFactory = trackDataFactory;
this.bufferedPositionUs = C.TIME_END_OF_SOURCE;
discontinuityPositionUs = C.TIME_UNSET; discontinuityPositionUs = C.TIME_UNSET;
sampleStreams = new ArrayList<>(); sampleStreams = new ArrayList<>();
fakePreparationLoadTaskId = LoadEventInfo.getNewId(); fakePreparationLoadTaskId = LoadEventInfo.getNewId();
...@@ -283,7 +285,11 @@ public class FakeMediaPeriod implements MediaPeriod { ...@@ -283,7 +285,11 @@ public class FakeMediaPeriod implements MediaPeriod {
@Override @Override
public long getBufferedPositionUs() { public long getBufferedPositionUs() {
assertThat(prepared).isTrue(); assertThat(prepared).isTrue();
return C.TIME_END_OF_SOURCE; return bufferedPositionUs;
}
public void setBufferedPositionUs(long bufferedPositionUs) {
this.bufferedPositionUs = bufferedPositionUs;
} }
@Override @Override
...@@ -293,6 +299,9 @@ public class FakeMediaPeriod implements MediaPeriod { ...@@ -293,6 +299,9 @@ public class FakeMediaPeriod implements MediaPeriod {
for (SampleStream sampleStream : sampleStreams) { for (SampleStream sampleStream : sampleStreams) {
seekSampleStream(sampleStream, seekPositionUs); seekSampleStream(sampleStream, seekPositionUs);
} }
if (bufferedPositionUs != C.TIME_END_OF_SOURCE && seekPositionUs > bufferedPositionUs) {
bufferedPositionUs = seekPositionUs;
}
return seekPositionUs; return seekPositionUs;
} }
......
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