Make DRM code removable from ProgressiveMediaSource

Add a constructor that takes a DrmSessionManagerProvider.
This allows R8 to strip the default implementation.

#minor-release

PiperOrigin-RevId: 425330083
This commit is contained in:
krocard 2022-01-31 12:05:30 +00:00 committed by Andrew Lewis
parent 40517200fc
commit d4eb1edff6

View File

@ -92,11 +92,38 @@ public final class ProgressiveMediaSource extends BaseMediaSource
public Factory(
DataSource.Factory dataSourceFactory,
ProgressiveMediaExtractor.Factory progressiveMediaExtractorFactory) {
this(
dataSourceFactory,
progressiveMediaExtractorFactory,
new DefaultDrmSessionManagerProvider(),
new DefaultLoadErrorHandlingPolicy(),
DEFAULT_LOADING_CHECK_INTERVAL_BYTES);
}
/**
* Creates a new factory for {@link ProgressiveMediaSource}s.
*
* @param dataSourceFactory A factory for {@link DataSource}s to read the media.
* @param progressiveMediaExtractorFactory A factory for the {@link ProgressiveMediaExtractor}
* to extract media from its container.
* @param drmSessionManagerProvider A provider to obtain a {@link DrmSessionManager} for a
* {@link MediaItem}.
* @param loadErrorHandlingPolicy A policy to handle load error.
* @param continueLoadingCheckIntervalBytes The number of bytes that should be loaded between
* each invocation of {@link
* MediaPeriod.Callback#onContinueLoadingRequested(SequenceableLoader)}.
*/
public Factory(
DataSource.Factory dataSourceFactory,
ProgressiveMediaExtractor.Factory progressiveMediaExtractorFactory,
DrmSessionManagerProvider drmSessionManagerProvider,
LoadErrorHandlingPolicy loadErrorHandlingPolicy,
int continueLoadingCheckIntervalBytes) {
this.dataSourceFactory = dataSourceFactory;
this.progressiveMediaExtractorFactory = progressiveMediaExtractorFactory;
drmSessionManagerProvider = new DefaultDrmSessionManagerProvider();
loadErrorHandlingPolicy = new DefaultLoadErrorHandlingPolicy();
continueLoadingCheckIntervalBytes = DEFAULT_LOADING_CHECK_INTERVAL_BYTES;
this.drmSessionManagerProvider = drmSessionManagerProvider;
this.loadErrorHandlingPolicy = loadErrorHandlingPolicy;
this.continueLoadingCheckIntervalBytes = continueLoadingCheckIntervalBytes;
}
/**