Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
51711a0c
authored
Nov 13, 2019
by
aquilescanta
Committed by
Oliver Woodman
Nov 15, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix MediaDrm leaks in OfflineLicenseHelper
PiperOrigin-RevId: 280176216
parent
65b49a49
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
15 deletions
RELEASENOTES.md
library/core/src/main/java/com/google/android/exoplayer2/drm/OfflineLicenseHelper.java
library/core/src/test/java/com/google/android/exoplayer2/drm/OfflineLicenseHelperTest.java
RELEASENOTES.md
View file @
51711a0c
...
...
@@ -5,6 +5,8 @@
*
Require an end time or duration for SubRip (SRT) and SubStation Alpha
(SSA/ASS) subtitles. This applies to both sidecar files & subtitles
[
embedded in Matroska streams
](
https://matroska.org/technical/specs/subtitles/index.html
)
.
*
Use
`ExoMediaDrm.Provider`
in
`OfflineLicenseHelper`
to avoid
`ExoMediaDrm`
leaks (
[
#4721
](
https://github.com/google/ExoPlayer/issues/4721
)
).
### 2.11.0 (not yet released) ###
...
...
library/core/src/main/java/com/google/android/exoplayer2/drm/OfflineLicenseHelper.java
View file @
51711a0c
...
...
@@ -29,7 +29,8 @@ import com.google.android.exoplayer2.drm.DrmSession.DrmSessionException;
import
com.google.android.exoplayer2.upstream.HttpDataSource
;
import
com.google.android.exoplayer2.upstream.HttpDataSource.Factory
;
import
com.google.android.exoplayer2.util.Assertions
;
import
java.util.HashMap
;
import
java.util.Collections
;
import
java.util.Map
;
import
java.util.UUID
;
/** Helper class to download, renew and release offline licenses. */
...
...
@@ -89,21 +90,21 @@ public final class OfflineLicenseHelper<T extends ExoMediaCrypto> {
* @param forceDefaultLicenseUrl Whether to use {@code defaultLicenseUrl} for key requests that
* include their own license URL.
* @param optionalKeyRequestParameters An optional map of parameters to pass as the last argument
* to {@link MediaDrm#getKeyRequest
(byte[], byte[], String, int, HashMap)
}. May be null.
* to {@link MediaDrm#getKeyRequest}. May be null.
* @return A new instance which uses Widevine CDM.
* @throws UnsupportedDrmException If the Widevine DRM scheme is unsupported or cannot be
* instantiated.
* @see DefaultDrmSessionManager#DefaultDrmSessionManager(java.util.UUID, ExoMediaDrm,
* MediaDrmCallback, HashMap)
* @see DefaultDrmSessionManager.Builder
*/
public
static
OfflineLicenseHelper
<
FrameworkMediaCrypto
>
newWidevineInstance
(
String
defaultLicenseUrl
,
boolean
forceDefaultLicenseUrl
,
Factory
httpDataSourceFactory
,
@Nullable
Hash
Map
<
String
,
String
>
optionalKeyRequestParameters
)
@Nullable
Map
<
String
,
String
>
optionalKeyRequestParameters
)
throws
UnsupportedDrmException
{
return
new
OfflineLicenseHelper
<>(
C
.
WIDEVINE_UUID
,
FrameworkMediaDrm
.
newInstance
(
C
.
WIDEVINE_UUID
),
return
new
OfflineLicenseHelper
<>(
C
.
WIDEVINE_UUID
,
FrameworkMediaDrm
.
DEFAULT_PROVIDER
,
new
HttpMediaDrmCallback
(
defaultLicenseUrl
,
forceDefaultLicenseUrl
,
httpDataSourceFactory
),
optionalKeyRequestParameters
);
}
...
...
@@ -112,18 +113,18 @@ public final class OfflineLicenseHelper<T extends ExoMediaCrypto> {
* Constructs an instance. Call {@link #release()} when the instance is no longer required.
*
* @param uuid The UUID of the drm scheme.
* @param mediaDrm
An underlying {@link ExoMediaDrm} for use by the manager
.
* @param mediaDrm
Provider A {@link ExoMediaDrm.Provider}
.
* @param callback Performs key and provisioning requests.
* @param optionalKeyRequestParameters An optional map of parameters to pass as the last argument
* to {@link MediaDrm#getKeyRequest(byte[], byte[], String, int, HashMap)}. May be null.
* @see DefaultDrmSessionManager#DefaultDrmSessionManager(java.util.UUID, ExoMediaDrm,
* MediaDrmCallback, HashMap)
* to {@link MediaDrm#getKeyRequest}. May be null.
* @see DefaultDrmSessionManager.Builder
*/
@SuppressWarnings
(
"unchecked"
)
public
OfflineLicenseHelper
(
UUID
uuid
,
ExoMediaDrm
<
T
>
mediaDrm
,
ExoMediaDrm
.
Provider
<
T
>
mediaDrmProvider
,
MediaDrmCallback
callback
,
@Nullable
Hash
Map
<
String
,
String
>
optionalKeyRequestParameters
)
{
@Nullable
Map
<
String
,
String
>
optionalKeyRequestParameters
)
{
handlerThread
=
new
HandlerThread
(
"OfflineLicenseHelper"
);
handlerThread
.
start
();
conditionVariable
=
new
ConditionVariable
();
...
...
@@ -149,8 +150,15 @@ public final class OfflineLicenseHelper<T extends ExoMediaCrypto> {
conditionVariable
.
open
();
}
};
if
(
optionalKeyRequestParameters
==
null
)
{
optionalKeyRequestParameters
=
Collections
.
emptyMap
();
}
drmSessionManager
=
new
DefaultDrmSessionManager
<>(
uuid
,
mediaDrm
,
callback
,
optionalKeyRequestParameters
);
(
DefaultDrmSessionManager
<
T
>)
new
DefaultDrmSessionManager
.
Builder
()
.
setUuidAndExoMediaDrmProvider
(
uuid
,
mediaDrmProvider
)
.
setKeyRequestParameters
(
optionalKeyRequestParameters
)
.
build
(
callback
);
drmSessionManager
.
addListener
(
new
Handler
(
handlerThread
.
getLooper
()),
eventListener
);
}
...
...
library/core/src/test/java/com/google/android/exoplayer2/drm/OfflineLicenseHelperTest.java
View file @
51711a0c
...
...
@@ -51,7 +51,11 @@ public class OfflineLicenseHelperTest {
.
thenReturn
(
new
ExoMediaDrm
.
KeyRequest
(
/* data= */
new
byte
[
0
],
/* licenseServerUrl= */
""
));
offlineLicenseHelper
=
new
OfflineLicenseHelper
<>(
C
.
WIDEVINE_UUID
,
mediaDrm
,
mediaDrmCallback
,
null
);
new
OfflineLicenseHelper
<>(
C
.
WIDEVINE_UUID
,
new
ExoMediaDrm
.
AppManagedProvider
<>(
mediaDrm
),
mediaDrmCallback
,
null
);
}
@After
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment