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
cc5e981e
authored
Dec 23, 2019
by
ybai001
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add AC-4 DRM Support
parent
c17d1467
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
7 deletions
library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java
library/core/src/main/java/com/google/android/exoplayer2/source/SampleDataQueue.java
library/core/src/main/java/com/google/android/exoplayer2/source/SampleQueue.java
library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java
View file @
cc5e981e
...
...
@@ -1222,6 +1222,7 @@ public class FragmentedMp4Extractor implements Extractor {
* @throws InterruptedException If the thread is interrupted.
*/
private
boolean
readSample
(
ExtractorInput
input
)
throws
IOException
,
InterruptedException
{
int
outputSampleEncryptionDataSize
=
0
;
if
(
parserState
==
STATE_READING_SAMPLE_START
)
{
if
(
currentTrackBundle
==
null
)
{
@Nullable
TrackBundle
currentTrackBundle
=
getNextFragmentRun
(
trackBundles
);
...
...
@@ -1269,6 +1270,7 @@ public class FragmentedMp4Extractor implements Extractor {
}
sampleBytesWritten
=
currentTrackBundle
.
outputSampleEncryptionData
();
sampleSize
+=
sampleBytesWritten
;
outputSampleEncryptionDataSize
=
sampleBytesWritten
;
parserState
=
STATE_READING_SAMPLE_CONTINUE
;
sampleCurrentNalBytesRemaining
=
0
;
isAc4HeaderRequired
=
...
...
@@ -1338,7 +1340,7 @@ public class FragmentedMp4Extractor implements Extractor {
}
}
else
{
if
(
isAc4HeaderRequired
)
{
Ac4Util
.
getAc4SampleHeader
(
sampleSize
,
scratch
);
Ac4Util
.
getAc4SampleHeader
(
sampleSize
-
outputSampleEncryptionDataSize
,
scratch
);
int
length
=
scratch
.
limit
();
output
.
sampleData
(
scratch
,
length
);
sampleSize
+=
length
;
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/SampleDataQueue.java
View file @
cc5e981e
...
...
@@ -23,6 +23,7 @@ import com.google.android.exoplayer2.extractor.TrackOutput.CryptoData;
import
com.google.android.exoplayer2.source.SampleQueue.SampleExtrasHolder
;
import
com.google.android.exoplayer2.upstream.Allocation
;
import
com.google.android.exoplayer2.upstream.Allocator
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.ParsableByteArray
;
import
java.io.EOFException
;
import
java.io.IOException
;
...
...
@@ -114,11 +115,13 @@ import java.nio.ByteBuffer;
*
* @param buffer The buffer to populate.
* @param extrasHolder The extras holder whose offset should be read and subsequently adjusted.
* @param mimeType The MIME type.
*/
public
void
readToBuffer
(
DecoderInputBuffer
buffer
,
SampleExtrasHolder
extrasHolder
)
{
public
void
readToBuffer
(
DecoderInputBuffer
buffer
,
SampleExtrasHolder
extrasHolder
,
String
mimeType
)
{
// Read encryption data if the sample is encrypted.
if
(
buffer
.
isEncrypted
())
{
readEncryptionData
(
buffer
,
extrasHolder
);
readEncryptionData
(
buffer
,
extrasHolder
,
mimeType
);
}
// Read sample data, extracting supplemental data into a separate buffer if needed.
if
(
buffer
.
hasSupplementalData
())
{
...
...
@@ -215,8 +218,10 @@ import java.nio.ByteBuffer;
*
* @param buffer The buffer into which the encryption data should be written.
* @param extrasHolder The extras holder whose offset should be read and subsequently adjusted.
* @param mimeType The MIME type.
*/
private
void
readEncryptionData
(
DecoderInputBuffer
buffer
,
SampleExtrasHolder
extrasHolder
)
{
private
void
readEncryptionData
(
DecoderInputBuffer
buffer
,
SampleExtrasHolder
extrasHolder
,
String
mimeType
)
{
long
offset
=
extrasHolder
.
offset
;
// Read the signal byte.
...
...
@@ -265,8 +270,10 @@ import java.nio.ByteBuffer;
encryptedDataSizes
[
i
]
=
scratch
.
readUnsignedIntToInt
();
}
}
else
{
clearDataSizes
[
0
]
=
0
;
encryptedDataSizes
[
0
]
=
extrasHolder
.
size
-
(
int
)
(
offset
-
extrasHolder
.
offset
);
int
addedHeaderSize
=
MimeTypes
.
AUDIO_AC4
.
equals
(
mimeType
)
?
7
:
0
;
clearDataSizes
[
0
]
=
addedHeaderSize
;
encryptedDataSizes
[
0
]
=
extrasHolder
.
size
-
(
int
)
(
offset
-
extrasHolder
.
offset
)
-
addedHeaderSize
;
}
// Populate the cryptoInfo.
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/SampleQueue.java
View file @
cc5e981e
...
...
@@ -323,7 +323,8 @@ public class SampleQueue implements TrackOutput {
readSampleMetadata
(
formatHolder
,
buffer
,
formatRequired
,
loadingFinished
,
decodeOnlyUntilUs
,
extrasHolder
);
if
(
result
==
C
.
RESULT_BUFFER_READ
&&
!
buffer
.
isEndOfStream
()
&&
!
buffer
.
isFlagsOnly
())
{
sampleDataQueue
.
readToBuffer
(
buffer
,
extrasHolder
);
sampleDataQueue
.
readToBuffer
(
buffer
,
extrasHolder
,
downstreamFormat
==
null
?
null
:
downstreamFormat
.
sampleMimeType
);
}
return
result
;
}
...
...
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