Remove constructor of SinglePeriodTimline without tag and media item

We aim for all SinglePeriodTimelines to set window.mediaItem and hence want to eliminate all constructors not passing a media item. The constructor removed in this CL is the easiest one to remove and fix in google3. It is still a breaking change for external ExoPlayer user who provide a custom media source with this timeline.

PiperOrigin-RevId: 311291493
This commit is contained in:
bachinger 2020-05-13 10:20:31 +01:00 committed by Oliver Woodman
parent 30bc77f249
commit 478be50219
5 changed files with 48 additions and 26 deletions

View file

@ -42,19 +42,6 @@ public final class SinglePeriodTimeline extends Timeline {
@Nullable private final Object manifest;
@Nullable private final MediaItem mediaItem;
/**
* Creates a timeline containing a single period and a window that spans it.
*
* @param durationUs The duration of the period, in microseconds.
* @param isSeekable Whether seeking is supported within the period.
* @param isDynamic Whether the window may change when the timeline is updated.
* @param isLive Whether the window is live.
*/
public SinglePeriodTimeline(
long durationUs, boolean isSeekable, boolean isDynamic, boolean isLive) {
this(durationUs, isSeekable, isDynamic, isLive, /* manifest= */ null, /* mediaItem= */ null);
}
/**
* @deprecated Use {@link #SinglePeriodTimeline(long, boolean, boolean, boolean, Object,
* MediaItem)} instead.

View file

@ -52,7 +52,12 @@ public final class MediaPeriodQueueTest {
private static final Timeline CONTENT_TIMELINE =
new SinglePeriodTimeline(
CONTENT_DURATION_US, /* isSeekable= */ true, /* isDynamic= */ false, /* isLive= */ false);
CONTENT_DURATION_US,
/* isSeekable= */ true,
/* isDynamic= */ false,
/* isLive= */ false,
/* manifest= */ null,
/* mediaItem= */ null);
private static final Uri AD_URI = Uri.EMPTY;
private MediaPeriodQueue mediaPeriodQueue;

View file

@ -69,7 +69,9 @@ public final class ClippingMediaSourceTest {
TEST_PERIOD_DURATION_US,
/* isSeekable= */ true,
/* isDynamic= */ false,
/* isLive= */ false);
/* isLive= */ false,
/* manifest= */ null,
/* mediaItem= */ null);
Timeline clippedTimeline = getClippedTimeline(timeline, 0, TEST_PERIOD_DURATION_US);
@ -88,7 +90,9 @@ public final class ClippingMediaSourceTest {
TEST_PERIOD_DURATION_US,
/* isSeekable= */ false,
/* isDynamic= */ false,
/* isLive= */ false);
/* isLive= */ false,
/* manifest= */ null,
/* mediaItem= */ null);
// If the unseekable window isn't clipped, clipping succeeds.
getClippedTimeline(timeline, 0, TEST_PERIOD_DURATION_US);
@ -108,7 +112,9 @@ public final class ClippingMediaSourceTest {
/* durationUs= */ C.TIME_UNSET,
/* isSeekable= */ false,
/* isDynamic= */ false,
/* isLive= */ false);
/* isLive= */ false,
/* manifest= */ null,
/* mediaItem= */ null);
// If the unseekable window isn't clipped, clipping succeeds.
getClippedTimeline(timeline, /* startUs= */ 0, TEST_PERIOD_DURATION_US);
@ -128,7 +134,9 @@ public final class ClippingMediaSourceTest {
TEST_PERIOD_DURATION_US,
/* isSeekable= */ true,
/* isDynamic= */ false,
/* isLive= */ false);
/* isLive= */ false,
/* manifest= */ null,
/* mediaItem= */ null);
Timeline clippedTimeline =
getClippedTimeline(timeline, TEST_CLIP_AMOUNT_US, TEST_PERIOD_DURATION_US);
@ -145,7 +153,9 @@ public final class ClippingMediaSourceTest {
TEST_PERIOD_DURATION_US,
/* isSeekable= */ true,
/* isDynamic= */ false,
/* isLive= */ false);
/* isLive= */ false,
/* manifest= */ null,
/* mediaItem= */ null);
Timeline clippedTimeline =
getClippedTimeline(timeline, 0, TEST_PERIOD_DURATION_US - TEST_CLIP_AMOUNT_US);
@ -179,7 +189,9 @@ public final class ClippingMediaSourceTest {
/* durationUs= */ TEST_PERIOD_DURATION_US,
/* isSeekable= */ true,
/* isDynamic= */ false,
/* isLive= */ false);
/* isLive= */ false,
/* manifest= */ null,
/* mediaItem= */ null);
// When clipping to the end, the clipped timeline should also have a duration.
Timeline clippedTimeline =
@ -196,7 +208,9 @@ public final class ClippingMediaSourceTest {
/* durationUs= */ C.TIME_UNSET,
/* isSeekable= */ true,
/* isDynamic= */ false,
/* isLive= */ false);
/* isLive= */ false,
/* manifest= */ null,
/* mediaItem= */ null);
// When clipping to the end, the clipped timeline should also have an unset duration.
Timeline clippedTimeline =
@ -212,7 +226,9 @@ public final class ClippingMediaSourceTest {
TEST_PERIOD_DURATION_US,
/* isSeekable= */ true,
/* isDynamic= */ false,
/* isLive= */ false);
/* isLive= */ false,
/* manifest= */ null,
/* mediaItem= */ null);
Timeline clippedTimeline =
getClippedTimeline(
@ -540,7 +556,9 @@ public final class ClippingMediaSourceTest {
TEST_PERIOD_DURATION_US,
/* isSeekable= */ true,
/* isDynamic= */ false,
/* isLive= */ false);
/* isLive= */ false,
/* manifest= */ null,
/* mediaItem= */ null);
FakeMediaSource fakeMediaSource =
new FakeMediaSource(timeline) {
@Override

View file

@ -45,7 +45,12 @@ public final class SinglePeriodTimelineTest {
public void getPeriodPositionDynamicWindowUnknownDuration() {
SinglePeriodTimeline timeline =
new SinglePeriodTimeline(
C.TIME_UNSET, /* isSeekable= */ false, /* isDynamic= */ true, /* isLive= */ true);
C.TIME_UNSET,
/* isSeekable= */ false,
/* isDynamic= */ true,
/* isLive= */ true,
/* manifest= */ null,
/* mediaItem= */ null);
// Should return null with any positive position projection.
Pair<Object, Long> position = timeline.getPeriodPosition(window, period, 0, C.TIME_UNSET, 1);
assertThat(position).isNull();

View file

@ -59,14 +59,21 @@ public final class AdsMediaSourceTest {
PREROLL_AD_DURATION_US,
/* isSeekable= */ true,
/* isDynamic= */ false,
/* isLive= */ false);
/* isLive= */ false,
/* manifest= */ null,
/* mediaItem= */ null);
private static final Object PREROLL_AD_PERIOD_UID =
PREROLL_AD_TIMELINE.getUidOfPeriod(/* periodIndex= */ 0);
private static final long CONTENT_DURATION_US = 30 * C.MICROS_PER_SECOND;
private static final Timeline CONTENT_TIMELINE =
new SinglePeriodTimeline(
CONTENT_DURATION_US, /* isSeekable= */ true, /* isDynamic= */ false, /* isLive= */ false);
CONTENT_DURATION_US,
/* isSeekable= */ true,
/* isDynamic= */ false,
/* isLive= */ false,
/* manifest= */ null,
/* mediaItem= */ null);
private static final Object CONTENT_PERIOD_UID =
CONTENT_TIMELINE.getUidOfPeriod(/* periodIndex= */ 0);