use of com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState in project ExoPlayer by google.
the class ImaServerSideAdInsertionMediaSourceTest method adsLoaderStateToBundle_marshallAndUnmarshalling_resultIsEqual.
@Test
public void adsLoaderStateToBundle_marshallAndUnmarshalling_resultIsEqual() {
AdPlaybackState firstAdPlaybackState = ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState(new AdPlaybackState("adsId1"), /* fromPositionUs= */
0, /* contentResumeOffsetUs= */
10, /* adDurationsUs...= */
5_000_000, 10_000_000, 20_000_000);
AdPlaybackState secondAdPlaybackState = ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState(new AdPlaybackState("adsId2"), /* fromPositionUs= */
0, /* contentResumeOffsetUs= */
10, /* 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);
thirdAdPlaybackState = ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState(thirdAdPlaybackState, /* fromPositionUs= */
0, /* contentResumeOffsetUs= */
10, /* adDurationsUs...= */
10_000_000).withRemovedAdGroupCount(1);
State state = new State(ImmutableMap.<String, AdPlaybackState>builder().put("adsId1", firstAdPlaybackState).put("adsId2", secondAdPlaybackState).put("adsId3", thirdAdPlaybackState).buildOrThrow());
assertThat(State.CREATOR.fromBundle(state.toBundle())).isEqualTo(state);
}
use of com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState in project ExoPlayer by google.
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 com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState in project ExoPlayer by google.
the class ImaUtilTest method insertAdDurationInAdGroup_insertLast_correctDurationAndPropagation.
@Test
public void insertAdDurationInAdGroup_insertLast_correctDurationAndPropagation() {
AdPlaybackState adPlaybackState = ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState(AdPlaybackState.NONE, /* fromPositionUs= */
0, /* contentResumeOffsetUs= */
0, /* adDurationsUs...= */
0, 10_000_000, 20_000_000);
adPlaybackState = ImaUtil.updateAdDurationInAdGroup(/* adGroupIndex= */
0, /* adIndexInAdGroup= */
2, /* adDurationUs= */
15_000_000, adPlaybackState);
AdPlaybackState.AdGroup adGroup = adPlaybackState.getAdGroup(0);
assertThat(adGroup.count).isEqualTo(3);
assertThat(adGroup.durationsUs[0]).isEqualTo(5_000_000);
assertThat(adGroup.durationsUs[1]).isEqualTo(10_000_000);
assertThat(adGroup.durationsUs[2]).isEqualTo(15_000_000);
}
use of com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState in project ExoPlayer by google.
the class ImaUtilTest method insertAdDurationInAdGroup_correctDurationAndPropagation.
@Test
public void insertAdDurationInAdGroup_correctDurationAndPropagation() {
AdPlaybackState adPlaybackState = ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState(AdPlaybackState.NONE, /* fromPositionUs= */
0, /* contentResumeOffsetUs= */
0, /* adDurationsUs...= */
10_000_000, 20_000_000, 0);
adPlaybackState = ImaUtil.updateAdDurationInAdGroup(/* adGroupIndex= */
0, /* adIndexInAdGroup= */
1, /* adDurationUs= */
15_000_000, adPlaybackState);
AdPlaybackState.AdGroup adGroup = adPlaybackState.getAdGroup(0);
assertThat(adGroup.count).isEqualTo(3);
assertThat(adGroup.durationsUs[0]).isEqualTo(10_000_000);
assertThat(adGroup.durationsUs[1]).isEqualTo(15_000_000);
assertThat(adGroup.durationsUs[2]).isEqualTo(5_000_000);
}
use of com.google.android.exoplayer2.source.ads.ServerSideAdInsertionUtil.addAdGroupToAdPlaybackState in project ExoPlayer by google.
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