mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Add MediaSourceFactory#setDrmSessionManagerProvider()
Deprecate other DRM config methods. Issue: #8466 PiperOrigin-RevId: 353251452
This commit is contained in:
parent
9825e5f9d7
commit
5b9fa7d7d9
9 changed files with 210 additions and 40 deletions
|
|
@ -191,6 +191,9 @@
|
||||||
waiting for the response. This fixes (harmless) `IllegalStateException:
|
waiting for the response. This fixes (harmless) `IllegalStateException:
|
||||||
sending message to a Handler on a dead thread` log messages
|
sending message to a Handler on a dead thread` log messages
|
||||||
([#8328](https://github.com/google/ExoPlayer/issues/8328)).
|
([#8328](https://github.com/google/ExoPlayer/issues/8328)).
|
||||||
|
* Allow apps to fully customize DRM behaviour per-`MediaItem` by passing a
|
||||||
|
`DrmSessionManagerProvider` to `MediaSourceFactory`
|
||||||
|
([#8466](https://github.com/google/ExoPlayer/issues/8466)).
|
||||||
* Analytics:
|
* Analytics:
|
||||||
* Pass a `DecoderReuseEvaluation` to `AnalyticsListener`'s
|
* Pass a `DecoderReuseEvaluation` to `AnalyticsListener`'s
|
||||||
`onVideoInputFormatChanged` and `onAudioInputFormatChanged` methods. The
|
`onVideoInputFormatChanged` and `onAudioInputFormatChanged` methods. The
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2021 The Android Open Source Project
|
* Copyright 2021 The Android Open Source Project
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.MediaItem;
|
import com.google.android.exoplayer2.MediaItem;
|
||||||
import com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider;
|
import com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider;
|
||||||
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
||||||
|
import com.google.android.exoplayer2.drm.DrmSessionManagerProvider;
|
||||||
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
|
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
|
||||||
import com.google.android.exoplayer2.extractor.ExtractorsFactory;
|
import com.google.android.exoplayer2.extractor.ExtractorsFactory;
|
||||||
import com.google.android.exoplayer2.offline.StreamKey;
|
import com.google.android.exoplayer2.offline.StreamKey;
|
||||||
|
|
@ -101,14 +102,14 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
||||||
|
|
||||||
private static final String TAG = "DefaultMediaSourceFactory";
|
private static final String TAG = "DefaultMediaSourceFactory";
|
||||||
|
|
||||||
private final DefaultDrmSessionManagerProvider drmSessionManagerProvider;
|
|
||||||
private final DataSource.Factory dataSourceFactory;
|
private final DataSource.Factory dataSourceFactory;
|
||||||
private final SparseArray<MediaSourceFactory> mediaSourceFactories;
|
private final SparseArray<MediaSourceFactory> mediaSourceFactories;
|
||||||
@C.ContentType private final int[] supportedTypes;
|
@C.ContentType private final int[] supportedTypes;
|
||||||
|
|
||||||
@Nullable private AdsLoaderProvider adsLoaderProvider;
|
@Nullable private AdsLoaderProvider adsLoaderProvider;
|
||||||
@Nullable private AdViewProvider adViewProvider;
|
@Nullable private AdViewProvider adViewProvider;
|
||||||
@Nullable private DrmSessionManager drmSessionManager;
|
private boolean usingCustomDrmSessionManagerProvider;
|
||||||
|
private DrmSessionManagerProvider drmSessionManagerProvider;
|
||||||
@Nullable private List<StreamKey> streamKeys;
|
@Nullable private List<StreamKey> streamKeys;
|
||||||
@Nullable private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
@Nullable private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
||||||
private long liveTargetOffsetMs;
|
private long liveTargetOffsetMs;
|
||||||
|
|
@ -258,20 +259,42 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
||||||
@Override
|
@Override
|
||||||
public DefaultMediaSourceFactory setDrmHttpDataSourceFactory(
|
public DefaultMediaSourceFactory setDrmHttpDataSourceFactory(
|
||||||
@Nullable HttpDataSource.Factory drmHttpDataSourceFactory) {
|
@Nullable HttpDataSource.Factory drmHttpDataSourceFactory) {
|
||||||
drmSessionManagerProvider.setDrmHttpDataSourceFactory(drmHttpDataSourceFactory);
|
if (!usingCustomDrmSessionManagerProvider) {
|
||||||
|
((DefaultDrmSessionManagerProvider) drmSessionManagerProvider)
|
||||||
|
.setDrmHttpDataSourceFactory(drmHttpDataSourceFactory);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DefaultMediaSourceFactory setDrmUserAgent(@Nullable String userAgent) {
|
public DefaultMediaSourceFactory setDrmUserAgent(@Nullable String userAgent) {
|
||||||
drmSessionManagerProvider.setDrmUserAgent(userAgent);
|
if (!usingCustomDrmSessionManagerProvider) {
|
||||||
|
((DefaultDrmSessionManagerProvider) drmSessionManagerProvider).setDrmUserAgent(userAgent);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DefaultMediaSourceFactory setDrmSessionManager(
|
public DefaultMediaSourceFactory setDrmSessionManager(
|
||||||
@Nullable DrmSessionManager drmSessionManager) {
|
@Nullable DrmSessionManager drmSessionManager) {
|
||||||
this.drmSessionManager = drmSessionManager;
|
if (drmSessionManager == null) {
|
||||||
|
setDrmSessionManagerProvider(null);
|
||||||
|
} else {
|
||||||
|
setDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DefaultMediaSourceFactory setDrmSessionManagerProvider(
|
||||||
|
@Nullable DrmSessionManagerProvider drmSessionManagerProvider) {
|
||||||
|
if (drmSessionManagerProvider != null) {
|
||||||
|
this.drmSessionManagerProvider = drmSessionManagerProvider;
|
||||||
|
this.usingCustomDrmSessionManagerProvider = true;
|
||||||
|
} else {
|
||||||
|
this.drmSessionManagerProvider = new DefaultDrmSessionManagerProvider();
|
||||||
|
this.usingCustomDrmSessionManagerProvider = false;
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -310,8 +333,7 @@ public final class DefaultMediaSourceFactory implements MediaSourceFactory {
|
||||||
@Nullable MediaSourceFactory mediaSourceFactory = mediaSourceFactories.get(type);
|
@Nullable MediaSourceFactory mediaSourceFactory = mediaSourceFactories.get(type);
|
||||||
Assertions.checkNotNull(
|
Assertions.checkNotNull(
|
||||||
mediaSourceFactory, "No suitable media source factory found for content type: " + type);
|
mediaSourceFactory, "No suitable media source factory found for content type: " + type);
|
||||||
mediaSourceFactory.setDrmSessionManager(
|
mediaSourceFactory.setDrmSessionManagerProvider(drmSessionManagerProvider);
|
||||||
drmSessionManager != null ? drmSessionManager : drmSessionManagerProvider.get(mediaItem));
|
|
||||||
mediaSourceFactory.setStreamKeys(
|
mediaSourceFactory.setStreamKeys(
|
||||||
!mediaItem.playbackProperties.streamKeys.isEmpty()
|
!mediaItem.playbackProperties.streamKeys.isEmpty()
|
||||||
? mediaItem.playbackProperties.streamKeys
|
? mediaItem.playbackProperties.streamKeys
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ import com.google.android.exoplayer2.MediaItem;
|
||||||
import com.google.android.exoplayer2.Player;
|
import com.google.android.exoplayer2.Player;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.Timeline;
|
||||||
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
||||||
|
import com.google.android.exoplayer2.drm.DrmSessionManagerProvider;
|
||||||
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
|
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
|
||||||
import com.google.android.exoplayer2.extractor.Extractor;
|
import com.google.android.exoplayer2.extractor.Extractor;
|
||||||
import com.google.android.exoplayer2.extractor.ExtractorsFactory;
|
import com.google.android.exoplayer2.extractor.ExtractorsFactory;
|
||||||
|
|
@ -154,6 +155,18 @@ public final class ExtractorMediaSource extends CompositeMediaSource<Void> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link
|
||||||
|
* ProgressiveMediaSource.Factory#setDrmSessionManagerProvider(DrmSessionManagerProvider)}
|
||||||
|
* instead.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
@Override
|
||||||
|
public Factory setDrmSessionManagerProvider(
|
||||||
|
@Nullable DrmSessionManagerProvider drmSessionManagerProvider) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
/** @deprecated Use {@link ProgressiveMediaSource.Factory#setDrmSessionManager} instead. */
|
/** @deprecated Use {@link ProgressiveMediaSource.Factory#setDrmSessionManager} instead. */
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,9 @@ import androidx.annotation.Nullable;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.MediaItem;
|
import com.google.android.exoplayer2.MediaItem;
|
||||||
import com.google.android.exoplayer2.drm.DefaultDrmSessionManager;
|
import com.google.android.exoplayer2.drm.DefaultDrmSessionManager;
|
||||||
|
import com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider;
|
||||||
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
||||||
|
import com.google.android.exoplayer2.drm.DrmSessionManagerProvider;
|
||||||
import com.google.android.exoplayer2.drm.HttpMediaDrmCallback;
|
import com.google.android.exoplayer2.drm.HttpMediaDrmCallback;
|
||||||
import com.google.android.exoplayer2.offline.StreamKey;
|
import com.google.android.exoplayer2.offline.StreamKey;
|
||||||
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
|
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
|
||||||
|
|
@ -56,41 +58,80 @@ public interface MediaSourceFactory {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@link DrmSessionManagerProvider} used to obtain a {@link DrmSessionManager} for a
|
||||||
|
* {@link MediaItem}.
|
||||||
|
*
|
||||||
|
* <p>If not set, {@link DefaultDrmSessionManagerProvider} is used.
|
||||||
|
*
|
||||||
|
* <p>If set, calls to the following (deprecated) methods are ignored:
|
||||||
|
*
|
||||||
|
* <ul>
|
||||||
|
* <li>{@link #setDrmUserAgent(String)}
|
||||||
|
* <li>{@link #setDrmHttpDataSourceFactory(HttpDataSource.Factory)}
|
||||||
|
* </ul>
|
||||||
|
*
|
||||||
|
* @return This factory, for convenience.
|
||||||
|
*/
|
||||||
|
MediaSourceFactory setDrmSessionManagerProvider(
|
||||||
|
@Nullable DrmSessionManagerProvider drmSessionManagerProvider);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link DrmSessionManager} to use for all media items regardless of their {@link
|
* Sets the {@link DrmSessionManager} to use for all media items regardless of their {@link
|
||||||
* MediaItem.DrmConfiguration}.
|
* MediaItem.DrmConfiguration}.
|
||||||
*
|
*
|
||||||
|
* <p>Calling this with a non-null {@code drmSessionManager} is equivalent to calling {@code
|
||||||
|
* setDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager)}.
|
||||||
|
*
|
||||||
* @param drmSessionManager The {@link DrmSessionManager}, or {@code null} to use the {@link
|
* @param drmSessionManager The {@link DrmSessionManager}, or {@code null} to use the {@link
|
||||||
* DefaultDrmSessionManager}.
|
* DefaultDrmSessionManager}.
|
||||||
* @return This factory, for convenience.
|
* @return This factory, for convenience.
|
||||||
|
* @deprecated Use {@link #setDrmSessionManagerProvider(DrmSessionManagerProvider)} and pass an
|
||||||
|
* implementation that always returns the same instance.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
MediaSourceFactory setDrmSessionManager(@Nullable DrmSessionManager drmSessionManager);
|
MediaSourceFactory setDrmSessionManager(@Nullable DrmSessionManager drmSessionManager);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the {@link HttpDataSource.Factory} to be used for creating {@link HttpMediaDrmCallback
|
* Sets the {@link HttpDataSource.Factory} to be used for creating {@link HttpMediaDrmCallback
|
||||||
* HttpMediaDrmCallbacks} to execute key and provisioning requests over HTTP.
|
* HttpMediaDrmCallbacks} to execute key and provisioning requests over HTTP.
|
||||||
*
|
*
|
||||||
* <p>In case a {@link DrmSessionManager} has been set by {@link
|
* <p>Calls to this method are ignored if either a {@link
|
||||||
* #setDrmSessionManager(DrmSessionManager)}, this data source factory is ignored.
|
* #setDrmSessionManagerProvider(DrmSessionManagerProvider) DrmSessionManager provider} or {@link
|
||||||
|
* #setDrmSessionManager(DrmSessionManager) concrete DrmSessionManager} are provided.
|
||||||
*
|
*
|
||||||
* @param drmHttpDataSourceFactory The HTTP data source factory, or {@code null} to use {@link
|
* @param drmHttpDataSourceFactory The HTTP data source factory, or {@code null} to use {@link
|
||||||
* DefaultHttpDataSourceFactory}.
|
* DefaultHttpDataSourceFactory}.
|
||||||
* @return This factory, for convenience.
|
* @return This factory, for convenience.
|
||||||
|
* @deprecated Use {@link #setDrmSessionManagerProvider(DrmSessionManagerProvider)} and pass an
|
||||||
|
* implementation that configures the returned {@link DrmSessionManager} with the desired
|
||||||
|
* {@link HttpDataSource.Factory}.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
MediaSourceFactory setDrmHttpDataSourceFactory(
|
MediaSourceFactory setDrmHttpDataSourceFactory(
|
||||||
@Nullable HttpDataSource.Factory drmHttpDataSourceFactory);
|
@Nullable HttpDataSource.Factory drmHttpDataSourceFactory);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the optional user agent to be used for DRM requests.
|
* Sets the optional user agent to be used for DRM requests.
|
||||||
*
|
*
|
||||||
* <p>In case a factory has been set by {@link
|
* <p>Calls to this method are ignored if any of the following are provided:
|
||||||
* #setDrmHttpDataSourceFactory(HttpDataSource.Factory)} or a {@link DrmSessionManager} has been
|
*
|
||||||
* set by {@link #setDrmSessionManager(DrmSessionManager)}, this user agent is ignored.
|
* <ul>
|
||||||
|
* <li>A {@link #setDrmSessionManagerProvider(DrmSessionManagerProvider) DrmSessionManager
|
||||||
|
* provider}.
|
||||||
|
* <li>A {@link #setDrmSessionManager(DrmSessionManager) concrete DrmSessionManager}.
|
||||||
|
* <li>A {@link #setDrmHttpDataSourceFactory(HttpDataSource.Factory) DRM
|
||||||
|
* HttpDataSource.Factory}.
|
||||||
|
* </ul>
|
||||||
*
|
*
|
||||||
* @param userAgent The user agent to be used for DRM requests, or {@code null} to use the
|
* @param userAgent The user agent to be used for DRM requests, or {@code null} to use the
|
||||||
* default.
|
* default.
|
||||||
* @return This factory, for convenience.
|
* @return This factory, for convenience.
|
||||||
|
* @deprecated Use {@link #setDrmSessionManagerProvider(DrmSessionManagerProvider)} and pass an
|
||||||
|
* implementation that configures the returned {@link DrmSessionManager} with the desired
|
||||||
|
* {@code userAgent}.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
MediaSourceFactory setDrmUserAgent(@Nullable String userAgent);
|
MediaSourceFactory setDrmUserAgent(@Nullable String userAgent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import com.google.android.exoplayer2.MediaItem;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.Timeline;
|
||||||
import com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider;
|
import com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider;
|
||||||
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
||||||
|
import com.google.android.exoplayer2.drm.DrmSessionManagerProvider;
|
||||||
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
|
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory;
|
||||||
import com.google.android.exoplayer2.extractor.Extractor;
|
import com.google.android.exoplayer2.extractor.Extractor;
|
||||||
import com.google.android.exoplayer2.extractor.ExtractorsFactory;
|
import com.google.android.exoplayer2.extractor.ExtractorsFactory;
|
||||||
|
|
@ -52,10 +53,10 @@ public final class ProgressiveMediaSource extends BaseMediaSource
|
||||||
public static final class Factory implements MediaSourceFactory {
|
public static final class Factory implements MediaSourceFactory {
|
||||||
|
|
||||||
private final DataSource.Factory dataSourceFactory;
|
private final DataSource.Factory dataSourceFactory;
|
||||||
private final DefaultDrmSessionManagerProvider drmSessionManagerProvider;
|
|
||||||
|
|
||||||
private ExtractorsFactory extractorsFactory;
|
private ExtractorsFactory extractorsFactory;
|
||||||
@Nullable private DrmSessionManager drmSessionManager;
|
private boolean usingCustomDrmSessionManagerProvider;
|
||||||
|
private DrmSessionManagerProvider drmSessionManagerProvider;
|
||||||
private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
||||||
private int continueLoadingCheckIntervalBytes;
|
private int continueLoadingCheckIntervalBytes;
|
||||||
@Nullable private String customCacheKey;
|
@Nullable private String customCacheKey;
|
||||||
|
|
@ -149,21 +150,42 @@ public final class ProgressiveMediaSource extends BaseMediaSource
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
public Factory setDrmSessionManagerProvider(
|
||||||
|
@Nullable DrmSessionManagerProvider drmSessionManagerProvider) {
|
||||||
|
if (drmSessionManagerProvider != null) {
|
||||||
|
this.drmSessionManagerProvider = drmSessionManagerProvider;
|
||||||
|
this.usingCustomDrmSessionManagerProvider = true;
|
||||||
|
} else {
|
||||||
|
this.drmSessionManagerProvider = new DefaultDrmSessionManagerProvider();
|
||||||
|
this.usingCustomDrmSessionManagerProvider = false;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Factory setDrmSessionManager(@Nullable DrmSessionManager drmSessionManager) {
|
public Factory setDrmSessionManager(@Nullable DrmSessionManager drmSessionManager) {
|
||||||
this.drmSessionManager = drmSessionManager;
|
if (drmSessionManager == null) {
|
||||||
|
setDrmSessionManagerProvider(null);
|
||||||
|
} else {
|
||||||
|
setDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Factory setDrmHttpDataSourceFactory(
|
public Factory setDrmHttpDataSourceFactory(
|
||||||
@Nullable HttpDataSource.Factory drmHttpDataSourceFactory) {
|
@Nullable HttpDataSource.Factory drmHttpDataSourceFactory) {
|
||||||
drmSessionManagerProvider.setDrmHttpDataSourceFactory(drmHttpDataSourceFactory);
|
if (!usingCustomDrmSessionManagerProvider) {
|
||||||
|
((DefaultDrmSessionManagerProvider) drmSessionManagerProvider)
|
||||||
|
.setDrmHttpDataSourceFactory(drmHttpDataSourceFactory);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Factory setDrmUserAgent(@Nullable String userAgent) {
|
public Factory setDrmUserAgent(@Nullable String userAgent) {
|
||||||
drmSessionManagerProvider.setDrmUserAgent(userAgent);
|
if (!usingCustomDrmSessionManagerProvider) {
|
||||||
|
((DefaultDrmSessionManagerProvider) drmSessionManagerProvider).setDrmUserAgent(userAgent);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -199,7 +221,7 @@ public final class ProgressiveMediaSource extends BaseMediaSource
|
||||||
mediaItem,
|
mediaItem,
|
||||||
dataSourceFactory,
|
dataSourceFactory,
|
||||||
extractorsFactory,
|
extractorsFactory,
|
||||||
drmSessionManager != null ? drmSessionManager : drmSessionManagerProvider.get(mediaItem),
|
drmSessionManagerProvider.get(mediaItem),
|
||||||
loadErrorHandlingPolicy,
|
loadErrorHandlingPolicy,
|
||||||
continueLoadingCheckIntervalBytes);
|
continueLoadingCheckIntervalBytes);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ import com.google.android.exoplayer2.Timeline;
|
||||||
import com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider;
|
import com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider;
|
||||||
import com.google.android.exoplayer2.drm.DrmSessionEventListener;
|
import com.google.android.exoplayer2.drm.DrmSessionEventListener;
|
||||||
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
||||||
|
import com.google.android.exoplayer2.drm.DrmSessionManagerProvider;
|
||||||
import com.google.android.exoplayer2.offline.FilteringManifestParser;
|
import com.google.android.exoplayer2.offline.FilteringManifestParser;
|
||||||
import com.google.android.exoplayer2.offline.StreamKey;
|
import com.google.android.exoplayer2.offline.StreamKey;
|
||||||
import com.google.android.exoplayer2.source.BaseMediaSource;
|
import com.google.android.exoplayer2.source.BaseMediaSource;
|
||||||
|
|
@ -99,10 +100,10 @@ public final class DashMediaSource extends BaseMediaSource {
|
||||||
public static final class Factory implements MediaSourceFactory {
|
public static final class Factory implements MediaSourceFactory {
|
||||||
|
|
||||||
private final DashChunkSource.Factory chunkSourceFactory;
|
private final DashChunkSource.Factory chunkSourceFactory;
|
||||||
private final DefaultDrmSessionManagerProvider drmSessionManagerProvider;
|
|
||||||
@Nullable private final DataSource.Factory manifestDataSourceFactory;
|
@Nullable private final DataSource.Factory manifestDataSourceFactory;
|
||||||
|
|
||||||
@Nullable private DrmSessionManager drmSessionManager;
|
private boolean usingCustomDrmSessionManagerProvider;
|
||||||
|
private DrmSessionManagerProvider drmSessionManagerProvider;
|
||||||
private CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory;
|
private CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory;
|
||||||
private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
||||||
private long targetLiveOffsetOverrideMs;
|
private long targetLiveOffsetOverrideMs;
|
||||||
|
|
@ -165,22 +166,44 @@ public final class DashMediaSource extends BaseMediaSource {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Factory setDrmSessionManagerProvider(
|
||||||
|
@Nullable DrmSessionManagerProvider drmSessionManagerProvider) {
|
||||||
|
if (drmSessionManagerProvider != null) {
|
||||||
|
this.drmSessionManagerProvider = drmSessionManagerProvider;
|
||||||
|
this.usingCustomDrmSessionManagerProvider = true;
|
||||||
|
} else {
|
||||||
|
this.drmSessionManagerProvider = new DefaultDrmSessionManagerProvider();
|
||||||
|
this.usingCustomDrmSessionManagerProvider = false;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Factory setDrmSessionManager(@Nullable DrmSessionManager drmSessionManager) {
|
public Factory setDrmSessionManager(@Nullable DrmSessionManager drmSessionManager) {
|
||||||
this.drmSessionManager = drmSessionManager;
|
if (drmSessionManager == null) {
|
||||||
|
setDrmSessionManagerProvider(null);
|
||||||
|
} else {
|
||||||
|
setDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Factory setDrmHttpDataSourceFactory(
|
public Factory setDrmHttpDataSourceFactory(
|
||||||
@Nullable HttpDataSource.Factory drmHttpDataSourceFactory) {
|
@Nullable HttpDataSource.Factory drmHttpDataSourceFactory) {
|
||||||
drmSessionManagerProvider.setDrmHttpDataSourceFactory(drmHttpDataSourceFactory);
|
if (!usingCustomDrmSessionManagerProvider) {
|
||||||
|
((DefaultDrmSessionManagerProvider) drmSessionManagerProvider)
|
||||||
|
.setDrmHttpDataSourceFactory(drmHttpDataSourceFactory);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Factory setDrmUserAgent(@Nullable String userAgent) {
|
public Factory setDrmUserAgent(@Nullable String userAgent) {
|
||||||
drmSessionManagerProvider.setDrmUserAgent(userAgent);
|
if (!usingCustomDrmSessionManagerProvider) {
|
||||||
|
((DefaultDrmSessionManagerProvider) drmSessionManagerProvider).setDrmUserAgent(userAgent);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -319,7 +342,7 @@ public final class DashMediaSource extends BaseMediaSource {
|
||||||
/* manifestParser= */ null,
|
/* manifestParser= */ null,
|
||||||
chunkSourceFactory,
|
chunkSourceFactory,
|
||||||
compositeSequenceableLoaderFactory,
|
compositeSequenceableLoaderFactory,
|
||||||
drmSessionManager != null ? drmSessionManager : drmSessionManagerProvider.get(mediaItem),
|
drmSessionManagerProvider.get(mediaItem),
|
||||||
loadErrorHandlingPolicy,
|
loadErrorHandlingPolicy,
|
||||||
fallbackTargetLiveOffsetMs);
|
fallbackTargetLiveOffsetMs);
|
||||||
}
|
}
|
||||||
|
|
@ -385,7 +408,7 @@ public final class DashMediaSource extends BaseMediaSource {
|
||||||
manifestParser,
|
manifestParser,
|
||||||
chunkSourceFactory,
|
chunkSourceFactory,
|
||||||
compositeSequenceableLoaderFactory,
|
compositeSequenceableLoaderFactory,
|
||||||
drmSessionManager != null ? drmSessionManager : drmSessionManagerProvider.get(mediaItem),
|
drmSessionManagerProvider.get(mediaItem),
|
||||||
loadErrorHandlingPolicy,
|
loadErrorHandlingPolicy,
|
||||||
fallbackTargetLiveOffsetMs);
|
fallbackTargetLiveOffsetMs);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ import com.google.android.exoplayer2.MediaItem;
|
||||||
import com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider;
|
import com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider;
|
||||||
import com.google.android.exoplayer2.drm.DrmSessionEventListener;
|
import com.google.android.exoplayer2.drm.DrmSessionEventListener;
|
||||||
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
||||||
|
import com.google.android.exoplayer2.drm.DrmSessionManagerProvider;
|
||||||
import com.google.android.exoplayer2.extractor.Extractor;
|
import com.google.android.exoplayer2.extractor.Extractor;
|
||||||
import com.google.android.exoplayer2.offline.StreamKey;
|
import com.google.android.exoplayer2.offline.StreamKey;
|
||||||
import com.google.android.exoplayer2.source.BaseMediaSource;
|
import com.google.android.exoplayer2.source.BaseMediaSource;
|
||||||
|
|
@ -94,13 +95,13 @@ public final class HlsMediaSource extends BaseMediaSource
|
||||||
public static final class Factory implements MediaSourceFactory {
|
public static final class Factory implements MediaSourceFactory {
|
||||||
|
|
||||||
private final HlsDataSourceFactory hlsDataSourceFactory;
|
private final HlsDataSourceFactory hlsDataSourceFactory;
|
||||||
private final DefaultDrmSessionManagerProvider drmSessionManagerProvider;
|
|
||||||
|
|
||||||
private HlsExtractorFactory extractorFactory;
|
private HlsExtractorFactory extractorFactory;
|
||||||
private HlsPlaylistParserFactory playlistParserFactory;
|
private HlsPlaylistParserFactory playlistParserFactory;
|
||||||
private HlsPlaylistTracker.Factory playlistTrackerFactory;
|
private HlsPlaylistTracker.Factory playlistTrackerFactory;
|
||||||
private CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory;
|
private CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory;
|
||||||
@Nullable private DrmSessionManager drmSessionManager;
|
private boolean usingCustomDrmSessionManagerProvider;
|
||||||
|
private DrmSessionManagerProvider drmSessionManagerProvider;
|
||||||
private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
||||||
private boolean allowChunklessPreparation;
|
private boolean allowChunklessPreparation;
|
||||||
@MetadataType private int metadataType;
|
@MetadataType private int metadataType;
|
||||||
|
|
@ -280,22 +281,44 @@ public final class HlsMediaSource extends BaseMediaSource
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Factory setDrmSessionManagerProvider(
|
||||||
|
@Nullable DrmSessionManagerProvider drmSessionManagerProvider) {
|
||||||
|
if (drmSessionManagerProvider != null) {
|
||||||
|
this.drmSessionManagerProvider = drmSessionManagerProvider;
|
||||||
|
this.usingCustomDrmSessionManagerProvider = true;
|
||||||
|
} else {
|
||||||
|
this.drmSessionManagerProvider = new DefaultDrmSessionManagerProvider();
|
||||||
|
this.usingCustomDrmSessionManagerProvider = false;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Factory setDrmSessionManager(@Nullable DrmSessionManager drmSessionManager) {
|
public Factory setDrmSessionManager(@Nullable DrmSessionManager drmSessionManager) {
|
||||||
this.drmSessionManager = drmSessionManager;
|
if (drmSessionManager == null) {
|
||||||
|
setDrmSessionManagerProvider(null);
|
||||||
|
} else {
|
||||||
|
setDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Factory setDrmHttpDataSourceFactory(
|
public Factory setDrmHttpDataSourceFactory(
|
||||||
@Nullable HttpDataSource.Factory drmHttpDataSourceFactory) {
|
@Nullable HttpDataSource.Factory drmHttpDataSourceFactory) {
|
||||||
drmSessionManagerProvider.setDrmHttpDataSourceFactory(drmHttpDataSourceFactory);
|
if (!usingCustomDrmSessionManagerProvider) {
|
||||||
|
((DefaultDrmSessionManagerProvider) drmSessionManagerProvider)
|
||||||
|
.setDrmHttpDataSourceFactory(drmHttpDataSourceFactory);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MediaSourceFactory setDrmUserAgent(@Nullable String userAgent) {
|
public Factory setDrmUserAgent(@Nullable String userAgent) {
|
||||||
drmSessionManagerProvider.setDrmUserAgent(userAgent);
|
if (!usingCustomDrmSessionManagerProvider) {
|
||||||
|
((DefaultDrmSessionManagerProvider) drmSessionManagerProvider).setDrmUserAgent(userAgent);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -369,7 +392,7 @@ public final class HlsMediaSource extends BaseMediaSource
|
||||||
hlsDataSourceFactory,
|
hlsDataSourceFactory,
|
||||||
extractorFactory,
|
extractorFactory,
|
||||||
compositeSequenceableLoaderFactory,
|
compositeSequenceableLoaderFactory,
|
||||||
drmSessionManager != null ? drmSessionManager : drmSessionManagerProvider.get(mediaItem),
|
drmSessionManagerProvider.get(mediaItem),
|
||||||
loadErrorHandlingPolicy,
|
loadErrorHandlingPolicy,
|
||||||
playlistTrackerFactory.createTracker(
|
playlistTrackerFactory.createTracker(
|
||||||
hlsDataSourceFactory, loadErrorHandlingPolicy, playlistParserFactory),
|
hlsDataSourceFactory, loadErrorHandlingPolicy, playlistParserFactory),
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import com.google.android.exoplayer2.Timeline;
|
||||||
import com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider;
|
import com.google.android.exoplayer2.drm.DefaultDrmSessionManagerProvider;
|
||||||
import com.google.android.exoplayer2.drm.DrmSessionEventListener;
|
import com.google.android.exoplayer2.drm.DrmSessionEventListener;
|
||||||
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
||||||
|
import com.google.android.exoplayer2.drm.DrmSessionManagerProvider;
|
||||||
import com.google.android.exoplayer2.offline.FilteringManifestParser;
|
import com.google.android.exoplayer2.offline.FilteringManifestParser;
|
||||||
import com.google.android.exoplayer2.offline.StreamKey;
|
import com.google.android.exoplayer2.offline.StreamKey;
|
||||||
import com.google.android.exoplayer2.source.BaseMediaSource;
|
import com.google.android.exoplayer2.source.BaseMediaSource;
|
||||||
|
|
@ -78,11 +79,11 @@ public final class SsMediaSource extends BaseMediaSource
|
||||||
public static final class Factory implements MediaSourceFactory {
|
public static final class Factory implements MediaSourceFactory {
|
||||||
|
|
||||||
private final SsChunkSource.Factory chunkSourceFactory;
|
private final SsChunkSource.Factory chunkSourceFactory;
|
||||||
private final DefaultDrmSessionManagerProvider drmSessionManagerProvider;
|
|
||||||
@Nullable private final DataSource.Factory manifestDataSourceFactory;
|
@Nullable private final DataSource.Factory manifestDataSourceFactory;
|
||||||
|
|
||||||
private CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory;
|
private CompositeSequenceableLoaderFactory compositeSequenceableLoaderFactory;
|
||||||
@Nullable private DrmSessionManager drmSessionManager;
|
private boolean usingCustomDrmSessionManagerProvider;
|
||||||
|
private DrmSessionManagerProvider drmSessionManagerProvider;
|
||||||
private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
private LoadErrorHandlingPolicy loadErrorHandlingPolicy;
|
||||||
private long livePresentationDelayMs;
|
private long livePresentationDelayMs;
|
||||||
@Nullable private ParsingLoadable.Parser<? extends SsManifest> manifestParser;
|
@Nullable private ParsingLoadable.Parser<? extends SsManifest> manifestParser;
|
||||||
|
|
@ -191,22 +192,44 @@ public final class SsMediaSource extends BaseMediaSource
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Factory setDrmSessionManagerProvider(
|
||||||
|
@Nullable DrmSessionManagerProvider drmSessionManagerProvider) {
|
||||||
|
if (drmSessionManagerProvider != null) {
|
||||||
|
this.drmSessionManagerProvider = drmSessionManagerProvider;
|
||||||
|
this.usingCustomDrmSessionManagerProvider = true;
|
||||||
|
} else {
|
||||||
|
this.drmSessionManagerProvider = new DefaultDrmSessionManagerProvider();
|
||||||
|
this.usingCustomDrmSessionManagerProvider = false;
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Factory setDrmSessionManager(@Nullable DrmSessionManager drmSessionManager) {
|
public Factory setDrmSessionManager(@Nullable DrmSessionManager drmSessionManager) {
|
||||||
this.drmSessionManager = drmSessionManager;
|
if (drmSessionManager == null) {
|
||||||
|
setDrmSessionManagerProvider(null);
|
||||||
|
} else {
|
||||||
|
setDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Factory setDrmHttpDataSourceFactory(
|
public Factory setDrmHttpDataSourceFactory(
|
||||||
@Nullable HttpDataSource.Factory drmHttpDataSourceFactory) {
|
@Nullable HttpDataSource.Factory drmHttpDataSourceFactory) {
|
||||||
drmSessionManagerProvider.setDrmHttpDataSourceFactory(drmHttpDataSourceFactory);
|
if (!usingCustomDrmSessionManagerProvider) {
|
||||||
|
((DefaultDrmSessionManagerProvider) drmSessionManagerProvider)
|
||||||
|
.setDrmHttpDataSourceFactory(drmHttpDataSourceFactory);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Factory setDrmUserAgent(@Nullable String userAgent) {
|
public Factory setDrmUserAgent(@Nullable String userAgent) {
|
||||||
drmSessionManagerProvider.setDrmUserAgent(userAgent);
|
if (!usingCustomDrmSessionManagerProvider) {
|
||||||
|
((DefaultDrmSessionManagerProvider) drmSessionManagerProvider).setDrmUserAgent(userAgent);
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -277,7 +300,7 @@ public final class SsMediaSource extends BaseMediaSource
|
||||||
/* manifestParser= */ null,
|
/* manifestParser= */ null,
|
||||||
chunkSourceFactory,
|
chunkSourceFactory,
|
||||||
compositeSequenceableLoaderFactory,
|
compositeSequenceableLoaderFactory,
|
||||||
drmSessionManager != null ? drmSessionManager : drmSessionManagerProvider.get(mediaItem),
|
drmSessionManagerProvider.get(mediaItem),
|
||||||
loadErrorHandlingPolicy,
|
loadErrorHandlingPolicy,
|
||||||
livePresentationDelayMs);
|
livePresentationDelayMs);
|
||||||
}
|
}
|
||||||
|
|
@ -321,7 +344,7 @@ public final class SsMediaSource extends BaseMediaSource
|
||||||
manifestParser,
|
manifestParser,
|
||||||
chunkSourceFactory,
|
chunkSourceFactory,
|
||||||
compositeSequenceableLoaderFactory,
|
compositeSequenceableLoaderFactory,
|
||||||
drmSessionManager != null ? drmSessionManager : drmSessionManagerProvider.get(mediaItem),
|
drmSessionManagerProvider.get(mediaItem),
|
||||||
loadErrorHandlingPolicy,
|
loadErrorHandlingPolicy,
|
||||||
livePresentationDelayMs);
|
livePresentationDelayMs);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue