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
37b58476
authored
Oct 21, 2021
by
olly
Committed by
Oliver Woodman
Oct 21, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Get decoder buffers into the right place
PiperOrigin-RevId: 404876228
parent
5e26ba82
Show whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
86 additions
and
135 deletions
extensions/av1/proguard-rules.txt
extensions/av1/src/main/java/com/google/android/exoplayer2/ext/av1/Gav1Decoder.java
extensions/av1/src/main/java/com/google/android/exoplayer2/ext/av1/Libgav1VideoRenderer.java
extensions/av1/src/main/jni/gav1_jni.cc
extensions/ffmpeg/src/main/java/com/google/android/exoplayer2/ext/ffmpeg/FfmpegAudioDecoder.java
extensions/ffmpeg/src/main/java/com/google/android/exoplayer2/ext/ffmpeg/FfmpegVideoRenderer.java
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoder.java
extensions/opus/proguard-rules.txt
extensions/opus/src/main/java/com/google/android/exoplayer2/ext/opus/OpusDecoder.java
extensions/opus/src/main/jni/opus_jni.cc
extensions/vp9/proguard-rules.txt
extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/LibvpxVideoRenderer.java
extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxDecoder.java
extensions/vp9/src/main/jni/vpx_jni.cc
library/core/src/main/java/com/google/android/exoplayer2/audio/DecoderAudioRenderer.java
library/core/src/main/java/com/google/android/exoplayer2/video/DecoderVideoRenderer.java
library/core/src/main/java/com/google/android/exoplayer2/video/VideoDecoderGLSurfaceView.java
library/core/src/main/java/com/google/android/exoplayer2/video/VideoDecoderInputBuffer.java
library/core/src/main/java/com/google/android/exoplayer2/video/VideoDecoderOutputBufferRenderer.java
library/core/src/test/java/com/google/android/exoplayer2/audio/DecoderAudioRendererTest.java
library/core/src/test/java/com/google/android/exoplayer2/video/DecoderVideoRendererTest.java
library/decoder/src/main/java/com/google/android/exoplayer2/decoder/DecoderInputBuffer.java
library/decoder/src/main/java/com/google/android/exoplayer2/decoder/OutputBuffer.java → library/decoder/src/main/java/com/google/android/exoplayer2/decoder/DecoderOutputBuffer.java
library/decoder/src/main/java/com/google/android/exoplayer2/decoder/SimpleDecoder.java
library/decoder/src/main/java/com/google/android/exoplayer2/decoder/SimpleOutputBuffer.java → library/decoder/src/main/java/com/google/android/exoplayer2/decoder/SimpleDecoderOutputBuffer.java
library/core/src/main/java/com/google/android/exoplayer2/video/VideoDecoderOutputBuffer.java → library/decoder/src/main/java/com/google/android/exoplayer2/decoder/VideoDecoderOutputBuffer.java
library/extractor/src/main/java/com/google/android/exoplayer2/text/SubtitleOutputBuffer.java
extensions/av1/proguard-rules.txt
View file @
37b58476
...
@@ -6,6 +6,6 @@
...
@@ -6,6 +6,6 @@
}
}
# Some members of this class are being accessed from native methods. Keep them unobfuscated.
# Some members of this class are being accessed from native methods. Keep them unobfuscated.
-keep class com.google.android.exoplayer2.
video
.VideoDecoderOutputBuffer {
-keep class com.google.android.exoplayer2.
decoder
.VideoDecoderOutputBuffer {
*;
*;
}
}
extensions/av1/src/main/java/com/google/android/exoplayer2/ext/av1/Gav1Decoder.java
View file @
37b58476
...
@@ -24,15 +24,14 @@ import androidx.annotation.VisibleForTesting;
...
@@ -24,15 +24,14 @@ import androidx.annotation.VisibleForTesting;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.SimpleDecoder
;
import
com.google.android.exoplayer2.decoder.SimpleDecoder
;
import
com.google.android.exoplayer2.decoder.VideoDecoderOutputBuffer
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.video.VideoDecoderInputBuffer
;
import
com.google.android.exoplayer2.video.VideoDecoderOutputBuffer
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
/** Gav1 decoder. */
/** Gav1 decoder. */
@VisibleForTesting
(
otherwise
=
PACKAGE_PRIVATE
)
@VisibleForTesting
(
otherwise
=
PACKAGE_PRIVATE
)
public
final
class
Gav1Decoder
public
final
class
Gav1Decoder
extends
SimpleDecoder
<
Video
DecoderInputBuffer
,
VideoDecoderOutputBuffer
,
Gav1DecoderException
>
{
extends
SimpleDecoder
<
DecoderInputBuffer
,
VideoDecoderOutputBuffer
,
Gav1DecoderException
>
{
private
static
final
int
GAV1_ERROR
=
0
;
private
static
final
int
GAV1_ERROR
=
0
;
private
static
final
int
GAV1_OK
=
1
;
private
static
final
int
GAV1_OK
=
1
;
...
@@ -56,9 +55,7 @@ public final class Gav1Decoder
...
@@ -56,9 +55,7 @@ public final class Gav1Decoder
public
Gav1Decoder
(
public
Gav1Decoder
(
int
numInputBuffers
,
int
numOutputBuffers
,
int
initialInputBufferSize
,
int
threads
)
int
numInputBuffers
,
int
numOutputBuffers
,
int
initialInputBufferSize
,
int
threads
)
throws
Gav1DecoderException
{
throws
Gav1DecoderException
{
super
(
super
(
new
DecoderInputBuffer
[
numInputBuffers
],
new
VideoDecoderOutputBuffer
[
numOutputBuffers
]);
new
VideoDecoderInputBuffer
[
numInputBuffers
],
new
VideoDecoderOutputBuffer
[
numOutputBuffers
]);
if
(!
Gav1Library
.
isAvailable
())
{
if
(!
Gav1Library
.
isAvailable
())
{
throw
new
Gav1DecoderException
(
"Failed to load decoder native library."
);
throw
new
Gav1DecoderException
(
"Failed to load decoder native library."
);
}
}
...
@@ -86,8 +83,8 @@ public final class Gav1Decoder
...
@@ -86,8 +83,8 @@ public final class Gav1Decoder
}
}
@Override
@Override
protected
Video
DecoderInputBuffer
createInputBuffer
()
{
protected
DecoderInputBuffer
createInputBuffer
()
{
return
new
Video
DecoderInputBuffer
(
DecoderInputBuffer
.
BUFFER_REPLACEMENT_MODE_DIRECT
);
return
new
DecoderInputBuffer
(
DecoderInputBuffer
.
BUFFER_REPLACEMENT_MODE_DIRECT
);
}
}
@Override
@Override
...
@@ -98,7 +95,7 @@ public final class Gav1Decoder
...
@@ -98,7 +95,7 @@ public final class Gav1Decoder
@Override
@Override
@Nullable
@Nullable
protected
Gav1DecoderException
decode
(
protected
Gav1DecoderException
decode
(
Video
DecoderInputBuffer
inputBuffer
,
VideoDecoderOutputBuffer
outputBuffer
,
boolean
reset
)
{
DecoderInputBuffer
inputBuffer
,
VideoDecoderOutputBuffer
outputBuffer
,
boolean
reset
)
{
ByteBuffer
inputData
=
Util
.
castNonNull
(
inputBuffer
.
data
);
ByteBuffer
inputData
=
Util
.
castNonNull
(
inputBuffer
.
data
);
int
inputSize
=
inputData
.
limit
();
int
inputSize
=
inputData
.
limit
();
if
(
gav1Decode
(
gav1DecoderContext
,
inputData
,
inputSize
)
==
GAV1_ERROR
)
{
if
(
gav1Decode
(
gav1DecoderContext
,
inputData
,
inputSize
)
==
GAV1_ERROR
)
{
...
...
extensions/av1/src/main/java/com/google/android/exoplayer2/ext/av1/Libgav1VideoRenderer.java
View file @
37b58476
...
@@ -25,11 +25,11 @@ import com.google.android.exoplayer2.Format;
...
@@ -25,11 +25,11 @@ import com.google.android.exoplayer2.Format;
import
com.google.android.exoplayer2.RendererCapabilities
;
import
com.google.android.exoplayer2.RendererCapabilities
;
import
com.google.android.exoplayer2.decoder.CryptoConfig
;
import
com.google.android.exoplayer2.decoder.CryptoConfig
;
import
com.google.android.exoplayer2.decoder.DecoderReuseEvaluation
;
import
com.google.android.exoplayer2.decoder.DecoderReuseEvaluation
;
import
com.google.android.exoplayer2.decoder.VideoDecoderOutputBuffer
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.TraceUtil
;
import
com.google.android.exoplayer2.util.TraceUtil
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.video.DecoderVideoRenderer
;
import
com.google.android.exoplayer2.video.DecoderVideoRenderer
;
import
com.google.android.exoplayer2.video.VideoDecoderOutputBuffer
;
import
com.google.android.exoplayer2.video.VideoRendererEventListener
;
import
com.google.android.exoplayer2.video.VideoRendererEventListener
;
/** Decodes and renders video using libgav1 decoder. */
/** Decodes and renders video using libgav1 decoder. */
...
...
extensions/av1/src/main/jni/gav1_jni.cc
View file @
37b58476
...
@@ -537,7 +537,7 @@ DECODER_FUNC(jlong, gav1Init, jint threads) {
...
@@ -537,7 +537,7 @@ DECODER_FUNC(jlong, gav1Init, jint threads) {
// Populate JNI References.
// Populate JNI References.
const
jclass
outputBufferClass
=
env
->
FindClass
(
const
jclass
outputBufferClass
=
env
->
FindClass
(
"com/google/android/exoplayer2/
video
/VideoDecoderOutputBuffer"
);
"com/google/android/exoplayer2/
decoder
/VideoDecoderOutputBuffer"
);
context
->
decoder_private_field
=
context
->
decoder_private_field
=
env
->
GetFieldID
(
outputBufferClass
,
"decoderPrivate"
,
"I"
);
env
->
GetFieldID
(
outputBufferClass
,
"decoderPrivate"
,
"I"
);
context
->
output_mode_field
=
env
->
GetFieldID
(
outputBufferClass
,
"mode"
,
"I"
);
context
->
output_mode_field
=
env
->
GetFieldID
(
outputBufferClass
,
"mode"
,
"I"
);
...
...
extensions/ffmpeg/src/main/java/com/google/android/exoplayer2/ext/ffmpeg/FfmpegAudioDecoder.java
View file @
37b58476
...
@@ -20,7 +20,7 @@ import com.google.android.exoplayer2.C;
...
@@ -20,7 +20,7 @@ import com.google.android.exoplayer2.C;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.SimpleDecoder
;
import
com.google.android.exoplayer2.decoder.SimpleDecoder
;
import
com.google.android.exoplayer2.decoder.SimpleOutputBuffer
;
import
com.google.android.exoplayer2.decoder.Simple
Decoder
OutputBuffer
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.ParsableByteArray
;
import
com.google.android.exoplayer2.util.ParsableByteArray
;
...
@@ -30,7 +30,7 @@ import java.util.List;
...
@@ -30,7 +30,7 @@ import java.util.List;
/** FFmpeg audio decoder. */
/** FFmpeg audio decoder. */
/* package */
final
class
FfmpegAudioDecoder
/* package */
final
class
FfmpegAudioDecoder
extends
SimpleDecoder
<
DecoderInputBuffer
,
SimpleOutputBuffer
,
FfmpegDecoderException
>
{
extends
SimpleDecoder
<
DecoderInputBuffer
,
Simple
Decoder
OutputBuffer
,
FfmpegDecoderException
>
{
// Output buffer sizes when decoding PCM mu-law streams, which is the maximum FFmpeg outputs.
// Output buffer sizes when decoding PCM mu-law streams, which is the maximum FFmpeg outputs.
private
static
final
int
OUTPUT_BUFFER_SIZE_16BIT
=
65536
;
private
static
final
int
OUTPUT_BUFFER_SIZE_16BIT
=
65536
;
...
@@ -56,7 +56,7 @@ import java.util.List;
...
@@ -56,7 +56,7 @@ import java.util.List;
int
initialInputBufferSize
,
int
initialInputBufferSize
,
boolean
outputFloat
)
boolean
outputFloat
)
throws
FfmpegDecoderException
{
throws
FfmpegDecoderException
{
super
(
new
DecoderInputBuffer
[
numInputBuffers
],
new
SimpleOutputBuffer
[
numOutputBuffers
]);
super
(
new
DecoderInputBuffer
[
numInputBuffers
],
new
Simple
Decoder
OutputBuffer
[
numOutputBuffers
]);
if
(!
FfmpegLibrary
.
isAvailable
())
{
if
(!
FfmpegLibrary
.
isAvailable
())
{
throw
new
FfmpegDecoderException
(
"Failed to load decoder native libraries."
);
throw
new
FfmpegDecoderException
(
"Failed to load decoder native libraries."
);
}
}
...
@@ -86,8 +86,8 @@ import java.util.List;
...
@@ -86,8 +86,8 @@ import java.util.List;
}
}
@Override
@Override
protected
SimpleOutputBuffer
createOutputBuffer
()
{
protected
Simple
Decoder
OutputBuffer
createOutputBuffer
()
{
return
new
SimpleOutputBuffer
(
this
::
releaseOutputBuffer
);
return
new
Simple
Decoder
OutputBuffer
(
this
::
releaseOutputBuffer
);
}
}
@Override
@Override
...
@@ -98,7 +98,7 @@ import java.util.List;
...
@@ -98,7 +98,7 @@ import java.util.List;
@Override
@Override
@Nullable
@Nullable
protected
FfmpegDecoderException
decode
(
protected
FfmpegDecoderException
decode
(
DecoderInputBuffer
inputBuffer
,
SimpleOutputBuffer
outputBuffer
,
boolean
reset
)
{
DecoderInputBuffer
inputBuffer
,
Simple
Decoder
OutputBuffer
outputBuffer
,
boolean
reset
)
{
if
(
reset
)
{
if
(
reset
)
{
nativeContext
=
ffmpegReset
(
nativeContext
,
extraData
);
nativeContext
=
ffmpegReset
(
nativeContext
,
extraData
);
if
(
nativeContext
==
0
)
{
if
(
nativeContext
==
0
)
{
...
...
extensions/ffmpeg/src/main/java/com/google/android/exoplayer2/ext/ffmpeg/FfmpegVideoRenderer.java
View file @
37b58476
...
@@ -27,12 +27,12 @@ import com.google.android.exoplayer2.Format;
...
@@ -27,12 +27,12 @@ import com.google.android.exoplayer2.Format;
import
com.google.android.exoplayer2.RendererCapabilities
;
import
com.google.android.exoplayer2.RendererCapabilities
;
import
com.google.android.exoplayer2.decoder.CryptoConfig
;
import
com.google.android.exoplayer2.decoder.CryptoConfig
;
import
com.google.android.exoplayer2.decoder.Decoder
;
import
com.google.android.exoplayer2.decoder.Decoder
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.DecoderReuseEvaluation
;
import
com.google.android.exoplayer2.decoder.DecoderReuseEvaluation
;
import
com.google.android.exoplayer2.decoder.VideoDecoderOutputBuffer
;
import
com.google.android.exoplayer2.util.TraceUtil
;
import
com.google.android.exoplayer2.util.TraceUtil
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.video.DecoderVideoRenderer
;
import
com.google.android.exoplayer2.video.DecoderVideoRenderer
;
import
com.google.android.exoplayer2.video.VideoDecoderInputBuffer
;
import
com.google.android.exoplayer2.video.VideoDecoderOutputBuffer
;
import
com.google.android.exoplayer2.video.VideoRendererEventListener
;
import
com.google.android.exoplayer2.video.VideoRendererEventListener
;
// TODO: Remove the NOTE below.
// TODO: Remove the NOTE below.
...
@@ -94,7 +94,7 @@ public final class FfmpegVideoRenderer extends DecoderVideoRenderer {
...
@@ -94,7 +94,7 @@ public final class FfmpegVideoRenderer extends DecoderVideoRenderer {
@SuppressWarnings
(
"nullness:return"
)
@SuppressWarnings
(
"nullness:return"
)
@Override
@Override
protected
Decoder
<
Video
DecoderInputBuffer
,
VideoDecoderOutputBuffer
,
FfmpegDecoderException
>
protected
Decoder
<
DecoderInputBuffer
,
VideoDecoderOutputBuffer
,
FfmpegDecoderException
>
createDecoder
(
Format
format
,
@Nullable
CryptoConfig
cryptoConfig
)
createDecoder
(
Format
format
,
@Nullable
CryptoConfig
cryptoConfig
)
throws
FfmpegDecoderException
{
throws
FfmpegDecoderException
{
TraceUtil
.
beginSection
(
"createFfmpegVideoDecoder"
);
TraceUtil
.
beginSection
(
"createFfmpegVideoDecoder"
);
...
...
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacDecoder.java
View file @
37b58476
...
@@ -23,7 +23,7 @@ import com.google.android.exoplayer2.Format;
...
@@ -23,7 +23,7 @@ import com.google.android.exoplayer2.Format;
import
com.google.android.exoplayer2.ParserException
;
import
com.google.android.exoplayer2.ParserException
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.SimpleDecoder
;
import
com.google.android.exoplayer2.decoder.SimpleDecoder
;
import
com.google.android.exoplayer2.decoder.SimpleOutputBuffer
;
import
com.google.android.exoplayer2.decoder.Simple
Decoder
OutputBuffer
;
import
com.google.android.exoplayer2.extractor.FlacStreamMetadata
;
import
com.google.android.exoplayer2.extractor.FlacStreamMetadata
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.util.Util
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -33,7 +33,7 @@ import java.util.List;
...
@@ -33,7 +33,7 @@ import java.util.List;
/** Flac decoder. */
/** Flac decoder. */
@VisibleForTesting
(
otherwise
=
PACKAGE_PRIVATE
)
@VisibleForTesting
(
otherwise
=
PACKAGE_PRIVATE
)
public
final
class
FlacDecoder
public
final
class
FlacDecoder
extends
SimpleDecoder
<
DecoderInputBuffer
,
SimpleOutputBuffer
,
FlacDecoderException
>
{
extends
SimpleDecoder
<
DecoderInputBuffer
,
Simple
Decoder
OutputBuffer
,
FlacDecoderException
>
{
private
final
FlacStreamMetadata
streamMetadata
;
private
final
FlacStreamMetadata
streamMetadata
;
private
final
FlacDecoderJni
decoderJni
;
private
final
FlacDecoderJni
decoderJni
;
...
@@ -55,7 +55,7 @@ public final class FlacDecoder
...
@@ -55,7 +55,7 @@ public final class FlacDecoder
int
maxInputBufferSize
,
int
maxInputBufferSize
,
List
<
byte
[]>
initializationData
)
List
<
byte
[]>
initializationData
)
throws
FlacDecoderException
{
throws
FlacDecoderException
{
super
(
new
DecoderInputBuffer
[
numInputBuffers
],
new
SimpleOutputBuffer
[
numOutputBuffers
]);
super
(
new
DecoderInputBuffer
[
numInputBuffers
],
new
Simple
Decoder
OutputBuffer
[
numOutputBuffers
]);
if
(
initializationData
.
size
()
!=
1
)
{
if
(
initializationData
.
size
()
!=
1
)
{
throw
new
FlacDecoderException
(
"Initialization data must be of length 1"
);
throw
new
FlacDecoderException
(
"Initialization data must be of length 1"
);
}
}
...
@@ -86,8 +86,8 @@ public final class FlacDecoder
...
@@ -86,8 +86,8 @@ public final class FlacDecoder
}
}
@Override
@Override
protected
SimpleOutputBuffer
createOutputBuffer
()
{
protected
Simple
Decoder
OutputBuffer
createOutputBuffer
()
{
return
new
SimpleOutputBuffer
(
this
::
releaseOutputBuffer
);
return
new
Simple
Decoder
OutputBuffer
(
this
::
releaseOutputBuffer
);
}
}
@Override
@Override
...
@@ -98,7 +98,7 @@ public final class FlacDecoder
...
@@ -98,7 +98,7 @@ public final class FlacDecoder
@Override
@Override
@Nullable
@Nullable
protected
FlacDecoderException
decode
(
protected
FlacDecoderException
decode
(
DecoderInputBuffer
inputBuffer
,
SimpleOutputBuffer
outputBuffer
,
boolean
reset
)
{
DecoderInputBuffer
inputBuffer
,
Simple
Decoder
OutputBuffer
outputBuffer
,
boolean
reset
)
{
if
(
reset
)
{
if
(
reset
)
{
decoderJni
.
flush
();
decoderJni
.
flush
();
}
}
...
...
extensions/opus/proguard-rules.txt
View file @
37b58476
...
@@ -6,6 +6,6 @@
...
@@ -6,6 +6,6 @@
}
}
# Some members of this class are being accessed from native methods. Keep them unobfuscated.
# Some members of this class are being accessed from native methods. Keep them unobfuscated.
-keep class com.google.android.exoplayer2.decoder.SimpleOutputBuffer {
-keep class com.google.android.exoplayer2.decoder.Simple
Decoder
OutputBuffer {
*;
*;
}
}
extensions/opus/src/main/java/com/google/android/exoplayer2/ext/opus/OpusDecoder.java
View file @
37b58476
...
@@ -26,7 +26,7 @@ import com.google.android.exoplayer2.decoder.CryptoException;
...
@@ -26,7 +26,7 @@ import com.google.android.exoplayer2.decoder.CryptoException;
import
com.google.android.exoplayer2.decoder.CryptoInfo
;
import
com.google.android.exoplayer2.decoder.CryptoInfo
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.SimpleDecoder
;
import
com.google.android.exoplayer2.decoder.SimpleDecoder
;
import
com.google.android.exoplayer2.decoder.SimpleOutputBuffer
;
import
com.google.android.exoplayer2.decoder.Simple
Decoder
OutputBuffer
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.util.Util
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
...
@@ -35,7 +35,7 @@ import java.util.List;
...
@@ -35,7 +35,7 @@ import java.util.List;
/** Opus decoder. */
/** Opus decoder. */
@VisibleForTesting
(
otherwise
=
PACKAGE_PRIVATE
)
@VisibleForTesting
(
otherwise
=
PACKAGE_PRIVATE
)
public
final
class
OpusDecoder
public
final
class
OpusDecoder
extends
SimpleDecoder
<
DecoderInputBuffer
,
SimpleOutputBuffer
,
OpusDecoderException
>
{
extends
SimpleDecoder
<
DecoderInputBuffer
,
Simple
Decoder
OutputBuffer
,
OpusDecoderException
>
{
private
static
final
int
NO_ERROR
=
0
;
private
static
final
int
NO_ERROR
=
0
;
private
static
final
int
DECODE_ERROR
=
-
1
;
private
static
final
int
DECODE_ERROR
=
-
1
;
...
@@ -73,7 +73,7 @@ public final class OpusDecoder
...
@@ -73,7 +73,7 @@ public final class OpusDecoder
@Nullable
CryptoConfig
cryptoConfig
,
@Nullable
CryptoConfig
cryptoConfig
,
boolean
outputFloat
)
boolean
outputFloat
)
throws
OpusDecoderException
{
throws
OpusDecoderException
{
super
(
new
DecoderInputBuffer
[
numInputBuffers
],
new
SimpleOutputBuffer
[
numOutputBuffers
]);
super
(
new
DecoderInputBuffer
[
numInputBuffers
],
new
Simple
Decoder
OutputBuffer
[
numOutputBuffers
]);
if
(!
OpusLibrary
.
isAvailable
())
{
if
(!
OpusLibrary
.
isAvailable
())
{
throw
new
OpusDecoderException
(
"Failed to load decoder native libraries"
);
throw
new
OpusDecoderException
(
"Failed to load decoder native libraries"
);
}
}
...
@@ -147,8 +147,8 @@ public final class OpusDecoder
...
@@ -147,8 +147,8 @@ public final class OpusDecoder
}
}
@Override
@Override
protected
SimpleOutputBuffer
createOutputBuffer
()
{
protected
Simple
Decoder
OutputBuffer
createOutputBuffer
()
{
return
new
SimpleOutputBuffer
(
this
::
releaseOutputBuffer
);
return
new
Simple
Decoder
OutputBuffer
(
this
::
releaseOutputBuffer
);
}
}
@Override
@Override
...
@@ -159,7 +159,7 @@ public final class OpusDecoder
...
@@ -159,7 +159,7 @@ public final class OpusDecoder
@Override
@Override
@Nullable
@Nullable
protected
OpusDecoderException
decode
(
protected
OpusDecoderException
decode
(
DecoderInputBuffer
inputBuffer
,
SimpleOutputBuffer
outputBuffer
,
boolean
reset
)
{
DecoderInputBuffer
inputBuffer
,
Simple
Decoder
OutputBuffer
outputBuffer
,
boolean
reset
)
{
if
(
reset
)
{
if
(
reset
)
{
opusReset
(
nativeDecoderContext
);
opusReset
(
nativeDecoderContext
);
// When seeking to 0, skip number of samples as specified in opus header. When seeking to
// When seeking to 0, skip number of samples as specified in opus header. When seeking to
...
@@ -239,14 +239,14 @@ public final class OpusDecoder
...
@@ -239,14 +239,14 @@ public final class OpusDecoder
long
timeUs
,
long
timeUs
,
ByteBuffer
inputBuffer
,
ByteBuffer
inputBuffer
,
int
inputSize
,
int
inputSize
,
SimpleOutputBuffer
outputBuffer
);
Simple
Decoder
OutputBuffer
outputBuffer
);
private
native
int
opusSecureDecode
(
private
native
int
opusSecureDecode
(
long
decoder
,
long
decoder
,
long
timeUs
,
long
timeUs
,
ByteBuffer
inputBuffer
,
ByteBuffer
inputBuffer
,
int
inputSize
,
int
inputSize
,
SimpleOutputBuffer
outputBuffer
,
Simple
Decoder
OutputBuffer
outputBuffer
,
int
sampleRate
,
int
sampleRate
,
@Nullable
CryptoConfig
mediaCrypto
,
@Nullable
CryptoConfig
mediaCrypto
,
int
inputMode
,
int
inputMode
,
...
...
extensions/opus/src/main/jni/opus_jni.cc
View file @
37b58476
...
@@ -87,7 +87,7 @@ DECODER_FUNC(jlong, opusInit, jint sampleRate, jint channelCount,
...
@@ -87,7 +87,7 @@ DECODER_FUNC(jlong, opusInit, jint sampleRate, jint channelCount,
// Populate JNI References.
// Populate JNI References.
const
jclass
outputBufferClass
=
env
->
FindClass
(
const
jclass
outputBufferClass
=
env
->
FindClass
(
"com/google/android/exoplayer2/decoder/SimpleOutputBuffer"
);
"com/google/android/exoplayer2/decoder/Simple
Decoder
OutputBuffer"
);
outputBufferInit
=
outputBufferInit
=
env
->
GetMethodID
(
outputBufferClass
,
"init"
,
"(JI)Ljava/nio/ByteBuffer;"
);
env
->
GetMethodID
(
outputBufferClass
,
"init"
,
"(JI)Ljava/nio/ByteBuffer;"
);
...
...
extensions/vp9/proguard-rules.txt
View file @
37b58476
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
}
}
# Some members of this class are being accessed from native methods. Keep them unobfuscated.
# Some members of this class are being accessed from native methods. Keep them unobfuscated.
-keep class com.google.android.exoplayer2.
video
.VideoDecoderOutputBuffer {
-keep class com.google.android.exoplayer2.
decoder
.VideoDecoderOutputBuffer {
*;
*;
}
}
extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/LibvpxVideoRenderer.java
View file @
37b58476
...
@@ -26,10 +26,10 @@ import com.google.android.exoplayer2.Format;
...
@@ -26,10 +26,10 @@ import com.google.android.exoplayer2.Format;
import
com.google.android.exoplayer2.RendererCapabilities
;
import
com.google.android.exoplayer2.RendererCapabilities
;
import
com.google.android.exoplayer2.decoder.CryptoConfig
;
import
com.google.android.exoplayer2.decoder.CryptoConfig
;
import
com.google.android.exoplayer2.decoder.DecoderReuseEvaluation
;
import
com.google.android.exoplayer2.decoder.DecoderReuseEvaluation
;
import
com.google.android.exoplayer2.decoder.VideoDecoderOutputBuffer
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.TraceUtil
;
import
com.google.android.exoplayer2.util.TraceUtil
;
import
com.google.android.exoplayer2.video.DecoderVideoRenderer
;
import
com.google.android.exoplayer2.video.DecoderVideoRenderer
;
import
com.google.android.exoplayer2.video.VideoDecoderOutputBuffer
;
import
com.google.android.exoplayer2.video.VideoRendererEventListener
;
import
com.google.android.exoplayer2.video.VideoRendererEventListener
;
/** Decodes and renders video using the native VP9 decoder. */
/** Decodes and renders video using the native VP9 decoder. */
...
...
extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxDecoder.java
View file @
37b58476
...
@@ -26,16 +26,15 @@ import com.google.android.exoplayer2.decoder.CryptoException;
...
@@ -26,16 +26,15 @@ import com.google.android.exoplayer2.decoder.CryptoException;
import
com.google.android.exoplayer2.decoder.CryptoInfo
;
import
com.google.android.exoplayer2.decoder.CryptoInfo
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.SimpleDecoder
;
import
com.google.android.exoplayer2.decoder.SimpleDecoder
;
import
com.google.android.exoplayer2.decoder.VideoDecoderOutputBuffer
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.video.VideoDecoderInputBuffer
;
import
com.google.android.exoplayer2.video.VideoDecoderOutputBuffer
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
/** Vpx decoder. */
/** Vpx decoder. */
@VisibleForTesting
(
otherwise
=
PACKAGE_PRIVATE
)
@VisibleForTesting
(
otherwise
=
PACKAGE_PRIVATE
)
public
final
class
VpxDecoder
public
final
class
VpxDecoder
extends
SimpleDecoder
<
Video
DecoderInputBuffer
,
VideoDecoderOutputBuffer
,
VpxDecoderException
>
{
extends
SimpleDecoder
<
DecoderInputBuffer
,
VideoDecoderOutputBuffer
,
VpxDecoderException
>
{
// These constants should match the codes returned from vpxDecode and vpxSecureDecode functions in
// These constants should match the codes returned from vpxDecode and vpxSecureDecode functions in
// https://github.com/google/ExoPlayer/blob/release-v2/extensions/vp9/src/main/jni/vpx_jni.cc.
// https://github.com/google/ExoPlayer/blob/release-v2/extensions/vp9/src/main/jni/vpx_jni.cc.
...
@@ -68,9 +67,7 @@ public final class VpxDecoder
...
@@ -68,9 +67,7 @@ public final class VpxDecoder
@Nullable
CryptoConfig
cryptoConfig
,
@Nullable
CryptoConfig
cryptoConfig
,
int
threads
)
int
threads
)
throws
VpxDecoderException
{
throws
VpxDecoderException
{
super
(
super
(
new
DecoderInputBuffer
[
numInputBuffers
],
new
VideoDecoderOutputBuffer
[
numOutputBuffers
]);
new
VideoDecoderInputBuffer
[
numInputBuffers
],
new
VideoDecoderOutputBuffer
[
numOutputBuffers
]);
if
(!
VpxLibrary
.
isAvailable
())
{
if
(!
VpxLibrary
.
isAvailable
())
{
throw
new
VpxDecoderException
(
"Failed to load decoder native libraries."
);
throw
new
VpxDecoderException
(
"Failed to load decoder native libraries."
);
}
}
...
@@ -92,8 +89,8 @@ public final class VpxDecoder
...
@@ -92,8 +89,8 @@ public final class VpxDecoder
}
}
@Override
@Override
protected
Video
DecoderInputBuffer
createInputBuffer
()
{
protected
DecoderInputBuffer
createInputBuffer
()
{
return
new
Video
DecoderInputBuffer
(
DecoderInputBuffer
.
BUFFER_REPLACEMENT_MODE_DIRECT
);
return
new
DecoderInputBuffer
(
DecoderInputBuffer
.
BUFFER_REPLACEMENT_MODE_DIRECT
);
}
}
@Override
@Override
...
@@ -119,7 +116,7 @@ public final class VpxDecoder
...
@@ -119,7 +116,7 @@ public final class VpxDecoder
@Override
@Override
@Nullable
@Nullable
protected
VpxDecoderException
decode
(
protected
VpxDecoderException
decode
(
Video
DecoderInputBuffer
inputBuffer
,
VideoDecoderOutputBuffer
outputBuffer
,
boolean
reset
)
{
DecoderInputBuffer
inputBuffer
,
VideoDecoderOutputBuffer
outputBuffer
,
boolean
reset
)
{
if
(
reset
&&
lastSupplementalData
!=
null
)
{
if
(
reset
&&
lastSupplementalData
!=
null
)
{
// Don't propagate supplemental data across calls to flush the decoder.
// Don't propagate supplemental data across calls to flush the decoder.
lastSupplementalData
.
clear
();
lastSupplementalData
.
clear
();
...
...
extensions/vp9/src/main/jni/vpx_jni.cc
View file @
37b58476
...
@@ -479,7 +479,7 @@ DECODER_FUNC(jlong, vpxInit, jboolean disableLoopFilter,
...
@@ -479,7 +479,7 @@ DECODER_FUNC(jlong, vpxInit, jboolean disableLoopFilter,
// Populate JNI References.
// Populate JNI References.
const
jclass
outputBufferClass
=
env
->
FindClass
(
const
jclass
outputBufferClass
=
env
->
FindClass
(
"com/google/android/exoplayer2/
video
/VideoDecoderOutputBuffer"
);
"com/google/android/exoplayer2/
decoder
/VideoDecoderOutputBuffer"
);
initForYuvFrame
=
initForYuvFrame
=
env
->
GetMethodID
(
outputBufferClass
,
"initForYuvFrame"
,
"(IIIII)Z"
);
env
->
GetMethodID
(
outputBufferClass
,
"initForYuvFrame"
,
"(IIIII)Z"
);
initForPrivateFrame
=
initForPrivateFrame
=
...
...
library/core/src/main/java/com/google/android/exoplayer2/audio/DecoderAudioRenderer.java
View file @
37b58476
...
@@ -44,7 +44,7 @@ import com.google.android.exoplayer2.decoder.DecoderCounters;
...
@@ -44,7 +44,7 @@ import com.google.android.exoplayer2.decoder.DecoderCounters;
import
com.google.android.exoplayer2.decoder.DecoderException
;
import
com.google.android.exoplayer2.decoder.DecoderException
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.DecoderReuseEvaluation
;
import
com.google.android.exoplayer2.decoder.DecoderReuseEvaluation
;
import
com.google.android.exoplayer2.decoder.SimpleOutputBuffer
;
import
com.google.android.exoplayer2.decoder.Simple
Decoder
OutputBuffer
;
import
com.google.android.exoplayer2.drm.DrmSession
;
import
com.google.android.exoplayer2.drm.DrmSession
;
import
com.google.android.exoplayer2.drm.DrmSession.DrmSessionException
;
import
com.google.android.exoplayer2.drm.DrmSession.DrmSessionException
;
import
com.google.android.exoplayer2.source.SampleStream.ReadDataResult
;
import
com.google.android.exoplayer2.source.SampleStream.ReadDataResult
;
...
@@ -82,7 +82,10 @@ import java.lang.annotation.RetentionPolicy;
...
@@ -82,7 +82,10 @@ import java.lang.annotation.RetentionPolicy;
*/
*/
public
abstract
class
DecoderAudioRenderer
<
public
abstract
class
DecoderAudioRenderer
<
T
extends
T
extends
Decoder
<
DecoderInputBuffer
,
?
extends
SimpleOutputBuffer
,
?
extends
DecoderException
>>
Decoder
<
DecoderInputBuffer
,
?
extends
SimpleDecoderOutputBuffer
,
?
extends
DecoderException
>>
extends
BaseRenderer
implements
MediaClock
{
extends
BaseRenderer
implements
MediaClock
{
private
static
final
String
TAG
=
"DecoderAudioRenderer"
;
private
static
final
String
TAG
=
"DecoderAudioRenderer"
;
...
@@ -124,7 +127,7 @@ public abstract class DecoderAudioRenderer<
...
@@ -124,7 +127,7 @@ public abstract class DecoderAudioRenderer<
@Nullable
private
T
decoder
;
@Nullable
private
T
decoder
;
@Nullable
private
DecoderInputBuffer
inputBuffer
;
@Nullable
private
DecoderInputBuffer
inputBuffer
;
@Nullable
private
SimpleOutputBuffer
outputBuffer
;
@Nullable
private
Simple
Decoder
OutputBuffer
outputBuffer
;
@Nullable
private
DrmSession
decoderDrmSession
;
@Nullable
private
DrmSession
decoderDrmSession
;
@Nullable
private
DrmSession
sourceDrmSession
;
@Nullable
private
DrmSession
sourceDrmSession
;
...
@@ -456,6 +459,7 @@ public abstract class DecoderAudioRenderer<
...
@@ -456,6 +459,7 @@ public abstract class DecoderAudioRenderer<
return
false
;
return
false
;
}
}
inputBuffer
.
flip
();
inputBuffer
.
flip
();
inputBuffer
.
format
=
inputFormat
;
onQueueInputBuffer
(
inputBuffer
);
onQueueInputBuffer
(
inputBuffer
);
decoder
.
queueInputBuffer
(
inputBuffer
);
decoder
.
queueInputBuffer
(
inputBuffer
);
decoderReceivedBuffers
=
true
;
decoderReceivedBuffers
=
true
;
...
...
library/core/src/main/java/com/google/android/exoplayer2/video/DecoderVideoRenderer.java
View file @
37b58476
...
@@ -42,6 +42,7 @@ import com.google.android.exoplayer2.decoder.DecoderCounters;
...
@@ -42,6 +42,7 @@ import com.google.android.exoplayer2.decoder.DecoderCounters;
import
com.google.android.exoplayer2.decoder.DecoderException
;
import
com.google.android.exoplayer2.decoder.DecoderException
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.DecoderReuseEvaluation
;
import
com.google.android.exoplayer2.decoder.DecoderReuseEvaluation
;
import
com.google.android.exoplayer2.decoder.VideoDecoderOutputBuffer
;
import
com.google.android.exoplayer2.drm.DrmSession
;
import
com.google.android.exoplayer2.drm.DrmSession
;
import
com.google.android.exoplayer2.drm.DrmSession.DrmSessionException
;
import
com.google.android.exoplayer2.drm.DrmSession.DrmSessionException
;
import
com.google.android.exoplayer2.source.SampleStream.ReadDataResult
;
import
com.google.android.exoplayer2.source.SampleStream.ReadDataResult
;
...
@@ -108,10 +109,10 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
...
@@ -108,10 +109,10 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
@Nullable
@Nullable
private
Decoder
<
private
Decoder
<
Video
DecoderInputBuffer
,
?
extends
VideoDecoderOutputBuffer
,
?
extends
DecoderException
>
DecoderInputBuffer
,
?
extends
VideoDecoderOutputBuffer
,
?
extends
DecoderException
>
decoder
;
decoder
;
private
Video
DecoderInputBuffer
inputBuffer
;
private
DecoderInputBuffer
inputBuffer
;
private
VideoDecoderOutputBuffer
outputBuffer
;
private
VideoDecoderOutputBuffer
outputBuffer
;
@VideoOutputMode
private
int
outputMode
;
@VideoOutputMode
private
int
outputMode
;
@Nullable
private
Object
output
;
@Nullable
private
Object
output
;
...
@@ -415,7 +416,7 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
...
@@ -415,7 +416,7 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
*
*
* @param buffer The buffer that will be queued.
* @param buffer The buffer that will be queued.
*/
*/
protected
void
onQueueInputBuffer
(
Video
DecoderInputBuffer
buffer
)
{
protected
void
onQueueInputBuffer
(
DecoderInputBuffer
buffer
)
{
// Do nothing.
// Do nothing.
}
}
...
@@ -536,7 +537,7 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
...
@@ -536,7 +537,7 @@ public abstract class DecoderVideoRenderer extends BaseRenderer {
* @throws DecoderException If an error occurred creating a suitable decoder.
* @throws DecoderException If an error occurred creating a suitable decoder.
*/
*/
protected
abstract
Decoder
<
protected
abstract
Decoder
<
Video
DecoderInputBuffer
,
?
extends
VideoDecoderOutputBuffer
,
?
extends
DecoderException
>
DecoderInputBuffer
,
?
extends
VideoDecoderOutputBuffer
,
?
extends
DecoderException
>
createDecoder
(
Format
format
,
@Nullable
CryptoConfig
cryptoConfig
)
throws
DecoderException
;
createDecoder
(
Format
format
,
@Nullable
CryptoConfig
cryptoConfig
)
throws
DecoderException
;
/**
/**
...
...
library/core/src/main/java/com/google/android/exoplayer2/video/VideoDecoderGLSurfaceView.java
View file @
37b58476
...
@@ -20,6 +20,7 @@ import android.opengl.GLES20;
...
@@ -20,6 +20,7 @@ import android.opengl.GLES20;
import
android.opengl.GLSurfaceView
;
import
android.opengl.GLSurfaceView
;
import
android.util.AttributeSet
;
import
android.util.AttributeSet
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.decoder.VideoDecoderOutputBuffer
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
com.google.android.exoplayer2.util.GlUtil
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
...
...
library/core/src/main/java/com/google/android/exoplayer2/video/VideoDecoderInputBuffer.java
deleted
100644 → 0
View file @
5e26ba82
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
google
.
android
.
exoplayer2
.
video
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
/** Input buffer to a video decoder. */
public
class
VideoDecoderInputBuffer
extends
DecoderInputBuffer
{
@Nullable
public
Format
format
;
/**
* Creates a new instance.
*
* @param bufferReplacementMode Determines the behavior of {@link #ensureSpaceForWrite(int)}. One
* of {@link #BUFFER_REPLACEMENT_MODE_DISABLED}, {@link #BUFFER_REPLACEMENT_MODE_NORMAL} and
* {@link #BUFFER_REPLACEMENT_MODE_DIRECT}.
*/
public
VideoDecoderInputBuffer
(
@BufferReplacementMode
int
bufferReplacementMode
)
{
super
(
bufferReplacementMode
);
}
/**
* Creates a new instance.
*
* @param bufferReplacementMode Determines the behavior of {@link #ensureSpaceForWrite(int)}. One
* of {@link #BUFFER_REPLACEMENT_MODE_DISABLED}, {@link #BUFFER_REPLACEMENT_MODE_NORMAL} and
* {@link #BUFFER_REPLACEMENT_MODE_DIRECT}.
* @param paddingSize If non-zero, {@link #ensureSpaceForWrite(int)} will ensure that the buffer
* is this number of bytes larger than the requested length. This can be useful for decoders
* that consume data in fixed size blocks, for efficiency. Setting the padding size to the
* decoder's fixed read size is necessary to prevent such a decoder from trying to read beyond
* the end of the buffer.
*/
public
VideoDecoderInputBuffer
(
@BufferReplacementMode
int
bufferReplacementMode
,
int
paddingSize
)
{
super
(
bufferReplacementMode
,
paddingSize
);
}
}
library/core/src/main/java/com/google/android/exoplayer2/video/VideoDecoderOutputBufferRenderer.java
View file @
37b58476
...
@@ -15,6 +15,8 @@
...
@@ -15,6 +15,8 @@
*/
*/
package
com
.
google
.
android
.
exoplayer2
.
video
;
package
com
.
google
.
android
.
exoplayer2
.
video
;
import
com.google.android.exoplayer2.decoder.VideoDecoderOutputBuffer
;
/** Renders the {@link VideoDecoderOutputBuffer}. */
/** Renders the {@link VideoDecoderOutputBuffer}. */
public
interface
VideoDecoderOutputBufferRenderer
{
public
interface
VideoDecoderOutputBufferRenderer
{
...
...
library/core/src/test/java/com/google/android/exoplayer2/audio/DecoderAudioRendererTest.java
View file @
37b58476
...
@@ -34,7 +34,7 @@ import com.google.android.exoplayer2.decoder.CryptoConfig;
...
@@ -34,7 +34,7 @@ import com.google.android.exoplayer2.decoder.CryptoConfig;
import
com.google.android.exoplayer2.decoder.DecoderException
;
import
com.google.android.exoplayer2.decoder.DecoderException
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.SimpleDecoder
;
import
com.google.android.exoplayer2.decoder.SimpleDecoder
;
import
com.google.android.exoplayer2.decoder.SimpleOutputBuffer
;
import
com.google.android.exoplayer2.decoder.Simple
Decoder
OutputBuffer
;
import
com.google.android.exoplayer2.drm.DrmSessionEventListener
;
import
com.google.android.exoplayer2.drm.DrmSessionEventListener
;
import
com.google.android.exoplayer2.drm.DrmSessionManager
;
import
com.google.android.exoplayer2.drm.DrmSessionManager
;
import
com.google.android.exoplayer2.testutil.FakeSampleStream
;
import
com.google.android.exoplayer2.testutil.FakeSampleStream
;
...
@@ -133,10 +133,10 @@ public class DecoderAudioRendererTest {
...
@@ -133,10 +133,10 @@ public class DecoderAudioRendererTest {
}
}
private
static
final
class
FakeDecoder
private
static
final
class
FakeDecoder
extends
SimpleDecoder
<
DecoderInputBuffer
,
SimpleOutputBuffer
,
DecoderException
>
{
extends
SimpleDecoder
<
DecoderInputBuffer
,
Simple
Decoder
OutputBuffer
,
DecoderException
>
{
public
FakeDecoder
()
{
public
FakeDecoder
()
{
super
(
new
DecoderInputBuffer
[
1
],
new
SimpleOutputBuffer
[
1
]);
super
(
new
DecoderInputBuffer
[
1
],
new
Simple
Decoder
OutputBuffer
[
1
]);
}
}
@Override
@Override
...
@@ -150,8 +150,8 @@ public class DecoderAudioRendererTest {
...
@@ -150,8 +150,8 @@ public class DecoderAudioRendererTest {
}
}
@Override
@Override
protected
SimpleOutputBuffer
createOutputBuffer
()
{
protected
Simple
Decoder
OutputBuffer
createOutputBuffer
()
{
return
new
SimpleOutputBuffer
(
this
::
releaseOutputBuffer
);
return
new
Simple
Decoder
OutputBuffer
(
this
::
releaseOutputBuffer
);
}
}
@Override
@Override
...
@@ -161,7 +161,7 @@ public class DecoderAudioRendererTest {
...
@@ -161,7 +161,7 @@ public class DecoderAudioRendererTest {
@Override
@Override
protected
DecoderException
decode
(
protected
DecoderException
decode
(
DecoderInputBuffer
inputBuffer
,
SimpleOutputBuffer
outputBuffer
,
boolean
reset
)
{
DecoderInputBuffer
inputBuffer
,
Simple
Decoder
OutputBuffer
outputBuffer
,
boolean
reset
)
{
if
(
inputBuffer
.
isEndOfStream
())
{
if
(
inputBuffer
.
isEndOfStream
())
{
outputBuffer
.
setFlags
(
C
.
BUFFER_FLAG_END_OF_STREAM
);
outputBuffer
.
setFlags
(
C
.
BUFFER_FLAG_END_OF_STREAM
);
}
}
...
...
library/core/src/test/java/com/google/android/exoplayer2/video/DecoderVideoRendererTest.java
View file @
37b58476
...
@@ -38,6 +38,7 @@ import com.google.android.exoplayer2.decoder.CryptoConfig;
...
@@ -38,6 +38,7 @@ import com.google.android.exoplayer2.decoder.CryptoConfig;
import
com.google.android.exoplayer2.decoder.DecoderException
;
import
com.google.android.exoplayer2.decoder.DecoderException
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.DecoderInputBuffer
;
import
com.google.android.exoplayer2.decoder.SimpleDecoder
;
import
com.google.android.exoplayer2.decoder.SimpleDecoder
;
import
com.google.android.exoplayer2.decoder.VideoDecoderOutputBuffer
;
import
com.google.android.exoplayer2.drm.DrmSessionEventListener
;
import
com.google.android.exoplayer2.drm.DrmSessionEventListener
;
import
com.google.android.exoplayer2.drm.DrmSessionManager
;
import
com.google.android.exoplayer2.drm.DrmSessionManager
;
import
com.google.android.exoplayer2.testutil.FakeSampleStream
;
import
com.google.android.exoplayer2.testutil.FakeSampleStream
;
...
@@ -108,7 +109,7 @@ public final class DecoderVideoRendererTest {
...
@@ -108,7 +109,7 @@ public final class DecoderVideoRendererTest {
}
}
@Override
@Override
protected
void
onQueueInputBuffer
(
Video
DecoderInputBuffer
buffer
)
{
protected
void
onQueueInputBuffer
(
DecoderInputBuffer
buffer
)
{
// Decoding is done on a background thread we have no control about from the test.
// Decoding is done on a background thread we have no control about from the test.
// Ensure the background calls are predictably serialized by waiting for them to finish:
// Ensure the background calls are predictably serialized by waiting for them to finish:
// 1. Register queued input buffers here.
// 1. Register queued input buffers here.
...
@@ -125,17 +126,16 @@ public final class DecoderVideoRendererTest {
...
@@ -125,17 +126,16 @@ public final class DecoderVideoRendererTest {
@Override
@Override
protected
SimpleDecoder
<
protected
SimpleDecoder
<
Video
DecoderInputBuffer
,
DecoderInputBuffer
,
?
extends
VideoDecoderOutputBuffer
,
?
extends
VideoDecoderOutputBuffer
,
?
extends
DecoderException
>
?
extends
DecoderException
>
createDecoder
(
Format
format
,
@Nullable
CryptoConfig
cryptoConfig
)
{
createDecoder
(
Format
format
,
@Nullable
CryptoConfig
cryptoConfig
)
{
return
new
SimpleDecoder
<
return
new
SimpleDecoder
<
Video
DecoderInputBuffer
,
VideoDecoderOutputBuffer
,
DecoderException
>(
DecoderInputBuffer
,
VideoDecoderOutputBuffer
,
DecoderException
>(
new
Video
DecoderInputBuffer
[
10
],
new
VideoDecoderOutputBuffer
[
10
])
{
new
DecoderInputBuffer
[
10
],
new
VideoDecoderOutputBuffer
[
10
])
{
@Override
@Override
protected
VideoDecoderInputBuffer
createInputBuffer
()
{
protected
DecoderInputBuffer
createInputBuffer
()
{
return
new
VideoDecoderInputBuffer
(
return
new
DecoderInputBuffer
(
DecoderInputBuffer
.
BUFFER_REPLACEMENT_MODE_DIRECT
)
{
DecoderInputBuffer
.
BUFFER_REPLACEMENT_MODE_DIRECT
)
{
@Override
@Override
public
void
clear
()
{
public
void
clear
()
{
super
.
clear
();
super
.
clear
();
...
@@ -157,7 +157,7 @@ public final class DecoderVideoRendererTest {
...
@@ -157,7 +157,7 @@ public final class DecoderVideoRendererTest {
@Nullable
@Nullable
@Override
@Override
protected
DecoderException
decode
(
protected
DecoderException
decode
(
Video
DecoderInputBuffer
inputBuffer
,
DecoderInputBuffer
inputBuffer
,
VideoDecoderOutputBuffer
outputBuffer
,
VideoDecoderOutputBuffer
outputBuffer
,
boolean
reset
)
{
boolean
reset
)
{
outputBuffer
.
init
(
inputBuffer
.
timeUs
,
outputMode
,
/* supplementalData= */
null
);
outputBuffer
.
init
(
inputBuffer
.
timeUs
,
outputMode
,
/* supplementalData= */
null
);
...
...
library/decoder/src/main/java/com/google/android/exoplayer2/decoder/DecoderInputBuffer.java
View file @
37b58476
...
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.decoder;
...
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.decoder;
import
androidx.annotation.IntDef
;
import
androidx.annotation.IntDef
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Documented
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.Retention
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.RetentionPolicy
;
...
@@ -73,6 +74,9 @@ public class DecoderInputBuffer extends Buffer {
...
@@ -73,6 +74,9 @@ public class DecoderInputBuffer extends Buffer {
/** Allows buffer replacement using {@link ByteBuffer#allocateDirect(int)}. */
/** Allows buffer replacement using {@link ByteBuffer#allocateDirect(int)}. */
public
static
final
int
BUFFER_REPLACEMENT_MODE_DIRECT
=
2
;
public
static
final
int
BUFFER_REPLACEMENT_MODE_DIRECT
=
2
;
/** The {@link Format}. */
@Nullable
public
Format
format
;
/** {@link CryptoInfo} for encrypted data. */
/** {@link CryptoInfo} for encrypted data. */
public
final
CryptoInfo
cryptoInfo
;
public
final
CryptoInfo
cryptoInfo
;
...
...
library/decoder/src/main/java/com/google/android/exoplayer2/decoder/OutputBuffer.java
→
library/decoder/src/main/java/com/google/android/exoplayer2/decoder/
Decoder
OutputBuffer.java
View file @
37b58476
...
@@ -16,10 +16,10 @@
...
@@ -16,10 +16,10 @@
package
com
.
google
.
android
.
exoplayer2
.
decoder
;
package
com
.
google
.
android
.
exoplayer2
.
decoder
;
/** Output buffer decoded by a {@link Decoder}. */
/** Output buffer decoded by a {@link Decoder}. */
public
abstract
class
OutputBuffer
extends
Buffer
{
public
abstract
class
Decoder
OutputBuffer
extends
Buffer
{
/** Buffer owner. */
/** Buffer owner. */
public
interface
Owner
<
S
extends
OutputBuffer
>
{
public
interface
Owner
<
S
extends
Decoder
OutputBuffer
>
{
/**
/**
* Releases the buffer.
* Releases the buffer.
...
...
library/decoder/src/main/java/com/google/android/exoplayer2/decoder/SimpleDecoder.java
View file @
37b58476
...
@@ -27,7 +27,7 @@ import java.util.ArrayDeque;
...
@@ -27,7 +27,7 @@ import java.util.ArrayDeque;
*/
*/
@SuppressWarnings
(
"UngroupedOverloads"
)
@SuppressWarnings
(
"UngroupedOverloads"
)
public
abstract
class
SimpleDecoder
<
public
abstract
class
SimpleDecoder
<
I
extends
DecoderInputBuffer
,
O
extends
OutputBuffer
,
E
extends
DecoderException
>
I
extends
DecoderInputBuffer
,
O
extends
Decoder
OutputBuffer
,
E
extends
DecoderException
>
implements
Decoder
<
I
,
O
,
E
>
{
implements
Decoder
<
I
,
O
,
E
>
{
private
final
Thread
decodeThread
;
private
final
Thread
decodeThread
;
...
...
library/decoder/src/main/java/com/google/android/exoplayer2/decoder/SimpleOutputBuffer.java
→
library/decoder/src/main/java/com/google/android/exoplayer2/decoder/Simple
Decoder
OutputBuffer.java
View file @
37b58476
...
@@ -20,13 +20,13 @@ import java.nio.ByteBuffer;
...
@@ -20,13 +20,13 @@ import java.nio.ByteBuffer;
import
java.nio.ByteOrder
;
import
java.nio.ByteOrder
;
/** Buffer for {@link SimpleDecoder} output. */
/** Buffer for {@link SimpleDecoder} output. */
public
class
Simple
OutputBuffer
extends
OutputBuffer
{
public
class
Simple
DecoderOutputBuffer
extends
Decoder
OutputBuffer
{
private
final
Owner
<
SimpleOutputBuffer
>
owner
;
private
final
Owner
<
Simple
Decoder
OutputBuffer
>
owner
;
@Nullable
public
ByteBuffer
data
;
@Nullable
public
ByteBuffer
data
;
public
Simple
OutputBuffer
(
Owner
<
Simple
OutputBuffer
>
owner
)
{
public
Simple
DecoderOutputBuffer
(
Owner
<
SimpleDecoder
OutputBuffer
>
owner
)
{
this
.
owner
=
owner
;
this
.
owner
=
owner
;
}
}
...
...
library/
core/src/main/java/com/google/android/exoplayer2/video
/VideoDecoderOutputBuffer.java
→
library/
decoder/src/main/java/com/google/android/exoplayer2/decoder
/VideoDecoderOutputBuffer.java
View file @
37b58476
...
@@ -13,16 +13,15 @@
...
@@ -13,16 +13,15 @@
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
com
.
google
.
android
.
exoplayer2
.
video
;
package
com
.
google
.
android
.
exoplayer2
.
decoder
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.decoder.OutputBuffer
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
/** Video decoder output buffer containing video frame data. */
/** Video decoder output buffer containing video frame data. */
public
class
VideoDecoderOutputBuffer
extends
OutputBuffer
{
public
class
VideoDecoderOutputBuffer
extends
Decoder
OutputBuffer
{
public
static
final
int
COLORSPACE_UNKNOWN
=
0
;
public
static
final
int
COLORSPACE_UNKNOWN
=
0
;
public
static
final
int
COLORSPACE_BT601
=
1
;
public
static
final
int
COLORSPACE_BT601
=
1
;
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/text/SubtitleOutputBuffer.java
View file @
37b58476
...
@@ -17,12 +17,12 @@ package com.google.android.exoplayer2.text;
...
@@ -17,12 +17,12 @@ package com.google.android.exoplayer2.text;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.decoder.OutputBuffer
;
import
com.google.android.exoplayer2.decoder.
Decoder
OutputBuffer
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Assertions
;
import
java.util.List
;
import
java.util.List
;
/** Base class for {@link SubtitleDecoder} output buffers. */
/** Base class for {@link SubtitleDecoder} output buffers. */
public
abstract
class
SubtitleOutputBuffer
extends
OutputBuffer
implements
Subtitle
{
public
abstract
class
SubtitleOutputBuffer
extends
Decoder
OutputBuffer
implements
Subtitle
{
@Nullable
private
Subtitle
subtitle
;
@Nullable
private
Subtitle
subtitle
;
private
long
subsampleOffsetUs
;
private
long
subsampleOffsetUs
;
...
...
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