Commit 61bbdb37 by tonihei Committed by bachinger

Add missing isPlaceholder forwarding in SinglePeriodAdTimeline

Also make future similar issues less likely by adding isPlaceholder
to the set method of Period (in case forwarding Timeline
implementations use this instead of just updating values selectively)

#minor-release

PiperOrigin-RevId: 372138523
parent 4c1a294b
......@@ -613,7 +613,14 @@ public abstract class Timeline implements Bundleable {
int windowIndex,
long durationUs,
long positionInWindowUs) {
return set(id, uid, windowIndex, durationUs, positionInWindowUs, AdPlaybackState.NONE);
return set(
id,
uid,
windowIndex,
durationUs,
positionInWindowUs,
AdPlaybackState.NONE,
/* isPlaceholder= */ false);
}
/**
......@@ -631,6 +638,8 @@ public abstract class Timeline implements Bundleable {
* period is not within the window.
* @param adPlaybackState The state of the period's ads, or {@link AdPlaybackState#NONE} if
* there are no ads.
* @param isPlaceholder Whether this period contains placeholder information because the real
* information has yet to be loaded.
* @return This period, for convenience.
*/
public Period set(
......@@ -639,14 +648,15 @@ public abstract class Timeline implements Bundleable {
int windowIndex,
long durationUs,
long positionInWindowUs,
AdPlaybackState adPlaybackState) {
AdPlaybackState adPlaybackState,
boolean isPlaceholder) {
this.id = id;
this.uid = uid;
this.windowIndex = windowIndex;
this.durationUs = durationUs;
this.positionInWindowUs = positionInWindowUs;
this.adPlaybackState = adPlaybackState;
this.isPlaceholder = false;
this.isPlaceholder = isPlaceholder;
return this;
}
......@@ -890,8 +900,8 @@ public abstract class Timeline implements Bundleable {
windowIndex,
durationUs,
positionInWindowUs,
adPlaybackState);
period.isPlaceholder = isPlaceholder;
adPlaybackState,
isPlaceholder);
return period;
}
......@@ -1469,8 +1479,14 @@ public abstract class Timeline implements Bundleable {
@Override
public Period getPeriod(int periodIndex, Period period, boolean ignoredSetIds) {
Period p = periods.get(periodIndex);
period.set(p.id, p.uid, p.windowIndex, p.durationUs, p.positionInWindowUs, p.adPlaybackState);
period.isPlaceholder = p.isPlaceholder;
period.set(
p.id,
p.uid,
p.windowIndex,
p.durationUs,
p.positionInWindowUs,
p.adPlaybackState,
p.isPlaceholder);
return period;
}
......
......@@ -24,6 +24,7 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.Timeline.Window;
import com.google.android.exoplayer2.source.ads.AdPlaybackState;
import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.Assertions;
......@@ -400,8 +401,9 @@ public final class MaskingMediaSource extends CompositeMediaSource<Void> {
/* uid= */ setIds ? MaskingTimeline.MASKING_EXTERNAL_PERIOD_UID : null,
/* windowIndex= */ 0,
/* durationUs = */ C.TIME_UNSET,
/* positionInWindowUs= */ 0);
period.isPlaceholder = true;
/* positionInWindowUs= */ 0,
/* adPlaybackState= */ AdPlaybackState.NONE,
/* isPlaceholder= */ true);
return period;
}
......
......@@ -52,7 +52,8 @@ public final class SinglePeriodAdTimeline extends ForwardingTimeline {
period.windowIndex,
durationUs,
period.getPositionInWindowUs(),
adPlaybackState);
adPlaybackState,
period.isPlaceholder);
return period;
}
}
......@@ -414,8 +414,8 @@ public final class FakeTimeline extends Timeline {
windowIndex,
periodDurationUs,
positionInWindowUs,
windowDefinition.adPlaybackState);
period.isPlaceholder = windowDefinition.isPlaceholder;
windowDefinition.adPlaybackState,
windowDefinition.isPlaceholder);
return period;
}
......
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