Use SKIPPED ad status when a playing ad period has been removed
PiperOrigin-RevId: 521476767
This commit is contained in:
parent
7babcf28dc
commit
e6b9bde1dd
@ -1435,7 +1435,7 @@ public final class ImaServerSideAdInsertionMediaSource extends CompositeMediaSou
|
|||||||
Timeline timeline = player.getCurrentTimeline();
|
Timeline timeline = player.getCurrentTimeline();
|
||||||
Timeline.Window window = new Timeline.Window();
|
Timeline.Window window = new Timeline.Window();
|
||||||
Timeline.Period adPeriod = new Timeline.Period();
|
Timeline.Period adPeriod = new Timeline.Period();
|
||||||
// In case all periods are in the live window, we need the correct ad group duration when
|
// In case all periods are in the live window, we need to correct the ad group duration when
|
||||||
// inserting the first ad. Try calculate ad group duration from media structure.
|
// inserting the first ad. Try calculate ad group duration from media structure.
|
||||||
long totalAdDurationUs =
|
long totalAdDurationUs =
|
||||||
getAdGroupDurationUsForLiveAdPeriodIndex(
|
getAdGroupDurationUsForLiveAdPeriodIndex(
|
||||||
|
@ -737,7 +737,7 @@ import java.util.Set;
|
|||||||
return adPlaybackState;
|
return adPlaybackState;
|
||||||
}
|
}
|
||||||
if (state == AD_STATE_AVAILABLE || state == AD_STATE_UNAVAILABLE) {
|
if (state == AD_STATE_AVAILABLE || state == AD_STATE_UNAVAILABLE) {
|
||||||
adPlaybackState = adPlaybackState.withPlayedAd(adGroupIndex, /* adIndexInAdGroup= */ i);
|
adPlaybackState = adPlaybackState.withSkippedAd(adGroupIndex, /* adIndexInAdGroup= */ i);
|
||||||
}
|
}
|
||||||
adGroupDurationUs += adGroup.durationsUs[i];
|
adGroupDurationUs += adGroup.durationsUs[i];
|
||||||
}
|
}
|
||||||
@ -751,7 +751,11 @@ import java.util.Set;
|
|||||||
long[] newDurationsUs = new long[adGroup.durationsUs.length];
|
long[] newDurationsUs = new long[adGroup.durationsUs.length];
|
||||||
for (int adIndex = 0; adIndex < newDurationsUs.length; adIndex++) {
|
for (int adIndex = 0; adIndex < newDurationsUs.length; adIndex++) {
|
||||||
newDurationsUs[adIndex] = preserveDurations ? adGroup.durationsUs[adIndex] : 0;
|
newDurationsUs[adIndex] = preserveDurations ? adGroup.durationsUs[adIndex] : 0;
|
||||||
adPlaybackState = adPlaybackState.withPlayedAd(adGroupIndex, /* adIndexInAdGroup= */ adIndex);
|
if (adGroup.states[adIndex] == AD_STATE_AVAILABLE
|
||||||
|
|| adGroup.states[adIndex] == AD_STATE_UNAVAILABLE) {
|
||||||
|
adPlaybackState =
|
||||||
|
adPlaybackState.withSkippedAd(adGroupIndex, /* adIndexInAdGroup= */ adIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return adPlaybackState
|
return adPlaybackState
|
||||||
.withAdDurationsUs(adGroupIndex, newDurationsUs)
|
.withAdDurationsUs(adGroupIndex, newDurationsUs)
|
||||||
|
@ -1663,7 +1663,6 @@ public class ImaUtilTest {
|
|||||||
/* totalAdDurationUs= */ 3 * AD_PERIOD_DURATION_US,
|
/* totalAdDurationUs= */ 3 * AD_PERIOD_DURATION_US,
|
||||||
/* totalAdsInAdPod= */ 3,
|
/* totalAdsInAdPod= */ 3,
|
||||||
adPlaybackState);
|
adPlaybackState);
|
||||||
AdPlaybackState finalAdPlaybackState = adPlaybackState;
|
|
||||||
|
|
||||||
assertThat(
|
assertThat(
|
||||||
getAdGroupAndIndexInLiveMultiPeriodTimeline(
|
getAdGroupAndIndexInLiveMultiPeriodTimeline(
|
||||||
@ -2040,7 +2039,7 @@ public class ImaUtilTest {
|
|||||||
.asList()
|
.asList()
|
||||||
.containsExactly(
|
.containsExactly(
|
||||||
AD_STATE_PLAYED,
|
AD_STATE_PLAYED,
|
||||||
AD_STATE_PLAYED,
|
AD_STATE_SKIPPED,
|
||||||
AD_STATE_UNAVAILABLE,
|
AD_STATE_UNAVAILABLE,
|
||||||
AD_STATE_UNAVAILABLE,
|
AD_STATE_UNAVAILABLE,
|
||||||
AD_STATE_UNAVAILABLE,
|
AD_STATE_UNAVAILABLE,
|
||||||
@ -2059,11 +2058,11 @@ public class ImaUtilTest {
|
|||||||
.asList()
|
.asList()
|
||||||
.containsExactly(
|
.containsExactly(
|
||||||
AD_STATE_PLAYED,
|
AD_STATE_PLAYED,
|
||||||
AD_STATE_PLAYED,
|
AD_STATE_SKIPPED,
|
||||||
AD_STATE_PLAYED,
|
AD_STATE_SKIPPED,
|
||||||
AD_STATE_PLAYED,
|
AD_STATE_SKIPPED,
|
||||||
AD_STATE_PLAYED,
|
AD_STATE_SKIPPED,
|
||||||
AD_STATE_PLAYED)
|
AD_STATE_SKIPPED)
|
||||||
.inOrder();
|
.inOrder();
|
||||||
assertThat(adPlaybackState5.getAdGroup(/* adGroupIndex= */ 0).durationsUs)
|
assertThat(adPlaybackState5.getAdGroup(/* adGroupIndex= */ 0).durationsUs)
|
||||||
.asList()
|
.asList()
|
||||||
@ -2085,11 +2084,11 @@ public class ImaUtilTest {
|
|||||||
.asList()
|
.asList()
|
||||||
.containsExactly(
|
.containsExactly(
|
||||||
AD_STATE_PLAYED,
|
AD_STATE_PLAYED,
|
||||||
AD_STATE_PLAYED,
|
AD_STATE_SKIPPED,
|
||||||
AD_STATE_PLAYED,
|
AD_STATE_SKIPPED,
|
||||||
AD_STATE_PLAYED,
|
AD_STATE_SKIPPED,
|
||||||
AD_STATE_PLAYED,
|
AD_STATE_SKIPPED,
|
||||||
AD_STATE_PLAYED)
|
AD_STATE_SKIPPED)
|
||||||
.inOrder();
|
.inOrder();
|
||||||
assertThat(adPlaybackState6.getAdGroup(/* adGroupIndex= */ 0).durationsUs)
|
assertThat(adPlaybackState6.getAdGroup(/* adGroupIndex= */ 0).durationsUs)
|
||||||
.asList()
|
.asList()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user