mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00

This change makes sure that the `AdPlaybackState` of any period can contain an empty postroll placeholder. The placeholder postroll should be represented in the `MediaPeriodId` of a content period as `nextAdGroupIndex`, but should be ignored when building the list of `MediaPeriodInfo` in the `MediaPeriodQueue`. This is required to allow to add an ad group to ad playback state of the content period that is currently being played, instantly insert an ad period into the media period queue and immediately transition playback to the new period. This change makes sure and tests that - a live server side inserted postroll placeholder can be inserted to a `AdPlaybackState` in well-defined and tested way (helper method) - a postroll placeholder is NOT ignored when `AdPlaybackState.getAdGroupIndexAfterPositionUs` is called (this is required when evaluating the `nextAdGroupIndex`). - a postroll placeholder is ignored when `AdPlaybackState.getAdGroupIndexForPositionUs` is called (this is required to not attempt to play the ad and is analogous to ignore the post roll placeholder in a single period timeline). - `MediaPeriod.getFollowingMediaPeriodInfo()` does not include a `MediaPeriodInfo` for the placeholder postroll when building the queue. PiperOrigin-RevId: 515079136