Search in sources :

Example 11 with MediaPeriodId

use of androidx.media3.exoplayer.source.MediaSource.MediaPeriodId in project media by androidx.

the class MediaPeriodQueueTest method resolveMediaPeriodIdForAdsAfterPeriodPositionChange_behindAdInMultiPeriodAllAdsPlayed_seekNotAdjusted.

@Test
public void resolveMediaPeriodIdForAdsAfterPeriodPositionChange_behindAdInMultiPeriodAllAdsPlayed_seekNotAdjusted() throws InterruptedException {
    Object windowId = new Object();
    Timeline timeline = createMultiPeriodServerSideInsertedTimeline(windowId, /* numberOfPlayedAds= */
    4, /* isAdPeriodFlags...= */
    true, false, true, true, true, false);
    MediaPeriodId mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange(timeline, new Pair<>(windowId, 1), /* positionUs= */
    11);
    assertThat(mediaPeriodId.adGroupIndex).isEqualTo(-1);
    assertThat(mediaPeriodId.adIndexInAdGroup).isEqualTo(-1);
    assertThat(mediaPeriodId.nextAdGroupIndex).isEqualTo(-1);
    assertThat(mediaPeriodId.periodUid).isEqualTo(new Pair<>(windowId, 1));
    mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange(timeline, new Pair<>(windowId, 5), /* positionUs= */
    33);
    assertThat(mediaPeriodId.adGroupIndex).isEqualTo(-1);
    assertThat(mediaPeriodId.adIndexInAdGroup).isEqualTo(-1);
    assertThat(mediaPeriodId.nextAdGroupIndex).isEqualTo(-1);
    assertThat(mediaPeriodId.periodUid).isEqualTo(new Pair<>(windowId, 5));
}
Also used : FakeTimeline(androidx.media3.test.utils.FakeTimeline) SinglePeriodTimeline(androidx.media3.exoplayer.source.SinglePeriodTimeline) SinglePeriodAdTimeline(androidx.media3.exoplayer.source.ads.SinglePeriodAdTimeline) Timeline(androidx.media3.common.Timeline) MediaPeriodId(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId) Pair(android.util.Pair) Test(org.junit.Test)

Example 12 with MediaPeriodId

use of androidx.media3.exoplayer.source.MediaSource.MediaPeriodId in project media by androidx.

the class MediaPeriodQueueTest method resolveMediaPeriodIdForAdsAfterPeriodPositionChange_consecutiveContentPeriods_rollForward.

@Test
public void resolveMediaPeriodIdForAdsAfterPeriodPositionChange_consecutiveContentPeriods_rollForward() throws InterruptedException {
    Object windowId = new Object();
    Timeline timeline = createMultiPeriodServerSideInsertedTimeline(windowId, /* numberOfPlayedAds= */
    0, /* isAdPeriodFlags...= */
    true, false, false, false);
    MediaPeriodId mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange(timeline, new Pair<>(windowId, 3), /* positionUs= */
    10_000);
    assertThat(mediaPeriodId.periodUid).isEqualTo(new Pair<>(windowId, 0));
    assertThat(mediaPeriodId.adGroupIndex).isEqualTo(0);
    assertThat(mediaPeriodId.adIndexInAdGroup).isEqualTo(0);
    assertThat(mediaPeriodId.nextAdGroupIndex).isEqualTo(-1);
}
Also used : FakeTimeline(androidx.media3.test.utils.FakeTimeline) SinglePeriodTimeline(androidx.media3.exoplayer.source.SinglePeriodTimeline) SinglePeriodAdTimeline(androidx.media3.exoplayer.source.ads.SinglePeriodAdTimeline) Timeline(androidx.media3.common.Timeline) MediaPeriodId(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId) Test(org.junit.Test)

Example 13 with MediaPeriodId

use of androidx.media3.exoplayer.source.MediaSource.MediaPeriodId in project media by androidx.

the class MediaPeriodQueueTest method resolveMediaPeriodIdForAdsAfterPeriodPositionChange_toUnplayedAdInMultiPeriodTimeline_resolvedAsAd.

@Test
public void resolveMediaPeriodIdForAdsAfterPeriodPositionChange_toUnplayedAdInMultiPeriodTimeline_resolvedAsAd() throws InterruptedException {
    Object windowId = new Object();
    Timeline timeline = createMultiPeriodServerSideInsertedTimeline(windowId, /* numberOfPlayedAds= */
    0, /* isAdPeriodFlags...= */
    false, true, false);
    MediaPeriodId mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange(timeline, new Pair<>(windowId, 1), /* positionUs= */
    0);
    assertThat(mediaPeriodId.adGroupIndex).isEqualTo(0);
    assertThat(mediaPeriodId.adIndexInAdGroup).isEqualTo(0);
    assertThat(mediaPeriodId.nextAdGroupIndex).isEqualTo(-1);
    assertThat(mediaPeriodId.periodUid).isEqualTo(new Pair<>(windowId, 1));
}
Also used : FakeTimeline(androidx.media3.test.utils.FakeTimeline) SinglePeriodTimeline(androidx.media3.exoplayer.source.SinglePeriodTimeline) SinglePeriodAdTimeline(androidx.media3.exoplayer.source.ads.SinglePeriodAdTimeline) Timeline(androidx.media3.common.Timeline) MediaPeriodId(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId) Test(org.junit.Test)

