From cc8b774b41fbfadb99421af1fd6922042c6c82bc Mon Sep 17 00:00:00 2001 From: aquilescanta Date: Mon, 23 Sep 2019 16:28:22 +0100 Subject: [PATCH] Remove DefaultDrmSessionManager factory methods that enforce MediaDrm leaks Inline invocations of these methods, which still leaks the MediaDrms. However, it will be fixed once the DefaultDrmSessionManager API is finalized and ExoMediaDrm.Providers are introduced. Issue:#4721 PiperOrigin-RevId: 270681467 --- RELEASENOTES.md | 2 + .../drm/DefaultDrmSessionManager.java | 60 ------------------- .../playbacktests/gts/DashTestRunner.java | 9 ++- 3 files changed, 10 insertions(+), 61 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 11b493d555..664a22e15e 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -7,6 +7,8 @@ `httpRequestHeaders`. * DASH: Support negative @r values in segment timelines ([#1787](https://github.com/google/ExoPlayer/issues/1787)). +* Remove `DefaultDrmSessionManager` factory methods that leak `ExoMediaDrm` + instances ([#4721](https://github.com/google/ExoPlayer/issues/4721)). * Add `allowedCapturePolicy` field to `AudioAttributes` wrapper to allow to opt-out of audio recording. * Add `DataSpec.httpRequestHeaders` to set HTTP request headers when connecting diff --git a/library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSessionManager.java b/library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSessionManager.java index 759f88cdab..6c90a3660d 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSessionManager.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/drm/DefaultDrmSessionManager.java @@ -20,7 +20,6 @@ import android.annotation.TargetApi; import android.os.Handler; import android.os.Looper; import android.os.Message; -import android.text.TextUtils; import androidx.annotation.IntDef; import androidx.annotation.Nullable; import com.google.android.exoplayer2.C; @@ -106,65 +105,6 @@ public class DefaultDrmSessionManager /* package */ volatile @Nullable MediaDrmHandler mediaDrmHandler; - /** - * Instantiates a new instance using the Widevine scheme. - * - * @param callback Performs key and provisioning requests. - * @param optionalKeyRequestParameters An optional map of parameters to pass as the last argument - * to {@link ExoMediaDrm#getKeyRequest(byte[], List, int, HashMap)}. May be null. - * @throws UnsupportedDrmException If the specified DRM scheme is not supported. - */ - public static DefaultDrmSessionManager newWidevineInstance( - MediaDrmCallback callback, @Nullable HashMap optionalKeyRequestParameters) - throws UnsupportedDrmException { - return newFrameworkInstance(C.WIDEVINE_UUID, callback, optionalKeyRequestParameters); - } - - /** - * Instantiates a new instance using the PlayReady scheme. - * - *

Note that PlayReady is unsupported by most Android devices, with the exception of Android TV - * devices, which do provide support. - * - * @param callback Performs key and provisioning requests. - * @param customData Optional custom data to include in requests generated by the instance. - * @throws UnsupportedDrmException If the specified DRM scheme is not supported. - */ - public static DefaultDrmSessionManager newPlayReadyInstance( - MediaDrmCallback callback, @Nullable String customData) throws UnsupportedDrmException { - HashMap optionalKeyRequestParameters; - if (!TextUtils.isEmpty(customData)) { - optionalKeyRequestParameters = new HashMap<>(); - optionalKeyRequestParameters.put(PLAYREADY_CUSTOM_DATA_KEY, customData); - } else { - optionalKeyRequestParameters = null; - } - return newFrameworkInstance(C.PLAYREADY_UUID, callback, optionalKeyRequestParameters); - } - - /** - * Instantiates a new instance. - * - * @param uuid The UUID of the drm scheme. - * @param callback Performs key and provisioning requests. - * @param optionalKeyRequestParameters An optional map of parameters to pass as the last argument - * to {@link ExoMediaDrm#getKeyRequest(byte[], List, int, HashMap)}. May be null. - * @throws UnsupportedDrmException If the specified DRM scheme is not supported. - */ - public static DefaultDrmSessionManager newFrameworkInstance( - UUID uuid, - MediaDrmCallback callback, - @Nullable HashMap optionalKeyRequestParameters) - throws UnsupportedDrmException { - return new DefaultDrmSessionManager<>( - uuid, - FrameworkMediaDrm.newInstance(uuid), - callback, - optionalKeyRequestParameters, - /* multiSession= */ false, - INITIAL_DRM_REQUEST_RETRY_COUNT); - } - /** * @param uuid The UUID of the drm scheme. * @param mediaDrm An underlying {@link ExoMediaDrm} for use by the manager. diff --git a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashTestRunner.java b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashTestRunner.java index 0d966c9080..fb64a7d13b 100644 --- a/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashTestRunner.java +++ b/playbacktests/src/androidTest/java/com/google/android/exoplayer2/playbacktests/gts/DashTestRunner.java @@ -30,6 +30,7 @@ import com.google.android.exoplayer2.decoder.DecoderCounters; import com.google.android.exoplayer2.drm.DefaultDrmSessionManager; import com.google.android.exoplayer2.drm.DrmSessionManager; import com.google.android.exoplayer2.drm.FrameworkMediaCrypto; +import com.google.android.exoplayer2.drm.FrameworkMediaDrm; import com.google.android.exoplayer2.drm.HttpMediaDrmCallback; import com.google.android.exoplayer2.drm.MediaDrmCallback; import com.google.android.exoplayer2.drm.UnsupportedDrmException; @@ -266,7 +267,13 @@ public final class DashTestRunner { MediaDrmCallback drmCallback = new HttpMediaDrmCallback(widevineLicenseUrl, new DefaultHttpDataSourceFactory(userAgent)); DefaultDrmSessionManager drmSessionManager = - DefaultDrmSessionManager.newWidevineInstance(drmCallback, null); + new DefaultDrmSessionManager<>( + C.WIDEVINE_UUID, + FrameworkMediaDrm.newInstance(C.WIDEVINE_UUID), + drmCallback, + /* optionalKeyRequestParameters= */ null, + /* multiSession= */ false, + DefaultDrmSessionManager.INITIAL_DRM_REQUEST_RETRY_COUNT); if (!useL1Widevine) { drmSessionManager.setPropertyString( SECURITY_LEVEL_PROPERTY, WIDEVINE_SECURITY_LEVEL_3);