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
adb9dcb4
authored
Jan 13, 2021
by
olly
Committed by
Ian Baker
Jan 15, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add KeyRequest.getRequestType
Issue: #7847 PiperOrigin-RevId: 351661084
parent
b5a319dc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
97 additions
and
4 deletions
RELEASENOTES.md
library/core/src/main/java/com/google/android/exoplayer2/drm/ExoMediaDrm.java
library/core/src/main/java/com/google/android/exoplayer2/drm/FrameworkMediaDrm.java
library/core/src/test/java/com/google/android/exoplayer2/drm/OfflineLicenseHelperTest.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeExoMediaDrm.java
RELEASENOTES.md
View file @
adb9dcb4
...
...
@@ -137,6 +137,8 @@
*
DRM:
*
Fix playback failure when switching from PlayReady protected content to
Widevine or Clearkey protected content in a playlist.
*
Add
`ExoMediaDrm.KeyRequest.getRequestType`
(
[
#7847
](
https://github.com/google/ExoPlayer/issues/7847
)
).
*
Analytics:
*
Pass a
`DecoderReuseEvaluation`
to
`AnalyticsListener`
's
`onVideoInputFormatChanged`
and
`onAudioInputFormatChanged`
methods. The
...
...
library/core/src/main/java/com/google/android/exoplayer2/drm/ExoMediaDrm.java
View file @
adb9dcb4
...
...
@@ -22,8 +22,12 @@ import android.media.MediaDrmException;
import
android.media.NotProvisionedException
;
import
android.os.Handler
;
import
android.os.PersistableBundle
;
import
androidx.annotation.IntDef
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.drm.DrmInitData.SchemeData
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -182,25 +186,99 @@ public interface ExoMediaDrm {
}
/** @see android.media.MediaDrm.KeyRequest */
/**
* Contains data used to request keys from a license server.
*
* @see android.media.MediaDrm.KeyRequest
*/
final
class
KeyRequest
{
/**
* Key request types. One of {@link #REQUEST_TYPE_UNKNOWN}, {@link #REQUEST_TYPE_INITIAL},
* {@link #REQUEST_TYPE_RENEWAL}, {@link #REQUEST_TYPE_RELEASE}, {@link #REQUEST_TYPE_NONE} or
* {@link #REQUEST_TYPE_UPDATE}.
*/
@Documented
@Retention
(
RetentionPolicy
.
SOURCE
)
@IntDef
({
REQUEST_TYPE_UNKNOWN
,
REQUEST_TYPE_INITIAL
,
REQUEST_TYPE_RENEWAL
,
REQUEST_TYPE_RELEASE
,
REQUEST_TYPE_NONE
,
REQUEST_TYPE_UPDATE
,
})
public
@interface
RequestType
{}
/**
* Value returned from {@link #getRequestType()} if the underlying key request does not specify
* a type.
*/
public
static
final
int
REQUEST_TYPE_UNKNOWN
=
Integer
.
MIN_VALUE
;
/** Key request type for an initial license request. */
public
static
final
int
REQUEST_TYPE_INITIAL
=
MediaDrm
.
KeyRequest
.
REQUEST_TYPE_INITIAL
;
/** Key request type for license renewal. */
public
static
final
int
REQUEST_TYPE_RENEWAL
=
MediaDrm
.
KeyRequest
.
REQUEST_TYPE_RENEWAL
;
/** Key request type for license release. */
public
static
final
int
REQUEST_TYPE_RELEASE
=
MediaDrm
.
KeyRequest
.
REQUEST_TYPE_RELEASE
;
/**
* Key request type if keys are already loaded and available for use. No license request is
* necessary, and no key request data is returned.
*/
public
static
final
int
REQUEST_TYPE_NONE
=
MediaDrm
.
KeyRequest
.
REQUEST_TYPE_NONE
;
/**
* Key request type if keys have been loaded, but an additional license request is needed to
* update their values.
*/
public
static
final
int
REQUEST_TYPE_UPDATE
=
MediaDrm
.
KeyRequest
.
REQUEST_TYPE_UPDATE
;
private
final
byte
[]
data
;
private
final
String
licenseServerUrl
;
@RequestType
private
final
int
requestType
;
/**
* Creates an instance with {@link #REQUEST_TYPE_UNKNOWN}.
*
* @param data The opaque key request data.
* @param licenseServerUrl The license server URL to which the request should be made.
*/
public
KeyRequest
(
byte
[]
data
,
String
licenseServerUrl
)
{
this
(
data
,
licenseServerUrl
,
REQUEST_TYPE_UNKNOWN
);
}
/**
* Creates an instance.
*
* @param data The opaque key request data.
* @param licenseServerUrl The license server URL to which the request should be made.
* @param requestType The type of the request, or {@link #REQUEST_TYPE_UNKNOWN}.
*/
public
KeyRequest
(
byte
[]
data
,
String
licenseServerUrl
,
@RequestType
int
requestType
)
{
this
.
data
=
data
;
this
.
licenseServerUrl
=
licenseServerUrl
;
this
.
requestType
=
requestType
;
}
/** Returns the opaque key request data. */
public
byte
[]
getData
()
{
return
data
;
}
/** Returns the URL of the license server to which the request should be made. */
public
String
getLicenseServerUrl
()
{
return
licenseServerUrl
;
}
/**
* Returns the type of the request, or {@link #REQUEST_TYPE_UNKNOWN} if the underlying key
* request does not specify a type. Note that when using a platform {@link MediaDrm} instance,
* key requests only specify a type on API levels 23 and above.
*/
@RequestType
public
int
getRequestType
()
{
return
requestType
;
}
}
/** @see android.media.MediaDrm.ProvisionRequest */
...
...
library/core/src/main/java/com/google/android/exoplayer2/drm/FrameworkMediaDrm.java
View file @
adb9dcb4
...
...
@@ -210,7 +210,11 @@ public final class FrameworkMediaDrm implements ExoMediaDrm {
licenseServerUrl
=
schemeData
.
licenseServerUrl
;
}
return
new
KeyRequest
(
requestData
,
licenseServerUrl
);
@KeyRequest
.
RequestType
int
requestType
=
Util
.
SDK_INT
>=
23
?
request
.
getRequestType
()
:
KeyRequest
.
REQUEST_TYPE_UNKNOWN
;
return
new
KeyRequest
(
requestData
,
licenseServerUrl
,
requestType
);
}
@Override
...
...
library/core/src/test/java/com/google/android/exoplayer2/drm/OfflineLicenseHelperTest.java
View file @
adb9dcb4
...
...
@@ -26,6 +26,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.drm.DrmInitData.SchemeData
;
import
com.google.android.exoplayer2.drm.ExoMediaDrm.KeyRequest
;
import
java.util.HashMap
;
import
org.junit.After
;
import
org.junit.Before
;
...
...
@@ -48,7 +49,10 @@ public class OfflineLicenseHelperTest {
when
(
mediaDrm
.
openSession
()).
thenReturn
(
new
byte
[]
{
1
,
2
,
3
});
when
(
mediaDrm
.
getKeyRequest
(
any
(),
any
(),
anyInt
(),
any
()))
.
thenReturn
(
new
ExoMediaDrm
.
KeyRequest
(
/* data= */
new
byte
[
0
],
/* licenseServerUrl= */
""
));
new
KeyRequest
(
/* data= */
new
byte
[
0
],
/* licenseServerUrl= */
""
,
KeyRequest
.
REQUEST_TYPE_INITIAL
));
offlineLicenseHelper
=
new
OfflineLicenseHelper
(
new
DefaultDrmSessionManager
.
Builder
()
...
...
testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeExoMediaDrm.java
View file @
adb9dcb4
...
...
@@ -167,7 +167,12 @@ public final class FakeExoMediaDrm implements ExoMediaDrm {
schemeDatas
,
keyType
,
optionalParameters
!=
null
?
optionalParameters
:
ImmutableMap
.
of
());
return
new
KeyRequest
(
requestData
.
toByteArray
(),
/* licenseServerUrl= */
""
);
@KeyRequest
.
RequestType
int
requestType
=
sessionIdsWithValidKeys
.
contains
(
toByteList
(
scope
))
?
KeyRequest
.
REQUEST_TYPE_RENEWAL
:
KeyRequest
.
REQUEST_TYPE_INITIAL
;
return
new
KeyRequest
(
requestData
.
toByteArray
(),
/* licenseServerUrl= */
""
,
requestType
);
}
@Nullable
...
...
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