Support clip end greater than the child's duration

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=164577001
This commit is contained in:
olly 2017-08-08 04:07:13 -07:00 committed by Oliver Woodman
parent e45345e21b
commit 24bf2aa0e2

View file

@ -47,7 +47,9 @@ public final class ClippingMediaSource implements MediaSource, MediaSource.Liste
* start providing samples, in microseconds.
* @param endPositionUs The end position within {@code mediaSource}'s timeline at which to stop
* providing samples, in microseconds. Specify {@link C#TIME_END_OF_SOURCE} to provide samples
* from the specified start point up to the end of the source.
* from the specified start point up to the end of the source. Specifying a position that
* exceeds the {@code mediaSource}'s duration will also result in the end of the source not
* being clipped.
*/
public ClippingMediaSource(MediaSource mediaSource, long startPositionUs, long endPositionUs) {
this(mediaSource, startPositionUs, endPositionUs, true);
@ -65,7 +67,9 @@ public final class ClippingMediaSource implements MediaSource, MediaSource.Liste
* start providing samples, in microseconds.
* @param endPositionUs The end position within {@code mediaSource}'s timeline at which to stop
* providing samples, in microseconds. Specify {@link C#TIME_END_OF_SOURCE} to provide samples
* from the specified start point up to the end of the source.
* from the specified start point up to the end of the source. Specifying a position that
* exceeds the {@code mediaSource}'s duration will also result in the end of the source not
* being clipped.
* @param enableInitialDiscontinuity Whether the initial discontinuity should be enabled.
*/
public ClippingMediaSource(MediaSource mediaSource, long startPositionUs, long endPositionUs,
@ -148,8 +152,10 @@ public final class ClippingMediaSource implements MediaSource, MediaSource.Liste
Assertions.checkArgument(!window.isDynamic);
long resolvedEndUs = endUs == C.TIME_END_OF_SOURCE ? window.durationUs : endUs;
if (window.durationUs != C.TIME_UNSET) {
if (resolvedEndUs > window.durationUs) {
resolvedEndUs = window.durationUs;
}
Assertions.checkArgument(startUs == 0 || window.isSeekable);
Assertions.checkArgument(resolvedEndUs <= window.durationUs);
Assertions.checkArgument(startUs <= resolvedEndUs);
}
Period period = timeline.getPeriod(0, new Period());