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
97fbbad6
authored
Feb 03, 2020
by
olly
Committed by
Oliver Woodman
Feb 03, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Avoid unnecessary decoder instantiations on key rotation
Issue: #6903 PiperOrigin-RevId: 292884280
parent
719b34a9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
12 deletions
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/MediaCodecRenderer.java
View file @
97fbbad6
...
...
@@ -1337,7 +1337,9 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
if
((
sourceDrmSession
==
null
&&
codecDrmSession
!=
null
)
||
(
sourceDrmSession
!=
null
&&
codecDrmSession
==
null
)
||
(
sourceDrmSession
!=
null
&&
!
codecInfo
.
secure
)
||
(
sourceDrmSession
!=
null
&&
!
codecInfo
.
secure
&&
maybeRequiresSecureDecoder
(
sourceDrmSession
,
newFormat
))
||
(
Util
.
SDK_INT
<
23
&&
sourceDrmSession
!=
codecDrmSession
))
{
// We might need to switch between the clear and protected output paths, or we're using DRM
// prior to API level 23 where the codec needs to be re-initialized to switch to the new DRM
...
...
@@ -1794,9 +1796,22 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
maybeInitCodec
();
}
private
boolean
isDecodeOnlyBuffer
(
long
presentationTimeUs
)
{
// We avoid using decodeOnlyPresentationTimestamps.remove(presentationTimeUs) because it would
// box presentationTimeUs, creating a Long object that would need to be garbage collected.
int
size
=
decodeOnlyPresentationTimestamps
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
if
(
decodeOnlyPresentationTimestamps
.
get
(
i
)
==
presentationTimeUs
)
{
decodeOnlyPresentationTimestamps
.
remove
(
i
);
return
true
;
}
}
return
false
;
}
@RequiresApi
(
23
)
private
void
updateDrmSessionOrReinitializeCodecV23
()
throws
ExoPlaybackException
{
FrameworkMediaCrypto
sessionMediaCrypto
=
sourceDrmSession
.
getMediaCrypto
();
@Nullable
FrameworkMediaCrypto
sessionMediaCrypto
=
sourceDrmSession
.
getMediaCrypto
();
if
(
sessionMediaCrypto
==
null
)
{
// We'd only expect this to happen if the CDM from which the pending session is obtained needs
// provisioning. This is unlikely to happen (it probably requires a switch from one DRM scheme
...
...
@@ -1830,17 +1845,38 @@ public abstract class MediaCodecRenderer extends BaseRenderer {
codecDrainAction
=
DRAIN_ACTION_NONE
;
}
private
boolean
isDecodeOnlyBuffer
(
long
presentationTimeUs
)
{
// We avoid using decodeOnlyPresentationTimestamps.remove(presentationTimeUs) because it would
// box presentationTimeUs, creating a Long object that would need to be garbage collected.
int
size
=
decodeOnlyPresentationTimestamps
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
if
(
decodeOnlyPresentationTimestamps
.
get
(
i
)
==
presentationTimeUs
)
{
decodeOnlyPresentationTimestamps
.
remove
(
i
);
return
true
;
}
/**
* Returns whether a {@link DrmSession} may require a secure decoder for a given {@link Format}.
*
* @param drmSession The {@link DrmSession}.
* @param format The {@link Format}.
* @return Whether a secure decoder may be required.
*/
private
static
boolean
maybeRequiresSecureDecoder
(
DrmSession
<
FrameworkMediaCrypto
>
drmSession
,
Format
format
)
{
@Nullable
FrameworkMediaCrypto
sessionMediaCrypto
=
drmSession
.
getMediaCrypto
();
if
(
sessionMediaCrypto
==
null
)
{
// We'd only expect this to happen if the CDM from which the pending session is obtained needs
// provisioning. This is unlikely to happen (it probably requires a switch from one DRM scheme
// to another, where the new CDM hasn't been used before and needs provisioning). Assume that
// a secure decoder may be required.
return
true
;
}
if
(
sessionMediaCrypto
.
forceAllowInsecureDecoderComponents
)
{
return
false
;
}
MediaCrypto
mediaCrypto
;
try
{
mediaCrypto
=
new
MediaCrypto
(
sessionMediaCrypto
.
uuid
,
sessionMediaCrypto
.
sessionId
);
}
catch
(
MediaCryptoException
e
)
{
// This shouldn't happen, but if it does then assume that a secure decoder may be required.
return
true
;
}
try
{
return
mediaCrypto
.
requiresSecureDecoderComponent
(
format
.
sampleMimeType
);
}
finally
{
mediaCrypto
.
release
();
}
return
false
;
}
private
static
MediaCodec
.
CryptoInfo
getFrameworkCryptoInfo
(
...
...
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