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
a9b93d7e
authored
Aug 06, 2019
by
tonihei
Committed by
Toni
Aug 06, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix some remaining extension API nullability issues.
PiperOrigin-RevId: 261910303
parent
b0330edc
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
57 additions
and
35 deletions
extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastUtils.java
extensions/ffmpeg/src/main/java/com/google/android/exoplayer2/ext/ffmpeg/FfmpegAudioRenderer.java
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/LibflacAudioRenderer.java
extensions/opus/src/main/java/com/google/android/exoplayer2/ext/opus/LibopusAudioRenderer.java
extensions/opus/src/main/java/com/google/android/exoplayer2/ext/opus/OpusDecoder.java
library/core/src/main/java/com/google/android/exoplayer2/audio/SimpleDecoderAudioRenderer.java
library/core/src/test/java/com/google/android/exoplayer2/audio/SimpleDecoderAudioRendererTest.java
extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastUtils.java
View file @
a9b93d7e
...
...
@@ -15,6 +15,7 @@
*/
package
com
.
google
.
android
.
exoplayer2
.
ext
.
cast
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.gms.cast.CastStatusCodes
;
...
...
@@ -33,7 +34,7 @@ import com.google.android.gms.cast.MediaTrack;
* @param mediaInfo The media info to get the duration from.
* @return The duration in microseconds, or {@link C#TIME_UNSET} if unknown or not applicable.
*/
public
static
long
getStreamDurationUs
(
MediaInfo
mediaInfo
)
{
public
static
long
getStreamDurationUs
(
@Nullable
MediaInfo
mediaInfo
)
{
if
(
mediaInfo
==
null
)
{
return
C
.
TIME_UNSET
;
}
...
...
extensions/ffmpeg/src/main/java/com/google/android/exoplayer2/ext/ffmpeg/FfmpegAudioRenderer.java
View file @
a9b93d7e
...
...
@@ -92,8 +92,8 @@ public final class FfmpegAudioRenderer extends SimpleDecoderAudioRenderer {
}
@Override
protected
int
supportsFormatInternal
(
DrmSessionManager
<
ExoMediaCrypto
>
drmSessionManager
,
Format
format
)
{
protected
int
supportsFormatInternal
(
@Nullable
DrmSessionManager
<
ExoMediaCrypto
>
drmSessionManager
,
Format
format
)
{
Assertions
.
checkNotNull
(
format
.
sampleMimeType
);
if
(!
FfmpegLibrary
.
isAvailable
())
{
return
FORMAT_UNSUPPORTED_TYPE
;
...
...
@@ -113,7 +113,7 @@ public final class FfmpegAudioRenderer extends SimpleDecoderAudioRenderer {
}
@Override
protected
FfmpegDecoder
createDecoder
(
Format
format
,
ExoMediaCrypto
mediaCrypto
)
protected
FfmpegDecoder
createDecoder
(
Format
format
,
@Nullable
ExoMediaCrypto
mediaCrypto
)
throws
FfmpegDecoderException
{
int
initialInputBufferSize
=
format
.
maxInputSize
!=
Format
.
NO_VALUE
?
format
.
maxInputSize
:
DEFAULT_INPUT_BUFFER_SIZE
;
...
...
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/LibflacAudioRenderer.java
View file @
a9b93d7e
...
...
@@ -51,8 +51,8 @@ public class LibflacAudioRenderer extends SimpleDecoderAudioRenderer {
}
@Override
protected
int
supportsFormatInternal
(
DrmSessionManager
<
ExoMediaCrypto
>
drmSessionManager
,
Format
format
)
{
protected
int
supportsFormatInternal
(
@Nullable
DrmSessionManager
<
ExoMediaCrypto
>
drmSessionManager
,
Format
format
)
{
if
(!
FlacLibrary
.
isAvailable
()
||
!
MimeTypes
.
AUDIO_FLAC
.
equalsIgnoreCase
(
format
.
sampleMimeType
))
{
return
FORMAT_UNSUPPORTED_TYPE
;
...
...
@@ -66,7 +66,7 @@ public class LibflacAudioRenderer extends SimpleDecoderAudioRenderer {
}
@Override
protected
FlacDecoder
createDecoder
(
Format
format
,
ExoMediaCrypto
mediaCrypto
)
protected
FlacDecoder
createDecoder
(
Format
format
,
@Nullable
ExoMediaCrypto
mediaCrypto
)
throws
FlacDecoderException
{
return
new
FlacDecoder
(
NUM_BUFFERS
,
NUM_BUFFERS
,
format
.
maxInputSize
,
format
.
initializationData
);
...
...
extensions/opus/src/main/java/com/google/android/exoplayer2/ext/opus/LibopusAudioRenderer.java
View file @
a9b93d7e
...
...
@@ -79,8 +79,8 @@ public class LibopusAudioRenderer extends SimpleDecoderAudioRenderer {
}
@Override
protected
int
supportsFormatInternal
(
DrmSessionManager
<
ExoMediaCrypto
>
drmSessionManager
,
Format
format
)
{
protected
int
supportsFormatInternal
(
@Nullable
DrmSessionManager
<
ExoMediaCrypto
>
drmSessionManager
,
Format
format
)
{
boolean
drmIsSupported
=
format
.
drmInitData
==
null
||
OpusLibrary
.
matchesExpectedExoMediaCryptoType
(
format
.
exoMediaCryptoType
)
...
...
@@ -99,7 +99,7 @@ public class LibopusAudioRenderer extends SimpleDecoderAudioRenderer {
}
@Override
protected
OpusDecoder
createDecoder
(
Format
format
,
ExoMediaCrypto
mediaCrypto
)
protected
OpusDecoder
createDecoder
(
Format
format
,
@Nullable
ExoMediaCrypto
mediaCrypto
)
throws
OpusDecoderException
{
int
initialInputBufferSize
=
format
.
maxInputSize
!=
Format
.
NO_VALUE
?
format
.
maxInputSize
:
DEFAULT_INPUT_BUFFER_SIZE
;
...
...
extensions/opus/src/main/java/com/google/android/exoplayer2/ext/opus/OpusDecoder.java
View file @
a9b93d7e
...
...
@@ -44,7 +44,7 @@ import java.util.List;
private
static
final
int
DECODE_ERROR
=
-
1
;
private
static
final
int
DRM_ERROR
=
-
2
;
private
final
ExoMediaCrypto
exoMediaCrypto
;
@Nullable
private
final
ExoMediaCrypto
exoMediaCrypto
;
private
final
int
channelCount
;
private
final
int
headerSkipSamples
;
...
...
@@ -66,8 +66,13 @@ import java.util.List;
* content. Maybe null and can be ignored if decoder does not handle encrypted content.
* @throws OpusDecoderException Thrown if an exception occurs when initializing the decoder.
*/
public
OpusDecoder
(
int
numInputBuffers
,
int
numOutputBuffers
,
int
initialInputBufferSize
,
List
<
byte
[]>
initializationData
,
ExoMediaCrypto
exoMediaCrypto
)
throws
OpusDecoderException
{
public
OpusDecoder
(
int
numInputBuffers
,
int
numOutputBuffers
,
int
initialInputBufferSize
,
List
<
byte
[]>
initializationData
,
@Nullable
ExoMediaCrypto
exoMediaCrypto
)
throws
OpusDecoderException
{
super
(
new
DecoderInputBuffer
[
numInputBuffers
],
new
SimpleOutputBuffer
[
numOutputBuffers
]);
if
(!
OpusLibrary
.
isAvailable
())
{
throw
new
OpusDecoderException
(
"Failed to load decoder native libraries."
);
...
...
@@ -232,10 +237,22 @@ import java.util.List;
int
gain
,
byte
[]
streamMap
);
private
native
int
opusDecode
(
long
decoder
,
long
timeUs
,
ByteBuffer
inputBuffer
,
int
inputSize
,
SimpleOutputBuffer
outputBuffer
);
private
native
int
opusSecureDecode
(
long
decoder
,
long
timeUs
,
ByteBuffer
inputBuffer
,
int
inputSize
,
SimpleOutputBuffer
outputBuffer
,
int
sampleRate
,
ExoMediaCrypto
mediaCrypto
,
int
inputMode
,
byte
[]
key
,
byte
[]
iv
,
int
numSubSamples
,
int
[]
numBytesOfClearData
,
int
[]
numBytesOfEncryptedData
);
private
native
int
opusSecureDecode
(
long
decoder
,
long
timeUs
,
ByteBuffer
inputBuffer
,
int
inputSize
,
SimpleOutputBuffer
outputBuffer
,
int
sampleRate
,
@Nullable
ExoMediaCrypto
mediaCrypto
,
int
inputMode
,
byte
[]
key
,
byte
[]
iv
,
int
numSubSamples
,
int
[]
numBytesOfClearData
,
int
[]
numBytesOfEncryptedData
);
private
native
void
opusClose
(
long
decoder
);
private
native
void
opusReset
(
long
decoder
);
private
native
int
opusGetErrorCode
(
long
decoder
);
...
...
library/core/src/main/java/com/google/android/exoplayer2/audio/SimpleDecoderAudioRenderer.java
View file @
a9b93d7e
...
...
@@ -246,7 +246,7 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
* @return The extent to which the renderer supports the format itself.
*/
protected
abstract
int
supportsFormatInternal
(
DrmSessionManager
<
ExoMediaCrypto
>
drmSessionManager
,
Format
format
);
@Nullable
DrmSessionManager
<
ExoMediaCrypto
>
drmSessionManager
,
Format
format
);
/**
* Returns whether the sink supports the audio format.
...
...
@@ -341,9 +341,10 @@ public abstract class SimpleDecoderAudioRenderer extends BaseRenderer implements
* @return The decoder.
* @throws AudioDecoderException If an error occurred creating a suitable decoder.
*/
protected
abstract
SimpleDecoder
<
DecoderInputBuffer
,
?
extends
SimpleOutputBuffer
,
?
extends
AudioDecoderException
>
createDecoder
(
Format
format
,
ExoMediaCrypto
mediaCrypto
)
throws
AudioDecoderException
;
protected
abstract
SimpleDecoder
<
DecoderInputBuffer
,
?
extends
SimpleOutputBuffer
,
?
extends
AudioDecoderException
>
createDecoder
(
Format
format
,
@Nullable
ExoMediaCrypto
mediaCrypto
)
throws
AudioDecoderException
;
/**
* Returns the format of audio buffers output by the decoder. Will not be called until the first
...
...
library/core/src/test/java/com/google/android/exoplayer2/audio/SimpleDecoderAudioRendererTest.java
View file @
a9b93d7e
...
...
@@ -24,6 +24,7 @@ import static org.mockito.Mockito.times;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
when
;
import
androidx.annotation.Nullable
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
...
...
@@ -54,20 +55,22 @@ public class SimpleDecoderAudioRendererTest {
@Before
public
void
setUp
()
throws
Exception
{
MockitoAnnotations
.
initMocks
(
this
);
audioRenderer
=
new
SimpleDecoderAudioRenderer
(
null
,
null
,
null
,
false
,
mockAudioSink
)
{
@Override
protected
int
supportsFormatInternal
(
DrmSessionManager
<
ExoMediaCrypto
>
drmSessionManager
,
Format
format
)
{
return
FORMAT_HANDLED
;
}
@Override
protected
SimpleDecoder
<
DecoderInputBuffer
,
?
extends
SimpleOutputBuffer
,
?
extends
AudioDecoderException
>
createDecoder
(
Format
format
,
ExoMediaCrypto
mediaCrypto
)
throws
AudioDecoderException
{
return
new
FakeDecoder
();
}
};
audioRenderer
=
new
SimpleDecoderAudioRenderer
(
null
,
null
,
null
,
false
,
mockAudioSink
)
{
@Override
protected
int
supportsFormatInternal
(
@Nullable
DrmSessionManager
<
ExoMediaCrypto
>
drmSessionManager
,
Format
format
)
{
return
FORMAT_HANDLED
;
}
@Override
protected
SimpleDecoder
<
DecoderInputBuffer
,
?
extends
SimpleOutputBuffer
,
?
extends
AudioDecoderException
>
createDecoder
(
Format
format
,
@Nullable
ExoMediaCrypto
mediaCrypto
)
throws
AudioDecoderException
{
return
new
FakeDecoder
();
}
};
}
@Config
(
sdk
=
19
)
...
...
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