Example 14 with MediaPeriodId

use of androidx.media3.exoplayer.source.MediaSource.MediaPeriodId in project media by androidx.

the class MediaPeriodQueueTest method resolveMediaPeriodIdForAdsAfterPeriodPositionChange_toStartOfWindowPlayedAdPreroll_skipsPlayedPrerolls.

@Test
public void resolveMediaPeriodIdForAdsAfterPeriodPositionChange_toStartOfWindowPlayedAdPreroll_skipsPlayedPrerolls() throws InterruptedException {
    Object windowId = new Object();
    Timeline timeline = createMultiPeriodServerSideInsertedTimeline(windowId, /* numberOfPlayedAds= */
    2, /* isAdPeriodFlags...= */
    true, true, false);
    MediaPeriodId mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange(timeline, new Pair<>(windowId, 0), /* positionUs= */
    0);
    assertThat(mediaPeriodId.adGroupIndex).isEqualTo(-1);
    assertThat(mediaPeriodId.adIndexInAdGroup).isEqualTo(-1);
    assertThat(mediaPeriodId.nextAdGroupIndex).isEqualTo(-1);
    assertThat(mediaPeriodId.periodUid).isEqualTo(new Pair<>(windowId, 2));
}
Also used : FakeTimeline(androidx.media3.test.utils.FakeTimeline) SinglePeriodTimeline(androidx.media3.exoplayer.source.SinglePeriodTimeline) SinglePeriodAdTimeline(androidx.media3.exoplayer.source.ads.SinglePeriodAdTimeline) Timeline(androidx.media3.common.Timeline) MediaPeriodId(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId) Test(org.junit.Test)

Example 15 with MediaPeriodId

use of androidx.media3.exoplayer.source.MediaSource.MediaPeriodId in project media by androidx.

the class MediaPeriodQueueTest method resolveMediaPeriodIdForAdsAfterPeriodPositionChange_onlyConsecutiveContentPeriods_seekNotAdjusted.

@Test
public void resolveMediaPeriodIdForAdsAfterPeriodPositionChange_onlyConsecutiveContentPeriods_seekNotAdjusted() throws InterruptedException {
    Object windowId = new Object();
    Timeline timeline = createMultiPeriodServerSideInsertedTimeline(windowId, /* numberOfPlayedAds= */
    0, /* isAdPeriodFlags...= */
    false, false, false, false);
    MediaPeriodId mediaPeriodId = mediaPeriodQueue.resolveMediaPeriodIdForAdsAfterPeriodPositionChange(timeline, new Pair<>(windowId, 3), /* positionUs= */
    10_000);
    assertThat(mediaPeriodId.periodUid).isEqualTo(new Pair<>(windowId, 3));
    assertThat(mediaPeriodId.adGroupIndex).isEqualTo(-1);
}
Also used : FakeTimeline(androidx.media3.test.utils.FakeTimeline) SinglePeriodTimeline(androidx.media3.exoplayer.source.SinglePeriodTimeline) SinglePeriodAdTimeline(androidx.media3.exoplayer.source.ads.SinglePeriodAdTimeline) Timeline(androidx.media3.common.Timeline) MediaPeriodId(androidx.media3.exoplayer.source.MediaSource.MediaPeriodId) Test(org.junit.Test)

Aggregations

MediaPeriodId (androidx.media3.exoplayer.source.MediaSource.MediaPeriodId)106 Test (org.junit.Test)85 FakeTimeline (androidx.media3.test.utils.FakeTimeline)75 Timeline (androidx.media3.common.Timeline)72 EventTime (androidx.media3.exoplayer.analytics.AnalyticsListener.EventTime)48 Nullable (androidx.annotation.Nullable)28 FakeMediaSource (androidx.media3.test.utils.FakeMediaSource)28 TimelineWindowDefinition (androidx.media3.test.utils.FakeTimeline.TimelineWindowDefinition)28 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)27 Allocator (androidx.media3.exoplayer.upstream.Allocator)22 SinglePeriodTimeline (androidx.media3.exoplayer.source.SinglePeriodTimeline)19 AdPlaybackState (androidx.media3.common.AdPlaybackState)17 DrmSessionManager (androidx.media3.exoplayer.drm.DrmSessionManager)17 TrackGroupArray (androidx.media3.common.TrackGroupArray)16 TransferListener (androidx.media3.datasource.TransferListener)16 FakeMediaPeriod (androidx.media3.test.utils.FakeMediaPeriod)15 TestExoPlayerBuilder (androidx.media3.test.utils.TestExoPlayerBuilder)15 ActionSchedule (androidx.media3.test.utils.ActionSchedule)13 DrmSessionEventListener (androidx.media3.exoplayer.drm.DrmSessionEventListener)12 MediaPeriod (androidx.media3.exoplayer.source.MediaPeriod)11