diff --git a/libraries/common/src/test/java/androidx/media3/common/AdPlaybackStateTest.java b/libraries/common/src/test/java/androidx/media3/common/AdPlaybackStateTest.java index 9110e6ec57..d398cd5b0f 100644 --- a/libraries/common/src/test/java/androidx/media3/common/AdPlaybackStateTest.java +++ b/libraries/common/src/test/java/androidx/media3/common/AdPlaybackStateTest.java @@ -80,7 +80,7 @@ public class AdPlaybackStateTest { @Test public void withAdGroupTimeUs_updatesAdGroupTimeUs() { 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); state = @@ -96,7 +96,7 @@ public class AdPlaybackStateTest { @Test public void withNewAdGroup_addsGroupAndKeepsExistingGroups() { 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) .withAdCount(/* adGroupIndex= */ 1, /* adCount= */ 2) .withAdCount(/* adGroupIndex= */ 2, /* adCount= */ 1) @@ -122,12 +122,12 @@ public class AdPlaybackStateTest { @Test public void withAdDurationsUs_updatesAdDurations() { 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= */ 1, /* adCount= */ 2) .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[1]).isEqualTo(6_000); @@ -314,7 +314,7 @@ public class AdPlaybackStateTest { @Test public void withOriginalAdCount() { 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); state = state.withOriginalAdCount(/* adGroupIndex= */ 0, /* originalAdCount= */ 3); @@ -326,7 +326,7 @@ public class AdPlaybackStateTest { @Test public void withOriginalAdCount_unsetValue_defaultsToIndexUnset() { 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); assertThat(state.getAdGroup(0).count).isEqualTo(2); @@ -335,7 +335,7 @@ public class AdPlaybackStateTest { @Test 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 .withAdCount(/* adGroupIndex= */ 0, 3) @@ -362,7 +362,7 @@ public class AdPlaybackStateTest { state = state.withAdCount(/* adGroupIndex= */ 1, /* adCount= */ 5); state = 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= */ 2, TEST_URI); state = state.withAvailableAdUri(/* adGroupIndex= */ 1, /* adIndexInAdGroup= */ 3, TEST_URI); @@ -418,8 +418,8 @@ public class AdPlaybackStateTest { .withContentResumeOffsetUs(/* adGroupIndex= */ 2, /* contentResumeOffsetUs= */ 3333) .withIsServerSideInserted(/* adGroupIndex= */ 1, /* isServerSideInserted= */ true) .withIsServerSideInserted(/* adGroupIndex= */ 2, /* isServerSideInserted= */ true) - .withAdDurationsUs(/* adGroupIndex= */ 1, /* adDurationsUs= */ 12) - .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs= */ 34, 56) + .withAdDurationsUs(/* adGroupIndex= */ 1, /* adDurationsUs...= */ 12) + .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs...= */ 34, 56) .withAdResumePositionUs(123) .withContentDurationUs(456); @@ -456,7 +456,7 @@ public class AdPlaybackStateTest { AdPlaybackState state = new AdPlaybackState( /* adsId= */ new Object(), - /* adGroupTimesUs= */ 0, + /* adGroupTimesUs...= */ 0, 1000, 2000, 3000, @@ -539,7 +539,7 @@ public class AdPlaybackStateTest { @Test public void getAdGroupIndexAfterPositionUs_withServerSideInsertedAds_returnsNextAdGroup() { 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= */ 1, /* isServerSideInserted= */ true) .withIsServerSideInserted(/* adGroupIndex= */ 2, /* isServerSideInserted= */ true) diff --git a/libraries/common/src/test/java/androidx/media3/common/FlagSetTest.java b/libraries/common/src/test/java/androidx/media3/common/FlagSetTest.java index 5a07be222b..b01ab87df3 100644 --- a/libraries/common/src/test/java/androidx/media3/common/FlagSetTest.java +++ b/libraries/common/src/test/java/androidx/media3/common/FlagSetTest.java @@ -80,7 +80,7 @@ public final class FlagSetTest { public void containsAny_withoutAdd_returnsFalseForAllValues() { 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 @@ -95,9 +95,9 @@ public final class FlagSetTest { assertThat( 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(); - assertThat(flags.containsAny(/* flags= */ -1235, 1, Integer.MAX_VALUE - 1)).isFalse(); + assertThat(flags.containsAny(/* flags...= */ -1235, 1, Integer.MAX_VALUE - 1)).isFalse(); } @Test diff --git a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/ExoPlayerTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/ExoPlayerTest.java index b01c457341..4afbf6aef9 100644 --- a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/ExoPlayerTest.java +++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/ExoPlayerTest.java @@ -756,7 +756,7 @@ public final class ExoPlayerTest { public void adGroupWithLoadError_noFurtherAdGroup_isSkipped() throws Exception { AdPlaybackState initialAdPlaybackState = FakeTimeline.createAdPlaybackState( - /* adsPerAdGroup= */ 1, /* adGroupTimesUs= */ + /* adsPerAdGroup= */ 1, /* adGroupTimesUs...= */ TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US + 5 * C.MICROS_PER_SECOND); Timeline fakeTimeline = @@ -809,7 +809,7 @@ public final class ExoPlayerTest { public void adGroupWithLoadError_withFurtherAdGroup_isSkipped() throws Exception { AdPlaybackState initialAdPlaybackState = FakeTimeline.createAdPlaybackState( - /* adsPerAdGroup= */ 1, /* adGroupTimesUs= */ + /* adsPerAdGroup= */ 1, /* adGroupTimesUs...= */ TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US + 5 * C.MICROS_PER_SECOND, TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US @@ -2938,7 +2938,8 @@ public final class ExoPlayerTest { AdPlaybackState adPlaybackStateWithMidroll = FakeTimeline.createAdPlaybackState( /* adsPerAdGroup= */ 1, - /* adGroupTimesUs= */ TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US + /* adGroupTimesUs...= */ TimelineWindowDefinition + .DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US + 5 * C.MICROS_PER_SECOND); Timeline timeline2 = new FakeTimeline( @@ -2989,7 +2990,8 @@ public final class ExoPlayerTest { AdPlaybackState adPlaybackState = FakeTimeline.createAdPlaybackState( /* adsPerAdGroup= */ 1, - /* adGroupTimesUs= */ TimelineWindowDefinition.DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US + /* adGroupTimesUs...= */ TimelineWindowDefinition + .DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US + Util.msToUs(adGroupWindowTimeMs)); Timeline timeline = new FakeTimeline( @@ -3622,7 +3624,7 @@ public final class ExoPlayerTest { @Test public void contentWithInitialSeekPositionAfterPrerollAdStartsAtSeekPosition() throws Exception { AdPlaybackState adPlaybackState = - FakeTimeline.createAdPlaybackState(/* adsPerAdGroup= */ 3, /* adGroupTimesUs= */ 0); + FakeTimeline.createAdPlaybackState(/* adsPerAdGroup= */ 3, /* adGroupTimesUs...= */ 0); Timeline fakeTimeline = new FakeTimeline( new TimelineWindowDefinition( @@ -3671,7 +3673,7 @@ public final class ExoPlayerTest { @Test public void contentWithoutInitialSeekStartsAtDefaultPositionAfterPrerollAd() throws Exception { AdPlaybackState adPlaybackState = - FakeTimeline.createAdPlaybackState(/* adsPerAdGroup= */ 3, /* adGroupTimesUs= */ 0); + FakeTimeline.createAdPlaybackState(/* adsPerAdGroup= */ 3, /* adGroupTimesUs...= */ 0); Timeline fakeTimeline = new FakeTimeline( new TimelineWindowDefinition( @@ -3725,7 +3727,7 @@ public final class ExoPlayerTest { ExoPlayer player = new TestExoPlayerBuilder(context).build(); AdPlaybackState adPlaybackState = FakeTimeline.createAdPlaybackState( - /* adsPerAdGroup= */ 1, /* adGroupTimesUs= */ 42_000_004_000_000L); + /* adsPerAdGroup= */ 1, /* adGroupTimesUs...= */ 42_000_004_000_000L); Timeline liveTimeline1 = new FakeTimeline( new TimelineWindowDefinition( @@ -4730,7 +4732,7 @@ public final class ExoPlayerTest { long contentDurationMs = 10_000; long adDurationMs = 100_000; AdPlaybackState adPlaybackState = - new AdPlaybackState(/* adsId= */ new Object(), /* adGroupTimesUs= */ 0); + new AdPlaybackState(/* adsId= */ new Object(), /* adGroupTimesUs...= */ 0); adPlaybackState = adPlaybackState.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1); adPlaybackState = adPlaybackState.withAvailableAdUri( @@ -4832,7 +4834,7 @@ public final class ExoPlayerTest { long contentDurationMs = 10_000; long adDurationMs = 4_000; AdPlaybackState adPlaybackState = - new AdPlaybackState(/* adsId= */ new Object(), /* adGroupTimesUs= */ 0); + new AdPlaybackState(/* adsId= */ new Object(), /* adGroupTimesUs...= */ 0); adPlaybackState = adPlaybackState.withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1); adPlaybackState = adPlaybackState.withAvailableAdUri( @@ -4915,7 +4917,7 @@ public final class ExoPlayerTest { long contentDurationMs = 10_000; long adDurationMs = 4_000; AdPlaybackState adPlaybackState = - new AdPlaybackState(/* adsId= */ new Object(), /* adGroupTimesUs= */ 0) + new AdPlaybackState(/* adsId= */ new Object(), /* adGroupTimesUs...= */ 0) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAvailableAdUri( /* adGroupIndex= */ 0, @@ -4960,7 +4962,7 @@ public final class ExoPlayerTest { FakeTimeline.createMultiPeriodAdTimeline( "windowId", /* numberOfPlayedAds= */ 0, - /* isAdPeriodFlags= */ false, + /* isAdPeriodFlags...= */ false, true, true, false); @@ -5051,7 +5053,7 @@ public final class ExoPlayerTest { FakeTimeline.createMultiPeriodAdTimeline( "windowId", /* numberOfPlayedAds= */ 0, - /* isAdPeriodFlags= */ false, + /* isAdPeriodFlags...= */ false, true, false, false); @@ -5113,7 +5115,7 @@ public final class ExoPlayerTest { FakeTimeline.createMultiPeriodAdTimeline( "windowId", /* numberOfPlayedAds= */ 0, - /* isAdPeriodFlags= */ false, + /* isAdPeriodFlags...= */ false, true, true, false); @@ -5180,7 +5182,7 @@ public final class ExoPlayerTest { FakeTimeline.createMultiPeriodAdTimeline( "windowId", /* numberOfPlayedAds= */ 0, - /* isAdPeriodFlags= */ false, + /* isAdPeriodFlags...= */ false, true, true, false); @@ -5261,7 +5263,7 @@ public final class ExoPlayerTest { FakeTimeline.createMultiPeriodAdTimeline( "windowId", /* numberOfPlayedAds= */ 2, - /* isAdPeriodFlags= */ false, + /* isAdPeriodFlags...= */ false, true, true, false); @@ -5316,7 +5318,7 @@ public final class ExoPlayerTest { FakeTimeline.createMultiPeriodAdTimeline( "windowId", /* numberOfPlayedAds= */ Integer.MAX_VALUE, - /* isAdPeriodFlags= */ true, + /* isAdPeriodFlags...= */ true, false, true, true, @@ -5384,28 +5386,28 @@ public final class ExoPlayerTest { new AdPlaybackState("adsId"), /* fromPositionUs= */ DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ C.MICROS_PER_SECOND); + /* adDurationsUs...= */ C.MICROS_PER_SECOND); adPlaybackState = addAdGroupToAdPlaybackState( adPlaybackState, /* fromPositionUs= */ DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US + (3 * C.MICROS_PER_SECOND), /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ C.MICROS_PER_SECOND); + /* adDurationsUs...= */ C.MICROS_PER_SECOND); adPlaybackState = addAdGroupToAdPlaybackState( adPlaybackState, /* fromPositionUs= */ DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US + (5 * C.MICROS_PER_SECOND), /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ C.MICROS_PER_SECOND); + /* adDurationsUs...= */ C.MICROS_PER_SECOND); adPlaybackState = addAdGroupToAdPlaybackState( adPlaybackState, /* fromPositionUs= */ DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US + (9 * C.MICROS_PER_SECOND), /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ C.MICROS_PER_SECOND); + /* adDurationsUs...= */ C.MICROS_PER_SECOND); adPlaybackState = adPlaybackState.withPlayedAd(/* adGroupIndex= */ 0, /* adIndexInAdGroup+ */ 0); adPlaybackState = @@ -5651,7 +5653,7 @@ public final class ExoPlayerTest { @Test public void shortAdFollowedByUnpreparedAd_playbackDoesNotGetStuck() throws Exception { AdPlaybackState adPlaybackState = - FakeTimeline.createAdPlaybackState(/* adsPerAdGroup= */ 2, /* adGroupTimesUs= */ 0); + FakeTimeline.createAdPlaybackState(/* adsPerAdGroup= */ 2, /* adGroupTimesUs...= */ 0); long shortAdDurationMs = 1_000; adPlaybackState = adPlaybackState.withAdDurationsUs(new long[][] {{shortAdDurationMs, shortAdDurationMs}}); @@ -9063,7 +9065,7 @@ public final class ExoPlayerTest { @Test public void isCommandAvailable_duringAd_isFalseForSeekCommands() throws Exception { AdPlaybackState adPlaybackState = - new AdPlaybackState(/* adsId= */ new Object(), /* adGroupTimesUs= */ 0) + new AdPlaybackState(/* adsId= */ new Object(), /* adGroupTimesUs...= */ 0) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAvailableAdUri( /* adGroupIndex= */ 0, @@ -10034,7 +10036,7 @@ public final class ExoPlayerTest { AdPlaybackState adPlaybackState = FakeTimeline.createAdPlaybackState( /* adsPerAdGroup= */ 1, - /* adGroupTimesUs= */ 0, + /* adGroupTimesUs...= */ 0, 7 * C.MICROS_PER_SECOND, C.TIME_END_OF_SOURCE); TimelineWindowDefinition adTimelineDefinition = @@ -10623,7 +10625,7 @@ public final class ExoPlayerTest { AdPlaybackState adPlaybackState = FakeTimeline.createAdPlaybackState( /* adsPerAdGroup= */ 2, - /* adGroupTimesUs= */ 0, + /* adGroupTimesUs...= */ 0, 7 * C.MICROS_PER_SECOND, C.TIME_END_OF_SOURCE); TimelineWindowDefinition adTimeline = @@ -10760,7 +10762,7 @@ public final class ExoPlayerTest { player.addListener(listener); AdPlaybackState adPlaybackState = FakeTimeline.createAdPlaybackState( - /* adsPerAdGroup= */ 1, /* adGroupTimesUs= */ 2 * C.MICROS_PER_SECOND); + /* adsPerAdGroup= */ 1, /* adGroupTimesUs...= */ 2 * C.MICROS_PER_SECOND); TimelineWindowDefinition adTimeline = new TimelineWindowDefinition( /* periodCount= */ 1, @@ -10849,7 +10851,7 @@ public final class ExoPlayerTest { player.addListener(listener); AdPlaybackState postRollAdPlaybackState = FakeTimeline.createAdPlaybackState( - /* adsPerAdGroup= */ 1, /* adGroupTimesUs= */ C.TIME_END_OF_SOURCE); + /* adsPerAdGroup= */ 1, /* adGroupTimesUs...= */ C.TIME_END_OF_SOURCE); TimelineWindowDefinition postRollWindow = new TimelineWindowDefinition( /* periodCount= */ 1, @@ -10863,7 +10865,7 @@ public final class ExoPlayerTest { /* windowOffsetInFirstPeriodUs= */ 0, postRollAdPlaybackState); AdPlaybackState preRollAdPlaybackState = - FakeTimeline.createAdPlaybackState(/* adsPerAdGroup= */ 1, /* adGroupTimesUs= */ 0); + FakeTimeline.createAdPlaybackState(/* adsPerAdGroup= */ 1, /* adGroupTimesUs...= */ 0); TimelineWindowDefinition preRollWindow = new TimelineWindowDefinition( /* periodCount= */ 1, @@ -11901,7 +11903,8 @@ public final class ExoPlayerTest { .build(); // Live stream timeline with unassigned next ad group. AdPlaybackState initialAdPlaybackState = - new AdPlaybackState(/* adsId= */ new Object(), /* adGroupTimesUs= */ C.TIME_END_OF_SOURCE) + new AdPlaybackState( + /* adsId= */ new Object(), /* adGroupTimesUs...= */ C.TIME_END_OF_SOURCE) .withIsServerSideInserted(/* adGroupIndex= */ 0, /* isServerSideInserted= */ true) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAdDurationsUs(new long[][] {new long[] {10 * C.MICROS_PER_SECOND}}); diff --git a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/MediaPeriodQueueTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/MediaPeriodQueueTest.java index a882a5928c..ca3bd02eeb 100644 --- a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/MediaPeriodQueueTest.java +++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/MediaPeriodQueueTest.java @@ -127,7 +127,7 @@ public final class MediaPeriodQueueTest { @Test public void getNextMediaPeriodInfo_withPrerollAd_returnsCorrectMediaPeriodInfos() { - setupAdTimeline(/* adGroupTimesUs= */ 0); + setupAdTimeline(/* adGroupTimesUs...= */ 0); setAdGroupLoaded(/* adGroupIndex= */ 0); assertNextMediaPeriodInfoIsAd( /* adGroupIndex= */ 0, @@ -149,7 +149,7 @@ public final class MediaPeriodQueueTest { @Test public void getNextMediaPeriodInfo_withMidrollAds_returnsCorrectMediaPeriodInfos() { - setupAdTimeline(/* adGroupTimesUs= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US); + setupAdTimeline(/* adGroupTimesUs...= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US); assertGetNextMediaPeriodInfoReturnsContentMediaPeriod( /* periodUid= */ firstPeriodUid, /* startPositionUs= */ 0, @@ -205,7 +205,7 @@ public final class MediaPeriodQueueTest { @Test public void getNextMediaPeriodInfo_withMidrollAndPostroll_returnsCorrectMediaPeriodInfos() { - setupAdTimeline(/* adGroupTimesUs= */ FIRST_AD_START_TIME_US, C.TIME_END_OF_SOURCE); + setupAdTimeline(/* adGroupTimesUs...= */ FIRST_AD_START_TIME_US, C.TIME_END_OF_SOURCE); assertGetNextMediaPeriodInfoReturnsContentMediaPeriod( /* periodUid= */ firstPeriodUid, /* startPositionUs= */ 0, @@ -259,7 +259,7 @@ public final class MediaPeriodQueueTest { adPlaybackState = new AdPlaybackState( /* adsId= */ new Object(), - /* adGroupTimesUs= */ 0, + /* adGroupTimesUs...= */ 0, FIRST_AD_START_TIME_US, C.TIME_END_OF_SOURCE) .withContentDurationUs(CONTENT_DURATION_US) @@ -330,7 +330,7 @@ public final class MediaPeriodQueueTest { adPlaybackState = new AdPlaybackState( /* adsId= */ new Object(), - /* adGroupTimesUs= */ 0, + /* adGroupTimesUs...= */ 0, FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US) .withContentDurationUs(CONTENT_DURATION_US) @@ -398,7 +398,7 @@ public final class MediaPeriodQueueTest { @Test public void getNextMediaPeriodInfo_withPostrollLoadError_returnsEmptyFinalMediaPeriodInfo() { - setupAdTimeline(/* adGroupTimesUs= */ C.TIME_END_OF_SOURCE); + setupAdTimeline(/* adGroupTimesUs...= */ C.TIME_END_OF_SOURCE); assertGetNextMediaPeriodInfoReturnsContentMediaPeriod( /* periodUid= */ firstPeriodUid, /* startPositionUs= */ 0, @@ -425,7 +425,7 @@ public final class MediaPeriodQueueTest { @Test public void getNextMediaPeriodInfo_withPlayedAdGroups_returnsCorrectMediaPeriodInfos() { - setupAdTimeline(/* adGroupTimesUs= */ 0, FIRST_AD_START_TIME_US, C.TIME_END_OF_SOURCE); + setupAdTimeline(/* adGroupTimesUs...= */ 0, FIRST_AD_START_TIME_US, C.TIME_END_OF_SOURCE); setAdGroupLoaded(/* adGroupIndex= */ 0); setAdGroupLoaded(/* adGroupIndex= */ 1); setAdGroupLoaded(/* adGroupIndex= */ 2); @@ -509,14 +509,14 @@ public final class MediaPeriodQueueTest { @Test public void updateQueuedPeriods_withDurationChangeInPlayingContent_handlesChangeAndRemovesPeriodsAfterChangedPeriod() { - setupAdTimeline(/* adGroupTimesUs= */ FIRST_AD_START_TIME_US); + setupAdTimeline(/* adGroupTimesUs...= */ FIRST_AD_START_TIME_US); setAdGroupLoaded(/* adGroupIndex= */ 0); enqueueNext(); // Content before ad. enqueueNext(); // Ad. enqueueNext(); // Content after ad. // Change position of first ad (= change duration of playing content before first ad). - updateAdPlaybackStateAndTimeline(/* adGroupTimesUs= */ FIRST_AD_START_TIME_US - 2000); + updateAdPlaybackStateAndTimeline(/* adGroupTimesUs...= */ FIRST_AD_START_TIME_US - 2000); setAdGroupLoaded(/* adGroupIndex= */ 0); long maxRendererReadPositionUs = MediaPeriodQueue.INITIAL_RENDERER_POSITION_OFFSET_US + FIRST_AD_START_TIME_US - 3000; @@ -537,14 +537,14 @@ public final class MediaPeriodQueueTest { @Test public void updateQueuedPeriods_withDurationChangeInPlayingContentAfterReadingPosition_doesntHandleChangeAndRemovesPeriodsAfterChangedPeriod() { - setupAdTimeline(/* adGroupTimesUs= */ FIRST_AD_START_TIME_US); + setupAdTimeline(/* adGroupTimesUs...= */ FIRST_AD_START_TIME_US); setAdGroupLoaded(/* adGroupIndex= */ 0); enqueueNext(); // Content before ad. enqueueNext(); // Ad. enqueueNext(); // Content after ad. // Change position of first ad (= change duration of playing content before first ad). - updateAdPlaybackStateAndTimeline(/* adGroupTimesUs= */ FIRST_AD_START_TIME_US - 2000); + updateAdPlaybackStateAndTimeline(/* adGroupTimesUs...= */ FIRST_AD_START_TIME_US - 2000); setAdGroupLoaded(/* adGroupIndex= */ 0); long maxRendererReadPositionUs = MediaPeriodQueue.INITIAL_RENDERER_POSITION_OFFSET_US + FIRST_AD_START_TIME_US - 1000; @@ -579,7 +579,7 @@ public final class MediaPeriodQueueTest { // Change position of first ad (= change duration of playing content before first ad). adPlaybackState = new AdPlaybackState( - /* adsId= */ new Object(), /* adGroupTimesUs= */ FIRST_AD_START_TIME_US - 2000) + /* adsId= */ new Object(), /* adGroupTimesUs...= */ FIRST_AD_START_TIME_US - 2000) .withIsServerSideInserted(/* adGroupIndex= */ 0, /* isServerSideInserted= */ true); updateTimeline(); setAdGroupLoaded(/* adGroupIndex= */ 0); @@ -602,7 +602,7 @@ public final class MediaPeriodQueueTest { @Test public void updateQueuedPeriods_withDurationChangeAfterReadingPeriod_handlesChangeAndRemovesPeriodsAfterChangedPeriod() { - setupAdTimeline(/* adGroupTimesUs= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US); + setupAdTimeline(/* adGroupTimesUs...= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US); setAdGroupLoaded(/* adGroupIndex= */ 0); setAdGroupLoaded(/* adGroupIndex= */ 1); enqueueNext(); // Content before first ad. @@ -612,7 +612,7 @@ public final class MediaPeriodQueueTest { // Change position of second ad (= change duration of content between ads). updateAdPlaybackStateAndTimeline( - /* adGroupTimesUs= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US - 1000); + /* adGroupTimesUs...= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US - 1000); setAdGroupLoaded(/* adGroupIndex= */ 0); setAdGroupLoaded(/* adGroupIndex= */ 1); boolean changeHandled = @@ -628,7 +628,7 @@ public final class MediaPeriodQueueTest { @Test public void updateQueuedPeriods_withDurationChangeBeforeReadingPeriod_doesntHandleChangeAndRemovesPeriodsAfterChangedPeriod() { - setupAdTimeline(/* adGroupTimesUs= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US); + setupAdTimeline(/* adGroupTimesUs...= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US); setAdGroupLoaded(/* adGroupIndex= */ 0); setAdGroupLoaded(/* adGroupIndex= */ 1); enqueueNext(); // Content before first ad. @@ -641,7 +641,7 @@ public final class MediaPeriodQueueTest { // Change position of second ad (= change duration of content between ads). updateAdPlaybackStateAndTimeline( - /* adGroupTimesUs= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US - 1000); + /* adGroupTimesUs...= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US - 1000); setAdGroupLoaded(/* adGroupIndex= */ 0); setAdGroupLoaded(/* adGroupIndex= */ 1); long maxRendererReadPositionUs = @@ -659,7 +659,7 @@ public final class MediaPeriodQueueTest { @Test public void updateQueuedPeriods_withDurationChangeInReadingPeriodAfterReadingPosition_handlesChangeAndRemovesPeriodsAfterChangedPeriod() { - setupAdTimeline(/* adGroupTimesUs= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US); + setupAdTimeline(/* adGroupTimesUs...= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US); setAdGroupLoaded(/* adGroupIndex= */ 0); setAdGroupLoaded(/* adGroupIndex= */ 1); enqueueNext(); // Content before first ad. @@ -671,7 +671,7 @@ public final class MediaPeriodQueueTest { // Change position of second ad (= change duration of content between ads). updateAdPlaybackStateAndTimeline( - /* adGroupTimesUs= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US - 1000); + /* adGroupTimesUs...= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US - 1000); setAdGroupLoaded(/* adGroupIndex= */ 0); setAdGroupLoaded(/* adGroupIndex= */ 1); long readingPositionAtStartOfContentBetweenAds = @@ -691,7 +691,7 @@ public final class MediaPeriodQueueTest { @Test public void updateQueuedPeriods_withDurationChangeInReadingPeriodBeforeReadingPosition_doesntHandleChangeAndRemovesPeriodsAfterChangedPeriod() { - setupAdTimeline(/* adGroupTimesUs= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US); + setupAdTimeline(/* adGroupTimesUs...= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US); setAdGroupLoaded(/* adGroupIndex= */ 0); setAdGroupLoaded(/* adGroupIndex= */ 1); enqueueNext(); // Content before first ad. @@ -703,7 +703,7 @@ public final class MediaPeriodQueueTest { // Change position of second ad (= change duration of content between ads). updateAdPlaybackStateAndTimeline( - /* adGroupTimesUs= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US - 1000); + /* adGroupTimesUs...= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US - 1000); setAdGroupLoaded(/* adGroupIndex= */ 0); setAdGroupLoaded(/* adGroupIndex= */ 1); long readingPositionAtEndOfContentBetweenAds = @@ -723,7 +723,7 @@ public final class MediaPeriodQueueTest { @Test public void updateQueuedPeriods_withDurationChangeInReadingPeriodReadToEnd_doesntHandleChangeAndRemovesPeriodsAfterChangedPeriod() { - setupAdTimeline(/* adGroupTimesUs= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US); + setupAdTimeline(/* adGroupTimesUs...= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US); setAdGroupLoaded(/* adGroupIndex= */ 0); setAdGroupLoaded(/* adGroupIndex= */ 1); enqueueNext(); // Content before first ad. @@ -735,7 +735,7 @@ public final class MediaPeriodQueueTest { // Change position of second ad (= change duration of content between ads). updateAdPlaybackStateAndTimeline( - /* adGroupTimesUs= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US - 1000); + /* adGroupTimesUs...= */ FIRST_AD_START_TIME_US, SECOND_AD_START_TIME_US - 1000); setAdGroupLoaded(/* adGroupIndex= */ 0); setAdGroupLoaded(/* adGroupIndex= */ 1); boolean changeHandled = @@ -838,7 +838,7 @@ public final class MediaPeriodQueueTest { createMultiPeriodServerSideInsertedTimeline( windowId, /* numberOfPlayedAds= */ 0, - /* isAdPeriodFlags= */ true, + /* isAdPeriodFlags...= */ true, false, true, true, @@ -873,7 +873,7 @@ public final class MediaPeriodQueueTest { createMultiPeriodServerSideInsertedTimeline( windowId, /* numberOfPlayedAds= */ 4, - /* isAdPeriodFlags= */ true, + /* isAdPeriodFlags...= */ true, false, true, true, @@ -908,7 +908,7 @@ public final class MediaPeriodQueueTest { createMultiPeriodServerSideInsertedTimeline( windowId, /* numberOfPlayedAds= */ 2, - /* isAdPeriodFlags= */ true, + /* isAdPeriodFlags...= */ true, false, true, true, @@ -932,7 +932,7 @@ public final class MediaPeriodQueueTest { Object windowId = new Object(); Timeline timeline = createMultiPeriodServerSideInsertedTimeline( - windowId, /* numberOfPlayedAds= */ 0, /* isAdPeriodFlags= */ false, true); + windowId, /* numberOfPlayedAds= */ 0, /* isAdPeriodFlags...= */ false, true); MediaPeriodId mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange( @@ -951,7 +951,7 @@ public final class MediaPeriodQueueTest { Object windowId = new Object(); Timeline timeline = createMultiPeriodServerSideInsertedTimeline( - windowId, /* numberOfPlayedAds= */ 0, /* isAdPeriodFlags= */ false, true, false); + windowId, /* numberOfPlayedAds= */ 0, /* isAdPeriodFlags...= */ false, true, false); MediaPeriodId mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange( @@ -970,7 +970,7 @@ public final class MediaPeriodQueueTest { Object windowId = new Object(); Timeline timeline = createMultiPeriodServerSideInsertedTimeline( - windowId, /* numberOfPlayedAds= */ 1, /* isAdPeriodFlags= */ false, true, false); + windowId, /* numberOfPlayedAds= */ 1, /* isAdPeriodFlags...= */ false, true, false); MediaPeriodId mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange( @@ -989,7 +989,7 @@ public final class MediaPeriodQueueTest { Object windowId = new Object(); Timeline timeline = createMultiPeriodServerSideInsertedTimeline( - windowId, /* numberOfPlayedAds= */ 2, /* isAdPeriodFlags= */ true, true, false); + windowId, /* numberOfPlayedAds= */ 2, /* isAdPeriodFlags...= */ true, true, false); MediaPeriodId mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange( timeline, new Pair<>(windowId, 0), /* positionUs= */ 0); @@ -1009,7 +1009,7 @@ public final class MediaPeriodQueueTest { createMultiPeriodServerSideInsertedTimeline( windowId, /* numberOfPlayedAds= */ 4, - /* isAdPeriodFlags= */ false, + /* isAdPeriodFlags...= */ false, true, true, true, @@ -1032,7 +1032,12 @@ public final class MediaPeriodQueueTest { Object windowId = new Object(); Timeline timeline = createMultiPeriodServerSideInsertedTimeline( - windowId, /* numberOfPlayedAds= */ 0, /* isAdPeriodFlags= */ true, false, false, false); + windowId, + /* numberOfPlayedAds= */ 0, + /* isAdPeriodFlags...= */ true, + false, + false, + false); MediaPeriodId mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange( @@ -1053,7 +1058,7 @@ public final class MediaPeriodQueueTest { createMultiPeriodServerSideInsertedTimeline( windowId, /* numberOfPlayedAds= */ 0, - /* isAdPeriodFlags= */ false, + /* isAdPeriodFlags...= */ false, false, false, false); diff --git a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/analytics/DefaultAnalyticsCollectorTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/analytics/DefaultAnalyticsCollectorTest.java index 36180e4e21..c25ddebdcf 100644 --- a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/analytics/DefaultAnalyticsCollectorTest.java +++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/analytics/DefaultAnalyticsCollectorTest.java @@ -1027,7 +1027,7 @@ public final class DefaultAnalyticsCollectorTest { new AtomicReference<>( FakeTimeline.createAdPlaybackState( /* adsPerAdGroup= */ 1, - /* adGroupTimesUs= */ windowOffsetInFirstPeriodUs, + /* adGroupTimesUs...= */ windowOffsetInFirstPeriodUs, windowOffsetInFirstPeriodUs + 5 * C.MICROS_PER_SECOND, C.TIME_END_OF_SOURCE)); AtomicInteger playedAdCount = new AtomicInteger(0); @@ -1300,7 +1300,7 @@ public final class DefaultAnalyticsCollectorTest { /* isDynamic= */ false, 10 * C.MICROS_PER_SECOND, FakeTimeline.createAdPlaybackState( - /* adsPerAdGroup= */ 1, /* adGroupTimesUs= */ + /* adsPerAdGroup= */ 1, /* adGroupTimesUs...= */ windowOffsetInFirstPeriodUs + 5 * C.MICROS_PER_SECOND))); FakeMediaSource fakeMediaSource = new FakeMediaSource( diff --git a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/audio/SilenceSkippingAudioProcessorTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/audio/SilenceSkippingAudioProcessorTest.java index a4577a5ae9..e9dfdf3e8e 100644 --- a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/audio/SilenceSkippingAudioProcessorTest.java +++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/audio/SilenceSkippingAudioProcessorTest.java @@ -289,10 +289,11 @@ public final class SilenceSkippingAudioProcessorTest { Pcm16BitAudioBuilder audioBuilder = new Pcm16BitAudioBuilder(channelCount, totalFrameCount); while (!audioBuilder.isFull()) { int silenceDurationFrames = (silenceDurationMs * sampleRate) / 1000; - audioBuilder.appendFrames(/* count= */ silenceDurationFrames, /* channelLevels= */ (short) 0); + audioBuilder.appendFrames( + /* count= */ silenceDurationFrames, /* channelLevels...= */ (short) 0); int noiseDurationFrames = (noiseDurationMs * sampleRate) / 1000; audioBuilder.appendFrames( - /* count= */ noiseDurationFrames, /* channelLevels= */ Short.MAX_VALUE); + /* count= */ noiseDurationFrames, /* channelLevels...= */ Short.MAX_VALUE); } return new InputBufferProvider(audioBuilder.build()); } diff --git a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/source/ads/AdsMediaSourceTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/source/ads/AdsMediaSourceTest.java index fc2198d049..53366ff2ba 100644 --- a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/source/ads/AdsMediaSourceTest.java +++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/source/ads/AdsMediaSourceTest.java @@ -79,7 +79,7 @@ public final class AdsMediaSourceTest { CONTENT_TIMELINE.getUidOfPeriod(/* periodIndex= */ 0); 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) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAvailableAdUri( diff --git a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/source/ads/ServerSideAdInsertionMediaSourceTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/source/ads/ServerSideAdInsertionMediaSourceTest.java index dc88f57e21..da101f451c 100644 --- a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/source/ads/ServerSideAdInsertionMediaSourceTest.java +++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/source/ads/ServerSideAdInsertionMediaSourceTest.java @@ -93,16 +93,19 @@ public final class ServerSideAdInsertionMediaSourceTest { // Test with one ad group before the window, and the window starting within the second ad group. AdPlaybackState 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= */ 1, /* isServerSideInserted= */ true) .withIsServerSideInserted(/* adGroupIndex= */ 2, /* isServerSideInserted= */ true) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAdCount(/* adGroupIndex= */ 1, /* adCount= */ 2) .withAdCount(/* adGroupIndex= */ 2, /* adCount= */ 1) - .withAdDurationsUs(/* adGroupIndex= */ 0, /* adDurationsUs= */ 500_000) - .withAdDurationsUs(/* adGroupIndex= */ 1, /* adDurationsUs= */ 300_000, 100_000) - .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs= */ 400_000) + .withAdDurationsUs(/* adGroupIndex= */ 0, /* adDurationsUs...= */ 500_000) + .withAdDurationsUs(/* adGroupIndex= */ 1, /* adDurationsUs...= */ 300_000, 100_000) + .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs...= */ 400_000) .withContentResumeOffsetUs(/* adGroupIndex= */ 0, /* contentResumeOffsetUs= */ 100_000) .withContentResumeOffsetUs(/* adGroupIndex= */ 1, /* contentResumeOffsetUs= */ 400_000) .withContentResumeOffsetUs(/* adGroupIndex= */ 2, /* contentResumeOffsetUs= */ 200_000); @@ -166,16 +169,19 @@ public final class ServerSideAdInsertionMediaSourceTest { // Test with one ad group before the window, and the window starting within the second ad group. AdPlaybackState 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= */ 1, /* isServerSideInserted= */ true) .withIsServerSideInserted(/* adGroupIndex= */ 2, /* isServerSideInserted= */ true) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAdCount(/* adGroupIndex= */ 1, /* adCount= */ 2) .withAdCount(/* adGroupIndex= */ 2, /* adCount= */ 1) - .withAdDurationsUs(/* adGroupIndex= */ 0, /* adDurationsUs= */ 500_000) - .withAdDurationsUs(/* adGroupIndex= */ 1, /* adDurationsUs= */ 300_000, 100_000) - .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs= */ 400_000) + .withAdDurationsUs(/* adGroupIndex= */ 0, /* adDurationsUs...= */ 500_000) + .withAdDurationsUs(/* adGroupIndex= */ 1, /* adDurationsUs...= */ 300_000, 100_000) + .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs...= */ 400_000) .withContentResumeOffsetUs(/* adGroupIndex= */ 0, /* contentResumeOffsetUs= */ 100_000) .withContentResumeOffsetUs(/* adGroupIndex= */ 1, /* contentResumeOffsetUs= */ 400_000) .withContentResumeOffsetUs(/* adGroupIndex= */ 2, /* contentResumeOffsetUs= */ 200_000); @@ -260,19 +266,19 @@ public final class ServerSideAdInsertionMediaSourceTest { adPlaybackState, /* fromPositionUs= */ 0, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ 200_000); + /* adDurationsUs...= */ 200_000); adPlaybackState = addAdGroupToAdPlaybackState( adPlaybackState, /* fromPositionUs= */ 400_000, /* contentResumeOffsetUs= */ 1_000_000, - /* adDurationsUs= */ 300_000); + /* adDurationsUs...= */ 300_000); AdPlaybackState firstAdPlaybackState = addAdGroupToAdPlaybackState( adPlaybackState, /* fromPositionUs= */ 900_000, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ 100_000); + /* adDurationsUs...= */ 100_000); AtomicReference mediaSourceRef = new AtomicReference<>(); mediaSourceRef.set( @@ -330,7 +336,7 @@ public final class ServerSideAdInsertionMediaSourceTest { new AdPlaybackState(/* adsId= */ new Object()), /* fromPositionUs= */ 900_000, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ 100_000); + /* adDurationsUs...= */ 100_000); AtomicReference mediaSourceRef = new AtomicReference<>(); mediaSourceRef.set( new ServerSideAdInsertionMediaSource( @@ -358,7 +364,7 @@ public final class ServerSideAdInsertionMediaSourceTest { firstAdPlaybackState, /* fromPositionUs= */ 0, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ 500_000); + /* adDurationsUs...= */ 500_000); mediaSourceRef .get() .setAdPlaybackStates(ImmutableMap.of(periodUid.get(), secondAdPlaybackState)); @@ -401,7 +407,7 @@ public final class ServerSideAdInsertionMediaSourceTest { new AdPlaybackState(/* adsId= */ new Object()), /* fromPositionUs= */ 0, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ 500_000); + /* adDurationsUs...= */ 500_000); AtomicReference mediaSourceRef = new AtomicReference<>(); mediaSourceRef.set( new ServerSideAdInsertionMediaSource( @@ -431,7 +437,7 @@ public final class ServerSideAdInsertionMediaSourceTest { firstAdPlaybackState .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 3) .withAdDurationsUs( - /* adGroupIndex= */ 0, /* adDurationsUs= */ 50_000, 250_000, 200_000); + /* adGroupIndex= */ 0, /* adDurationsUs...= */ 50_000, 250_000, 200_000); mediaSourceRef .get() .setAdPlaybackStates(ImmutableMap.of(periodUid.get(), secondAdPlaybackState)); @@ -469,19 +475,19 @@ public final class ServerSideAdInsertionMediaSourceTest { adPlaybackState, /* fromPositionUs= */ 0, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ 100_000); + /* adDurationsUs...= */ 100_000); adPlaybackState = addAdGroupToAdPlaybackState( adPlaybackState, /* fromPositionUs= */ 600_000, /* contentResumeOffsetUs= */ 1_000_000, - /* adDurationsUs= */ 100_000); + /* adDurationsUs...= */ 100_000); AdPlaybackState firstAdPlaybackState = addAdGroupToAdPlaybackState( adPlaybackState, /* fromPositionUs= */ 900_000, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ 100_000); + /* adDurationsUs...= */ 100_000); AtomicReference mediaSourceRef = new AtomicReference<>(); mediaSourceRef.set( diff --git a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/source/ads/ServerSideAdInsertionUtilTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/source/ads/ServerSideAdInsertionUtilTest.java index be531c4e36..8ed0eb90fa 100644 --- a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/source/ads/ServerSideAdInsertionUtilTest.java +++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/source/ads/ServerSideAdInsertionUtilTest.java @@ -39,7 +39,7 @@ public final class ServerSideAdInsertionUtilTest { @Test public void addAdGroupToAdPlaybackState_insertsCorrectAdGroupData() { AdPlaybackState state = - new AdPlaybackState(ADS_ID, /* adGroupTimesUs= */ 0, 1, C.TIME_END_OF_SOURCE) + new AdPlaybackState(ADS_ID, /* adGroupTimesUs...= */ 0, 1, C.TIME_END_OF_SOURCE) .withRemovedAdGroupCount(2); // stream: 0-- content --4300-- ad1 --4500-- content @@ -49,16 +49,16 @@ public final class ServerSideAdInsertionUtilTest { state, /* fromPositionUs= */ 4300, /* contentResumeOffsetUs= */ 400, - /* adDurationsUs= */ 200); + /* adDurationsUs...= */ 200); assertThat(state) .isEqualTo( - new AdPlaybackState(ADS_ID, /* adGroupTimesUs= */ 0, 0, 4300, C.TIME_END_OF_SOURCE) + new AdPlaybackState(ADS_ID, /* adGroupTimesUs...= */ 0, 0, 4300, C.TIME_END_OF_SOURCE) .withRemovedAdGroupCount(2) .withAdCount(/* adGroupIndex= */ 2, /* adCount= */ 1) .withIsServerSideInserted(/* adGroupIndex= */ 2, /* isServerSideInserted= */ true) .withContentResumeOffsetUs(/* adGroupIndex= */ 2, /* contentResumeOffsetUs= */ 400) - .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs= */ 200)); + .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs...= */ 200)); // stream: 0-- content --2100-- ad1 --2400-- content --4300-- ad2 --4500-- content // content timeline: 0-2100 - [ad1] - 2100-4000 - [ad2] - 4400-end @@ -67,20 +67,20 @@ public final class ServerSideAdInsertionUtilTest { state, /* fromPositionUs= */ 2100, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ 300); + /* adDurationsUs...= */ 300); assertThat(state) .isEqualTo( new AdPlaybackState( - ADS_ID, /* adGroupTimesUs= */ 0, 0, 2100, 4000, C.TIME_END_OF_SOURCE) + ADS_ID, /* adGroupTimesUs...= */ 0, 0, 2100, 4000, C.TIME_END_OF_SOURCE) .withRemovedAdGroupCount(2) .withAdCount(/* adGroupIndex= */ 2, /* adCount= */ 1) .withAdCount(/* adGroupIndex= */ 3, /* adCount= */ 1) .withIsServerSideInserted(/* adGroupIndex= */ 2, /* isServerSideInserted= */ true) .withIsServerSideInserted(/* adGroupIndex= */ 3, /* isServerSideInserted= */ true) .withContentResumeOffsetUs(/* adGroupIndex= */ 3, /* contentResumeOffsetUs= */ 400) - .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs= */ 300) - .withAdDurationsUs(/* adGroupIndex= */ 3, /* adDurationsUs= */ 200)); + .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs...= */ 300) + .withAdDurationsUs(/* adGroupIndex= */ 3, /* adDurationsUs...= */ 200)); // stream: 0-- ad1 --100-- content --2100-- ad2 --2400-- content --4300-- ad3 --4500-- content // content timeline: 0 - [ad1] - 50-2050 -[ad2] - 2050-3950 - [ad3] - 4350-end @@ -89,12 +89,12 @@ public final class ServerSideAdInsertionUtilTest { state, /* fromPositionUs= */ 0, /* contentResumeOffsetUs= */ 50, - /* adDurationsUs= */ 100); + /* adDurationsUs...= */ 100); assertThat(state) .isEqualTo( new AdPlaybackState( - ADS_ID, /* adGroupTimesUs= */ 0, 0, 0, 2050, 3950, C.TIME_END_OF_SOURCE) + ADS_ID, /* adGroupTimesUs...= */ 0, 0, 0, 2050, 3950, C.TIME_END_OF_SOURCE) .withRemovedAdGroupCount(2) .withAdCount(/* adGroupIndex= */ 2, /* adCount= */ 1) .withAdCount(/* adGroupIndex= */ 3, /* adCount= */ 1) @@ -104,9 +104,9 @@ public final class ServerSideAdInsertionUtilTest { .withIsServerSideInserted(/* adGroupIndex= */ 4, /* isServerSideInserted= */ true) .withContentResumeOffsetUs(/* adGroupIndex= */ 2, /* contentResumeOffsetUs= */ 50) .withContentResumeOffsetUs(/* adGroupIndex= */ 4, /* contentResumeOffsetUs= */ 400) - .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs= */ 100) - .withAdDurationsUs(/* adGroupIndex= */ 3, /* adDurationsUs= */ 300) - .withAdDurationsUs(/* adGroupIndex= */ 4, /* adDurationsUs= */ 200)); + .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs...= */ 100) + .withAdDurationsUs(/* adGroupIndex= */ 3, /* adDurationsUs...= */ 300) + .withAdDurationsUs(/* adGroupIndex= */ 4, /* adDurationsUs...= */ 200)); // stream: 0-- ad1 --100-- c --2100-- ad2 --2400-- c --4300-- ad3 --4500-- c --5000-- ad4 --6000 // content timeline: 0 - [ad1] - 50-2050 -[ad2] - 2050-3950 - [ad3] - 4350-4850 - [ad4] - 4850 @@ -115,12 +115,19 @@ public final class ServerSideAdInsertionUtilTest { state, /* fromPositionUs= */ 5000, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ 1000); + /* adDurationsUs...= */ 1000); assertThat(state) .isEqualTo( new AdPlaybackState( - ADS_ID, /* adGroupTimesUs= */ 0, 0, 0, 2050, 3950, 4850, C.TIME_END_OF_SOURCE) + ADS_ID, /* adGroupTimesUs...= */ + 0, + 0, + 0, + 2050, + 3950, + 4850, + C.TIME_END_OF_SOURCE) .withRemovedAdGroupCount(2) .withAdCount(/* adGroupIndex= */ 2, /* adCount= */ 1) .withAdCount(/* adGroupIndex= */ 3, /* adCount= */ 1) @@ -132,10 +139,10 @@ public final class ServerSideAdInsertionUtilTest { .withIsServerSideInserted(/* adGroupIndex= */ 5, /* isServerSideInserted= */ true) .withContentResumeOffsetUs(/* adGroupIndex= */ 2, /* contentResumeOffsetUs= */ 50) .withContentResumeOffsetUs(/* adGroupIndex= */ 4, /* contentResumeOffsetUs= */ 400) - .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs= */ 100) - .withAdDurationsUs(/* adGroupIndex= */ 3, /* adDurationsUs= */ 300) - .withAdDurationsUs(/* adGroupIndex= */ 4, /* adDurationsUs= */ 200) - .withAdDurationsUs(/* adGroupIndex= */ 5, /* adDurationsUs= */ 1000)); + .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs...= */ 100) + .withAdDurationsUs(/* adGroupIndex= */ 3, /* adDurationsUs...= */ 300) + .withAdDurationsUs(/* adGroupIndex= */ 4, /* adDurationsUs...= */ 200) + .withAdDurationsUs(/* adGroupIndex= */ 5, /* adDurationsUs...= */ 1000)); } @Test @@ -147,7 +154,7 @@ public final class ServerSideAdInsertionUtilTest { state, /* fromPositionUs= */ 0, /* contentResumeOffsetUs= */ 50_000, - /* adDurationsUs= */ 0, + /* adDurationsUs...= */ 0, 0, 10_000, 40_000, @@ -170,7 +177,7 @@ public final class ServerSideAdInsertionUtilTest { // stream: 0-- ad1 --200-- content --2100-- ad2 --2300-- content --4300-- ad3 --4500-- content // content timeline: 0 - [ad1] - 100-2000 -[ad2] - 2000-4000 - [ad3] - 4400-end AdPlaybackState state = - new AdPlaybackState(ADS_ID, /* adGroupTimesUs= */ 0, 0, 0, 2000, 4000) + new AdPlaybackState(ADS_ID, /* adGroupTimesUs...= */ 0, 0, 0, 2000, 4000) .withRemovedAdGroupCount(2) .withAdCount(/* adGroupIndex= */ 2, /* adCount= */ 2) .withAdCount(/* adGroupIndex= */ 3, /* adCount= */ 1) @@ -178,9 +185,9 @@ public final class ServerSideAdInsertionUtilTest { .withContentResumeOffsetUs(/* adGroupIndex= */ 2, /* contentResumeOffsetUs= */ 100) .withContentResumeOffsetUs(/* adGroupIndex= */ 3, /* contentResumeOffsetUs= */ 0) .withContentResumeOffsetUs(/* adGroupIndex= */ 4, /* contentResumeOffsetUs= */ 400) - .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs= */ 150, 50) - .withAdDurationsUs(/* adGroupIndex= */ 3, /* adDurationsUs= */ 200) - .withAdDurationsUs(/* adGroupIndex= */ 4, /* adDurationsUs= */ 50, 50, 100); + .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs...= */ 150, 50) + .withAdDurationsUs(/* adGroupIndex= */ 3, /* adDurationsUs...= */ 200) + .withAdDurationsUs(/* adGroupIndex= */ 4, /* adDurationsUs...= */ 50, 50, 100); assertThat( getStreamPositionUsForAd( @@ -270,7 +277,7 @@ public final class ServerSideAdInsertionUtilTest { // stream: 0-- ad1 --200-- content --2100-- ad2 --2300-- content --4300-- ad3 --4500-- content // content timeline: 0 - [ad1] - 100-2000 -[ad2] - 2000-4000 - [ad3] - 4400-end AdPlaybackState state = - new AdPlaybackState(ADS_ID, /* adGroupTimesUs= */ 0, 0, 0, 2000, 4000) + new AdPlaybackState(ADS_ID, /* adGroupTimesUs...= */ 0, 0, 0, 2000, 4000) .withRemovedAdGroupCount(2) .withAdCount(/* adGroupIndex= */ 2, /* adCount= */ 2) .withAdCount(/* adGroupIndex= */ 3, /* adCount= */ 1) @@ -278,9 +285,9 @@ public final class ServerSideAdInsertionUtilTest { .withContentResumeOffsetUs(/* adGroupIndex= */ 2, /* contentResumeOffsetUs= */ 100) .withContentResumeOffsetUs(/* adGroupIndex= */ 3, /* contentResumeOffsetUs= */ 0) .withContentResumeOffsetUs(/* adGroupIndex= */ 4, /* contentResumeOffsetUs= */ 400) - .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs= */ 150, 50) - .withAdDurationsUs(/* adGroupIndex= */ 3, /* adDurationsUs= */ 200) - .withAdDurationsUs(/* adGroupIndex= */ 4, /* adDurationsUs= */ 50, 50, 100); + .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs...= */ 150, 50) + .withAdDurationsUs(/* adGroupIndex= */ 3, /* adDurationsUs...= */ 200) + .withAdDurationsUs(/* adGroupIndex= */ 4, /* adDurationsUs...= */ 50, 50, 100); assertThat( getMediaPeriodPositionUsForAd( @@ -375,7 +382,7 @@ public final class ServerSideAdInsertionUtilTest { // stream: 0-- ad1 --200-- content --2100-- ad2 --2300-- content --4300-- ad3 --4500-- content // content timeline: 0 - [ad1] - 100-2000 -[ad2] - 2000-4000 - [ad3] - 4400-end AdPlaybackState state = - new AdPlaybackState(ADS_ID, /* adGroupTimesUs= */ 0, 0, 0, 2000, 4000) + new AdPlaybackState(ADS_ID, /* adGroupTimesUs...= */ 0, 0, 0, 2000, 4000) .withRemovedAdGroupCount(2) .withAdCount(/* adGroupIndex= */ 2, /* adCount= */ 2) .withAdCount(/* adGroupIndex= */ 3, /* adCount= */ 1) @@ -383,9 +390,9 @@ public final class ServerSideAdInsertionUtilTest { .withContentResumeOffsetUs(/* adGroupIndex= */ 2, /* contentResumeOffsetUs= */ 100) .withContentResumeOffsetUs(/* adGroupIndex= */ 3, /* contentResumeOffsetUs= */ 0) .withContentResumeOffsetUs(/* adGroupIndex= */ 4, /* contentResumeOffsetUs= */ 400) - .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs= */ 150, 50) - .withAdDurationsUs(/* adGroupIndex= */ 3, /* adDurationsUs= */ 200) - .withAdDurationsUs(/* adGroupIndex= */ 4, /* adDurationsUs= */ 50, 50, 100); + .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs...= */ 150, 50) + .withAdDurationsUs(/* adGroupIndex= */ 3, /* adDurationsUs...= */ 200) + .withAdDurationsUs(/* adGroupIndex= */ 4, /* adDurationsUs...= */ 50, 50, 100); assertThat(getStreamPositionUsForContent(/* positionUs= */ 0, /* nextAdGroupIndex= */ 2, state)) .isEqualTo(0); @@ -471,7 +478,7 @@ public final class ServerSideAdInsertionUtilTest { // stream: 0-- ad1 --200-- content --2100-- ad2 --2300-- content --4300-- ad3 --4500-- content // content timeline: 0 - [ad1] - 100-2000 -[ad2] - 2000-4000 - [ad3] - 4400-end AdPlaybackState state = - new AdPlaybackState(ADS_ID, /* adGroupTimesUs= */ 0, 0, 0, 2000, 4000) + new AdPlaybackState(ADS_ID, /* adGroupTimesUs...= */ 0, 0, 0, 2000, 4000) .withRemovedAdGroupCount(2) .withAdCount(/* adGroupIndex= */ 2, /* adCount= */ 2) .withAdCount(/* adGroupIndex= */ 3, /* adCount= */ 1) @@ -479,9 +486,9 @@ public final class ServerSideAdInsertionUtilTest { .withContentResumeOffsetUs(/* adGroupIndex= */ 2, /* contentResumeOffsetUs= */ 100) .withContentResumeOffsetUs(/* adGroupIndex= */ 3, /* contentResumeOffsetUs= */ 0) .withContentResumeOffsetUs(/* adGroupIndex= */ 4, /* contentResumeOffsetUs= */ 400) - .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs= */ 150, 50) - .withAdDurationsUs(/* adGroupIndex= */ 3, /* adDurationsUs= */ 200) - .withAdDurationsUs(/* adGroupIndex= */ 4, /* adDurationsUs= */ 50, 50, 100); + .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs...= */ 150, 50) + .withAdDurationsUs(/* adGroupIndex= */ 3, /* adDurationsUs...= */ 200) + .withAdDurationsUs(/* adGroupIndex= */ 4, /* adDurationsUs...= */ 50, 50, 100); assertThat( getMediaPeriodPositionUsForContent( @@ -588,7 +595,7 @@ public final class ServerSideAdInsertionUtilTest { @Test public void getAdCountInGroup_withUnsetCount_returnsZero() { - AdPlaybackState state = new AdPlaybackState(ADS_ID, /* adGroupTimesUs= */ 0, 2000); + AdPlaybackState state = new AdPlaybackState(ADS_ID, /* adGroupTimesUs...= */ 0, 2000); assertThat(getAdCountInGroup(state, /* adGroupIndex= */ 0)).isEqualTo(0); assertThat(getAdCountInGroup(state, /* adGroupIndex= */ 1)).isEqualTo(0); @@ -597,7 +604,7 @@ public final class ServerSideAdInsertionUtilTest { @Test public void getAdCountInGroup_withSetCount_returnsCount() { AdPlaybackState state = - new AdPlaybackState(ADS_ID, /* adGroupTimesUs= */ 0, 2000) + new AdPlaybackState(ADS_ID, /* adGroupTimesUs...= */ 0, 2000) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 4) .withAdCount(/* adGroupIndex= */ 1, /* adCount= */ 6); diff --git a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelectionTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelectionTest.java index 65666cd019..6c7061b414 100644 --- a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelectionTest.java +++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/trackselection/AdaptiveTrackSelectionTest.java @@ -570,9 +570,9 @@ public final class AdaptiveTrackSelectionTest { TrackGroup trackGroupMultipleFixed = new TrackGroup(formatFixed1, formatFixed2); TrackGroup trackGroupAdaptive = new TrackGroup(formatAdaptive1, formatAdaptive2, formatAdaptive3, formatAdaptive4); - Definition definitionFixed1 = new Definition(trackGroupMultipleFixed, /* tracks= */ 0); - Definition definitionFixed2 = new Definition(trackGroupMultipleFixed, /* tracks= */ 1); - Definition definitionAdaptive = new Definition(trackGroupAdaptive, /* tracks= */ 1, 2, 3); + Definition definitionFixed1 = new Definition(trackGroupMultipleFixed, /* tracks...= */ 0); + Definition definitionFixed2 = new Definition(trackGroupMultipleFixed, /* tracks...= */ 1); + Definition definitionAdaptive = new Definition(trackGroupAdaptive, /* tracks...= */ 1, 2, 3); List> checkPoints = new ArrayList<>(); AdaptiveTrackSelection.Factory factory = new AdaptiveTrackSelection.Factory() { @@ -621,9 +621,9 @@ public final class AdaptiveTrackSelectionTest { TrackGroup trackGroup2 = new TrackGroup(group2Format1, group2Format2, group2Format3, group2UnusedFormat); TrackGroup fixedGroup = new TrackGroup(fixedFormat); - Definition definition1 = new Definition(trackGroup1, /* tracks= */ 0, 1); - Definition definition2 = new Definition(trackGroup2, /* tracks= */ 0, 1, 2); - Definition fixedDefinition = new Definition(fixedGroup, /* tracks= */ 0); + Definition definition1 = new Definition(trackGroup1, /* tracks...= */ 0, 1); + Definition definition2 = new Definition(trackGroup2, /* tracks...= */ 0, 1, 2); + Definition fixedDefinition = new Definition(fixedGroup, /* tracks...= */ 0); List> checkPoints = new ArrayList<>(); AdaptiveTrackSelection.Factory factory = new AdaptiveTrackSelection.Factory() { diff --git a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/trackselection/DefaultTrackSelectorTest.java b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/trackselection/DefaultTrackSelectorTest.java index 8af97dbde4..b791d44ae0 100644 --- a/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/trackselection/DefaultTrackSelectorTest.java +++ b/libraries/exoplayer/src/test/java/androidx/media3/exoplayer/trackselection/DefaultTrackSelectorTest.java @@ -2173,8 +2173,10 @@ public final class DefaultTrackSelectorTest { TIMELINE); assertThat(result.length).isEqualTo(2); - assertAdaptiveSelection(result.selections[0], trackGroups.get(0), /* expectedTracks= */ 1, 0); - assertAdaptiveSelection(result.selections[1], trackGroups.get(1), /* expectedTracks= */ 1, 0); + assertAdaptiveSelection( + result.selections[0], trackGroups.get(0), /* expectedTracks...= */ 1, 0); + assertAdaptiveSelection( + result.selections[1], trackGroups.get(1), /* expectedTracks...= */ 1, 0); // Multiple adaptive selection disallowed. trackSelector.setParameters( @@ -2187,7 +2189,8 @@ public final class DefaultTrackSelectorTest { TIMELINE); 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); } @@ -2231,7 +2234,7 @@ public final class DefaultTrackSelectorTest { trackSelector.selectTracks( new RendererCapabilities[] {VIDEO_CAPABILITIES}, trackGroups, periodId, TIMELINE); 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. trackSelector.setParameters(defaultParameters.buildUpon().setPreferredVideoMimeType(null)); @@ -2239,7 +2242,7 @@ public final class DefaultTrackSelectorTest { trackSelector.selectTracks( new RendererCapabilities[] {VIDEO_CAPABILITIES}, trackGroups, periodId, TIMELINE); assertThat(result.length).isEqualTo(1); - assertAdaptiveSelection(result.selections[0], adaptiveGroup, /* expectedTracks= */ 1, 0); + assertAdaptiveSelection(result.selections[0], adaptiveGroup, /* expectedTracks...= */ 1, 0); } /** @@ -2418,7 +2421,7 @@ public final class DefaultTrackSelectorTest { @Test public void roundTripViaBundle_ofSelectionOverride_yieldsEqualInstance() { SelectionOverride selectionOverrideToBundle = - new SelectionOverride(/* groupIndex= */ 1, /* tracks= */ 2, 3); + new SelectionOverride(/* groupIndex= */ 1, /* tracks...= */ 2, 3); SelectionOverride selectionOverrideFromBundle = DefaultTrackSelector.SelectionOverride.CREATOR.fromBundle( diff --git a/libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/HlsMediaPeriod.java b/libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/HlsMediaPeriod.java index bd592882bd..c4bcfc50ec 100644 --- a/libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/HlsMediaPeriod.java +++ b/libraries/exoplayer_hls/src/main/java/androidx/media3/exoplayer/hls/HlsMediaPeriod.java @@ -689,7 +689,7 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsPlaylistTracker.Pla sampleStreamWrapper.prepareWithMultivariantPlaylistInfo( muxedTrackGroups.toArray(new TrackGroup[0]), /* primaryTrackGroupIndex= */ 0, - /* optionalTrackGroupsIndices= */ muxedTrackGroups.indexOf(id3TrackGroup)); + /* optionalTrackGroupsIndices...= */ muxedTrackGroups.indexOf(id3TrackGroup)); } } diff --git a/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource.java b/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource.java index 52a73ccdda..e5467d7a54 100644 --- a/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource.java +++ b/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSource.java @@ -682,7 +682,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou adPlaybackState, /* fromPositionUs= */ fromPositionUs, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ getAdDuration( + /* adDurationsUs...= */ getAdDuration( /* startTimeSeconds= */ cuePoint.getStartTime(), /* endTimeSeconds= */ cuePoint.getEndTime())); } diff --git a/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaUtil.java b/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaUtil.java index 4600c310bf..9c24e62009 100644 --- a/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaUtil.java +++ b/libraries/exoplayer_ima/src/main/java/androidx/media3/exoplayer/ima/ImaUtil.java @@ -443,7 +443,7 @@ import java.util.Set; private static AdPlaybackState splitAdGroupForPeriod( Object adsId, AdGroup adGroup, long periodStartUs, long periodDurationUs) { AdPlaybackState adPlaybackState = - new AdPlaybackState(checkNotNull(adsId), /* adGroupTimesUs= */ 0) + new AdPlaybackState(checkNotNull(adsId), /* adGroupTimesUs...= */ 0) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAdDurationsUs(/* adGroupIndex= */ 0, periodDurationUs) .withIsServerSideInserted(/* adGroupIndex= */ 0, true) @@ -605,7 +605,7 @@ import java.util.Set; adPlaybackState, /* fromPositionUs= */ currentContentPeriodPositionUs, /* contentResumeOffsetUs= */ sum(adDurationsUs), - /* adDurationsUs= */ adDurationsUs); + /* adDurationsUs...= */ adDurationsUs); adGroupIndex = adPlaybackState.getAdGroupIndexForPositionUs( mediaPeriodPositionUs, /* periodDurationUs= */ C.TIME_UNSET); diff --git a/libraries/exoplayer_ima/src/test/java/androidx/media3/exoplayer/ima/ImaAdsLoaderTest.java b/libraries/exoplayer_ima/src/test/java/androidx/media3/exoplayer/ima/ImaAdsLoaderTest.java index af1df2ed8b..753be43218 100644 --- a/libraries/exoplayer_ima/src/test/java/androidx/media3/exoplayer/ima/ImaAdsLoaderTest.java +++ b/libraries/exoplayer_ima/src/test/java/androidx/media3/exoplayer/ima/ImaAdsLoaderTest.java @@ -239,7 +239,7 @@ public final class ImaAdsLoaderTest { assertThat(getAdPlaybackState(/* periodIndex= */ 0)) .isEqualTo( - new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs= */ 0) + new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */ 0) .withContentDurationUs(CONTENT_PERIOD_DURATION_US)); } @@ -312,7 +312,7 @@ public final class ImaAdsLoaderTest { // Verify that the preroll ad has been marked as played. assertThat(getAdPlaybackState(/* periodIndex= */ 0)) .isEqualTo( - new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs= */ 0) + new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */ 0) .withContentDurationUs(CONTENT_PERIOD_DURATION_US) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAvailableAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, TEST_URI) @@ -336,7 +336,7 @@ public final class ImaAdsLoaderTest { assertThat(getAdPlaybackState(/* periodIndex= */ 0)) .isEqualTo( - new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs= */ 20_500_000) + new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */ 20_500_000) .withContentDurationUs(CONTENT_PERIOD_DURATION_US) .withAdDurationsUs(new long[][] {{TEST_AD_DURATION_US}}) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) @@ -384,7 +384,7 @@ public final class ImaAdsLoaderTest { assertThat(getAdPlaybackState(/* periodIndex= */ 0)) .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) .withAdDurationsUs(new long[][] {{TEST_AD_DURATION_US}}) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) @@ -1114,7 +1114,7 @@ public final class ImaAdsLoaderTest { // Verify that the preroll ad has been marked as played. assertThat(getAdPlaybackState(/* periodIndex= */ 0)) .isEqualTo( - new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs= */ 0) + new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */ 0) .withContentDurationUs(CONTENT_PERIOD_DURATION_US) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAvailableAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, TEST_URI) @@ -1123,7 +1123,7 @@ public final class ImaAdsLoaderTest { .withAdResumePositionUs(/* adResumePositionUs= */ 0)); // Verify that the second source's ad cue points have preloaded. assertThat(getAdPlaybackState(/* periodIndex= */ 1)) - .isEqualTo(new AdPlaybackState(secondAdsId, /* adGroupTimesUs= */ 0)); + .isEqualTo(new AdPlaybackState(secondAdsId, /* adGroupTimesUs...= */ 0)); } @Test @@ -1181,7 +1181,7 @@ public final class ImaAdsLoaderTest { // Verify that the preroll ad has been marked as played. assertThat(getAdPlaybackState(/* periodIndex= */ 0)) .isEqualTo( - new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs= */ 0) + new AdPlaybackState(TEST_ADS_ID, /* adGroupTimesUs...= */ 0) .withContentDurationUs(CONTENT_PERIOD_DURATION_US) .withAdCount(/* adGroupIndex= */ 0, /* adCount= */ 1) .withAvailableAdUri(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0, TEST_URI) @@ -1190,7 +1190,7 @@ public final class ImaAdsLoaderTest { .withAdResumePositionUs(/* adResumePositionUs= */ 0)); // Verify that the second source's ad cue points have preloaded. assertThat(getAdPlaybackState(/* periodIndex= */ 1)) - .isEqualTo(new AdPlaybackState(secondAdsId, /* adGroupTimesUs= */ 0)); + .isEqualTo(new AdPlaybackState(secondAdsId, /* adGroupTimesUs...= */ 0)); } @Test diff --git a/libraries/exoplayer_ima/src/test/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSourceTest.java b/libraries/exoplayer_ima/src/test/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSourceTest.java index a29c80adf4..981ac9adb3 100644 --- a/libraries/exoplayer_ima/src/test/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSourceTest.java +++ b/libraries/exoplayer_ima/src/test/java/androidx/media3/exoplayer/ima/ImaServerSideAdInsertionMediaSourceTest.java @@ -37,7 +37,7 @@ public class ImaServerSideAdInsertionMediaSourceTest { new AdPlaybackState("adsId1"), /* fromPositionUs= */ 0, /* contentResumeOffsetUs= */ 10, - /* adDurationsUs= */ 5_000_000, + /* adDurationsUs...= */ 5_000_000, 10_000_000, 20_000_000); AdPlaybackState secondAdPlaybackState = @@ -45,20 +45,20 @@ public class ImaServerSideAdInsertionMediaSourceTest { new AdPlaybackState("adsId2"), /* fromPositionUs= */ 0, /* contentResumeOffsetUs= */ 10, - /* adDurationsUs= */ 10_000_000) + /* adDurationsUs...= */ 10_000_000) .withPlayedAd(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0); AdPlaybackState thirdAdPlaybackState = ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState( new AdPlaybackState("adsId3"), /* fromPositionUs= */ C.TIME_END_OF_SOURCE, /* contentResumeOffsetUs= */ 10, - /* adDurationsUs= */ 10_000_000); + /* adDurationsUs...= */ 10_000_000); thirdAdPlaybackState = ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState( thirdAdPlaybackState, /* fromPositionUs= */ 0, /* contentResumeOffsetUs= */ 10, - /* adDurationsUs= */ 10_000_000) + /* adDurationsUs...= */ 10_000_000) .withRemovedAdGroupCount(1); State state = new State( diff --git a/libraries/exoplayer_ima/src/test/java/androidx/media3/exoplayer/ima/ImaUtilTest.java b/libraries/exoplayer_ima/src/test/java/androidx/media3/exoplayer/ima/ImaUtilTest.java index a17236513b..8dfeb785ba 100644 --- a/libraries/exoplayer_ima/src/test/java/androidx/media3/exoplayer/ima/ImaUtilTest.java +++ b/libraries/exoplayer_ima/src/test/java/androidx/media3/exoplayer/ima/ImaUtilTest.java @@ -435,7 +435,7 @@ public class ImaUtilTest { new AdPlaybackState(/* adsId= */ "adsId", 0) .withAdCount(/* adGroupIndex= */ 0, periodCount) .withAdDurationsUs( - /* adGroupIndex= */ 0, /* adDurationsUs= */ + /* adGroupIndex= */ 0, /* adDurationsUs...= */ DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US + periodDurationUs, periodDurationUs, periodDurationUs, @@ -475,10 +475,12 @@ public class ImaUtilTest { .withAdCount(/* adGroupIndex= */ 1, 1) .withAdCount(/* adGroupIndex= */ 2, 1) .withAdDurationsUs( - /* adGroupIndex= */ 0, /* adDurationsUs= */ + /* adGroupIndex= */ 0, /* adDurationsUs...= */ DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US + (2 * periodDurationUs)) - .withAdDurationsUs(/* adGroupIndex= */ 1, /* adDurationsUs= */ (2 * periodDurationUs)) - .withAdDurationsUs(/* adGroupIndex= */ 2, /* adDurationsUs= */ (2 * periodDurationUs)) + .withAdDurationsUs( + /* adGroupIndex= */ 1, /* adDurationsUs...= */ (2 * periodDurationUs)) + .withAdDurationsUs( + /* adGroupIndex= */ 2, /* adDurationsUs...= */ (2 * periodDurationUs)) .withPlayedAd(/* adGroupIndex= */ 0, /* adIndexInAdGroup= */ 0) .withPlayedAd(/* adGroupIndex= */ 1, /* adIndexInAdGroup= */ 0) .withIsServerSideInserted(/* adGroupIndex= */ 0, true) @@ -520,7 +522,7 @@ public class ImaUtilTest { // around removed. DEFAULT_WINDOW_OFFSET_IN_FIRST_PERIOD_US + periodDurationUs + 2) .withAdCount(/* adGroupIndex= */ 0, 1) - .withAdDurationsUs(/* adGroupIndex= */ 0, /* adDurationsUs= */ periodDurationUs) + .withAdDurationsUs(/* adGroupIndex= */ 0, /* adDurationsUs...= */ periodDurationUs) .withIsServerSideInserted(/* adGroupIndex= */ 0, true); FakeTimeline timeline = new FakeTimeline( @@ -543,7 +545,7 @@ public class ImaUtilTest { AdPlaybackState adPlaybackState = new AdPlaybackState(/* adsId= */ "adsId", periodDurationUs - 1) .withAdCount(/* adGroupIndex= */ 0, 1) - .withAdDurationsUs(/* adGroupIndex= */ 0, /* adDurationsUs= */ periodDurationUs) + .withAdDurationsUs(/* adGroupIndex= */ 0, /* adDurationsUs...= */ periodDurationUs) .withIsServerSideInserted(/* adGroupIndex= */ 0, true); FakeTimeline timeline = new FakeTimeline( @@ -567,7 +569,7 @@ public class ImaUtilTest { AdPlaybackState.NONE, /* fromPositionUs= */ 0, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ 30_000_000); + /* adDurationsUs...= */ 30_000_000); adPlaybackState = ImaUtil.expandAdGroupPlaceholder( @@ -592,7 +594,7 @@ public class ImaUtilTest { AdPlaybackState.NONE, /* fromPositionUs= */ 0, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ 30_000_000); + /* adDurationsUs...= */ 30_000_000); adPlaybackState = ImaUtil.expandAdGroupPlaceholder( @@ -617,7 +619,7 @@ public class ImaUtilTest { AdPlaybackState.NONE, /* fromPositionUs= */ 0, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ 30_000_000); + /* adDurationsUs...= */ 30_000_000); adPlaybackState = ImaUtil.expandAdGroupPlaceholder( @@ -642,7 +644,7 @@ public class ImaUtilTest { AdPlaybackState.NONE, /* fromPositionUs= */ 0, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ 30_000_000); + /* adDurationsUs...= */ 30_000_000); adPlaybackState = ImaUtil.expandAdGroupPlaceholder( @@ -665,7 +667,7 @@ public class ImaUtilTest { AdPlaybackState.NONE, /* fromPositionUs= */ 0, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ 10_000_001); + /* adDurationsUs...= */ 10_000_001); adPlaybackState = ImaUtil.expandAdGroupPlaceholder( @@ -688,7 +690,7 @@ public class ImaUtilTest { AdPlaybackState.NONE, /* fromPositionUs= */ 0, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ 30_000_000); + /* adDurationsUs...= */ 30_000_000); adPlaybackState = ImaUtil.expandAdGroupPlaceholder( @@ -712,7 +714,7 @@ public class ImaUtilTest { AdPlaybackState.NONE, /* fromPositionUs= */ 0, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ 10_000_000, + /* adDurationsUs...= */ 10_000_000, 20_000_000, 0); @@ -737,7 +739,7 @@ public class ImaUtilTest { AdPlaybackState.NONE, /* fromPositionUs= */ 0, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ 0, + /* adDurationsUs...= */ 0, 10_000_000, 20_000_000); @@ -762,7 +764,7 @@ public class ImaUtilTest { AdPlaybackState.NONE, /* fromPositionUs= */ 0, /* contentResumeOffsetUs= */ 0, - /* adDurationsUs= */ 5_000_000, + /* adDurationsUs...= */ 5_000_000, 10_000_000, 20_000_000); diff --git a/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeTrackSelector.java b/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeTrackSelector.java index 1d2f586227..1fa7bf119c 100644 --- a/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeTrackSelector.java +++ b/libraries/test_utils/src/main/java/androidx/media3/test/utils/FakeTrackSelector.java @@ -69,7 +69,7 @@ public class FakeTrackSelector extends DefaultTrackSelector { boolean hasTracks = trackGroupArray.length > 0; definitions[i] = hasTracks - ? new ExoTrackSelection.Definition(trackGroupArray.get(0), /* tracks= */ 0) + ? new ExoTrackSelection.Definition(trackGroupArray.get(0), /* tracks...= */ 0) : null; } return definitions; diff --git a/libraries/test_utils/src/test/java/androidx/media3/test/utils/FakeTimelineTest.java b/libraries/test_utils/src/test/java/androidx/media3/test/utils/FakeTimelineTest.java index 9e79f13261..9d03c10dd1 100644 --- a/libraries/test_utils/src/test/java/androidx/media3/test/utils/FakeTimelineTest.java +++ b/libraries/test_utils/src/test/java/androidx/media3/test/utils/FakeTimelineTest.java @@ -39,7 +39,7 @@ public class FakeTimelineTest { FakeTimeline.createMultiPeriodAdTimeline( windowId, numberOfPlayedAds, - /* isAdPeriodFlags= */ true, + /* isAdPeriodFlags...= */ true, false, true, true, @@ -94,7 +94,7 @@ public class FakeTimelineTest { FakeTimeline.createMultiPeriodAdTimeline( /* windowId= */ new Object(), /* numberOfPlayedAds= */ 0, - /* isAdPeriodFlags= */ false, + /* isAdPeriodFlags...= */ false, true, true, false); diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/ExoPlayerAssetLoader.java b/libraries/transformer/src/main/java/androidx/media3/transformer/ExoPlayerAssetLoader.java index 302539c8a1..e348ea0e3e 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/ExoPlayerAssetLoader.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/ExoPlayerAssetLoader.java @@ -24,8 +24,6 @@ import static androidx.media3.exoplayer.DefaultLoadControl.DEFAULT_MIN_BUFFER_MS import android.content.Context; import android.os.Handler; -import android.os.Looper; -import androidx.annotation.Nullable; import androidx.media3.common.C; import androidx.media3.common.Format; import androidx.media3.common.MediaItem; @@ -64,31 +62,16 @@ import androidx.media3.exoplayer.video.VideoRendererEventListener; void onError(Exception e); } - private final Context context; - 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; + private final ExoPlayer player; public ExoPlayerAssetLoader( Context context, + MediaItem mediaItem, boolean removeAudio, boolean removeVideo, MediaSource.Factory mediaSourceFactory, - Looper looper, + Listener listener, 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); trackSelector.setParameters( new DefaultTrackSelector.Parameters.Builder(context) @@ -108,8 +91,7 @@ import androidx.media3.exoplayer.video.VideoRendererEventListener; new ExoPlayer.Builder(context, new RenderersFactoryImpl(removeAudio, removeVideo, listener)) .setMediaSourceFactory(mediaSourceFactory) .setTrackSelector(trackSelector) - .setLoadControl(loadControl) - .setLooper(looper); + .setLoadControl(loadControl); if (clock != Clock.DEFAULT) { // Transformer.Builder#setClock is also @VisibleForTesting, so if we're using a non-default // clock we must be in a test context. @@ -120,14 +102,14 @@ import androidx.media3.exoplayer.video.VideoRendererEventListener; player = playerBuilder.build(); player.setMediaItem(mediaItem); player.addListener(new PlayerListener(listener)); + } + + public void start() { player.prepare(); } public void release() { - if (player != null) { - player.release(); - player = null; - } + player.release(); } private static final class RenderersFactoryImpl implements RenderersFactory { diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java b/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java index d9ffe41245..66a07ab6e1 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/Transformer.java @@ -16,7 +16,6 @@ package androidx.media3.transformer; -import static androidx.media3.common.util.Assertions.checkNotNull; import static androidx.media3.common.util.Assertions.checkState; import static java.lang.annotation.ElementType.TYPE_USE; @@ -49,7 +48,6 @@ import androidx.media3.extractor.DefaultExtractorsFactory; import androidx.media3.extractor.mp4.Mp4Extractor; import com.google.common.collect.ImmutableList; import com.google.errorprone.annotations.CanIgnoreReturnValue; -import java.io.File; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -566,13 +564,8 @@ public final class Transformer { private final Looper looper; private final DebugViewProvider debugViewProvider; private final Clock clock; - private final TransformerInternal transformerInternal; - @Nullable private MuxerWrapper muxerWrapper; - @Nullable private String outputPath; - @Nullable private ParcelFileDescriptor outputParcelFileDescriptor; - private boolean transformationInProgress; - private boolean isCancelling; + @Nullable private TransformerInternal transformerInternal; private Transformer( Context context, @@ -606,21 +599,6 @@ public final class Transformer { this.looper = looper; this.debugViewProvider = debugViewProvider; this.clock = clock; - transformerInternal = - new TransformerInternal( - context, - transformationRequest, - audioProcessors, - videoEffects, - removeAudio, - removeVideo, - mediaSourceFactory, - decoderFactory, - encoderFactory, - frameProcessorFactory, - looper, - debugViewProvider, - clock); } /** Returns a {@link Transformer.Builder} initialized with the values of this instance. */ @@ -691,9 +669,7 @@ public final class Transformer { * @throws IllegalStateException If a transformation is already in progress. */ public void startTransformation(MediaItem mediaItem, String path) { - this.outputPath = path; - this.outputParcelFileDescriptor = null; - startTransformationInternal(mediaItem); + startTransformationInternal(mediaItem, path, /* parcelFileDescriptor= */ null); } /** @@ -720,12 +696,13 @@ public final class Transformer { */ @RequiresApi(26) public void startTransformation(MediaItem mediaItem, ParcelFileDescriptor parcelFileDescriptor) { - this.outputParcelFileDescriptor = parcelFileDescriptor; - this.outputPath = null; - startTransformationInternal(mediaItem); + startTransformationInternal(mediaItem, /* path= */ null, parcelFileDescriptor); } - private void startTransformationInternal(MediaItem mediaItem) { + private void startTransformationInternal( + MediaItem mediaItem, + @Nullable String path, + @Nullable ParcelFileDescriptor parcelFileDescriptor) { if (!mediaItem.clippingConfiguration.equals(MediaItem.ClippingConfiguration.UNSET) && transformationRequest.flattenForSlowMotion) { // TODO(b/233986762): Support clipping with SEF flattening. @@ -733,23 +710,34 @@ public final class Transformer { "Clipping is not supported when slow motion flattening is requested"); } verifyApplicationThread(); - if (transformationInProgress) { + if (transformerInternal != null) { throw new IllegalStateException("There is already a transformation in progress."); } - transformationInProgress = true; TransformerInternalListener transformerInternalListener = - new TransformerInternalListener(mediaItem, looper); - MuxerWrapper muxerWrapper = - new MuxerWrapper( - outputPath, - outputParcelFileDescriptor, - muxerFactory, - /* errorConsumer= */ transformerInternalListener::onTransformationError); - this.muxerWrapper = muxerWrapper; + new TransformerInternalListener(mediaItem); FallbackListener fallbackListener = new FallbackListener(mediaItem, listeners, transformationRequest); - transformerInternal.start( - mediaItem, muxerWrapper, transformerInternalListener, fallbackListener); + transformerInternal = + new TransformerInternal( + context, + mediaItem, + path, + parcelFileDescriptor, + transformationRequest, + audioProcessors, + videoEffects, + removeAudio, + removeVideo, + mediaSourceFactory, + decoderFactory, + encoderFactory, + frameProcessorFactory, + muxerFactory, + transformerInternalListener, + fallbackListener, + debugViewProvider, + clock); + transformerInternal.start(); } /** @@ -775,7 +763,9 @@ public final class Transformer { */ public @ProgressState int getProgress(ProgressHolder progressHolder) { verifyApplicationThread(); - return transformerInternal.getProgress(progressHolder); + return transformerInternal == null + ? PROGRESS_STATE_NO_TRANSFORMATION + : transformerInternal.getProgress(progressHolder); } /** @@ -785,36 +775,15 @@ public final class Transformer { */ public void cancel() { verifyApplicationThread(); - isCancelling = true; + if (transformerInternal == null) { + return; + } try { - releaseResources(/* forCancellation= */ true); + transformerInternal.release(/* forCancellation= */ true); } catch (TransformationException impossible) { throw new IllegalStateException(impossible); } - isCancelling = false; - } - - /** - * Releases the resources. - * - * @param forCancellation Whether the reason for releasing the resources is the transformation - * cancellation. - * @throws IllegalStateException If this method is called from the wrong thread. - * @throws TransformationException If the muxer is in the wrong state and {@code forCancellation} - * is false. - */ - private void releaseResources(boolean forCancellation) throws TransformationException { - transformationInProgress = false; - transformerInternal.release(); - if (muxerWrapper != null) { - try { - muxerWrapper.release(forCancellation); - } catch (Muxer.MuxerException e) { - throw TransformationException.createForMuxer( - e, TransformationException.ERROR_CODE_MUXING_FAILED); - } - muxerWrapper = null; - } + transformerInternal = null; } private void verifyApplicationThread() { @@ -823,101 +792,41 @@ public final class Transformer { } } - /** - * Returns the current size in bytes of the current/latest output file, or {@link C#LENGTH_UNSET} - * if unavailable. - */ - private long getCurrentOutputFileCurrentSizeBytes() { - long fileSize = C.LENGTH_UNSET; - - if (outputPath != null) { - fileSize = new File(outputPath).length(); - } else if (outputParcelFileDescriptor != null) { - fileSize = outputParcelFileDescriptor.getStatSize(); - } - - if (fileSize <= 0) { - fileSize = C.LENGTH_UNSET; - } - - return fileSize; - } - private final class TransformerInternalListener implements TransformerInternal.Listener { private final MediaItem mediaItem; private final Handler handler; - public TransformerInternalListener(MediaItem mediaItem, Looper looper) { + public TransformerInternalListener(MediaItem mediaItem) { this.mediaItem = mediaItem; - handler = new Handler(looper); + handler = Util.createHandlerForCurrentLooper(); } @Override - public void onTransformationCompleted() { - handleTransformationEnded(/* exception= */ null); + public void onTransformationCompleted(TransformationResult transformationResult) { + // TODO(b/213341814): Add event flags for Transformer events. + Util.postOrRun( + handler, + () -> { + transformerInternal = null; + listeners.queueEvent( + /* eventFlag= */ C.INDEX_UNSET, + listener -> listener.onTransformationCompleted(mediaItem, transformationResult)); + listeners.flushEvents(); + }); } @Override public void onTransformationError(TransformationException exception) { - if (Looper.myLooper() == looper) { - handleTransformationException(exception); - } else { - handler.post(() -> handleTransformationException(exception)); - } - } - - private void handleTransformationException(TransformationException transformationException) { - if (isCancelling) { - // Resources are already being released. - listeners.queueEvent( - /* eventFlag= */ C.INDEX_UNSET, - listener -> listener.onTransformationError(mediaItem, transformationException)); - listeners.flushEvents(); - } else { - handleTransformationEnded(transformationException); - } - } - - private void handleTransformationEnded(@Nullable TransformationException exception) { - MuxerWrapper muxerWrapper = Transformer.this.muxerWrapper; - @Nullable TransformationException resourceReleaseException = null; - try { - releaseResources(/* forCancellation= */ false); - } catch (TransformationException e) { - resourceReleaseException = e; - } catch (RuntimeException e) { - resourceReleaseException = TransformationException.createForUnexpected(e); - } - if (exception == null) { - // We only report the exception caused by releasing the resources if there is no other - // exception. It is more intuitive to call the error callback only once and reporting the - // exception caused by releasing the resources can be confusing if it is a consequence of - // the first exception. - exception = resourceReleaseException; - } - - if (exception != null) { - TransformationException finalException = exception; - // TODO(b/213341814): Add event flags for Transformer events. - listeners.queueEvent( - /* eventFlag= */ C.INDEX_UNSET, - listener -> listener.onTransformationError(mediaItem, finalException)); - } else { - TransformationResult result = - new TransformationResult.Builder() - .setDurationMs(checkNotNull(muxerWrapper).getDurationMs()) - .setAverageAudioBitrate(muxerWrapper.getTrackAverageBitrate(C.TRACK_TYPE_AUDIO)) - .setAverageVideoBitrate(muxerWrapper.getTrackAverageBitrate(C.TRACK_TYPE_VIDEO)) - .setVideoFrameCount(muxerWrapper.getTrackSampleCount(C.TRACK_TYPE_VIDEO)) - .setFileSizeBytes(getCurrentOutputFileCurrentSizeBytes()) - .build(); - - listeners.queueEvent( - /* eventFlag= */ C.INDEX_UNSET, - listener -> listener.onTransformationCompleted(mediaItem, result)); - } - listeners.flushEvents(); + Util.postOrRun( + handler, + () -> { + transformerInternal = null; + listeners.queueEvent( + /* eventFlag= */ C.INDEX_UNSET, + listener -> listener.onTransformationError(mediaItem, exception)); + listeners.flushEvents(); + }); } } } diff --git a/libraries/transformer/src/main/java/androidx/media3/transformer/TransformerInternal.java b/libraries/transformer/src/main/java/androidx/media3/transformer/TransformerInternal.java index 0fcd7bb05b..f0a3c84c09 100644 --- a/libraries/transformer/src/main/java/androidx/media3/transformer/TransformerInternal.java +++ b/libraries/transformer/src/main/java/androidx/media3/transformer/TransformerInternal.java @@ -16,6 +16,7 @@ package androidx.media3.transformer; +import static androidx.media3.common.util.Assertions.checkNotNull; import static androidx.media3.transformer.Transformer.PROGRESS_STATE_AVAILABLE; import static androidx.media3.transformer.Transformer.PROGRESS_STATE_NO_TRANSFORMATION; import static androidx.media3.transformer.Transformer.PROGRESS_STATE_UNAVAILABLE; @@ -23,7 +24,8 @@ import static androidx.media3.transformer.Transformer.PROGRESS_STATE_WAITING_FOR import static java.lang.Math.min; import android.content.Context; -import android.os.Looper; +import android.os.Handler; +import android.os.ParcelFileDescriptor; import androidx.annotation.Nullable; import androidx.media3.common.C; import androidx.media3.common.DebugViewProvider; @@ -36,9 +38,11 @@ import androidx.media3.common.MimeTypes; import androidx.media3.common.PlaybackException; import androidx.media3.common.audio.AudioProcessor; import androidx.media3.common.util.Clock; +import androidx.media3.common.util.Util; import androidx.media3.exoplayer.source.MediaSource; import androidx.media3.extractor.metadata.mp4.SlowMotionData; import com.google.common.collect.ImmutableList; +import java.io.File; import java.util.ArrayList; import java.util.List; @@ -46,27 +50,36 @@ import java.util.List; public interface Listener { - void onTransformationCompleted(); + void onTransformationCompleted(TransformationResult transformationResult); void onTransformationError(TransformationException exception); } private final Context context; + @Nullable private final String outputPath; + @Nullable private final ParcelFileDescriptor outputParcelFileDescriptor; private final TransformationRequest transformationRequest; private final ImmutableList audioProcessors; private final ImmutableList videoEffects; private final Codec.DecoderFactory decoderFactory; private final Codec.EncoderFactory encoderFactory; private final FrameProcessor.Factory frameProcessorFactory; + private final Listener listener; private final DebugViewProvider debugViewProvider; + private final Handler handler; private final ExoPlayerAssetLoader exoPlayerAssetLoader; + private final MuxerWrapper muxerWrapper; private final List samplePipelines; private @Transformer.ProgressState int progressState; private long durationMs; + private boolean released; public TransformerInternal( Context context, + MediaItem mediaItem, + @Nullable String outputPath, + @Nullable ParcelFileDescriptor outputParcelFileDescriptor, TransformationRequest transformationRequest, ImmutableList audioProcessors, ImmutableList videoEffects, @@ -76,33 +89,45 @@ import java.util.List; Codec.DecoderFactory decoderFactory, Codec.EncoderFactory encoderFactory, FrameProcessor.Factory frameProcessorFactory, - Looper looper, + Muxer.Factory muxerFactory, + Listener listener, + FallbackListener fallbackListener, DebugViewProvider debugViewProvider, Clock clock) { this.context = context; + this.outputPath = outputPath; + this.outputParcelFileDescriptor = outputParcelFileDescriptor; this.transformationRequest = transformationRequest; this.audioProcessors = audioProcessors; this.videoEffects = videoEffects; this.decoderFactory = decoderFactory; this.encoderFactory = encoderFactory; this.frameProcessorFactory = frameProcessorFactory; + this.listener = listener; this.debugViewProvider = debugViewProvider; + handler = Util.createHandlerForCurrentLooper(); + AssetLoaderListener assetLoaderListener = new AssetLoaderListener(mediaItem, fallbackListener); + muxerWrapper = + new MuxerWrapper( + outputPath, + outputParcelFileDescriptor, + muxerFactory, + /* errorConsumer= */ assetLoaderListener::onError); exoPlayerAssetLoader = new ExoPlayerAssetLoader( - context, removeAudio, removeVideo, mediaSourceFactory, looper, clock); + context, + mediaItem, + removeAudio, + removeVideo, + mediaSourceFactory, + assetLoaderListener, + clock); samplePipelines = new ArrayList<>(/* initialCapacity= */ 2); - progressState = PROGRESS_STATE_NO_TRANSFORMATION; + progressState = PROGRESS_STATE_WAITING_FOR_AVAILABILITY; } - public void start( - MediaItem mediaItem, - MuxerWrapper muxerWrapper, - Listener listener, - FallbackListener fallbackListener) { - AssetLoaderListener assetLoaderListener = - new AssetLoaderListener(mediaItem, muxerWrapper, listener, fallbackListener); - exoPlayerAssetLoader.start(mediaItem, assetLoaderListener); - progressState = PROGRESS_STATE_WAITING_FOR_AVAILABILITY; + public void start() { + exoPlayerAssetLoader.start(); } public @Transformer.ProgressState int getProgress(ProgressHolder progressHolder) { @@ -113,10 +138,28 @@ import java.util.List; return progressState; } - public void release() { + /** + * Releases the resources. + * + * @param forCancellation Whether the reason for releasing the resources is the transformation + * cancellation. + * @throws TransformationException If the muxer is in the wrong state and {@code forCancellation} + * is false. + */ + public void release(boolean forCancellation) throws TransformationException { + if (released) { + return; + } samplePipelines.clear(); progressState = PROGRESS_STATE_NO_TRANSFORMATION; + released = true; exoPlayerAssetLoader.release(); + try { + muxerWrapper.release(forCancellation); + } catch (Muxer.MuxerException e) { + throw TransformationException.createForMuxer( + e, TransformationException.ERROR_CODE_MUXING_FAILED); + } } private long getCurrentPositionMs() { @@ -130,23 +173,35 @@ import java.util.List; return positionMsSum / samplePipelines.size(); } + /** + * Returns the current size in bytes of the current/latest output file, or {@link C#LENGTH_UNSET} + * if unavailable. + */ + private long getCurrentOutputFileCurrentSizeBytes() { + long fileSize = C.LENGTH_UNSET; + + if (outputPath != null) { + fileSize = new File(outputPath).length(); + } else if (outputParcelFileDescriptor != null) { + fileSize = outputParcelFileDescriptor.getStatSize(); + } + + if (fileSize <= 0) { + fileSize = C.LENGTH_UNSET; + } + + return fileSize; + } + private class AssetLoaderListener implements ExoPlayerAssetLoader.Listener { private final MediaItem mediaItem; - private final MuxerWrapper muxerWrapper; - private final TransformerInternal.Listener listener; private final FallbackListener fallbackListener; private volatile boolean trackRegistered; - public AssetLoaderListener( - MediaItem mediaItem, - MuxerWrapper muxerWrapper, - Listener listener, - FallbackListener fallbackListener) { + public AssetLoaderListener(MediaItem mediaItem, FallbackListener fallbackListener) { this.mediaItem = mediaItem; - this.muxerWrapper = muxerWrapper; - this.listener = listener; this.fallbackListener = fallbackListener; } @@ -197,12 +252,12 @@ import java.util.List; } else { transformationException = TransformationException.createForUnexpected(e); } - listener.onTransformationError(transformationException); + handleTransformationEnded(transformationException); } @Override public void onEnded() { - listener.onTransformationCompleted(); + handleTransformationEnded(/* transformationException= */ null); } private SamplePipeline getSamplePipeline( @@ -233,7 +288,7 @@ import java.util.List; encoderFactory, muxerWrapper, fallbackListener, - listener::onTransformationError, + this::onError, debugViewProvider); } else { return new PassthroughSamplePipeline( @@ -324,5 +379,45 @@ import java.util.List; } return false; } + + private void handleTransformationEnded( + @Nullable TransformationException transformationException) { + Util.postOrRun( + handler, + () -> { + @Nullable TransformationException releaseException = null; + try { + release(/* forCancellation= */ false); + } catch (TransformationException e) { + releaseException = e; + } catch (RuntimeException e) { + releaseException = TransformationException.createForUnexpected(e); + } + TransformationException exception = transformationException; + if (exception == null) { + // We only report the exception caused by releasing the resources if there is no other + // exception. It is more intuitive to call the error callback only once and reporting + // the exception caused by releasing the resources can be confusing if it is a + // consequence of the first exception. + exception = releaseException; + } + + if (exception != null) { + listener.onTransformationError(exception); + } else { + TransformationResult result = + new TransformationResult.Builder() + .setDurationMs(checkNotNull(muxerWrapper).getDurationMs()) + .setAverageAudioBitrate( + muxerWrapper.getTrackAverageBitrate(C.TRACK_TYPE_AUDIO)) + .setAverageVideoBitrate( + muxerWrapper.getTrackAverageBitrate(C.TRACK_TYPE_VIDEO)) + .setVideoFrameCount(muxerWrapper.getTrackSampleCount(C.TRACK_TYPE_VIDEO)) + .setFileSizeBytes(getCurrentOutputFileCurrentSizeBytes()) + .build(); + listener.onTransformationCompleted(result); + } + }); + } } } diff --git a/libraries/ui_leanback/src/main/java/androidx/media3/ui/leanback/LeanbackPlayerAdapter.java b/libraries/ui_leanback/src/main/java/androidx/media3/ui/leanback/LeanbackPlayerAdapter.java index 0e6e71e517..b111890b8a 100644 --- a/libraries/ui_leanback/src/main/java/androidx/media3/ui/leanback/LeanbackPlayerAdapter.java +++ b/libraries/ui_leanback/src/main/java/androidx/media3/ui/leanback/LeanbackPlayerAdapter.java @@ -266,7 +266,7 @@ public final class LeanbackPlayerAdapter extends PlayerAdapter implements Runnab // int arguments (int what, int extra). Since PlaybackException defines a single error // code, we pass 0 as the extra. context.getString( - R.string.lb_media_player_error, /* formatArgs= */ error.errorCode, 0)); + R.string.lb_media_player_error, /* formatArgs...= */ error.errorCode, 0)); } }