Migrate usages of Timeline#getPeriodPosition to getPeriodPositionUs

#minor-release

PiperOrigin-RevId: 414671861
This commit is contained in:
ibaker 2021-12-07 11:23:22 +00:00 committed by Ian Baker
parent 07352a4585
commit 5c2f618613
7 changed files with 124 additions and 95 deletions

View file

@ -700,7 +700,7 @@ public final class ImaAdsLoader implements Player.Listener, AdsLoader {
return;
}
long periodPositionUs =
timeline.getPeriodPosition(
timeline.getPeriodPositionUs(
window, period, period.windowIndex, /* windowPositionUs= */ C.TIME_UNSET)
.second;
nextAdTagLoader.maybePreloadAds(Util.usToMs(periodPositionUs), Util.usToMs(period.durationUs));

View file

@ -1190,13 +1190,13 @@ public abstract class Timeline implements Bundleable {
}
/**
* Calls {@link #getPeriodPosition(Window, Period, int, long, long)} with a zero default position
* Calls {@link #getPeriodPositionUs(Window, Period, int, long)} with a zero default position
* projection.
*/
public final Pair<Object, Long> getPeriodPositionUs(
Window window, Period period, int windowIndex, long windowPositionUs) {
return Assertions.checkNotNull(
getPeriodPosition(
getPeriodPositionUs(
window, period, windowIndex, windowPositionUs, /* defaultPositionProjectionUs= */ 0));
}

View file

@ -499,7 +499,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
maskTimelineAndPosition(
playbackInfo,
newTimeline,
getPeriodPositionAfterTimelineChanged(oldTimeline, newTimeline));
getPeriodPositionUsAfterTimelineChanged(oldTimeline, newTimeline));
internalPlayer.addMediaSources(index, holders, shuffleOrder);
updatePlaybackInfo(
newPlaybackInfo,
@ -543,7 +543,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
maskTimelineAndPosition(
playbackInfo,
newTimeline,
getPeriodPositionAfterTimelineChanged(oldTimeline, newTimeline));
getPeriodPositionUsAfterTimelineChanged(oldTimeline, newTimeline));
internalPlayer.moveMediaSources(fromIndex, toIndex, newFromIndex, shuffleOrder);
updatePlaybackInfo(
newPlaybackInfo,
@ -562,7 +562,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
maskTimelineAndPosition(
playbackInfo,
timeline,
getPeriodPositionOrMaskWindowPosition(
maskWindowPositionMsOrGetPeriodPositionUs(
timeline, getCurrentMediaItemIndex(), getCurrentPosition()));
pendingOperationAcks++;
this.shuffleOrder = shuffleOrder;
@ -680,7 +680,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
maskTimelineAndPosition(
newPlaybackInfo,
timeline,
getPeriodPositionOrMaskWindowPosition(timeline, mediaItemIndex, positionMs));
maskWindowPositionMsOrGetPeriodPositionUs(timeline, mediaItemIndex, positionMs));
internalPlayer.seekTo(timeline, mediaItemIndex, Util.msToUs(positionMs));
updatePlaybackInfo(
newPlaybackInfo,
@ -1441,7 +1441,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
maskTimelineAndPosition(
playbackInfo,
timeline,
getPeriodPositionOrMaskWindowPosition(timeline, startWindowIndex, startPositionMs));
maskWindowPositionMsOrGetPeriodPositionUs(timeline, startWindowIndex, startPositionMs));
// Mask the playback state.
int maskingPlaybackState = newPlaybackInfo.playbackState;
if (startWindowIndex != C.INDEX_UNSET && newPlaybackInfo.playbackState != STATE_IDLE) {
@ -1499,7 +1499,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
maskTimelineAndPosition(
playbackInfo,
newTimeline,
getPeriodPositionAfterTimelineChanged(oldTimeline, newTimeline));
getPeriodPositionUsAfterTimelineChanged(oldTimeline, newTimeline));
// Player transitions to STATE_ENDED if the current index is part of the removed tail.
final boolean transitionsToEnded =
newPlaybackInfo.playbackState != STATE_IDLE
@ -1526,8 +1526,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
}
private PlaybackInfo maskTimelineAndPosition(
PlaybackInfo playbackInfo, Timeline timeline, @Nullable Pair<Object, Long> periodPosition) {
Assertions.checkArgument(timeline.isEmpty() || periodPosition != null);
PlaybackInfo playbackInfo, Timeline timeline, @Nullable Pair<Object, Long> periodPositionUs) {
Assertions.checkArgument(timeline.isEmpty() || periodPositionUs != null);
Timeline oldTimeline = playbackInfo.timeline;
// Mask the timeline.
playbackInfo = playbackInfo.copyWithTimeline(timeline);
@ -1552,10 +1552,10 @@ import java.util.concurrent.CopyOnWriteArraySet;
}
Object oldPeriodUid = playbackInfo.periodId.periodUid;
boolean playingPeriodChanged = !oldPeriodUid.equals(castNonNull(periodPosition).first);
boolean playingPeriodChanged = !oldPeriodUid.equals(castNonNull(periodPositionUs).first);
MediaPeriodId newPeriodId =
playingPeriodChanged ? new MediaPeriodId(periodPosition.first) : playbackInfo.periodId;
long newContentPositionUs = periodPosition.second;
playingPeriodChanged ? new MediaPeriodId(periodPositionUs.first) : playbackInfo.periodId;
long newContentPositionUs = periodPositionUs.second;
long oldContentPositionUs = Util.msToUs(getContentPosition());
if (!oldTimeline.isEmpty()) {
oldContentPositionUs -=
@ -1631,25 +1631,25 @@ import java.util.concurrent.CopyOnWriteArraySet;
}
@Nullable
private Pair<Object, Long> getPeriodPositionAfterTimelineChanged(
private Pair<Object, Long> getPeriodPositionUsAfterTimelineChanged(
Timeline oldTimeline, Timeline newTimeline) {
long currentPositionMs = getContentPosition();
if (oldTimeline.isEmpty() || newTimeline.isEmpty()) {
boolean isCleared = !oldTimeline.isEmpty() && newTimeline.isEmpty();
return getPeriodPositionOrMaskWindowPosition(
return maskWindowPositionMsOrGetPeriodPositionUs(
newTimeline,
isCleared ? C.INDEX_UNSET : getCurrentWindowIndexInternal(),
isCleared ? C.TIME_UNSET : currentPositionMs);
}
int currentMediaItemIndex = getCurrentMediaItemIndex();
@Nullable
Pair<Object, Long> oldPeriodPosition =
oldTimeline.getPeriodPosition(
Pair<Object, Long> oldPeriodPositionUs =
oldTimeline.getPeriodPositionUs(
window, period, currentMediaItemIndex, Util.msToUs(currentPositionMs));
Object periodUid = castNonNull(oldPeriodPosition).first;
Object periodUid = castNonNull(oldPeriodPositionUs).first;
if (newTimeline.getIndexOfPeriod(periodUid) != C.INDEX_UNSET) {
// The old period position is still available in the new timeline.
return oldPeriodPosition;
return oldPeriodPositionUs;
}
// Period uid not found in new timeline. Try to get subsequent period.
@Nullable
@ -1659,19 +1659,19 @@ import java.util.concurrent.CopyOnWriteArraySet;
if (nextPeriodUid != null) {
// Reset position to the default position of the window of the subsequent period.
newTimeline.getPeriodByUid(nextPeriodUid, period);
return getPeriodPositionOrMaskWindowPosition(
return maskWindowPositionMsOrGetPeriodPositionUs(
newTimeline,
period.windowIndex,
newTimeline.getWindow(period.windowIndex, window).getDefaultPositionMs());
} else {
// No subsequent period found and the new timeline is not empty. Use the default position.
return getPeriodPositionOrMaskWindowPosition(
return maskWindowPositionMsOrGetPeriodPositionUs(
newTimeline, /* windowIndex= */ C.INDEX_UNSET, /* windowPositionMs= */ C.TIME_UNSET);
}
}
@Nullable
private Pair<Object, Long> getPeriodPositionOrMaskWindowPosition(
private Pair<Object, Long> maskWindowPositionMsOrGetPeriodPositionUs(
Timeline timeline, int windowIndex, long windowPositionMs) {
if (timeline.isEmpty()) {
// If empty we store the initial seek in the masking variables.
@ -1686,7 +1686,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
windowIndex = timeline.getFirstWindowIndex(shuffleModeEnabled);
windowPositionMs = timeline.getWindow(windowIndex, window).getDefaultPositionMs();
}
return timeline.getPeriodPosition(window, period, windowIndex, Util.msToUs(windowPositionMs));
return timeline.getPeriodPositionUs(window, period, windowIndex, Util.msToUs(windowPositionMs));
}
private long periodPositionUsToWindowPositionUs(

View file

@ -1123,7 +1123,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
boolean seekPositionAdjusted;
@Nullable
Pair<Object, Long> resolvedSeekPosition =
resolveSeekPosition(
resolveSeekPositionUs(
playbackInfo.timeline,
seekPosition,
/* trySubsequentPeriods= */ true,
@ -1134,10 +1134,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
if (resolvedSeekPosition == null) {
// The seek position was valid for the timeline that it was performed into, but the
// timeline has changed or is not ready and a suitable seek position could not be resolved.
Pair<MediaPeriodId, Long> firstPeriodAndPosition =
getPlaceholderFirstMediaPeriodPosition(playbackInfo.timeline);
periodId = firstPeriodAndPosition.first;
periodPositionUs = firstPeriodAndPosition.second;
Pair<MediaPeriodId, Long> firstPeriodAndPositionUs =
getPlaceholderFirstMediaPeriodPositionUs(playbackInfo.timeline);
periodId = firstPeriodAndPositionUs.first;
periodPositionUs = firstPeriodAndPositionUs.second;
requestedContentPositionUs = C.TIME_UNSET;
seekPositionAdjusted = !playbackInfo.timeline.isEmpty();
} else {
@ -1412,10 +1412,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
boolean resetTrackInfo = false;
if (resetPosition) {
pendingInitialSeekPosition = null;
Pair<MediaPeriodId, Long> firstPeriodAndPosition =
getPlaceholderFirstMediaPeriodPosition(playbackInfo.timeline);
mediaPeriodId = firstPeriodAndPosition.first;
startPositionUs = firstPeriodAndPosition.second;
Pair<MediaPeriodId, Long> firstPeriodAndPositionUs =
getPlaceholderFirstMediaPeriodPositionUs(playbackInfo.timeline);
mediaPeriodId = firstPeriodAndPositionUs.first;
startPositionUs = firstPeriodAndPositionUs.second;
requestedContentPositionUs = C.TIME_UNSET;
if (!mediaPeriodId.equals(playbackInfo.periodId)) {
resetTrackInfo = true;
@ -1451,19 +1451,19 @@ import java.util.concurrent.atomic.AtomicBoolean;
}
}
private Pair<MediaPeriodId, Long> getPlaceholderFirstMediaPeriodPosition(Timeline timeline) {
private Pair<MediaPeriodId, Long> getPlaceholderFirstMediaPeriodPositionUs(Timeline timeline) {
if (timeline.isEmpty()) {
return Pair.create(PlaybackInfo.getDummyPeriodForEmptyTimeline(), 0L);
}
int firstWindowIndex = timeline.getFirstWindowIndex(shuffleModeEnabled);
Pair<Object, Long> firstPeriodAndPosition =
timeline.getPeriodPosition(
Pair<Object, Long> firstPeriodAndPositionUs =
timeline.getPeriodPositionUs(
window, period, firstWindowIndex, /* windowPositionUs= */ C.TIME_UNSET);
// Add ad metadata if any and propagate the window sequence number to new period id.
MediaPeriodId firstPeriodId =
queue.resolveMediaPeriodIdForAds(
timeline, firstPeriodAndPosition.first, /* positionUs= */ 0);
long positionUs = firstPeriodAndPosition.second;
timeline, firstPeriodAndPositionUs.first, /* positionUs= */ 0);
long positionUs = firstPeriodAndPositionUs.second;
if (firstPeriodId.isAd()) {
timeline.getPeriodByUid(firstPeriodId.periodUid, period);
positionUs =
@ -2543,7 +2543,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
// Resolve initial seek position.
@Nullable
Pair<Object, Long> periodPosition =
resolveSeekPosition(
resolveSeekPositionUs(
timeline,
pendingInitialSeekPosition,
/* trySubsequentPeriods= */ true,
@ -2608,10 +2608,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
// at position 0 and don't need to be resolved.
long windowPositionUs = oldContentPositionUs + period.getPositionInWindowUs();
int windowIndex = timeline.getPeriodByUid(newPeriodUid, period).windowIndex;
Pair<Object, Long> periodPosition =
timeline.getPeriodPosition(window, period, windowIndex, windowPositionUs);
newPeriodUid = periodPosition.first;
newContentPositionUs = periodPosition.second;
Pair<Object, Long> periodPositionUs =
timeline.getPeriodPositionUs(window, period, windowIndex, windowPositionUs);
newPeriodUid = periodPositionUs.first;
newContentPositionUs = periodPositionUs.second;
}
// Use an explicitly requested content position as new target live offset.
setTargetLiveOffset = true;
@ -2620,14 +2620,14 @@ import java.util.concurrent.atomic.AtomicBoolean;
// Set period uid for default positions and resolve position for ad resolution.
long contentPositionForAdResolutionUs = newContentPositionUs;
if (startAtDefaultPositionWindowIndex != C.INDEX_UNSET) {
Pair<Object, Long> defaultPosition =
timeline.getPeriodPosition(
Pair<Object, Long> defaultPositionUs =
timeline.getPeriodPositionUs(
window,
period,
startAtDefaultPositionWindowIndex,
/* windowPositionUs= */ C.TIME_UNSET);
newPeriodUid = defaultPosition.first;
contentPositionForAdResolutionUs = defaultPosition.second;
newPeriodUid = defaultPositionUs.first;
contentPositionForAdResolutionUs = defaultPositionUs.second;
newContentPositionUs = C.TIME_UNSET;
}
@ -2741,7 +2741,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
: Util.msToUs(pendingMessageInfo.message.getPositionMs());
@Nullable
Pair<Object, Long> periodPosition =
resolveSeekPosition(
resolveSeekPositionUs(
newTimeline,
new SeekPosition(
pendingMessageInfo.message.getTimeline(),
@ -2786,12 +2786,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
pendingMessageInfo.resolvedPeriodTimeUs + period.getPositionInWindowUs();
int windowIndex =
newTimeline.getPeriodByUid(pendingMessageInfo.resolvedPeriodUid, period).windowIndex;
Pair<Object, Long> periodPosition =
newTimeline.getPeriodPosition(window, period, windowIndex, windowPositionUs);
Pair<Object, Long> periodPositionUs =
newTimeline.getPeriodPositionUs(window, period, windowIndex, windowPositionUs);
pendingMessageInfo.setResolvedPosition(
/* periodIndex= */ newTimeline.getIndexOfPeriod(periodPosition.first),
/* periodTimeUs= */ periodPosition.second,
/* periodUid= */ periodPosition.first);
/* periodIndex= */ newTimeline.getIndexOfPeriod(periodPositionUs.first),
/* periodTimeUs= */ periodPositionUs.second,
/* periodUid= */ periodPositionUs.first);
}
return true;
}
@ -2820,7 +2820,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
* bounds of the timeline.
*/
@Nullable
private static Pair<Object, Long> resolveSeekPosition(
private static Pair<Object, Long> resolveSeekPositionUs(
Timeline timeline,
SeekPosition seekPosition,
boolean trySubsequentPeriods,
@ -2839,10 +2839,10 @@ import java.util.concurrent.atomic.AtomicBoolean;
seekTimeline = timeline;
}
// Map the SeekPosition to a position in the corresponding timeline.
Pair<Object, Long> periodPosition;
Pair<Object, Long> periodPositionUs;
try {
periodPosition =
seekTimeline.getPeriodPosition(
periodPositionUs =
seekTimeline.getPeriodPositionUs(
window, period, seekPosition.windowIndex, seekPosition.windowPositionUs);
} catch (IndexOutOfBoundsException e) {
// The window index of the seek position was outside the bounds of the timeline.
@ -2850,24 +2850,24 @@ import java.util.concurrent.atomic.AtomicBoolean;
}
if (timeline.equals(seekTimeline)) {
// Our internal timeline is the seek timeline, so the mapped position is correct.
return periodPosition;
return periodPositionUs;
}
// Attempt to find the mapped period in the internal timeline.
int periodIndex = timeline.getIndexOfPeriod(periodPosition.first);
int periodIndex = timeline.getIndexOfPeriod(periodPositionUs.first);
if (periodIndex != C.INDEX_UNSET) {
// We successfully located the period in the internal timeline.
if (seekTimeline.getPeriodByUid(periodPosition.first, period).isPlaceholder
if (seekTimeline.getPeriodByUid(periodPositionUs.first, period).isPlaceholder
&& seekTimeline.getWindow(period.windowIndex, window).firstPeriodIndex
== seekTimeline.getIndexOfPeriod(periodPosition.first)) {
== seekTimeline.getIndexOfPeriod(periodPositionUs.first)) {
// The seek timeline was using a placeholder, so we need to re-resolve using the updated
// timeline in case the resolved position changed. Only resolve the first period in a window
// because subsequent periods must start at position 0 and don't need to be resolved.
int newWindowIndex = timeline.getPeriodByUid(periodPosition.first, period).windowIndex;
periodPosition =
timeline.getPeriodPosition(
int newWindowIndex = timeline.getPeriodByUid(periodPositionUs.first, period).windowIndex;
periodPositionUs =
timeline.getPeriodPositionUs(
window, period, newWindowIndex, seekPosition.windowPositionUs);
}
return periodPosition;
return periodPositionUs;
}
if (trySubsequentPeriods) {
// Try and find a subsequent period from the seek timeline in the internal timeline.
@ -2878,12 +2878,12 @@ import java.util.concurrent.atomic.AtomicBoolean;
period,
repeatMode,
shuffleModeEnabled,
periodPosition.first,
periodPositionUs.first,
seekTimeline,
timeline);
if (periodUid != null) {
// We found one. Use the default position of the corresponding window.
return timeline.getPeriodPosition(
return timeline.getPeriodPositionUs(
window,
period,
timeline.getPeriodByUid(periodUid, period).windowIndex,

View file

@ -661,18 +661,18 @@ import com.google.common.collect.ImmutableList;
// forward by the duration of the buffer, and start buffering from this point.
contentPositionUs = C.TIME_UNSET;
@Nullable
Pair<Object, Long> defaultPosition =
timeline.getPeriodPosition(
Pair<Object, Long> defaultPositionUs =
timeline.getPeriodPositionUs(
window,
period,
nextWindowIndex,
/* windowPositionUs= */ C.TIME_UNSET,
/* defaultPositionProjectionUs= */ max(0, bufferedDurationUs));
if (defaultPosition == null) {
if (defaultPositionUs == null) {
return null;
}
nextPeriodUid = defaultPosition.first;
startPositionUs = defaultPosition.second;
nextPeriodUid = defaultPositionUs.first;
startPositionUs = defaultPositionUs.second;
MediaPeriodHolder nextMediaPeriodHolder = mediaPeriodHolder.getNext();
if (nextMediaPeriodHolder != null && nextMediaPeriodHolder.uid.equals(nextPeriodUid)) {
windowSequenceNumber = nextMediaPeriodHolder.info.id.windowSequenceNumber;
@ -716,17 +716,17 @@ import com.google.common.collect.ImmutableList;
// If we're transitioning from an ad group to content starting from its default position,
// project the start position forward as if this were a transition to a new window.
@Nullable
Pair<Object, Long> defaultPosition =
timeline.getPeriodPosition(
Pair<Object, Long> defaultPositionUs =
timeline.getPeriodPositionUs(
window,
period,
period.windowIndex,
/* windowPositionUs= */ C.TIME_UNSET,
/* defaultPositionProjectionUs= */ max(0, bufferedDurationUs));
if (defaultPosition == null) {
if (defaultPositionUs == null) {
return null;
}
startPositionUs = defaultPosition.second;
startPositionUs = defaultPositionUs.second;
}
long minStartPositionUs =
getMinStartPositionAfterAdGroupUs(

View file

@ -179,11 +179,11 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
windowStartPositionUs = windowPreparePositionUs;
}
}
Pair<Object, Long> periodPosition =
newTimeline.getPeriodPosition(
Pair<Object, Long> periodUidAndPositionUs =
newTimeline.getPeriodPositionUs(
window, period, /* windowIndex= */ 0, windowStartPositionUs);
Object periodUid = periodPosition.first;
long periodPositionUs = periodPosition.second;
Object periodUid = periodUidAndPositionUs.first;
long periodPositionUs = periodUidAndPositionUs.second;
timeline =
hasRealTimeline
? timeline.cloneWithUpdatedTimeline(newTimeline)

View file

@ -45,19 +45,31 @@ public final class SinglePeriodTimelineTest {
public void getPeriodPositionDynamicWindowUnknownDuration() {
SinglePeriodTimeline timeline =
new SinglePeriodTimeline(
C.TIME_UNSET,
/* durationUs= */ C.TIME_UNSET,
/* isSeekable= */ false,
/* isDynamic= */ true,
/* isLive= */ true,
/* manifest= */ null,
MediaItem.fromUri(Uri.EMPTY));
// Should return null with any positive position projection.
Pair<Object, Long> position = timeline.getPeriodPosition(window, period, 0, C.TIME_UNSET, 1);
assertThat(position).isNull();
Pair<Object, Long> positionUs =
timeline.getPeriodPositionUs(
window,
period,
/* windowIndex= */ 0,
/* windowPositionUs= */ C.TIME_UNSET,
/* defaultPositionProjectionUs= */ 1);
assertThat(positionUs).isNull();
// Should return (0, 0) without a position projection.
position = timeline.getPeriodPosition(window, period, 0, C.TIME_UNSET, 0);
assertThat(position.first).isEqualTo(timeline.getUidOfPeriod(0));
assertThat(position.second).isEqualTo(0);
positionUs =
timeline.getPeriodPositionUs(
window,
period,
/* windowIndex= */ 0,
/* windowPositionUs= */ C.TIME_UNSET,
/* defaultPositionProjectionUs= */ 0);
assertThat(positionUs.first).isEqualTo(timeline.getUidOfPeriod(0));
assertThat(positionUs.second).isEqualTo(0);
}
@Test
@ -75,17 +87,34 @@ public final class SinglePeriodTimelineTest {
/* manifest= */ null,
MediaItem.fromUri(Uri.EMPTY));
// Should return null with a positive position projection beyond window duration.
Pair<Object, Long> position =
timeline.getPeriodPosition(window, period, 0, C.TIME_UNSET, windowDurationUs + 1);
assertThat(position).isNull();
Pair<Object, Long> positionUs =
timeline.getPeriodPositionUs(
window,
period,
/* windowIndex= */ 0,
/* windowPositionUs= */ C.TIME_UNSET,
/* defaultPositionProjectionUs= */ windowDurationUs + 1);
assertThat(positionUs).isNull();
// Should return (0, duration) with a projection equal to window duration.
position = timeline.getPeriodPosition(window, period, 0, C.TIME_UNSET, windowDurationUs - 1);
assertThat(position.first).isEqualTo(timeline.getUidOfPeriod(0));
assertThat(position.second).isEqualTo(windowDurationUs - 1);
positionUs =
timeline.getPeriodPositionUs(
window,
period,
/* windowIndex= */ 0,
/* windowPositionUs= */ C.TIME_UNSET,
/* defaultPositionProjectionUs= */ windowDurationUs - 1);
assertThat(positionUs.first).isEqualTo(timeline.getUidOfPeriod(0));
assertThat(positionUs.second).isEqualTo(windowDurationUs - 1);
// Should return (0, 0) without a position projection.
position = timeline.getPeriodPosition(window, period, 0, C.TIME_UNSET, 0);
assertThat(position.first).isEqualTo(timeline.getUidOfPeriod(0));
assertThat(position.second).isEqualTo(0);
positionUs =
timeline.getPeriodPositionUs(
window,
period,
/* windowIndex= */ 0,
/* windowPositionUs= */ C.TIME_UNSET,
/* defaultPositionProjectionUs= */ 0);
assertThat(positionUs.first).isEqualTo(timeline.getUidOfPeriod(0));
assertThat(positionUs.second).isEqualTo(0);
}
@Test