mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
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:
parent
30bc77f249
commit
478be50219
5 changed files with 48 additions and 26 deletions
|
|
@ -42,19 +42,6 @@ public final class SinglePeriodTimeline extends Timeline {
|
||||||
@Nullable private final Object manifest;
|
@Nullable private final Object manifest;
|
||||||
@Nullable private final MediaItem mediaItem;
|
@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,
|
* @deprecated Use {@link #SinglePeriodTimeline(long, boolean, boolean, boolean, Object,
|
||||||
* MediaItem)} instead.
|
* MediaItem)} instead.
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,12 @@ public final class MediaPeriodQueueTest {
|
||||||
|
|
||||||
private static final Timeline CONTENT_TIMELINE =
|
private static final Timeline CONTENT_TIMELINE =
|
||||||
new SinglePeriodTimeline(
|
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 static final Uri AD_URI = Uri.EMPTY;
|
||||||
|
|
||||||
private MediaPeriodQueue mediaPeriodQueue;
|
private MediaPeriodQueue mediaPeriodQueue;
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,9 @@ public final class ClippingMediaSourceTest {
|
||||||
TEST_PERIOD_DURATION_US,
|
TEST_PERIOD_DURATION_US,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* isLive= */ false);
|
/* isLive= */ false,
|
||||||
|
/* manifest= */ null,
|
||||||
|
/* mediaItem= */ null);
|
||||||
|
|
||||||
Timeline clippedTimeline = getClippedTimeline(timeline, 0, TEST_PERIOD_DURATION_US);
|
Timeline clippedTimeline = getClippedTimeline(timeline, 0, TEST_PERIOD_DURATION_US);
|
||||||
|
|
||||||
|
|
@ -88,7 +90,9 @@ public final class ClippingMediaSourceTest {
|
||||||
TEST_PERIOD_DURATION_US,
|
TEST_PERIOD_DURATION_US,
|
||||||
/* isSeekable= */ false,
|
/* isSeekable= */ false,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* isLive= */ false);
|
/* isLive= */ false,
|
||||||
|
/* manifest= */ null,
|
||||||
|
/* mediaItem= */ null);
|
||||||
|
|
||||||
// If the unseekable window isn't clipped, clipping succeeds.
|
// If the unseekable window isn't clipped, clipping succeeds.
|
||||||
getClippedTimeline(timeline, 0, TEST_PERIOD_DURATION_US);
|
getClippedTimeline(timeline, 0, TEST_PERIOD_DURATION_US);
|
||||||
|
|
@ -108,7 +112,9 @@ public final class ClippingMediaSourceTest {
|
||||||
/* durationUs= */ C.TIME_UNSET,
|
/* durationUs= */ C.TIME_UNSET,
|
||||||
/* isSeekable= */ false,
|
/* isSeekable= */ false,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* isLive= */ false);
|
/* isLive= */ false,
|
||||||
|
/* manifest= */ null,
|
||||||
|
/* mediaItem= */ null);
|
||||||
|
|
||||||
// If the unseekable window isn't clipped, clipping succeeds.
|
// If the unseekable window isn't clipped, clipping succeeds.
|
||||||
getClippedTimeline(timeline, /* startUs= */ 0, TEST_PERIOD_DURATION_US);
|
getClippedTimeline(timeline, /* startUs= */ 0, TEST_PERIOD_DURATION_US);
|
||||||
|
|
@ -128,7 +134,9 @@ public final class ClippingMediaSourceTest {
|
||||||
TEST_PERIOD_DURATION_US,
|
TEST_PERIOD_DURATION_US,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* isLive= */ false);
|
/* isLive= */ false,
|
||||||
|
/* manifest= */ null,
|
||||||
|
/* mediaItem= */ null);
|
||||||
|
|
||||||
Timeline clippedTimeline =
|
Timeline clippedTimeline =
|
||||||
getClippedTimeline(timeline, TEST_CLIP_AMOUNT_US, TEST_PERIOD_DURATION_US);
|
getClippedTimeline(timeline, TEST_CLIP_AMOUNT_US, TEST_PERIOD_DURATION_US);
|
||||||
|
|
@ -145,7 +153,9 @@ public final class ClippingMediaSourceTest {
|
||||||
TEST_PERIOD_DURATION_US,
|
TEST_PERIOD_DURATION_US,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* isLive= */ false);
|
/* isLive= */ false,
|
||||||
|
/* manifest= */ null,
|
||||||
|
/* mediaItem= */ null);
|
||||||
|
|
||||||
Timeline clippedTimeline =
|
Timeline clippedTimeline =
|
||||||
getClippedTimeline(timeline, 0, TEST_PERIOD_DURATION_US - TEST_CLIP_AMOUNT_US);
|
getClippedTimeline(timeline, 0, TEST_PERIOD_DURATION_US - TEST_CLIP_AMOUNT_US);
|
||||||
|
|
@ -179,7 +189,9 @@ public final class ClippingMediaSourceTest {
|
||||||
/* durationUs= */ TEST_PERIOD_DURATION_US,
|
/* durationUs= */ TEST_PERIOD_DURATION_US,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* isLive= */ false);
|
/* isLive= */ false,
|
||||||
|
/* manifest= */ null,
|
||||||
|
/* mediaItem= */ null);
|
||||||
|
|
||||||
// When clipping to the end, the clipped timeline should also have a duration.
|
// When clipping to the end, the clipped timeline should also have a duration.
|
||||||
Timeline clippedTimeline =
|
Timeline clippedTimeline =
|
||||||
|
|
@ -196,7 +208,9 @@ public final class ClippingMediaSourceTest {
|
||||||
/* durationUs= */ C.TIME_UNSET,
|
/* durationUs= */ C.TIME_UNSET,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* isLive= */ false);
|
/* isLive= */ false,
|
||||||
|
/* manifest= */ null,
|
||||||
|
/* mediaItem= */ null);
|
||||||
|
|
||||||
// When clipping to the end, the clipped timeline should also have an unset duration.
|
// When clipping to the end, the clipped timeline should also have an unset duration.
|
||||||
Timeline clippedTimeline =
|
Timeline clippedTimeline =
|
||||||
|
|
@ -212,7 +226,9 @@ public final class ClippingMediaSourceTest {
|
||||||
TEST_PERIOD_DURATION_US,
|
TEST_PERIOD_DURATION_US,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* isLive= */ false);
|
/* isLive= */ false,
|
||||||
|
/* manifest= */ null,
|
||||||
|
/* mediaItem= */ null);
|
||||||
|
|
||||||
Timeline clippedTimeline =
|
Timeline clippedTimeline =
|
||||||
getClippedTimeline(
|
getClippedTimeline(
|
||||||
|
|
@ -540,7 +556,9 @@ public final class ClippingMediaSourceTest {
|
||||||
TEST_PERIOD_DURATION_US,
|
TEST_PERIOD_DURATION_US,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* isLive= */ false);
|
/* isLive= */ false,
|
||||||
|
/* manifest= */ null,
|
||||||
|
/* mediaItem= */ null);
|
||||||
FakeMediaSource fakeMediaSource =
|
FakeMediaSource fakeMediaSource =
|
||||||
new FakeMediaSource(timeline) {
|
new FakeMediaSource(timeline) {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,12 @@ public final class SinglePeriodTimelineTest {
|
||||||
public void getPeriodPositionDynamicWindowUnknownDuration() {
|
public void getPeriodPositionDynamicWindowUnknownDuration() {
|
||||||
SinglePeriodTimeline timeline =
|
SinglePeriodTimeline timeline =
|
||||||
new SinglePeriodTimeline(
|
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.
|
// Should return null with any positive position projection.
|
||||||
Pair<Object, Long> position = timeline.getPeriodPosition(window, period, 0, C.TIME_UNSET, 1);
|
Pair<Object, Long> position = timeline.getPeriodPosition(window, period, 0, C.TIME_UNSET, 1);
|
||||||
assertThat(position).isNull();
|
assertThat(position).isNull();
|
||||||
|
|
|
||||||
|
|
@ -59,14 +59,21 @@ public final class AdsMediaSourceTest {
|
||||||
PREROLL_AD_DURATION_US,
|
PREROLL_AD_DURATION_US,
|
||||||
/* isSeekable= */ true,
|
/* isSeekable= */ true,
|
||||||
/* isDynamic= */ false,
|
/* isDynamic= */ false,
|
||||||
/* isLive= */ false);
|
/* isLive= */ false,
|
||||||
|
/* manifest= */ null,
|
||||||
|
/* mediaItem= */ null);
|
||||||
private static final Object PREROLL_AD_PERIOD_UID =
|
private static final Object PREROLL_AD_PERIOD_UID =
|
||||||
PREROLL_AD_TIMELINE.getUidOfPeriod(/* periodIndex= */ 0);
|
PREROLL_AD_TIMELINE.getUidOfPeriod(/* periodIndex= */ 0);
|
||||||
|
|
||||||
private static final long CONTENT_DURATION_US = 30 * C.MICROS_PER_SECOND;
|
private static final long CONTENT_DURATION_US = 30 * C.MICROS_PER_SECOND;
|
||||||
private static final Timeline CONTENT_TIMELINE =
|
private static final Timeline CONTENT_TIMELINE =
|
||||||
new SinglePeriodTimeline(
|
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 =
|
private static final Object CONTENT_PERIOD_UID =
|
||||||
CONTENT_TIMELINE.getUidOfPeriod(/* periodIndex= */ 0);
|
CONTENT_TIMELINE.getUidOfPeriod(/* periodIndex= */ 0);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue