Add ConcatenatingMediaSource version that fully combines windows.
The published Timeline contains one window only with all periods of the child sources. Issue: #4868 PiperOrigin-RevId: 358150276
This commit is contained in:
parent
7b119beffb
commit
1a12018dae
@ -435,7 +435,13 @@ public abstract class Timeline {
|
|||||||
*/
|
*/
|
||||||
public long durationUs;
|
public long durationUs;
|
||||||
|
|
||||||
private long positionInWindowUs;
|
/**
|
||||||
|
* The position of the start of this period relative to the start of the window to which it
|
||||||
|
* belongs, in microseconds. May be negative if the start of the period is not within the
|
||||||
|
* window.
|
||||||
|
*/
|
||||||
|
public long positionInWindowUs;
|
||||||
|
|
||||||
private AdPlaybackState adPlaybackState;
|
private AdPlaybackState adPlaybackState;
|
||||||
|
|
||||||
/** Creates a new instance with no ad playback state. */
|
/** Creates a new instance with no ad playback state. */
|
||||||
@ -922,13 +928,14 @@ public abstract class Timeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int periodIndex = window.firstPeriodIndex;
|
int periodIndex = window.firstPeriodIndex;
|
||||||
long periodPositionUs = window.getPositionInFirstPeriodUs() + windowPositionUs;
|
getPeriod(periodIndex, period);
|
||||||
long periodDurationUs = getPeriod(periodIndex, period, /* setIds= */ true).getDurationUs();
|
while (periodIndex < window.lastPeriodIndex
|
||||||
while (periodDurationUs != C.TIME_UNSET && periodPositionUs >= periodDurationUs
|
&& period.positionInWindowUs != windowPositionUs
|
||||||
&& periodIndex < window.lastPeriodIndex) {
|
&& getPeriod(periodIndex + 1, period).positionInWindowUs <= windowPositionUs) {
|
||||||
periodPositionUs -= periodDurationUs;
|
periodIndex++;
|
||||||
periodDurationUs = getPeriod(++periodIndex, period, /* setIds= */ true).getDurationUs();
|
|
||||||
}
|
}
|
||||||
|
getPeriod(periodIndex, period, /* setIds= */ true);
|
||||||
|
long periodPositionUs = windowPositionUs - period.positionInWindowUs;
|
||||||
return Pair.create(Assertions.checkNotNull(period.uid), periodPositionUs);
|
return Pair.create(Assertions.checkNotNull(period.uid), periodPositionUs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +152,14 @@ public class MediaPeriodId {
|
|||||||
newPeriodUid, adGroupIndex, adIndexInAdGroup, windowSequenceNumber, nextAdGroupIndex);
|
newPeriodUid, adGroupIndex, adIndexInAdGroup, windowSequenceNumber, nextAdGroupIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns a copy of this period identifier with a new {@code windowSequenceNumber}. */
|
||||||
|
public MediaPeriodId copyWithWindowSequenceNumber(long windowSequenceNumber) {
|
||||||
|
return this.windowSequenceNumber == windowSequenceNumber
|
||||||
|
? this
|
||||||
|
: new MediaPeriodId(
|
||||||
|
periodUid, adGroupIndex, adIndexInAdGroup, windowSequenceNumber, nextAdGroupIndex);
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns whether this period identifier identifies an ad in an ad group in a period. */
|
/** Returns whether this period identifier identifies an ad in an ad group in a period. */
|
||||||
public boolean isAd() {
|
public boolean isAd() {
|
||||||
return adGroupIndex != C.INDEX_UNSET;
|
return adGroupIndex != C.INDEX_UNSET;
|
||||||
|
@ -104,9 +104,19 @@ public interface MediaSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** See {@link com.google.android.exoplayer2.source.MediaPeriodId#copyWithPeriodUid(Object)}. */
|
/** See {@link com.google.android.exoplayer2.source.MediaPeriodId#copyWithPeriodUid(Object)}. */
|
||||||
|
@Override
|
||||||
public MediaPeriodId copyWithPeriodUid(Object newPeriodUid) {
|
public MediaPeriodId copyWithPeriodUid(Object newPeriodUid) {
|
||||||
return new MediaPeriodId(super.copyWithPeriodUid(newPeriodUid));
|
return new MediaPeriodId(super.copyWithPeriodUid(newPeriodUid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See {@link
|
||||||
|
* com.google.android.exoplayer2.source.MediaPeriodId#copyWithWindowSequenceNumber(long)}.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public MediaPeriodId copyWithWindowSequenceNumber(long windowSequenceNumber) {
|
||||||
|
return new MediaPeriodId(super.copyWithWindowSequenceNumber(windowSequenceNumber));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user