Commit de359cd6 by ibaker Committed by Oliver Woodman

Propagate DRM config when creating ad media sources

The `DrmConfiguration.sessionForClearTypes` property is often used
to ensure a secure decoder is used for clear ads played in encrypted
content. This is because some devices show black frames when switching
decoders.

Before this change the DRM config isn't propagated down when
constructing the ad media source, meaning
`DrmSessionManager.DRM_UNSUPPORTED` is always used, which will
cause playback to switch from secure to clear decoder when transitioning
to an ad break (ignoring the MediaItem `sessionForClearTypes` option.

Issue: #8568

#minor-release

PiperOrigin-RevId: 356951124
parent f8505204
...@@ -19,6 +19,12 @@ ...@@ -19,6 +19,12 @@
* Add `ImaAdsLoader.focusSkipButton` to allow apps to request that the * Add `ImaAdsLoader.focusSkipButton` to allow apps to request that the
skip button should receive UI focus, if shown skip button should receive UI focus, if shown
([#8565](https://github.com/google/ExoPlayer/issues/8565)). ([#8565](https://github.com/google/ExoPlayer/issues/8565)).
* DRM:
* Re-use the previous `DrmSessionManager` instance when playing a playlist
(if possible)
([#8523](https://github.com/google/ExoPlayer/issues/8523)).
* Propagate DRM configuration when creating media sources for ad content
([#8568](https://github.com/google/ExoPlayer/issues/8568)).
* Remove deprecated symbols: * Remove deprecated symbols:
* Remove `Player.DefaultEventListener`. Use `Player.EventListener` * Remove `Player.DefaultEventListener`. Use `Player.EventListener`
instead. instead.
...@@ -26,10 +32,6 @@ ...@@ -26,10 +32,6 @@
instead. instead.
* Remove `extension-jobdispatcher` module. Use the `extension-workmanager` * Remove `extension-jobdispatcher` module. Use the `extension-workmanager`
module instead. module instead.
* DRM:
* Re-use the previous `DrmSessionManager` instance when playing a playlist
(if possible)
([#8523](https://github.com/google/ExoPlayer/issues/8523)).
### 2.13.0 (2021-02-04) ### 2.13.0 (2021-02-04)
......
...@@ -318,8 +318,28 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> { ...@@ -318,8 +318,28 @@ public final class AdsMediaSource extends CompositeMediaSource<MediaPeriodId> {
&& adIndexInAdGroup < adPlaybackState.adGroups[adGroupIndex].uris.length) { && adIndexInAdGroup < adPlaybackState.adGroups[adGroupIndex].uris.length) {
@Nullable Uri adUri = adPlaybackState.adGroups[adGroupIndex].uris[adIndexInAdGroup]; @Nullable Uri adUri = adPlaybackState.adGroups[adGroupIndex].uris[adIndexInAdGroup];
if (adUri != null) { if (adUri != null) {
MediaSource adMediaSource = MediaItem.Builder adMediaItem = new MediaItem.Builder().setUri(adUri);
adMediaSourceFactory.createMediaSource(MediaItem.fromUri(adUri)); // Propagate the content's DRM config into the ad media source.
@Nullable
MediaItem.PlaybackProperties contentPlaybackProperties =
contentMediaSource.getMediaItem().playbackProperties;
if (contentPlaybackProperties != null
&& contentPlaybackProperties.drmConfiguration != null) {
MediaItem.DrmConfiguration drmConfiguration =
contentPlaybackProperties.drmConfiguration;
// TODO(internal b/179984779): Use MediaItem.Builder#setDrmConfiguration() when it's
// available.
adMediaItem.setDrmUuid(drmConfiguration.uuid);
adMediaItem.setDrmKeySetId(drmConfiguration.getKeySetId());
adMediaItem.setDrmLicenseUri(drmConfiguration.licenseUri);
adMediaItem.setDrmForceDefaultLicenseUri(drmConfiguration.forceDefaultLicenseUri);
adMediaItem.setDrmLicenseRequestHeaders(drmConfiguration.requestHeaders);
adMediaItem.setDrmMultiSession(drmConfiguration.multiSession);
adMediaItem.setDrmPlayClearContentWithoutKey(
drmConfiguration.playClearContentWithoutKey);
adMediaItem.setDrmSessionForClearTypes(drmConfiguration.sessionForClearTypes);
}
MediaSource adMediaSource = adMediaSourceFactory.createMediaSource(adMediaItem.build());
adMediaSourceHolder.initializeWithMediaSource(adMediaSource, adUri); adMediaSourceHolder.initializeWithMediaSource(adMediaSource, adUri);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment