Replace isTopLevelSource check by period count check in AdsMediaSource.

The top level requirement only tried to ensure that the entire timeline only
has one period. This is already asserted by ImaAdsLoader. AdsMediaSource
itself works fine as long as the wrapped timeline has one period only. This
is now asserted instead.

PiperOrigin-RevId: 227682141
This commit is contained in:
tonihei 2019-01-03 14:54:37 +00:00 committed by Oliver Woodman
parent e4ad90efd0
commit c130723929

View file

@ -331,9 +331,6 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
boolean isTopLevelSource,
@Nullable TransferListener mediaTransferListener) {
super.prepareSourceInternal(player, isTopLevelSource, mediaTransferListener);
Assertions.checkArgument(
isTopLevelSource,
"AdsMediaSource must be the top-level source used to prepare the player.");
final ComponentListener componentListener = new ComponentListener();
this.componentListener = componentListener;
prepareChildSource(DUMMY_CONTENT_MEDIA_PERIOD_ID, contentMediaSource);
@ -444,6 +441,7 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
}
private void onContentSourceInfoRefreshed(Timeline timeline, Object manifest) {
Assertions.checkArgument(timeline.getPeriodCount() == 1);
contentTimeline = timeline;
contentManifest = manifest;
maybeUpdateSourceInfo();