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
e4e743a3
authored
Jul 01, 2020
by
tonihei
Committed by
Oliver Woodman
Jul 03, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix remaining common module nullness issues.
PiperOrigin-RevId: 319183621
parent
7d46be55
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
100 additions
and
62 deletions
extensions/opus/src/main/java/com/google/android/exoplayer2/ext/opus/OpusDecoder.java
extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxDecoder.java
library/common/src/main/java/com/google/android/exoplayer2/Format.java
library/common/src/main/java/com/google/android/exoplayer2/decoder/CryptoInfo.java
library/common/src/main/java/com/google/android/exoplayer2/util/CopyOnWriteMultiset.java
library/common/src/main/java/com/google/android/exoplayer2/util/NalUnitUtil.java
library/common/src/main/java/com/google/android/exoplayer2/util/Util.java
library/common/src/test/java/com/google/android/exoplayer2/util/NalUnitUtilTest.java
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/AsynchronousMediaCodecBufferEnqueuer.java
extensions/opus/src/main/java/com/google/android/exoplayer2/ext/opus/OpusDecoder.java
View file @
e4e743a3
...
@@ -23,6 +23,7 @@ import com.google.android.exoplayer2.decoder.SimpleDecoder;
...
@@ -23,6 +23,7 @@ import com.google.android.exoplayer2.decoder.SimpleDecoder;
import
com.google.android.exoplayer2.decoder.SimpleOutputBuffer
;
import
com.google.android.exoplayer2.decoder.SimpleOutputBuffer
;
import
com.google.android.exoplayer2.drm.DecryptionException
;
import
com.google.android.exoplayer2.drm.DecryptionException
;
import
com.google.android.exoplayer2.drm.ExoMediaCrypto
;
import
com.google.android.exoplayer2.drm.ExoMediaCrypto
;
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
;
import
java.nio.ByteOrder
;
import
java.nio.ByteOrder
;
...
@@ -166,13 +167,28 @@ import java.util.List;
...
@@ -166,13 +167,28 @@ import java.util.List;
}
}
ByteBuffer
inputData
=
Util
.
castNonNull
(
inputBuffer
.
data
);
ByteBuffer
inputData
=
Util
.
castNonNull
(
inputBuffer
.
data
);
CryptoInfo
cryptoInfo
=
inputBuffer
.
cryptoInfo
;
CryptoInfo
cryptoInfo
=
inputBuffer
.
cryptoInfo
;
int
result
=
inputBuffer
.
isEncrypted
()
int
result
=
?
opusSecureDecode
(
nativeDecoderContext
,
inputBuffer
.
timeUs
,
inputData
,
inputData
.
limit
(),
inputBuffer
.
isEncrypted
()
outputBuffer
,
SAMPLE_RATE
,
exoMediaCrypto
,
cryptoInfo
.
mode
,
?
opusSecureDecode
(
cryptoInfo
.
key
,
cryptoInfo
.
iv
,
cryptoInfo
.
numSubSamples
,
nativeDecoderContext
,
cryptoInfo
.
numBytesOfClearData
,
cryptoInfo
.
numBytesOfEncryptedData
)
inputBuffer
.
timeUs
,
:
opusDecode
(
nativeDecoderContext
,
inputBuffer
.
timeUs
,
inputData
,
inputData
.
limit
(),
inputData
,
outputBuffer
);
inputData
.
limit
(),
outputBuffer
,
SAMPLE_RATE
,
exoMediaCrypto
,
cryptoInfo
.
mode
,
Assertions
.
checkNotNull
(
cryptoInfo
.
key
),
Assertions
.
checkNotNull
(
cryptoInfo
.
iv
),
cryptoInfo
.
numSubSamples
,
cryptoInfo
.
numBytesOfClearData
,
cryptoInfo
.
numBytesOfEncryptedData
)
:
opusDecode
(
nativeDecoderContext
,
inputBuffer
.
timeUs
,
inputData
,
inputData
.
limit
(),
outputBuffer
);
if
(
result
<
0
)
{
if
(
result
<
0
)
{
if
(
result
==
DRM_ERROR
)
{
if
(
result
==
DRM_ERROR
)
{
String
message
=
"Drm error: "
+
opusGetErrorMessage
(
nativeDecoderContext
);
String
message
=
"Drm error: "
+
opusGetErrorMessage
(
nativeDecoderContext
);
...
@@ -253,8 +269,8 @@ import java.util.List;
...
@@ -253,8 +269,8 @@ import java.util.List;
byte
[]
key
,
byte
[]
key
,
byte
[]
iv
,
byte
[]
iv
,
int
numSubSamples
,
int
numSubSamples
,
int
[]
numBytesOfClearData
,
@Nullable
int
[]
numBytesOfClearData
,
int
[]
numBytesOfEncryptedData
);
@Nullable
int
[]
numBytesOfEncryptedData
);
private
native
void
opusClose
(
long
decoder
);
private
native
void
opusClose
(
long
decoder
);
private
native
void
opusReset
(
long
decoder
);
private
native
void
opusReset
(
long
decoder
);
...
...
extensions/vp9/src/main/java/com/google/android/exoplayer2/ext/vp9/VpxDecoder.java
View file @
e4e743a3
...
@@ -124,11 +124,20 @@ import java.nio.ByteBuffer;
...
@@ -124,11 +124,20 @@ import java.nio.ByteBuffer;
ByteBuffer
inputData
=
Util
.
castNonNull
(
inputBuffer
.
data
);
ByteBuffer
inputData
=
Util
.
castNonNull
(
inputBuffer
.
data
);
int
inputSize
=
inputData
.
limit
();
int
inputSize
=
inputData
.
limit
();
CryptoInfo
cryptoInfo
=
inputBuffer
.
cryptoInfo
;
CryptoInfo
cryptoInfo
=
inputBuffer
.
cryptoInfo
;
final
long
result
=
inputBuffer
.
isEncrypted
()
final
long
result
=
?
vpxSecureDecode
(
vpxDecContext
,
inputData
,
inputSize
,
exoMediaCrypto
,
inputBuffer
.
isEncrypted
()
cryptoInfo
.
mode
,
cryptoInfo
.
key
,
cryptoInfo
.
iv
,
cryptoInfo
.
numSubSamples
,
?
vpxSecureDecode
(
cryptoInfo
.
numBytesOfClearData
,
cryptoInfo
.
numBytesOfEncryptedData
)
vpxDecContext
,
:
vpxDecode
(
vpxDecContext
,
inputData
,
inputSize
);
inputData
,
inputSize
,
exoMediaCrypto
,
cryptoInfo
.
mode
,
Assertions
.
checkNotNull
(
cryptoInfo
.
key
),
Assertions
.
checkNotNull
(
cryptoInfo
.
iv
),
cryptoInfo
.
numSubSamples
,
cryptoInfo
.
numBytesOfClearData
,
cryptoInfo
.
numBytesOfEncryptedData
)
:
vpxDecode
(
vpxDecContext
,
inputData
,
inputSize
);
if
(
result
!=
NO_ERROR
)
{
if
(
result
!=
NO_ERROR
)
{
if
(
result
==
DRM_ERROR
)
{
if
(
result
==
DRM_ERROR
)
{
String
message
=
"Drm error: "
+
vpxGetErrorMessage
(
vpxDecContext
);
String
message
=
"Drm error: "
+
vpxGetErrorMessage
(
vpxDecContext
);
...
@@ -207,8 +216,8 @@ import java.nio.ByteBuffer;
...
@@ -207,8 +216,8 @@ import java.nio.ByteBuffer;
byte
[]
key
,
byte
[]
key
,
byte
[]
iv
,
byte
[]
iv
,
int
numSubSamples
,
int
numSubSamples
,
int
[]
numBytesOfClearData
,
@Nullable
int
[]
numBytesOfClearData
,
int
[]
numBytesOfEncryptedData
);
@Nullable
int
[]
numBytesOfEncryptedData
);
private
native
int
vpxGetFrame
(
long
context
,
VideoDecoderOutputBuffer
outputBuffer
);
private
native
int
vpxGetFrame
(
long
context
,
VideoDecoderOutputBuffer
outputBuffer
);
...
...
library/common/src/main/java/com/google/android/exoplayer2/Format.java
View file @
e4e743a3
...
@@ -21,6 +21,7 @@ import androidx.annotation.Nullable;
...
@@ -21,6 +21,7 @@ import androidx.annotation.Nullable;
import
com.google.android.exoplayer2.drm.DrmInitData
;
import
com.google.android.exoplayer2.drm.DrmInitData
;
import
com.google.android.exoplayer2.drm.ExoMediaCrypto
;
import
com.google.android.exoplayer2.drm.ExoMediaCrypto
;
import
com.google.android.exoplayer2.metadata.Metadata
;
import
com.google.android.exoplayer2.metadata.Metadata
;
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.Util
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.video.ColorInfo
;
import
com.google.android.exoplayer2.video.ColorInfo
;
...
@@ -1309,7 +1310,7 @@ public final class Format implements Parcelable {
...
@@ -1309,7 +1310,7 @@ public final class Format implements Parcelable {
int
initializationDataSize
=
in
.
readInt
();
int
initializationDataSize
=
in
.
readInt
();
initializationData
=
new
ArrayList
<>(
initializationDataSize
);
initializationData
=
new
ArrayList
<>(
initializationDataSize
);
for
(
int
i
=
0
;
i
<
initializationDataSize
;
i
++)
{
for
(
int
i
=
0
;
i
<
initializationDataSize
;
i
++)
{
initializationData
.
add
(
in
.
createByteArray
(
));
initializationData
.
add
(
Assertions
.
checkNotNull
(
in
.
createByteArray
()
));
}
}
drmInitData
=
in
.
readParcelable
(
DrmInitData
.
class
.
getClassLoader
());
drmInitData
=
in
.
readParcelable
(
DrmInitData
.
class
.
getClassLoader
());
subsampleOffsetUs
=
in
.
readLong
();
subsampleOffsetUs
=
in
.
readLong
();
...
...
library/common/src/main/java/com/google/android/exoplayer2/decoder/CryptoInfo.java
View file @
e4e743a3
...
@@ -15,8 +15,10 @@
...
@@ -15,8 +15,10 @@
*/
*/
package
com
.
google
.
android
.
exoplayer2
.
decoder
;
package
com
.
google
.
android
.
exoplayer2
.
decoder
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.RequiresApi
;
import
androidx.annotation.RequiresApi
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.util.Util
;
/**
/**
...
@@ -30,13 +32,13 @@ public final class CryptoInfo {
...
@@ -30,13 +32,13 @@ public final class CryptoInfo {
*
*
* @see android.media.MediaCodec.CryptoInfo#iv
* @see android.media.MediaCodec.CryptoInfo#iv
*/
*/
public
byte
[]
iv
;
@Nullable
public
byte
[]
iv
;
/**
/**
* The 16 byte key id.
* The 16 byte key id.
*
*
* @see android.media.MediaCodec.CryptoInfo#key
* @see android.media.MediaCodec.CryptoInfo#key
*/
*/
public
byte
[]
key
;
@Nullable
public
byte
[]
key
;
/**
/**
* The type of encryption that has been applied. Must be one of the {@link C.CryptoMode} values.
* The type of encryption that has been applied. Must be one of the {@link C.CryptoMode} values.
*
*
...
@@ -49,14 +51,14 @@ public final class CryptoInfo {
...
@@ -49,14 +51,14 @@ public final class CryptoInfo {
*
*
* @see android.media.MediaCodec.CryptoInfo#numBytesOfClearData
* @see android.media.MediaCodec.CryptoInfo#numBytesOfClearData
*/
*/
public
int
[]
numBytesOfClearData
;
@Nullable
public
int
[]
numBytesOfClearData
;
/**
/**
* The number of trailing encrypted bytes in each sub-sample. If null, all bytes are treated as
* The number of trailing encrypted bytes in each sub-sample. If null, all bytes are treated as
* clear and {@link #numBytesOfClearData} must be specified.
* clear and {@link #numBytesOfClearData} must be specified.
*
*
* @see android.media.MediaCodec.CryptoInfo#numBytesOfEncryptedData
* @see android.media.MediaCodec.CryptoInfo#numBytesOfEncryptedData
*/
*/
public
int
[]
numBytesOfEncryptedData
;
@Nullable
public
int
[]
numBytesOfEncryptedData
;
/**
/**
* The number of subSamples that make up the buffer's contents.
* The number of subSamples that make up the buffer's contents.
*
*
...
@@ -73,7 +75,7 @@ public final class CryptoInfo {
...
@@ -73,7 +75,7 @@ public final class CryptoInfo {
public
int
clearBlocks
;
public
int
clearBlocks
;
private
final
android
.
media
.
MediaCodec
.
CryptoInfo
frameworkCryptoInfo
;
private
final
android
.
media
.
MediaCodec
.
CryptoInfo
frameworkCryptoInfo
;
private
final
PatternHolderV24
patternHolder
;
@Nullable
private
final
PatternHolderV24
patternHolder
;
public
CryptoInfo
()
{
public
CryptoInfo
()
{
frameworkCryptoInfo
=
new
android
.
media
.
MediaCodec
.
CryptoInfo
();
frameworkCryptoInfo
=
new
android
.
media
.
MediaCodec
.
CryptoInfo
();
...
@@ -102,7 +104,7 @@ public final class CryptoInfo {
...
@@ -102,7 +104,7 @@ public final class CryptoInfo {
frameworkCryptoInfo
.
iv
=
iv
;
frameworkCryptoInfo
.
iv
=
iv
;
frameworkCryptoInfo
.
mode
=
mode
;
frameworkCryptoInfo
.
mode
=
mode
;
if
(
Util
.
SDK_INT
>=
24
)
{
if
(
Util
.
SDK_INT
>=
24
)
{
patternHolder
.
set
(
encryptedBlocks
,
clearBlocks
);
Assertions
.
checkNotNull
(
patternHolder
)
.
set
(
encryptedBlocks
,
clearBlocks
);
}
}
}
}
...
...
library/common/src/main/java/com/google/android/exoplayer2/util/CopyOnWriteMultiset.java
View file @
e4e743a3
...
@@ -41,7 +41,9 @@ import java.util.Set;
...
@@ -41,7 +41,9 @@ import java.util.Set;
*
*
* @param <E> The type of element being stored.
* @param <E> The type of element being stored.
*/
*/
public
final
class
CopyOnWriteMultiset
<
E
>
implements
Iterable
<
E
>
{
// Intentionally extending @NonNull-by-default Object to disallow @Nullable E types.
@SuppressWarnings
(
"TypeParameterExplicitlyExtendsObject"
)
public
final
class
CopyOnWriteMultiset
<
E
extends
Object
>
implements
Iterable
<
E
>
{
private
final
Object
lock
;
private
final
Object
lock
;
...
...
library/common/src/main/java/com/google/android/exoplayer2/util/NalUnitUtil.java
View file @
e4e743a3
...
@@ -431,18 +431,18 @@ public final class NalUnitUtil {
...
@@ -431,18 +431,18 @@ public final class NalUnitUtil {
return
endOffset
;
return
endOffset
;
}
}
if
(
prefixFlags
!=
null
)
{
if
(
prefixFlags
[
0
]
)
{
if
(
prefixFlags
[
0
])
{
clearPrefixFlags
(
prefixFlags
);
clearPrefixFlags
(
prefixFlags
)
;
return
startOffset
-
3
;
return
startOffset
-
3
;
}
else
if
(
length
>
1
&&
prefixFlags
[
1
]
&&
data
[
startOffset
]
==
1
)
{
}
else
if
(
length
>
1
&&
prefixFlags
[
1
]
&&
data
[
startOffset
]
==
1
)
{
clearPrefixFlags
(
prefixFlags
);
clearPrefixFlags
(
prefixFlags
)
;
return
startOffset
-
2
;
return
startOffset
-
2
;
}
else
if
(
length
>
2
}
else
if
(
length
>
2
&&
prefixFlags
[
2
]
&&
data
[
startOffset
]
==
0
&&
prefixFlags
[
2
]
&&
data
[
startOffset
+
1
]
==
1
)
{
&&
data
[
startOffset
]
==
0
clearPrefixFlags
(
prefixFlags
);
&&
data
[
startOffset
+
1
]
==
1
)
{
return
startOffset
-
1
;
clearPrefixFlags
(
prefixFlags
)
;
}
return
startOffset
-
1
;
}
}
int
limit
=
endOffset
-
1
;
int
limit
=
endOffset
-
1
;
...
@@ -453,9 +453,7 @@ public final class NalUnitUtil {
...
@@ -453,9 +453,7 @@ public final class NalUnitUtil {
// There isn't a NAL prefix here, or at the next two positions. Do nothing and let the
// There isn't a NAL prefix here, or at the next two positions. Do nothing and let the
// loop advance the index by three.
// loop advance the index by three.
}
else
if
(
data
[
i
-
2
]
==
0
&&
data
[
i
-
1
]
==
0
&&
data
[
i
]
==
1
)
{
}
else
if
(
data
[
i
-
2
]
==
0
&&
data
[
i
-
1
]
==
0
&&
data
[
i
]
==
1
)
{
if
(
prefixFlags
!=
null
)
{
clearPrefixFlags
(
prefixFlags
);
clearPrefixFlags
(
prefixFlags
);
}
return
i
-
2
;
return
i
-
2
;
}
else
{
}
else
{
// There isn't a NAL prefix here, but there might be at the next position. We should
// There isn't a NAL prefix here, but there might be at the next position. We should
...
@@ -464,18 +462,20 @@ public final class NalUnitUtil {
...
@@ -464,18 +462,20 @@ public final class NalUnitUtil {
}
}
}
}
if
(
prefixFlags
!=
null
)
{
// True if the last three bytes in the data seen so far are {0,0,1}.
// True if the last three bytes in the data seen so far are {0,0,1}.
prefixFlags
[
0
]
=
prefixFlags
[
0
]
=
length
>
2
length
>
2
?
(
data
[
endOffset
-
3
]
==
0
&&
data
[
endOffset
-
2
]
==
0
&&
data
[
endOffset
-
1
]
==
1
)
?
(
data
[
endOffset
-
3
]
==
0
&&
data
[
endOffset
-
2
]
==
0
&&
data
[
endOffset
-
1
]
==
1
)
:
length
==
2
?
(
prefixFlags
[
2
]
&&
data
[
endOffset
-
2
]
==
0
&&
data
[
endOffset
-
1
]
==
1
)
:
length
==
2
:
(
prefixFlags
[
1
]
&&
data
[
endOffset
-
1
]
==
1
);
?
(
prefixFlags
[
2
]
&&
data
[
endOffset
-
2
]
==
0
&&
data
[
endOffset
-
1
]
==
1
)
// True if the last two bytes in the data seen so far are {0,0}.
:
(
prefixFlags
[
1
]
&&
data
[
endOffset
-
1
]
==
1
);
prefixFlags
[
1
]
=
length
>
1
?
data
[
endOffset
-
2
]
==
0
&&
data
[
endOffset
-
1
]
==
0
// True if the last two bytes in the data seen so far are {0,0}.
:
prefixFlags
[
2
]
&&
data
[
endOffset
-
1
]
==
0
;
prefixFlags
[
1
]
=
// True if the last byte in the data seen so far is {0}.
length
>
1
prefixFlags
[
2
]
=
data
[
endOffset
-
1
]
==
0
;
?
data
[
endOffset
-
2
]
==
0
&&
data
[
endOffset
-
1
]
==
0
}
:
prefixFlags
[
2
]
&&
data
[
endOffset
-
1
]
==
0
;
// True if the last byte in the data seen so far is {0}.
prefixFlags
[
2
]
=
data
[
endOffset
-
1
]
==
0
;
return
endOffset
;
return
endOffset
;
}
}
...
...
library/common/src/main/java/com/google/android/exoplayer2/util/Util.java
View file @
e4e743a3
...
@@ -1937,6 +1937,8 @@ public final class Util {
...
@@ -1937,6 +1937,8 @@ public final class Util {
* @param context A context to access the connectivity manager.
* @param context A context to access the connectivity manager.
* @return The {@link C.NetworkType} of the current network connection.
* @return The {@link C.NetworkType} of the current network connection.
*/
*/
// Intentional null check to guard against user input.
@SuppressWarnings
(
"known.nonnull"
)
@C
.
NetworkType
@C
.
NetworkType
public
static
int
getNetworkType
(
Context
context
)
{
public
static
int
getNetworkType
(
Context
context
)
{
if
(
context
==
null
)
{
if
(
context
==
null
)
{
...
@@ -1944,6 +1946,7 @@ public final class Util {
...
@@ -1944,6 +1946,7 @@ public final class Util {
return
C
.
NETWORK_TYPE_UNKNOWN
;
return
C
.
NETWORK_TYPE_UNKNOWN
;
}
}
NetworkInfo
networkInfo
;
NetworkInfo
networkInfo
;
@Nullable
ConnectivityManager
connectivityManager
=
ConnectivityManager
connectivityManager
=
(
ConnectivityManager
)
context
.
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
);
(
ConnectivityManager
)
context
.
getSystemService
(
Context
.
CONNECTIVITY_SERVICE
);
if
(
connectivityManager
==
null
)
{
if
(
connectivityManager
==
null
)
{
...
@@ -1983,6 +1986,7 @@ public final class Util {
...
@@ -1983,6 +1986,7 @@ public final class Util {
*/
*/
public
static
String
getCountryCode
(
@Nullable
Context
context
)
{
public
static
String
getCountryCode
(
@Nullable
Context
context
)
{
if
(
context
!=
null
)
{
if
(
context
!=
null
)
{
@Nullable
TelephonyManager
telephonyManager
=
TelephonyManager
telephonyManager
=
(
TelephonyManager
)
context
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
);
(
TelephonyManager
)
context
.
getSystemService
(
Context
.
TELEPHONY_SERVICE
);
if
(
telephonyManager
!=
null
)
{
if
(
telephonyManager
!=
null
)
{
...
@@ -2062,6 +2066,7 @@ public final class Util {
...
@@ -2062,6 +2066,7 @@ public final class Util {
*/
*/
public
static
boolean
isTv
(
Context
context
)
{
public
static
boolean
isTv
(
Context
context
)
{
// See https://developer.android.com/training/tv/start/hardware.html#runtime-check.
// See https://developer.android.com/training/tv/start/hardware.html#runtime-check.
@Nullable
UiModeManager
uiModeManager
=
UiModeManager
uiModeManager
=
(
UiModeManager
)
context
.
getApplicationContext
().
getSystemService
(
UI_MODE_SERVICE
);
(
UiModeManager
)
context
.
getApplicationContext
().
getSystemService
(
UI_MODE_SERVICE
);
return
uiModeManager
!=
null
return
uiModeManager
!=
null
...
...
library/common/src/test/java/com/google/android/exoplayer2/util/NalUnitUtilTest.java
View file @
e4e743a3
...
@@ -40,19 +40,19 @@ public final class NalUnitUtilTest {
...
@@ -40,19 +40,19 @@ public final class NalUnitUtilTest {
byte
[]
data
=
buildTestData
();
byte
[]
data
=
buildTestData
();
// Should find NAL unit.
// Should find NAL unit.
int
result
=
NalUnitUtil
.
findNalUnit
(
data
,
0
,
data
.
length
,
n
ull
);
int
result
=
NalUnitUtil
.
findNalUnit
(
data
,
0
,
data
.
length
,
n
ew
boolean
[
3
]
);
assertThat
(
result
).
isEqualTo
(
TEST_NAL_POSITION
);
assertThat
(
result
).
isEqualTo
(
TEST_NAL_POSITION
);
// Should find NAL unit whose prefix ends one byte before the limit.
// Should find NAL unit whose prefix ends one byte before the limit.
result
=
NalUnitUtil
.
findNalUnit
(
data
,
0
,
TEST_NAL_POSITION
+
4
,
n
ull
);
result
=
NalUnitUtil
.
findNalUnit
(
data
,
0
,
TEST_NAL_POSITION
+
4
,
n
ew
boolean
[
3
]
);
assertThat
(
result
).
isEqualTo
(
TEST_NAL_POSITION
);
assertThat
(
result
).
isEqualTo
(
TEST_NAL_POSITION
);
// Shouldn't find NAL unit whose prefix ends at the limit (since the limit is exclusive).
// Shouldn't find NAL unit whose prefix ends at the limit (since the limit is exclusive).
result
=
NalUnitUtil
.
findNalUnit
(
data
,
0
,
TEST_NAL_POSITION
+
3
,
n
ull
);
result
=
NalUnitUtil
.
findNalUnit
(
data
,
0
,
TEST_NAL_POSITION
+
3
,
n
ew
boolean
[
3
]
);
assertThat
(
result
).
isEqualTo
(
TEST_NAL_POSITION
+
3
);
assertThat
(
result
).
isEqualTo
(
TEST_NAL_POSITION
+
3
);
// Should find NAL unit whose prefix starts at the offset.
// Should find NAL unit whose prefix starts at the offset.
result
=
NalUnitUtil
.
findNalUnit
(
data
,
TEST_NAL_POSITION
,
data
.
length
,
n
ull
);
result
=
NalUnitUtil
.
findNalUnit
(
data
,
TEST_NAL_POSITION
,
data
.
length
,
n
ew
boolean
[
3
]
);
assertThat
(
result
).
isEqualTo
(
TEST_NAL_POSITION
);
assertThat
(
result
).
isEqualTo
(
TEST_NAL_POSITION
);
// Shouldn't find NAL unit whose prefix starts one byte past the offset.
// Shouldn't find NAL unit whose prefix starts one byte past the offset.
result
=
NalUnitUtil
.
findNalUnit
(
data
,
TEST_NAL_POSITION
+
1
,
data
.
length
,
n
ull
);
result
=
NalUnitUtil
.
findNalUnit
(
data
,
TEST_NAL_POSITION
+
1
,
data
.
length
,
n
ew
boolean
[
3
]
);
assertThat
(
result
).
isEqualTo
(
data
.
length
);
assertThat
(
result
).
isEqualTo
(
data
.
length
);
}
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/mediacodec/AsynchronousMediaCodecBufferEnqueuer.java
View file @
e4e743a3
...
@@ -16,11 +16,14 @@
...
@@ -16,11 +16,14 @@
package
com
.
google
.
android
.
exoplayer2
.
mediacodec
;
package
com
.
google
.
android
.
exoplayer2
.
mediacodec
;
import
static
com
.
google
.
android
.
exoplayer2
.
util
.
Assertions
.
checkNotNull
;
import
android.media.MediaCodec
;
import
android.media.MediaCodec
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.os.HandlerThread
;
import
android.os.HandlerThread
;
import
android.os.Message
;
import
android.os.Message
;
import
androidx.annotation.GuardedBy
;
import
androidx.annotation.GuardedBy
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.RequiresApi
;
import
androidx.annotation.RequiresApi
;
import
androidx.annotation.VisibleForTesting
;
import
androidx.annotation.VisibleForTesting
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
...
@@ -292,8 +295,6 @@ class AsynchronousMediaCodecBufferEnqueuer implements MediaCodecInputBufferEnque
...
@@ -292,8 +295,6 @@ class AsynchronousMediaCodecBufferEnqueuer implements MediaCodecInputBufferEnque
}
}
/** Performs a deep copy of {@code cryptoInfo} to {@code frameworkCryptoInfo}. */
/** Performs a deep copy of {@code cryptoInfo} to {@code frameworkCryptoInfo}. */
// TODO: Remove suppression [internal b/78934030].
@SuppressWarnings
(
"nullness:argument.type.incompatible"
)
private
static
void
copy
(
private
static
void
copy
(
CryptoInfo
cryptoInfo
,
android
.
media
.
MediaCodec
.
CryptoInfo
frameworkCryptoInfo
)
{
CryptoInfo
cryptoInfo
,
android
.
media
.
MediaCodec
.
CryptoInfo
frameworkCryptoInfo
)
{
// Update frameworkCryptoInfo fields directly because CryptoInfo.set performs an unnecessary
// Update frameworkCryptoInfo fields directly because CryptoInfo.set performs an unnecessary
...
@@ -303,8 +304,8 @@ class AsynchronousMediaCodecBufferEnqueuer implements MediaCodecInputBufferEnque
...
@@ -303,8 +304,8 @@ class AsynchronousMediaCodecBufferEnqueuer implements MediaCodecInputBufferEnque
copy
(
cryptoInfo
.
numBytesOfClearData
,
frameworkCryptoInfo
.
numBytesOfClearData
);
copy
(
cryptoInfo
.
numBytesOfClearData
,
frameworkCryptoInfo
.
numBytesOfClearData
);
frameworkCryptoInfo
.
numBytesOfEncryptedData
=
frameworkCryptoInfo
.
numBytesOfEncryptedData
=
copy
(
cryptoInfo
.
numBytesOfEncryptedData
,
frameworkCryptoInfo
.
numBytesOfEncryptedData
);
copy
(
cryptoInfo
.
numBytesOfEncryptedData
,
frameworkCryptoInfo
.
numBytesOfEncryptedData
);
frameworkCryptoInfo
.
key
=
c
opy
(
cryptoInfo
.
key
,
frameworkCryptoInfo
.
key
);
frameworkCryptoInfo
.
key
=
c
heckNotNull
(
copy
(
cryptoInfo
.
key
,
frameworkCryptoInfo
.
key
)
);
frameworkCryptoInfo
.
iv
=
c
opy
(
cryptoInfo
.
iv
,
frameworkCryptoInfo
.
iv
);
frameworkCryptoInfo
.
iv
=
c
heckNotNull
(
copy
(
cryptoInfo
.
iv
,
frameworkCryptoInfo
.
iv
)
);
frameworkCryptoInfo
.
mode
=
cryptoInfo
.
mode
;
frameworkCryptoInfo
.
mode
=
cryptoInfo
.
mode
;
if
(
Util
.
SDK_INT
>=
24
)
{
if
(
Util
.
SDK_INT
>=
24
)
{
android
.
media
.
MediaCodec
.
CryptoInfo
.
Pattern
pattern
=
android
.
media
.
MediaCodec
.
CryptoInfo
.
Pattern
pattern
=
...
@@ -321,7 +322,8 @@ class AsynchronousMediaCodecBufferEnqueuer implements MediaCodecInputBufferEnque
...
@@ -321,7 +322,8 @@ class AsynchronousMediaCodecBufferEnqueuer implements MediaCodecInputBufferEnque
* @param dst The destination array, which will be reused if it's at least as long as {@code src}.
* @param dst The destination array, which will be reused if it's at least as long as {@code src}.
* @return The copy, which may be {@code dst} if it was reused.
* @return The copy, which may be {@code dst} if it was reused.
*/
*/
private
static
int
[]
copy
(
int
[]
src
,
int
[]
dst
)
{
@Nullable
private
static
int
[]
copy
(
@Nullable
int
[]
src
,
@Nullable
int
[]
dst
)
{
if
(
src
==
null
)
{
if
(
src
==
null
)
{
return
dst
;
return
dst
;
}
}
...
@@ -341,7 +343,8 @@ class AsynchronousMediaCodecBufferEnqueuer implements MediaCodecInputBufferEnque
...
@@ -341,7 +343,8 @@ class AsynchronousMediaCodecBufferEnqueuer implements MediaCodecInputBufferEnque
* @param dst The destination array, which will be reused if it's at least as long as {@code src}.
* @param dst The destination array, which will be reused if it's at least as long as {@code src}.
* @return The copy, which may be {@code dst} if it was reused.
* @return The copy, which may be {@code dst} if it was reused.
*/
*/
private
static
byte
[]
copy
(
byte
[]
src
,
byte
[]
dst
)
{
@Nullable
private
static
byte
[]
copy
(
@Nullable
byte
[]
src
,
@Nullable
byte
[]
dst
)
{
if
(
src
==
null
)
{
if
(
src
==
null
)
{
return
dst
;
return
dst
;
}
}
...
...
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