mirror of
https://github.com/samsonjs/media.git
synced 2026-04-10 12:05:47 +00:00
Fix clipping to end of source
Issue: #3966 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=188465096
This commit is contained in:
parent
8f952162ff
commit
a58bffbe52
2 changed files with 31 additions and 1 deletions
|
|
@ -226,7 +226,7 @@ public final class ClippingMediaSource extends CompositeMediaSource<Void> {
|
|||
}
|
||||
this.startUs = startUs;
|
||||
this.endUs = resolvedEndUs;
|
||||
durationUs = endUs == C.TIME_UNSET ? C.TIME_UNSET : endUs - startUs;
|
||||
durationUs = resolvedEndUs == C.TIME_UNSET ? C.TIME_UNSET : (resolvedEndUs - startUs);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -124,6 +124,36 @@ public final class ClippingMediaSourceTest {
|
|||
.isEqualTo(TEST_PERIOD_DURATION_US - TEST_CLIP_AMOUNT_US * 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClippingToEndOfSourceWithDurationSetsDuration() throws IOException {
|
||||
// Create a child timeline that has a known duration.
|
||||
Timeline timeline =
|
||||
new SinglePeriodTimeline(
|
||||
/* durationUs= */ TEST_PERIOD_DURATION_US,
|
||||
/* isSeekable= */ true,
|
||||
/* isDynamic= */ false);
|
||||
|
||||
// When clipping to the end, the clipped timeline should also have a duration.
|
||||
Timeline clippedTimeline =
|
||||
getClippedTimeline(timeline, TEST_CLIP_AMOUNT_US, C.TIME_END_OF_SOURCE);
|
||||
assertThat(clippedTimeline.getWindow(/* windowIndex= */ 0, window).getDurationUs())
|
||||
.isEqualTo(TEST_PERIOD_DURATION_US - TEST_CLIP_AMOUNT_US);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClippingToEndOfSourceWithUnsetDurationDoesNotSetDuration() throws IOException {
|
||||
// Create a child timeline that has an unknown duration.
|
||||
Timeline timeline =
|
||||
new SinglePeriodTimeline(
|
||||
/* durationUs= */ C.TIME_UNSET, /* isSeekable= */ true, /* isDynamic= */ false);
|
||||
|
||||
// When clipping to the end, the clipped timeline should also have an unset duration.
|
||||
Timeline clippedTimeline =
|
||||
getClippedTimeline(timeline, TEST_CLIP_AMOUNT_US, C.TIME_END_OF_SOURCE);
|
||||
assertThat(clippedTimeline.getWindow(/* windowIndex= */ 0, window).getDurationUs())
|
||||
.isEqualTo(C.TIME_UNSET);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClippingStartAndEnd() throws IOException {
|
||||
Timeline timeline = new SinglePeriodTimeline(C.msToUs(TEST_PERIOD_DURATION_US), true, false);
|
||||
|
|
|
|||
Loading…
Reference in a new issue