Commit ea7e8cff by kimvde Committed by microkatz

Refactor transformation completion

PiperOrigin-RevId: 488929446
parent f2a63e9d
Showing with 227 additions and 138 deletions
...@@ -680,7 +680,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou ...@@ -680,7 +680,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
adPlaybackState, adPlaybackState,
/* fromPositionUs= */ fromPositionUs, /* fromPositionUs= */ fromPositionUs,
/* contentResumeOffsetUs= */ 0, /* contentResumeOffsetUs= */ 0,
/* adDurationsUs= */ getAdDuration( /* adDurationsUs...= */ getAdDuration(
/* startTimeSeconds= */ cuePoint.getStartTime(), /* startTimeSeconds= */ cuePoint.getStartTime(),
/* endTimeSeconds= */ cuePoint.getEndTime())); /* endTimeSeconds= */ cuePoint.getEndTime()));
} }
......
...@@ -443,7 +443,7 @@ import java.util.Set; ...@@ -443,7 +443,7 @@ import java.util.Set;
private static AdPlaybackState splitAdGroupForPeriod( private static AdPlaybackState splitAdGroupForPeriod(
Object adsId, AdGroup adGroup, long periodStartUs, long periodDurationUs) { Object adsId, AdGroup adGroup, long periodStartUs, long periodDurationUs) {
AdPlaybackState adPlaybackState = AdPlaybackState adPlaybackState =
new AdPlaybackState(checkNotNull(adsId), /* adGroupTimesUs= */ 0) new AdPlaybackState(checkNotNull(adsId), /* adGroupTimesUs...= */ 0)
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1)
.withAdDurationsUs(/* adGroupIndex= */ 0, periodDurationUs) .withAdDurationsUs(/* adGroupIndex= */ 0, periodDurationUs)
.withIsServerSideInserted(/* adGroupIndex= */ 0, true) .withIsServerSideInserted(/* adGroupIndex= */ 0, true)
...@@ -605,7 +605,7 @@ import java.util.Set; ...@@ -605,7 +605,7 @@ import java.util.Set;
adPlaybackState, adPlaybackState,
/* fromPositionUs= */ currentContentPeriodPositionUs, /* fromPositionUs= */ currentContentPeriodPositionUs,
/* contentResumeOffsetUs= */ sum(adDurationsUs), /* contentResumeOffsetUs= */ sum(adDurationsUs),
/* adDurationsUs= */ adDurationsUs); /* adDurationsUs...= */ adDurationsUs);
adGroupIndex = adGroupIndex =
adPlaybackState.getAdGroupIndexForPositionUs( adPlaybackState.getAdGroupIndexForPositionUs(
mediaPeriodPositionUs, /* periodDurationUs= */ C.TIME_UNSET); mediaPeriodPositionUs, /* periodDurationUs= */ C.TIME_UNSET);
......
...@@ -239,7 +239,7 @@ public final class ImaAdsLoaderTest { ...@@ -239,7 +239,7 @@ public final class ImaAdsLoaderTest {
assertThat(getAdPlaybackState(/* periodIndex= */ 0)) assertThat(getAdPlaybackState(/* periodIndex= */ 0))
.isEqualTo( .isEqualTo(
new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs= */ 0) new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */ 0)
.withContentDurationUs(CONTENT_PERIOD_DURATION_US)); .withContentDurationUs(CONTENT_PERIOD_DURATION_US));
} }
...@@ -312,7 +312,7 @@ public final class ImaAdsLoaderTest { ...@@ -312,7 +312,7 @@ public final class ImaAdsLoaderTest {
// Verify that the preroll ad has been marked as played. // Verify that the preroll ad has been marked as played.
assertThat(getAdPlaybackState(/* periodIndex= */ 0)) assertThat(getAdPlaybackState(/* periodIndex= */ 0))
.isEqualTo( .isEqualTo(
new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs= */ 0) new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */ 0)
.withContentDurationUs(CONTENT_PERIOD_DURATION_US) .withContentDurationUs(CONTENT_PERIOD_DURATION_US)
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1)
.withAvailableAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, TEST_URI) .withAvailableAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, TEST_URI)
...@@ -336,7 +336,7 @@ public final class ImaAdsLoaderTest { ...@@ -336,7 +336,7 @@ public final class ImaAdsLoaderTest {
assertThat(getAdPlaybackState(/* periodIndex= */ 0)) assertThat(getAdPlaybackState(/* periodIndex= */ 0))
.isEqualTo( .isEqualTo(
new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs= */ 20_500_000) new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */ 20_500_000)
.withContentDurationUs(CONTENT_PERIOD_DURATION_US) .withContentDurationUs(CONTENT_PERIOD_DURATION_US)
.withAdDurationsUs(new long[][] {{TEST_AD_DURATION_US}}) .withAdDurationsUs(new long[][] {{TEST_AD_DURATION_US}})
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1)
...@@ -384,7 +384,7 @@ public final class ImaAdsLoaderTest { ...@@ -384,7 +384,7 @@ public final class ImaAdsLoaderTest {
assertThat(getAdPlaybackState(/* periodIndex= */ 0)) assertThat(getAdPlaybackState(/* periodIndex= */ 0))
.isEqualTo( .isEqualTo(
new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs= */ C.TIME_END_OF_SOURCE) new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */ C.TIME_END_OF_SOURCE)
.withContentDurationUs(CONTENT_PERIOD_DURATION_US) .withContentDurationUs(CONTENT_PERIOD_DURATION_US)
.withAdDurationsUs(new long[][] {{TEST_AD_DURATION_US}}) .withAdDurationsUs(new long[][] {{TEST_AD_DURATION_US}})
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1)
...@@ -1114,7 +1114,7 @@ public final class ImaAdsLoaderTest { ...@@ -1114,7 +1114,7 @@ public final class ImaAdsLoaderTest {
// Verify that the preroll ad has been marked as played. // Verify that the preroll ad has been marked as played.
assertThat(getAdPlaybackState(/* periodIndex= */ 0)) assertThat(getAdPlaybackState(/* periodIndex= */ 0))
.isEqualTo( .isEqualTo(
new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs= */ 0) new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */ 0)
.withContentDurationUs(CONTENT_PERIOD_DURATION_US) .withContentDurationUs(CONTENT_PERIOD_DURATION_US)
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1)
.withAvailableAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, TEST_URI) .withAvailableAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, TEST_URI)
...@@ -1123,7 +1123,7 @@ public final class ImaAdsLoaderTest { ...@@ -1123,7 +1123,7 @@ public final class ImaAdsLoaderTest {
.withAdResumePositionUs(/* adResumePositionUs= */ 0)); .withAdResumePositionUs(/* adResumePositionUs= */ 0));
// Verify that the second source's ad cue points have preloaded. // Verify that the second source's ad cue points have preloaded.
assertThat(getAdPlaybackState(/* periodIndex= */ 1)) assertThat(getAdPlaybackState(/* periodIndex= */ 1))
.isEqualTo(new AdPlaybackState(secondAdsId, /* adGroupTimesUs= */ 0)); .isEqualTo(new AdPlaybackState(secondAdsId, /* adGroupTimesUs...= */ 0));
} }
@Test @Test
...@@ -1181,7 +1181,7 @@ public final class ImaAdsLoaderTest { ...@@ -1181,7 +1181,7 @@ public final class ImaAdsLoaderTest {
// Verify that the preroll ad has been marked as played. // Verify that the preroll ad has been marked as played.
assertThat(getAdPlaybackState(/* periodIndex= */ 0)) assertThat(getAdPlaybackState(/* periodIndex= */ 0))
.isEqualTo( .isEqualTo(
new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs= */ 0) new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */ 0)
.withContentDurationUs(CONTENT_PERIOD_DURATION_US) .withContentDurationUs(CONTENT_PERIOD_DURATION_US)
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1)
.withAvailableAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, TEST_URI) .withAvailableAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, TEST_URI)
...@@ -1190,7 +1190,7 @@ public final class ImaAdsLoaderTest { ...@@ -1190,7 +1190,7 @@ public final class ImaAdsLoaderTest {
.withAdResumePositionUs(/* adResumePositionUs= */ 0)); .withAdResumePositionUs(/* adResumePositionUs= */ 0));
// Verify that the second source's ad cue points have preloaded. // Verify that the second source's ad cue points have preloaded.
assertThat(getAdPlaybackState(/* periodIndex= */ 1)) assertThat(getAdPlaybackState(/* periodIndex= */ 1))
.isEqualTo(new AdPlaybackState(secondAdsId, /* adGroupTimesUs= */ 0)); .isEqualTo(new AdPlaybackState(secondAdsId, /* adGroupTimesUs...= */ 0));
} }
@Test @Test
......
...@@ -37,7 +37,7 @@ public class ImaServerSideAdInsertionMediaSourceTest { ...@@ -37,7 +37,7 @@ public class ImaServerSideAdInsertionMediaSourceTest {
new AdPlaybackState("adsId1"), new AdPlaybackState("adsId1"),
/* fromPositionUs= */ 0, /* fromPositionUs= */ 0,
/* contentResumeOffsetUs= */ 10, /* contentResumeOffsetUs= */ 10,
/* adDurationsUs= */ 5_000_000, /* adDurationsUs...= */ 5_000_000,
10_000_000, 10_000_000,
20_000_000); 20_000_000);
AdPlaybackState secondAdPlaybackState = AdPlaybackState secondAdPlaybackState =
...@@ -45,20 +45,20 @@ public class ImaServerSideAdInsertionMediaSourceTest { ...@@ -45,20 +45,20 @@ public class ImaServerSideAdInsertionMediaSourceTest {
new AdPlaybackState("adsId2"), new AdPlaybackState("adsId2"),
/* fromPositionUs= */ 0, /* fromPositionUs= */ 0,
/* contentResumeOffsetUs= */ 10, /* contentResumeOffsetUs= */ 10,
/* adDurationsUs= */ 10_000_000) /* adDurationsUs...= */ 10_000_000)
.withPlayedAd(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0); .withPlayedAd(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0);
AdPlaybackState thirdAdPlaybackState = AdPlaybackState thirdAdPlaybackState =
ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState( ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState(
new AdPlaybackState("adsId3"), new AdPlaybackState("adsId3"),
/* fromPositionUs= */ C.TIME_END_OF_SOURCE, /* fromPositionUs= */ C.TIME_END_OF_SOURCE,
/* contentResumeOffsetUs= */ 10, /* contentResumeOffsetUs= */ 10,
/* adDurationsUs= */ 10_000_000); /* adDurationsUs...= */ 10_000_000);
thirdAdPlaybackState = thirdAdPlaybackState =
ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState( ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState(
thirdAdPlaybackState, thirdAdPlaybackState,
/* fromPositionUs= */ 0, /* fromPositionUs= */ 0,
/* contentResumeOffsetUs= */ 10, /* contentResumeOffsetUs= */ 10,
/* adDurationsUs= */ 10_000_000) /* adDurationsUs...= */ 10_000_000)
.withRemovedAdGroupCount(1); .withRemovedAdGroupCount(1);
State state = State state =
new State( new State(
......
...@@ -435,7 +435,7 @@ public class ImaUtilTest { ...@@ -435,7 +435,7 @@ public class ImaUtilTest {
new AdPlaybackState(/* adsId= */ "adsId", 0) new AdPlaybackState(/* adsId= */ "adsId", 0)
.withAdCount(/* adGroupIndex= */ 0, periodCount) .withAdCount(/* adGroupIndex= */ 0, periodCount)
.withAdDurationsUs( .withAdDurationsUs(
/* adGroupIndex= */ 0, /* adDurationsUs= */ /* adGroupIndex= */ 0, /* adDurationsUs...= */
DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US + periodDurationUs, DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US + periodDurationUs,
periodDurationUs, periodDurationUs,
periodDurationUs, periodDurationUs,
...@@ -475,10 +475,12 @@ public class ImaUtilTest { ...@@ -475,10 +475,12 @@ public class ImaUtilTest {
.withAdCount(/* adGroupIndex= */ 1, 1) .withAdCount(/* adGroupIndex= */ 1, 1)
.withAdCount(/* adGroupIndex= */ 2, 1) .withAdCount(/* adGroupIndex= */ 2, 1)
.withAdDurationsUs( .withAdDurationsUs(
/* adGroupIndex= */ 0, /* adDurationsUs= */ /* adGroupIndex= */ 0, /* adDurationsUs...= */
DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US + (2 * periodDurationUs)) DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US + (2 * periodDurationUs))
.withAdDurationsUs(/* adGroupIndex= */ 1, /* adDurationsUs= */ (2 * periodDurationUs)) .withAdDurationsUs(
.withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs= */ (2 * periodDurationUs)) /* adGroupIndex= */ 1, /* adDurationsUs...= */ (2 * periodDurationUs))
.withAdDurationsUs(
/* adGroupIndex= */ 2, /* adDurationsUs...= */ (2 * periodDurationUs))
.withPlayedAd(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0) .withPlayedAd(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0)
.withPlayedAd(/* adGroupIndex= */ 1, /* adIndexInAdGroup= */ 0) .withPlayedAd(/* adGroupIndex= */ 1, /* adIndexInAdGroup= */ 0)
.withIsServerSideInserted(/* adGroupIndex= */ 0, true) .withIsServerSideInserted(/* adGroupIndex= */ 0, true)
...@@ -520,7 +522,7 @@ public class ImaUtilTest { ...@@ -520,7 +522,7 @@ public class ImaUtilTest {
// around removed. // around removed.
DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US + periodDurationUs + 2) DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US + periodDurationUs + 2)
.withAdCount(/* adGroupIndex= */ 0, 1) .withAdCount(/* adGroupIndex= */ 0, 1)
.withAdDurationsUs(/* adGroupIndex= */ 0, /* adDurationsUs= */ periodDurationUs) .withAdDurationsUs(/* adGroupIndex= */ 0, /* adDurationsUs...= */ periodDurationUs)
.withIsServerSideInserted(/* adGroupIndex= */ 0, true); .withIsServerSideInserted(/* adGroupIndex= */ 0, true);
FakeTimeline timeline = FakeTimeline timeline =
new FakeTimeline( new FakeTimeline(
...@@ -543,7 +545,7 @@ public class ImaUtilTest { ...@@ -543,7 +545,7 @@ public class ImaUtilTest {
AdPlaybackState adPlaybackState = AdPlaybackState adPlaybackState =
new AdPlaybackState(/* adsId= */ "adsId", periodDurationUs - 1) new AdPlaybackState(/* adsId= */ "adsId", periodDurationUs - 1)
.withAdCount(/* adGroupIndex= */ 0, 1) .withAdCount(/* adGroupIndex= */ 0, 1)
.withAdDurationsUs(/* adGroupIndex= */ 0, /* adDurationsUs= */ periodDurationUs) .withAdDurationsUs(/* adGroupIndex= */ 0, /* adDurationsUs...= */ periodDurationUs)
.withIsServerSideInserted(/* adGroupIndex= */ 0, true); .withIsServerSideInserted(/* adGroupIndex= */ 0, true);
FakeTimeline timeline = FakeTimeline timeline =
new FakeTimeline( new FakeTimeline(
...@@ -567,7 +569,7 @@ public class ImaUtilTest { ...@@ -567,7 +569,7 @@ public class ImaUtilTest {
AdPlaybackState.NONE, AdPlaybackState.NONE,
/* fromPositionUs= */ 0, /* fromPositionUs= */ 0,
/* contentResumeOffsetUs= */ 0, /* contentResumeOffsetUs= */ 0,
/* adDurationsUs= */ 30_000_000); /* adDurationsUs...= */ 30_000_000);
adPlaybackState = adPlaybackState =
ImaUtil.expandAdGroupPlaceholder( ImaUtil.expandAdGroupPlaceholder(
...@@ -592,7 +594,7 @@ public class ImaUtilTest { ...@@ -592,7 +594,7 @@ public class ImaUtilTest {
AdPlaybackState.NONE, AdPlaybackState.NONE,
/* fromPositionUs= */ 0, /* fromPositionUs= */ 0,
/* contentResumeOffsetUs= */ 0, /* contentResumeOffsetUs= */ 0,
/* adDurationsUs= */ 30_000_000); /* adDurationsUs...= */ 30_000_000);
adPlaybackState = adPlaybackState =
ImaUtil.expandAdGroupPlaceholder( ImaUtil.expandAdGroupPlaceholder(
...@@ -617,7 +619,7 @@ public class ImaUtilTest { ...@@ -617,7 +619,7 @@ public class ImaUtilTest {
AdPlaybackState.NONE, AdPlaybackState.NONE,
/* fromPositionUs= */ 0, /* fromPositionUs= */ 0,
/* contentResumeOffsetUs= */ 0, /* contentResumeOffsetUs= */ 0,
/* adDurationsUs= */ 30_000_000); /* adDurationsUs...= */ 30_000_000);
adPlaybackState = adPlaybackState =
ImaUtil.expandAdGroupPlaceholder( ImaUtil.expandAdGroupPlaceholder(
...@@ -642,7 +644,7 @@ public class ImaUtilTest { ...@@ -642,7 +644,7 @@ public class ImaUtilTest {
AdPlaybackState.NONE, AdPlaybackState.NONE,
/* fromPositionUs= */ 0, /* fromPositionUs= */ 0,
/* contentResumeOffsetUs= */ 0, /* contentResumeOffsetUs= */ 0,
/* adDurationsUs= */ 30_000_000); /* adDurationsUs...= */ 30_000_000);
adPlaybackState = adPlaybackState =
ImaUtil.expandAdGroupPlaceholder( ImaUtil.expandAdGroupPlaceholder(
...@@ -665,7 +667,7 @@ public class ImaUtilTest { ...@@ -665,7 +667,7 @@ public class ImaUtilTest {
AdPlaybackState.NONE, AdPlaybackState.NONE,
/* fromPositionUs= */ 0, /* fromPositionUs= */ 0,
/* contentResumeOffsetUs= */ 0, /* contentResumeOffsetUs= */ 0,
/* adDurationsUs= */ 10_000_001); /* adDurationsUs...= */ 10_000_001);
adPlaybackState = adPlaybackState =
ImaUtil.expandAdGroupPlaceholder( ImaUtil.expandAdGroupPlaceholder(
...@@ -688,7 +690,7 @@ public class ImaUtilTest { ...@@ -688,7 +690,7 @@ public class ImaUtilTest {
AdPlaybackState.NONE, AdPlaybackState.NONE,
/* fromPositionUs= */ 0, /* fromPositionUs= */ 0,
/* contentResumeOffsetUs= */ 0, /* contentResumeOffsetUs= */ 0,
/* adDurationsUs= */ 30_000_000); /* adDurationsUs...= */ 30_000_000);
adPlaybackState = adPlaybackState =
ImaUtil.expandAdGroupPlaceholder( ImaUtil.expandAdGroupPlaceholder(
...@@ -712,7 +714,7 @@ public class ImaUtilTest { ...@@ -712,7 +714,7 @@ public class ImaUtilTest {
AdPlaybackState.NONE, AdPlaybackState.NONE,
/* fromPositionUs= */ 0, /* fromPositionUs= */ 0,
/* contentResumeOffsetUs= */ 0, /* contentResumeOffsetUs= */ 0,
/* adDurationsUs= */ 10_000_000, /* adDurationsUs...= */ 10_000_000,
20_000_000, 20_000_000,
0); 0);
...@@ -737,7 +739,7 @@ public class ImaUtilTest { ...@@ -737,7 +739,7 @@ public class ImaUtilTest {
AdPlaybackState.NONE, AdPlaybackState.NONE,
/* fromPositionUs= */ 0, /* fromPositionUs= */ 0,
/* contentResumeOffsetUs= */ 0, /* contentResumeOffsetUs= */ 0,
/* adDurationsUs= */ 0, /* adDurationsUs...= */ 0,
10_000_000, 10_000_000,
20_000_000); 20_000_000);
...@@ -762,7 +764,7 @@ public class ImaUtilTest { ...@@ -762,7 +764,7 @@ public class ImaUtilTest {
AdPlaybackState.NONE, AdPlaybackState.NONE,
/* fromPositionUs= */ 0, /* fromPositionUs= */ 0,
/* contentResumeOffsetUs= */ 0, /* contentResumeOffsetUs= */ 0,
/* adDurationsUs= */ 5_000_000, /* adDurationsUs...= */ 5_000_000,
10_000_000, 10_000_000,
20_000_000); 20_000_000);
......
...@@ -264,7 +264,7 @@ public final class LeanbackPlayerAdapter extends PlayerAdapter implements Runnab ...@@ -264,7 +264,7 @@ public final class LeanbackPlayerAdapter extends PlayerAdapter implements Runnab
// int arguments (int what, int extra). Since PlaybackException defines a single error // int arguments (int what, int extra). Since PlaybackException defines a single error
// code, we pass 0 as the extra. // code, we pass 0 as the extra.
context.getString( context.getString(
R.string.lb_media_player_error, /* formatArgs= */ error.errorCode, 0)); R.string.lb_media_player_error, /* formatArgs...= */ error.errorCode, 0));
} }
} }
......
...@@ -81,7 +81,7 @@ public class AdPlaybackStateTest { ...@@ -81,7 +81,7 @@ public class AdPlaybackStateTest {
@Test @Test
public void withAdGroupTimeUs_updatesAdGroupTimeUs() { public void withAdGroupTimeUs_updatesAdGroupTimeUs() {
AdPlaybackState state = AdPlaybackState state =
new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs= */ 0, 5_000, 10_000) new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */ 0, 5_000, 10_000)
.withRemovedAdGroupCount(1); .withRemovedAdGroupCount(1);
state = state =
...@@ -97,7 +97,7 @@ public class AdPlaybackStateTest { ...@@ -97,7 +97,7 @@ public class AdPlaybackStateTest {
@Test @Test
public void withNewAdGroup_addsGroupAndKeepsExistingGroups() { public void withNewAdGroup_addsGroupAndKeepsExistingGroups() {
AdPlaybackState state = AdPlaybackState state =
new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs= */ 0, 3_000, 6_000) new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */ 0, 3_000, 6_000)
.withRemovedAdGroupCount(1) .withRemovedAdGroupCount(1)
.withAdCount(/* adGroupIndex= */ 1, /* adCount= */ 2) .withAdCount(/* adGroupIndex= */ 1, /* adCount= */ 2)
.withAdCount(/* adGroupIndex= */ 2, /* adCount= */ 1) .withAdCount(/* adGroupIndex= */ 2, /* adCount= */ 1)
...@@ -123,12 +123,12 @@ public class AdPlaybackStateTest { ...@@ -123,12 +123,12 @@ public class AdPlaybackStateTest {
@Test @Test
public void withAdDurationsUs_updatesAdDurations() { public void withAdDurationsUs_updatesAdDurations() {
AdPlaybackState state = AdPlaybackState state =
new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs= */ 0, 10_000) new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */ 0, 10_000)
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 2) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 2)
.withAdCount(/* adGroupIndex= */ 1, /* adCount= */ 2) .withAdCount(/* adGroupIndex= */ 1, /* adCount= */ 2)
.withAdDurationsUs(new long[][] {new long[] {5_000, 6_000}, new long[] {7_000, 8_000}}); .withAdDurationsUs(new long[][] {new long[] {5_000, 6_000}, new long[] {7_000, 8_000}});
state = state.withAdDurationsUs(/* adGroupIndex= */ 1, /* adDurationsUs= */ 1_000, 2_000); state = state.withAdDurationsUs(/* adGroupIndex= */ 1, /* adDurationsUs...= */ 1_000, 2_000);
assertThat(state.getAdGroup(0).durationsUs[0]).isEqualTo(5_000); assertThat(state.getAdGroup(0).durationsUs[0]).isEqualTo(5_000);
assertThat(state.getAdGroup(0).durationsUs[1]).isEqualTo(6_000); assertThat(state.getAdGroup(0).durationsUs[1]).isEqualTo(6_000);
...@@ -315,7 +315,7 @@ public class AdPlaybackStateTest { ...@@ -315,7 +315,7 @@ public class AdPlaybackStateTest {
@Test @Test
public void withOriginalAdCount() { public void withOriginalAdCount() {
AdPlaybackState state = AdPlaybackState state =
new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs= */ 5_000_000) new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */ 5_000_000)
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 2); .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 2);
state = state.withOriginalAdCount(/* adGroupIndex= */ 0, /* originalAdCount= */ 3); state = state.withOriginalAdCount(/* adGroupIndex= */ 0, /* originalAdCount= */ 3);
...@@ -327,7 +327,7 @@ public class AdPlaybackStateTest { ...@@ -327,7 +327,7 @@ public class AdPlaybackStateTest {
@Test @Test
public void withOriginalAdCount_unsetValue_defaultsToIndexUnset() { public void withOriginalAdCount_unsetValue_defaultsToIndexUnset() {
AdPlaybackState state = AdPlaybackState state =
new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs= */ 5_000_000) new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */ 5_000_000)
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 2); .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 2);
assertThat(state.getAdGroup(0).count).isEqualTo(2); assertThat(state.getAdGroup(0).count).isEqualTo(2);
...@@ -336,7 +336,7 @@ public class AdPlaybackStateTest { ...@@ -336,7 +336,7 @@ public class AdPlaybackStateTest {
@Test @Test
public void withLastAdGroupRemoved() { public void withLastAdGroupRemoved() {
AdPlaybackState state = new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs= */ 5_000_000); AdPlaybackState state = new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */ 5_000_000);
state = state =
state state
.withAdCount(/* adGroupIndex= */ 0, 3) .withAdCount(/* adGroupIndex= */ 0, 3)
...@@ -363,7 +363,7 @@ public class AdPlaybackStateTest { ...@@ -363,7 +363,7 @@ public class AdPlaybackStateTest {
state = state.withAdCount(/* adGroupIndex= */ 1, /* adCount= */ 5); state = state.withAdCount(/* adGroupIndex= */ 1, /* adCount= */ 5);
state = state =
state.withAdDurationsUs( state.withAdDurationsUs(
/* adGroupIndex= */ 1, /* adDurationsUs= */ 1_000L, 2_000L, 3_000L, 4_000L, 5_000L); /* adGroupIndex= */ 1, /* adDurationsUs...= */ 1_000L, 2_000L, 3_000L, 4_000L, 5_000L);
state = state.withAvailableAdUri(/* adGroupIndex= */ 1, /* adIndexInAdGroup= */ 1, TEST_URI); state = state.withAvailableAdUri(/* adGroupIndex= */ 1, /* adIndexInAdGroup= */ 1, TEST_URI);
state = state.withAvailableAdUri(/* adGroupIndex= */ 1, /* adIndexInAdGroup= */ 2, TEST_URI); state = state.withAvailableAdUri(/* adGroupIndex= */ 1, /* adIndexInAdGroup= */ 2, TEST_URI);
state = state.withAvailableAdUri(/* adGroupIndex= */ 1, /* adIndexInAdGroup= */ 3, TEST_URI); state = state.withAvailableAdUri(/* adGroupIndex= */ 1, /* adIndexInAdGroup= */ 3, TEST_URI);
...@@ -419,8 +419,8 @@ public class AdPlaybackStateTest { ...@@ -419,8 +419,8 @@ public class AdPlaybackStateTest {
.withContentResumeOffsetUs(/* adGroupIndex= */ 2, /* contentResumeOffsetUs= */ 3333) .withContentResumeOffsetUs(/* adGroupIndex= */ 2, /* contentResumeOffsetUs= */ 3333)
.withIsServerSideInserted(/* adGroupIndex= */ 1, /* isServerSideInserted= */ true) .withIsServerSideInserted(/* adGroupIndex= */ 1, /* isServerSideInserted= */ true)
.withIsServerSideInserted(/* adGroupIndex= */ 2, /* isServerSideInserted= */ true) .withIsServerSideInserted(/* adGroupIndex= */ 2, /* isServerSideInserted= */ true)
.withAdDurationsUs(/* adGroupIndex= */ 1, /* adDurationsUs= */ 12) .withAdDurationsUs(/* adGroupIndex= */ 1, /* adDurationsUs...= */ 12)
.withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs= */ 34, 56) .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs...= */ 34, 56)
.withAdResumePositionUs(123) .withAdResumePositionUs(123)
.withContentDurationUs(456); .withContentDurationUs(456);
...@@ -457,7 +457,7 @@ public class AdPlaybackStateTest { ...@@ -457,7 +457,7 @@ public class AdPlaybackStateTest {
AdPlaybackState state = AdPlaybackState state =
new AdPlaybackState( new AdPlaybackState(
/* adsId= */ new Object(), /* adsId= */ new Object(),
/* adGroupTimesUs= */ 0, /* adGroupTimesUs...= */ 0,
1000, 1000,
2000, 2000,
3000, 3000,
...@@ -540,7 +540,7 @@ public class AdPlaybackStateTest { ...@@ -540,7 +540,7 @@ public class AdPlaybackStateTest {
@Test @Test
public void getAdGroupIndexAfterPositionUs_withServerSideInsertedAds_returnsNextAdGroup() { public void getAdGroupIndexAfterPositionUs_withServerSideInsertedAds_returnsNextAdGroup() {
AdPlaybackState state = AdPlaybackState state =
new AdPlaybackState(/* adsId= */ new Object(), /* adGroupTimesUs= */ 0, 1000, 2000) new AdPlaybackState(/* adsId= */ new Object(), /* adGroupTimesUs...= */ 0, 1000, 2000)
.withIsServerSideInserted(/* adGroupIndex= */ 0, /* isServerSideInserted= */ true) .withIsServerSideInserted(/* adGroupIndex= */ 0, /* isServerSideInserted= */ true)
.withIsServerSideInserted(/* adGroupIndex= */ 1, /* isServerSideInserted= */ true) .withIsServerSideInserted(/* adGroupIndex= */ 1, /* isServerSideInserted= */ true)
.withIsServerSideInserted(/* adGroupIndex= */ 2, /* isServerSideInserted= */ true) .withIsServerSideInserted(/* adGroupIndex= */ 2, /* isServerSideInserted= */ true)
......
...@@ -80,7 +80,7 @@ public final class FlagSetTest { ...@@ -80,7 +80,7 @@ public final class FlagSetTest {
public void containsAny_withoutAdd_returnsFalseForAllValues() { public void containsAny_withoutAdd_returnsFalseForAllValues() {
FlagSet flags = new FlagSet.Builder().build(); FlagSet flags = new FlagSet.Builder().build();
assertThat(flags.containsAny(/* flags= */ -1234, 0, 2, Integer.MAX_VALUE)).isFalse(); assertThat(flags.containsAny(/* flags...= */ -1234, 0, 2, Integer.MAX_VALUE)).isFalse();
} }
@Test @Test
...@@ -95,9 +95,9 @@ public final class FlagSetTest { ...@@ -95,9 +95,9 @@ public final class FlagSetTest {
assertThat( assertThat(
flags.containsAny( flags.containsAny(
/* flags= */ -1235, -1234, 0, 1, 2, Integer.MAX_VALUE - 1, Integer.MAX_VALUE)) /* flags...= */ -1235, -1234, 0, 1, 2, Integer.MAX_VALUE - 1, Integer.MAX_VALUE))
.isTrue(); .isTrue();
assertThat(flags.containsAny(/* flags= */ -1235, 1, Integer.MAX_VALUE - 1)).isFalse(); assertThat(flags.containsAny(/* flags...= */ -1235, 1, Integer.MAX_VALUE - 1)).isFalse();
} }
@Test @Test
......
...@@ -1027,7 +1027,7 @@ public final class DefaultAnalyticsCollectorTest { ...@@ -1027,7 +1027,7 @@ public final class DefaultAnalyticsCollectorTest {
new AtomicReference<>( new AtomicReference<>(
FakeTimeline.createAdPlaybackState( FakeTimeline.createAdPlaybackState(
/* adsPerAdGroup= */ 1, /* adsPerAdGroup= */ 1,
/* adGroupTimesUs= */ windowOffsetInFirstPeriodUs, /* adGroupTimesUs...= */ windowOffsetInFirstPeriodUs,
windowOffsetInFirstPeriodUs + 5 * C.MICROS_PER_SECOND, windowOffsetInFirstPeriodUs + 5 * C.MICROS_PER_SECOND,
C.TIME_END_OF_SOURCE)); C.TIME_END_OF_SOURCE));
AtomicInteger playedAdCount = new AtomicInteger(0); AtomicInteger playedAdCount = new AtomicInteger(0);
...@@ -1300,7 +1300,7 @@ public final class DefaultAnalyticsCollectorTest { ...@@ -1300,7 +1300,7 @@ public final class DefaultAnalyticsCollectorTest {
/* isDynamic= */ false, /* isDynamic= */ false,
10 * C.MICROS_PER_SECOND, 10 * C.MICROS_PER_SECOND,
FakeTimeline.createAdPlaybackState( FakeTimeline.createAdPlaybackState(
/* adsPerAdGroup= */ 1, /* adGroupTimesUs= */ /* adsPerAdGroup= */ 1, /* adGroupTimesUs...= */
windowOffsetInFirstPeriodUs + 5 * C.MICROS_PER_SECOND))); windowOffsetInFirstPeriodUs + 5 * C.MICROS_PER_SECOND)));
FakeMediaSource fakeMediaSource = FakeMediaSource fakeMediaSource =
new FakeMediaSource( new FakeMediaSource(
......
...@@ -289,10 +289,11 @@ public final class SilenceSkippingAudioProcessorTest { ...@@ -289,10 +289,11 @@ public final class SilenceSkippingAudioProcessorTest {
Pcm16BitAudioBuilder audioBuilder = new Pcm16BitAudioBuilder(channelCount, totalFrameCount); Pcm16BitAudioBuilder audioBuilder = new Pcm16BitAudioBuilder(channelCount, totalFrameCount);
while (!audioBuilder.isFull()) { while (!audioBuilder.isFull()) {
int silenceDurationFrames = (silenceDurationMs * sampleRate) / 1000; int silenceDurationFrames = (silenceDurationMs * sampleRate) / 1000;
audioBuilder.appendFrames(/* count= */ silenceDurationFrames, /* channelLevels= */ (short) 0); audioBuilder.appendFrames(
/* count= */ silenceDurationFrames, /* channelLevels...= */ (short) 0);
int noiseDurationFrames = (noiseDurationMs * sampleRate) / 1000; int noiseDurationFrames = (noiseDurationMs * sampleRate) / 1000;
audioBuilder.appendFrames( audioBuilder.appendFrames(
/* count= */ noiseDurationFrames, /* channelLevels= */ Short.MAX_VALUE); /* count= */ noiseDurationFrames, /* channelLevels...= */ Short.MAX_VALUE);
} }
return new InputBufferProvider(audioBuilder.build()); return new InputBufferProvider(audioBuilder.build());
} }
......
...@@ -78,7 +78,7 @@ public final class AdsMediaSourceTest { ...@@ -78,7 +78,7 @@ public final class AdsMediaSourceTest {
CONTENT_TIMELINE.getUidOfPeriod(/* periodIndex= */ 0); CONTENT_TIMELINE.getUidOfPeriod(/* periodIndex= */ 0);
private static final AdPlaybackState AD_PLAYBACK_STATE = private static final AdPlaybackState AD_PLAYBACK_STATE =
new AdPlaybackState(/* adsId= */ new Object(), /* adGroupTimesUs= */ 0) new AdPlaybackState(/* adsId= */ new Object(), /* adGroupTimesUs...= */ 0)
.withContentDurationUs(CONTENT_DURATION_US) .withContentDurationUs(CONTENT_DURATION_US)
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1)
.withAvailableAdUri( .withAvailableAdUri(
......
...@@ -92,16 +92,19 @@ public final class ServerSideAdInsertionMediaSourceTest { ...@@ -92,16 +92,19 @@ public final class ServerSideAdInsertionMediaSourceTest {
// Test with one ad group before the window, and the window starting within the second ad group. // Test with one ad group before the window, and the window starting within the second ad group.
AdPlaybackState adPlaybackState = AdPlaybackState adPlaybackState =
new AdPlaybackState( new AdPlaybackState(
/* adsId= */ new Object(), /* adGroupTimesUs= */ 15_000_000, 41_500_000, 42_200_000) /* adsId= */ new Object(), /* adGroupTimesUs...= */
15_000_000,
41_500_000,
42_200_000)
.withIsServerSideInserted(/* adGroupIndex= */ 0, /* isServerSideInserted= */ true) .withIsServerSideInserted(/* adGroupIndex= */ 0, /* isServerSideInserted= */ true)
.withIsServerSideInserted(/* adGroupIndex= */ 1, /* isServerSideInserted= */ true) .withIsServerSideInserted(/* adGroupIndex= */ 1, /* isServerSideInserted= */ true)
.withIsServerSideInserted(/* adGroupIndex= */ 2, /* isServerSideInserted= */ true) .withIsServerSideInserted(/* adGroupIndex= */ 2, /* isServerSideInserted= */ true)
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1)
.withAdCount(/* adGroupIndex= */ 1, /* adCount= */ 2) .withAdCount(/* adGroupIndex= */ 1, /* adCount= */ 2)
.withAdCount(/* adGroupIndex= */ 2, /* adCount= */ 1) .withAdCount(/* adGroupIndex= */ 2, /* adCount= */ 1)
.withAdDurationsUs(/* adGroupIndex= */ 0, /* adDurationsUs= */ 500_000) .withAdDurationsUs(/* adGroupIndex= */ 0, /* adDurationsUs...= */ 500_000)
.withAdDurationsUs(/* adGroupIndex= */ 1, /* adDurationsUs= */ 300_000, 100_000) .withAdDurationsUs(/* adGroupIndex= */ 1, /* adDurationsUs...= */ 300_000, 100_000)
.withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs= */ 400_000) .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs...= */ 400_000)
.withContentResumeOffsetUs(/* adGroupIndex= */ 0, /* contentResumeOffsetUs= */ 100_000) .withContentResumeOffsetUs(/* adGroupIndex= */ 0, /* contentResumeOffsetUs= */ 100_000)
.withContentResumeOffsetUs(/* adGroupIndex= */ 1, /* contentResumeOffsetUs= */ 400_000) .withContentResumeOffsetUs(/* adGroupIndex= */ 1, /* contentResumeOffsetUs= */ 400_000)
.withContentResumeOffsetUs(/* adGroupIndex= */ 2, /* contentResumeOffsetUs= */ 200_000); .withContentResumeOffsetUs(/* adGroupIndex= */ 2, /* contentResumeOffsetUs= */ 200_000);
...@@ -165,16 +168,19 @@ public final class ServerSideAdInsertionMediaSourceTest { ...@@ -165,16 +168,19 @@ public final class ServerSideAdInsertionMediaSourceTest {
// Test with one ad group before the window, and the window starting within the second ad group. // Test with one ad group before the window, and the window starting within the second ad group.
AdPlaybackState adPlaybackState = AdPlaybackState adPlaybackState =
new AdPlaybackState( new AdPlaybackState(
/* adsId= */ new Object(), /* adGroupTimesUs= */ 15_000_000, 41_500_000, 42_200_000) /* adsId= */ new Object(), /* adGroupTimesUs...= */
15_000_000,
41_500_000,
42_200_000)
.withIsServerSideInserted(/* adGroupIndex= */ 0, /* isServerSideInserted= */ true) .withIsServerSideInserted(/* adGroupIndex= */ 0, /* isServerSideInserted= */ true)
.withIsServerSideInserted(/* adGroupIndex= */ 1, /* isServerSideInserted= */ true) .withIsServerSideInserted(/* adGroupIndex= */ 1, /* isServerSideInserted= */ true)
.withIsServerSideInserted(/* adGroupIndex= */ 2, /* isServerSideInserted= */ true) .withIsServerSideInserted(/* adGroupIndex= */ 2, /* isServerSideInserted= */ true)
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1)
.withAdCount(/* adGroupIndex= */ 1, /* adCount= */ 2) .withAdCount(/* adGroupIndex= */ 1, /* adCount= */ 2)
.withAdCount(/* adGroupIndex= */ 2, /* adCount= */ 1) .withAdCount(/* adGroupIndex= */ 2, /* adCount= */ 1)
.withAdDurationsUs(/* adGroupIndex= */ 0, /* adDurationsUs= */ 500_000) .withAdDurationsUs(/* adGroupIndex= */ 0, /* adDurationsUs...= */ 500_000)
.withAdDurationsUs(/* adGroupIndex= */ 1, /* adDurationsUs= */ 300_000, 100_000) .withAdDurationsUs(/* adGroupIndex= */ 1, /* adDurationsUs...= */ 300_000, 100_000)
.withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs= */ 400_000) .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs...= */ 400_000)
.withContentResumeOffsetUs(/* adGroupIndex= */ 0, /* contentResumeOffsetUs= */ 100_000) .withContentResumeOffsetUs(/* adGroupIndex= */ 0, /* contentResumeOffsetUs= */ 100_000)
.withContentResumeOffsetUs(/* adGroupIndex= */ 1, /* contentResumeOffsetUs= */ 400_000) .withContentResumeOffsetUs(/* adGroupIndex= */ 1, /* contentResumeOffsetUs= */ 400_000)
.withContentResumeOffsetUs(/* adGroupIndex= */ 2, /* contentResumeOffsetUs= */ 200_000); .withContentResumeOffsetUs(/* adGroupIndex= */ 2, /* contentResumeOffsetUs= */ 200_000);
...@@ -259,19 +265,19 @@ public final class ServerSideAdInsertionMediaSourceTest { ...@@ -259,19 +265,19 @@ public final class ServerSideAdInsertionMediaSourceTest {
adPlaybackState, adPlaybackState,
/* fromPositionUs= */ 0, /* fromPositionUs= */ 0,
/* contentResumeOffsetUs= */ 0, /* contentResumeOffsetUs= */ 0,
/* adDurationsUs= */ 200_000); /* adDurationsUs...= */ 200_000);
adPlaybackState = adPlaybackState =
addAdGroupToAdPlaybackState( addAdGroupToAdPlaybackState(
adPlaybackState, adPlaybackState,
/* fromPositionUs= */ 400_000, /* fromPositionUs= */ 400_000,
/* contentResumeOffsetUs= */ 1_000_000, /* contentResumeOffsetUs= */ 1_000_000,
/* adDurationsUs= */ 300_000); /* adDurationsUs...= */ 300_000);
AdPlaybackState firstAdPlaybackState = AdPlaybackState firstAdPlaybackState =
addAdGroupToAdPlaybackState( addAdGroupToAdPlaybackState(
adPlaybackState, adPlaybackState,
/* fromPositionUs= */ 900_000, /* fromPositionUs= */ 900_000,
/* contentResumeOffsetUs= */ 0, /* contentResumeOffsetUs= */ 0,
/* adDurationsUs= */ 100_000); /* adDurationsUs...= */ 100_000);
AtomicReference<ServerSideAdInsertionMediaSource> mediaSourceRef = new AtomicReference<>(); AtomicReference<ServerSideAdInsertionMediaSource> mediaSourceRef = new AtomicReference<>();
mediaSourceRef.set( mediaSourceRef.set(
...@@ -329,7 +335,7 @@ public final class ServerSideAdInsertionMediaSourceTest { ...@@ -329,7 +335,7 @@ public final class ServerSideAdInsertionMediaSourceTest {
new AdPlaybackState(/* adsId= */ new Object()), new AdPlaybackState(/* adsId= */ new Object()),
/* fromPositionUs= */ 900_000, /* fromPositionUs= */ 900_000,
/* contentResumeOffsetUs= */ 0, /* contentResumeOffsetUs= */ 0,
/* adDurationsUs= */ 100_000); /* adDurationsUs...= */ 100_000);
AtomicReference<ServerSideAdInsertionMediaSource> mediaSourceRef = new AtomicReference<>(); AtomicReference<ServerSideAdInsertionMediaSource> mediaSourceRef = new AtomicReference<>();
mediaSourceRef.set( mediaSourceRef.set(
new ServerSideAdInsertionMediaSource( new ServerSideAdInsertionMediaSource(
...@@ -357,7 +363,7 @@ public final class ServerSideAdInsertionMediaSourceTest { ...@@ -357,7 +363,7 @@ public final class ServerSideAdInsertionMediaSourceTest {
firstAdPlaybackState, firstAdPlaybackState,
/* fromPositionUs= */ 0, /* fromPositionUs= */ 0,
/* contentResumeOffsetUs= */ 0, /* contentResumeOffsetUs= */ 0,
/* adDurationsUs= */ 500_000); /* adDurationsUs...= */ 500_000);
mediaSourceRef mediaSourceRef
.get() .get()
.setAdPlaybackStates(ImmutableMap.of(periodUid.get(), secondAdPlaybackState)); .setAdPlaybackStates(ImmutableMap.of(periodUid.get(), secondAdPlaybackState));
...@@ -400,7 +406,7 @@ public final class ServerSideAdInsertionMediaSourceTest { ...@@ -400,7 +406,7 @@ public final class ServerSideAdInsertionMediaSourceTest {
new AdPlaybackState(/* adsId= */ new Object()), new AdPlaybackState(/* adsId= */ new Object()),
/* fromPositionUs= */ 0, /* fromPositionUs= */ 0,
/* contentResumeOffsetUs= */ 0, /* contentResumeOffsetUs= */ 0,
/* adDurationsUs= */ 500_000); /* adDurationsUs...= */ 500_000);
AtomicReference<ServerSideAdInsertionMediaSource> mediaSourceRef = new AtomicReference<>(); AtomicReference<ServerSideAdInsertionMediaSource> mediaSourceRef = new AtomicReference<>();
mediaSourceRef.set( mediaSourceRef.set(
new ServerSideAdInsertionMediaSource( new ServerSideAdInsertionMediaSource(
...@@ -430,7 +436,7 @@ public final class ServerSideAdInsertionMediaSourceTest { ...@@ -430,7 +436,7 @@ public final class ServerSideAdInsertionMediaSourceTest {
firstAdPlaybackState firstAdPlaybackState
.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 3) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 3)
.withAdDurationsUs( .withAdDurationsUs(
/* adGroupIndex= */ 0, /* adDurationsUs= */ 50_000, 250_000, 200_000); /* adGroupIndex= */ 0, /* adDurationsUs...= */ 50_000, 250_000, 200_000);
mediaSourceRef mediaSourceRef
.get() .get()
.setAdPlaybackStates(ImmutableMap.of(periodUid.get(), secondAdPlaybackState)); .setAdPlaybackStates(ImmutableMap.of(periodUid.get(), secondAdPlaybackState));
...@@ -468,19 +474,19 @@ public final class ServerSideAdInsertionMediaSourceTest { ...@@ -468,19 +474,19 @@ public final class ServerSideAdInsertionMediaSourceTest {
adPlaybackState, adPlaybackState,
/* fromPositionUs= */ 0, /* fromPositionUs= */ 0,
/* contentResumeOffsetUs= */ 0, /* contentResumeOffsetUs= */ 0,
/* adDurationsUs= */ 100_000); /* adDurationsUs...= */ 100_000);
adPlaybackState = adPlaybackState =
addAdGroupToAdPlaybackState( addAdGroupToAdPlaybackState(
adPlaybackState, adPlaybackState,
/* fromPositionUs= */ 600_000, /* fromPositionUs= */ 600_000,
/* contentResumeOffsetUs= */ 1_000_000, /* contentResumeOffsetUs= */ 1_000_000,
/* adDurationsUs= */ 100_000); /* adDurationsUs...= */ 100_000);
AdPlaybackState firstAdPlaybackState = AdPlaybackState firstAdPlaybackState =
addAdGroupToAdPlaybackState( addAdGroupToAdPlaybackState(
adPlaybackState, adPlaybackState,
/* fromPositionUs= */ 900_000, /* fromPositionUs= */ 900_000,
/* contentResumeOffsetUs= */ 0, /* contentResumeOffsetUs= */ 0,
/* adDurationsUs= */ 100_000); /* adDurationsUs...= */ 100_000);
AtomicReference<ServerSideAdInsertionMediaSource> mediaSourceRef = new AtomicReference<>(); AtomicReference<ServerSideAdInsertionMediaSource> mediaSourceRef = new AtomicReference<>();
mediaSourceRef.set( mediaSourceRef.set(
......
...@@ -570,9 +570,9 @@ public final class AdaptiveTrackSelectionTest { ...@@ -570,9 +570,9 @@ public final class AdaptiveTrackSelectionTest {
TrackGroup trackGroupMultipleFixed = new TrackGroup(formatFixed1, formatFixed2); TrackGroup trackGroupMultipleFixed = new TrackGroup(formatFixed1, formatFixed2);
TrackGroup trackGroupAdaptive = TrackGroup trackGroupAdaptive =
new TrackGroup(formatAdaptive1, formatAdaptive2, formatAdaptive3, formatAdaptive4); new TrackGroup(formatAdaptive1, formatAdaptive2, formatAdaptive3, formatAdaptive4);
Definition definitionFixed1 = new Definition(trackGroupMultipleFixed, /* tracks= */ 0); Definition definitionFixed1 = new Definition(trackGroupMultipleFixed, /* tracks...= */ 0);
Definition definitionFixed2 = new Definition(trackGroupMultipleFixed, /* tracks= */ 1); Definition definitionFixed2 = new Definition(trackGroupMultipleFixed, /* tracks...= */ 1);
Definition definitionAdaptive = new Definition(trackGroupAdaptive, /* tracks= */ 1, 2, 3); Definition definitionAdaptive = new Definition(trackGroupAdaptive, /* tracks...= */ 1, 2, 3);
List<List<AdaptationCheckpoint>> checkPoints = new ArrayList<>(); List<List<AdaptationCheckpoint>> checkPoints = new ArrayList<>();
AdaptiveTrackSelection.Factory factory = AdaptiveTrackSelection.Factory factory =
new AdaptiveTrackSelection.Factory() { new AdaptiveTrackSelection.Factory() {
...@@ -621,9 +621,9 @@ public final class AdaptiveTrackSelectionTest { ...@@ -621,9 +621,9 @@ public final class AdaptiveTrackSelectionTest {
TrackGroup trackGroup2 = TrackGroup trackGroup2 =
new TrackGroup(group2Format1, group2Format2, group2Format3, group2UnusedFormat); new TrackGroup(group2Format1, group2Format2, group2Format3, group2UnusedFormat);
TrackGroup fixedGroup = new TrackGroup(fixedFormat); TrackGroup fixedGroup = new TrackGroup(fixedFormat);
Definition definition1 = new Definition(trackGroup1, /* tracks= */ 0, 1); Definition definition1 = new Definition(trackGroup1, /* tracks...= */ 0, 1);
Definition definition2 = new Definition(trackGroup2, /* tracks= */ 0, 1, 2); Definition definition2 = new Definition(trackGroup2, /* tracks...= */ 0, 1, 2);
Definition fixedDefinition = new Definition(fixedGroup, /* tracks= */ 0); Definition fixedDefinition = new Definition(fixedGroup, /* tracks...= */ 0);
List<List<AdaptationCheckpoint>> checkPoints = new ArrayList<>(); List<List<AdaptationCheckpoint>> checkPoints = new ArrayList<>();
AdaptiveTrackSelection.Factory factory = AdaptiveTrackSelection.Factory factory =
new AdaptiveTrackSelection.Factory() { new AdaptiveTrackSelection.Factory() {
......
...@@ -2171,8 +2171,10 @@ public final class DefaultTrackSelectorTest { ...@@ -2171,8 +2171,10 @@ public final class DefaultTrackSelectorTest {
TIMELINE); TIMELINE);
assertThat(result.length).isEqualTo(2); assertThat(result.length).isEqualTo(2);
assertAdaptiveSelection(result.selections[0], trackGroups.get(0), /* expectedTracks= */ 1, 0); assertAdaptiveSelection(
assertAdaptiveSelection(result.selections[1], trackGroups.get(1), /* expectedTracks= */ 1, 0); result.selections[0], trackGroups.get(0), /* expectedTracks...= */ 1, 0);
assertAdaptiveSelection(
result.selections[1], trackGroups.get(1), /* expectedTracks...= */ 1, 0);
// Multiple adaptive selection disallowed. // Multiple adaptive selection disallowed.
trackSelector.setParameters( trackSelector.setParameters(
...@@ -2185,7 +2187,8 @@ public final class DefaultTrackSelectorTest { ...@@ -2185,7 +2187,8 @@ public final class DefaultTrackSelectorTest {
TIMELINE); TIMELINE);
assertThat(result.length).isEqualTo(2); assertThat(result.length).isEqualTo(2);
assertAdaptiveSelection(result.selections[0], trackGroups.get(0), /* expectedTracks= */ 1, 0); assertAdaptiveSelection(
result.selections[0], trackGroups.get(0), /* expectedTracks...= */ 1, 0);
assertFixedSelection(result.selections[1], trackGroups.get(1), /* expectedTrack= */ 1); assertFixedSelection(result.selections[1], trackGroups.get(1), /* expectedTrack= */ 1);
} }
...@@ -2229,7 +2232,7 @@ public final class DefaultTrackSelectorTest { ...@@ -2229,7 +2232,7 @@ public final class DefaultTrackSelectorTest {
trackSelector.selectTracks( trackSelector.selectTracks(
new RendererCapabilities[] {VIDEO_CAPABILITIES}, trackGroups, periodId, TIMELINE); new RendererCapabilities[] {VIDEO_CAPABILITIES}, trackGroups, periodId, TIMELINE);
assertThat(result.length).isEqualTo(1); assertThat(result.length).isEqualTo(1);
assertAdaptiveSelection(result.selections[0], adaptiveGroup, /* expectedTracks= */ 1, 0); assertAdaptiveSelection(result.selections[0], adaptiveGroup, /* expectedTracks...= */ 1, 0);
// Select default (=most tracks) if no preference is specified. // Select default (=most tracks) if no preference is specified.
trackSelector.setParameters(defaultParameters.buildUpon().setPreferredVideoMimeType(null)); trackSelector.setParameters(defaultParameters.buildUpon().setPreferredVideoMimeType(null));
...@@ -2237,7 +2240,7 @@ public final class DefaultTrackSelectorTest { ...@@ -2237,7 +2240,7 @@ public final class DefaultTrackSelectorTest {
trackSelector.selectTracks( trackSelector.selectTracks(
new RendererCapabilities[] {VIDEO_CAPABILITIES}, trackGroups, periodId, TIMELINE); new RendererCapabilities[] {VIDEO_CAPABILITIES}, trackGroups, periodId, TIMELINE);
assertThat(result.length).isEqualTo(1); assertThat(result.length).isEqualTo(1);
assertAdaptiveSelection(result.selections[0], adaptiveGroup, /* expectedTracks= */ 1, 0); assertAdaptiveSelection(result.selections[0], adaptiveGroup, /* expectedTracks...= */ 1, 0);
} }
/** /**
...@@ -2416,7 +2419,7 @@ public final class DefaultTrackSelectorTest { ...@@ -2416,7 +2419,7 @@ public final class DefaultTrackSelectorTest {
@Test @Test
public void roundTripViaBundle_ofSelectionOverride_yieldsEqualInstance() { public void roundTripViaBundle_ofSelectionOverride_yieldsEqualInstance() {
SelectionOverride selectionOverrideToBundle = SelectionOverride selectionOverrideToBundle =
new SelectionOverride(/* groupIndex= */ 1, /* tracks= */ 2, 3); new SelectionOverride(/* groupIndex= */ 1, /* tracks...= */ 2, 3);
SelectionOverride selectionOverrideFromBundle = SelectionOverride selectionOverrideFromBundle =
DefaultTrackSelector.SelectionOverride.CREATOR.fromBundle( DefaultTrackSelector.SelectionOverride.CREATOR.fromBundle(
......
...@@ -687,7 +687,7 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsPlaylistTracker.Pla ...@@ -687,7 +687,7 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsPlaylistTracker.Pla
sampleStreamWrapper.prepareWithMultivariantPlaylistInfo( sampleStreamWrapper.prepareWithMultivariantPlaylistInfo(
muxedTrackGroups.toArray(new TrackGroup[0]), muxedTrackGroups.toArray(new TrackGroup[0]),
/* primaryTrackGroupIndex= */ 0, /* primaryTrackGroupIndex= */ 0,
/* optionalTrackGroupsIndices= */ muxedTrackGroups.indexOf(id3TrackGroup)); /* optionalTrackGroupsIndices...= */ muxedTrackGroups.indexOf(id3TrackGroup));
} }
} }
......
...@@ -24,8 +24,6 @@ import static com.google.android.exoplayer2.util.Assertions.checkNotNull; ...@@ -24,8 +24,6 @@ import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import android.content.Context; import android.content.Context;
import android.os.Handler; import android.os.Handler;
import android.os.Looper;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.DefaultLoadControl; import com.google.android.exoplayer2.DefaultLoadControl;
import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayer;
...@@ -64,31 +62,16 @@ import com.google.android.exoplayer2.video.VideoRendererEventListener; ...@@ -64,31 +62,16 @@ import com.google.android.exoplayer2.video.VideoRendererEventListener;
void onError(Exception e); void onError(Exception e);
} }
private final Context context; private final ExoPlayer player;
private final boolean removeAudio;
private final boolean removeVideo;
private final MediaSource.Factory mediaSourceFactory;
private final Looper looper;
private final Clock clock;
@Nullable private ExoPlayer player;
public ExoPlayerAssetLoader( public ExoPlayerAssetLoader(
Context context, Context context,
MediaItem mediaItem,
boolean removeAudio, boolean removeAudio,
boolean removeVideo, boolean removeVideo,
MediaSource.Factory mediaSourceFactory, MediaSource.Factory mediaSourceFactory,
Looper looper, Listener listener,
Clock clock) { Clock clock) {
this.context = context;
this.removeAudio = removeAudio;
this.removeVideo = removeVideo;
this.mediaSourceFactory = mediaSourceFactory;
this.looper = looper;
this.clock = clock;
}
public void start(MediaItem mediaItem, Listener listener) {
DefaultTrackSelector trackSelector = new DefaultTrackSelector(context); DefaultTrackSelector trackSelector = new DefaultTrackSelector(context);
trackSelector.setParameters( trackSelector.setParameters(
new DefaultTrackSelector.Parameters.Builder(context) new DefaultTrackSelector.Parameters.Builder(context)
...@@ -108,8 +91,7 @@ import com.google.android.exoplayer2.video.VideoRendererEventListener; ...@@ -108,8 +91,7 @@ import com.google.android.exoplayer2.video.VideoRendererEventListener;
new ExoPlayer.Builder(context, new RenderersFactoryImpl(removeAudio, removeVideo, listener)) new ExoPlayer.Builder(context, new RenderersFactoryImpl(removeAudio, removeVideo, listener))
.setMediaSourceFactory(mediaSourceFactory) .setMediaSourceFactory(mediaSourceFactory)
.setTrackSelector(trackSelector) .setTrackSelector(trackSelector)
.setLoadControl(loadControl) .setLoadControl(loadControl);
.setLooper(looper);
if (clock != Clock.DEFAULT) { if (clock != Clock.DEFAULT) {
// Transformer.Builder#setClock is also @VisibleForTesting, so if we're using a non-default // Transformer.Builder#setClock is also @VisibleForTesting, so if we're using a non-default
// clock we must be in a test context. // clock we must be in a test context.
...@@ -120,14 +102,14 @@ import com.google.android.exoplayer2.video.VideoRendererEventListener; ...@@ -120,14 +102,14 @@ import com.google.android.exoplayer2.video.VideoRendererEventListener;
player = playerBuilder.build(); player = playerBuilder.build();
player.setMediaItem(mediaItem); player.setMediaItem(mediaItem);
player.addListener(new PlayerListener(listener)); player.addListener(new PlayerListener(listener));
}
public void start() {
player.prepare(); player.prepare();
} }
public void release() { public void release() {
if (player != null) { player.release();
player.release();
player = null;
}
} }
private static final class RenderersFactoryImpl implements RenderersFactory { private static final class RenderersFactoryImpl implements RenderersFactory {
......
...@@ -67,7 +67,7 @@ public class FakeTrackSelector extends DefaultTrackSelector { ...@@ -67,7 +67,7 @@ public class FakeTrackSelector extends DefaultTrackSelector {
boolean hasTracks = trackGroupArray.length > 0; boolean hasTracks = trackGroupArray.length > 0;
definitions[i] = definitions[i] =
hasTracks hasTracks
? new ExoTrackSelection.Definition(trackGroupArray.get(0), /* tracks= */ 0) ? new ExoTrackSelection.Definition(trackGroupArray.get(0), /* tracks...= */ 0)
: null; : null;
} }
return definitions; return definitions;
......
...@@ -39,7 +39,7 @@ public class FakeTimelineTest { ...@@ -39,7 +39,7 @@ public class FakeTimelineTest {
FakeTimeline.createMultiPeriodAdTimeline( FakeTimeline.createMultiPeriodAdTimeline(
windowId, windowId,
numberOfPlayedAds, numberOfPlayedAds,
/* isAdPeriodFlags= */ true, /* isAdPeriodFlags...= */ true,
false, false,
true, true,
true, true,
...@@ -94,7 +94,7 @@ public class FakeTimelineTest { ...@@ -94,7 +94,7 @@ public class FakeTimelineTest {
FakeTimeline.createMultiPeriodAdTimeline( FakeTimeline.createMultiPeriodAdTimeline(
/* windowId= */ new Object(), /* windowId= */ new Object(),
/* numberOfPlayedAds= */ 0, /* numberOfPlayedAds= */ 0,
/* isAdPeriodFlags= */ false, /* isAdPeriodFlags...= */ false,
true, true,
true, true,
false); false);
......
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