use of androidx.media3.exoplayer.source.ads.ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState in project media by androidx.
the class ImaUtilTest method expandAdGroupPlaceHolder_expandWithLastAdInGroup_correctDurationWrappedAround.
@Test
public void expandAdGroupPlaceHolder_expandWithLastAdInGroup_correctDurationWrappedAround() {
AdPlaybackState adPlaybackState = ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState(AdPlaybackState.NONE, /* fromPositionUs= */
0, /* contentResumeOffsetUs= */
0, /* adDurationsUs...= */
30_000_000);
adPlaybackState = ImaUtil.expandAdGroupPlaceholder(/* adGroupIndex= */
0, /* adGroupDurationUs= */
30_000_000, /* adIndexInAdGroup= */
2, /* adDurationUs= */
10_000_000, /* adsInAdGroupCount= */
3, adPlaybackState);
AdPlaybackState.AdGroup adGroup = adPlaybackState.getAdGroup(/* adGroupIndex= */
0);
assertThat(adGroup.count).isEqualTo(3);
assertThat(adGroup.durationsUs[0]).isEqualTo(20_000_000);
assertThat(adGroup.durationsUs[1]).isEqualTo(0);
assertThat(adGroup.durationsUs[2]).isEqualTo(10_000_000);
}
use of androidx.media3.exoplayer.source.ads.ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState in project media by androidx.
the class ImaUtilTest method expandAdGroupPlaceHolder_expandWithFirstAdInGroup_correctExpansion.
@Test
public void expandAdGroupPlaceHolder_expandWithFirstAdInGroup_correctExpansion() {
AdPlaybackState adPlaybackState = ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState(AdPlaybackState.NONE, /* fromPositionUs= */
0, /* contentResumeOffsetUs= */
0, /* adDurationsUs...= */
30_000_000);
adPlaybackState = ImaUtil.expandAdGroupPlaceholder(/* adGroupIndex= */
0, /* adGroupDurationUs= */
30_000_000, /* adIndexInAdGroup= */
0, /* adDurationUs= */
10_000_000, /* adsInAdGroupCount= */
3, adPlaybackState);
AdPlaybackState.AdGroup adGroup = adPlaybackState.getAdGroup(/* adGroupIndex= */
0);
assertThat(adGroup.count).isEqualTo(3);
assertThat(adGroup.durationsUs[0]).isEqualTo(10_000_000);
assertThat(adGroup.durationsUs[1]).isEqualTo(20_000_000);
assertThat(adGroup.durationsUs[2]).isEqualTo(0);
}
use of androidx.media3.exoplayer.source.ads.ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState in project media by androidx.
the class ImaUtilTest method expandAdGroupPlaceHolder_expandSingleAdInAdGroup_noExpansionCorrectDuration.
@Test
public void expandAdGroupPlaceHolder_expandSingleAdInAdGroup_noExpansionCorrectDuration() {
AdPlaybackState adPlaybackState = ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState(AdPlaybackState.NONE, /* fromPositionUs= */
0, /* contentResumeOffsetUs= */
0, /* adDurationsUs...= */
30_000_000);
adPlaybackState = ImaUtil.expandAdGroupPlaceholder(/* adGroupIndex= */
0, /* adGroupDurationUs= */
30_000_000, /* adIndexInAdGroup= */
0, /* adDurationUs= */
10_000_000, /* adsInAdGroupCount= */
1, adPlaybackState);
AdPlaybackState.AdGroup adGroup = adPlaybackState.getAdGroup(/* adGroupIndex= */
0);
assertThat(adGroup.count).isEqualTo(1);
assertThat(adGroup.durationsUs[0]).isEqualTo(10_000_000);
}
use of androidx.media3.exoplayer.source.ads.ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState in project media by androidx.
the class ImaUtilTest method expandAdGroupPlaceHolder_initialDurationTooLarge_overriddenWhenExpanded.
@Test
public void expandAdGroupPlaceHolder_initialDurationTooLarge_overriddenWhenExpanded() {
AdPlaybackState adPlaybackState = ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState(AdPlaybackState.NONE, /* fromPositionUs= */
0, /* contentResumeOffsetUs= */
0, /* adDurationsUs...= */
30_000_000);
adPlaybackState = ImaUtil.expandAdGroupPlaceholder(/* adGroupIndex= */
0, /* adGroupDurationUs= */
20_000_000, /* adIndexInAdGroup= */
1, /* adDurationUs= */
10_000_000, /* adsInAdGroupCount= */
2, adPlaybackState);
AdPlaybackState.AdGroup adGroup = adPlaybackState.getAdGroup(/* adGroupIndex= */
0);
assertThat(adGroup.count).isEqualTo(2);
assertThat(adGroup.durationsUs[0]).isEqualTo(10_000_000);
assertThat(adGroup.durationsUs[1]).isEqualTo(10_000_000);
}
use of androidx.media3.exoplayer.source.ads.ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState in project media by androidx.
the class ImaUtilTest method expandAdGroupPlaceHolder_expandWithMiddleAdInGroup_correctExpansion.
@Test
public void expandAdGroupPlaceHolder_expandWithMiddleAdInGroup_correctExpansion() {
AdPlaybackState adPlaybackState = ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState(AdPlaybackState.NONE, /* fromPositionUs= */
0, /* contentResumeOffsetUs= */
0, /* adDurationsUs...= */
30_000_000);
adPlaybackState = ImaUtil.expandAdGroupPlaceholder(/* adGroupIndex= */
0, /* adGroupDurationUs= */
30_000_000, /* adIndexInAdGroup= */
1, /* adDurationUs= */
10_000_000, /* adsInAdGroupCount= */
3, adPlaybackState);
AdPlaybackState.AdGroup adGroup = adPlaybackState.getAdGroup(/* adGroupIndex= */
0);
assertThat(adGroup.count).isEqualTo(3);
assertThat(adGroup.durationsUs[0]).isEqualTo(0);
assertThat(adGroup.durationsUs[1]).isEqualTo(10_000_000);
assertThat(adGroup.durationsUs[2]).isEqualTo(20_000_000);
}
Aggregations