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
d82da93e
authored
Nov 21, 2019
by
olly
Committed by
Oliver Woodman
Nov 22, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Simplify checking whether a sample can be read
PiperOrigin-RevId: 281763672
parent
cc520a67
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
27 deletions
library/core/src/main/java/com/google/android/exoplayer2/source/SampleMetadataQueue.java
library/core/src/main/java/com/google/android/exoplayer2/source/SampleMetadataQueue.java
View file @
d82da93e
...
@@ -266,20 +266,8 @@ import java.io.IOException;
...
@@ -266,20 +266,8 @@ import java.io.IOException;
if
(
formats
[
relativeReadIndex
]
!=
downstreamFormat
)
{
if
(
formats
[
relativeReadIndex
]
!=
downstreamFormat
)
{
// A format can be read.
// A format can be read.
return
true
;
return
true
;
}
else
if
(
Assertions
.
checkNotNull
(
downstreamFormat
).
drmInitData
==
null
)
{
// A sample from a clear section can be read.
return
true
;
}
else
if
(
drmSessionManager
==
DrmSessionManager
.
DUMMY
||
Assertions
.
checkNotNull
(
currentDrmSession
).
getState
()
==
DrmSession
.
STATE_OPENED_WITH_KEYS
)
{
// TODO: Remove DUMMY DrmSessionManager check once renderers are migrated [Internal ref:
// b/122519809].
return
true
;
}
else
{
// A clear sample in an encrypted section may be read if playClearSamplesWithoutKeys is true.
return
(
flags
[
relativeReadIndex
]
&
C
.
BUFFER_FLAG_ENCRYPTED
)
==
0
&&
Assertions
.
checkNotNull
(
currentDrmSession
).
playClearSamplesWithoutKeys
();
}
}
return
mayReadSample
(
relativeReadIndex
);
}
}
/**
/**
...
@@ -328,20 +316,7 @@ import java.io.IOException;
...
@@ -328,20 +316,7 @@ import java.io.IOException;
return
C
.
RESULT_FORMAT_READ
;
return
C
.
RESULT_FORMAT_READ
;
}
}
// It's likely that the media source creation has not yet been migrated and the renderer can
if
(!
mayReadSample
(
relativeReadIndex
))
{
// acquire the session for the sample.
// TODO: Remove once renderers are migrated [Internal ref: b/122519809].
boolean
skipDrmChecks
=
drmSessionManager
==
DrmSessionManager
.
DUMMY
;
boolean
isNextSampleEncrypted
=
(
flags
[
relativeReadIndex
]
&
C
.
BUFFER_FLAG_ENCRYPTED
)
!=
0
;
boolean
mayReadSample
=
skipDrmChecks
||
Util
.
castNonNull
(
downstreamFormat
).
drmInitData
==
null
||
(
Assertions
.
checkNotNull
(
currentDrmSession
).
playClearSamplesWithoutKeys
()
&&
!
isNextSampleEncrypted
)
||
Assertions
.
checkNotNull
(
currentDrmSession
).
getState
()
==
DrmSession
.
STATE_OPENED_WITH_KEYS
;
if
(!
mayReadSample
)
{
return
C
.
RESULT_NOTHING_READ
;
return
C
.
RESULT_NOTHING_READ
;
}
}
...
@@ -631,6 +606,25 @@ import java.io.IOException;
...
@@ -631,6 +606,25 @@ import java.io.IOException;
}
}
/**
/**
* Returns whether it's possible to read the next sample.
*
* @param relativeReadIndex The relative read index of the next sample.
* @return Whether it's possible to read the next sample.
*/
private
boolean
mayReadSample
(
int
relativeReadIndex
)
{
if
(
drmSessionManager
==
DrmSessionManager
.
DUMMY
)
{
// TODO: Remove once renderers are migrated [Internal ref: b/122519809].
// For protected content it's likely that the DrmSessionManager is still being injected into
// the renderers. We assume that the renderers will be able to acquire a DrmSession if needed.
return
true
;
}
return
currentDrmSession
==
null
||
currentDrmSession
.
getState
()
==
DrmSession
.
STATE_OPENED_WITH_KEYS
||
((
flags
[
relativeReadIndex
]
&
C
.
BUFFER_FLAG_ENCRYPTED
)
==
0
&&
currentDrmSession
.
playClearSamplesWithoutKeys
());
}
/**
* Finds the sample in the specified range that's before or at the specified time. If {@code
* Finds the sample in the specified range that's before or at the specified time. If {@code
* keyframe} is {@code true} then the sample is additionally required to be a keyframe.
* keyframe} is {@code true} then the sample is additionally required to be a keyframe.
*
*
...
...
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