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
498a23e3
authored
Oct 14, 2019
by
ibaker
Committed by
Oliver Woodman
Oct 14, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add null-checker annotations to HlsSampleStreamWrapper
PiperOrigin-RevId: 274545728
parent
6ebcac38
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
18 deletions
library/core/src/main/java/com/google/android/exoplayer2/Format.java
library/core/src/main/java/com/google/android/exoplayer2/util/Util.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java
library/core/src/main/java/com/google/android/exoplayer2/Format.java
View file @
498a23e3
...
@@ -1472,7 +1472,8 @@ public final class Format implements Parcelable {
...
@@ -1472,7 +1472,8 @@ public final class Format implements Parcelable {
exoMediaCryptoType
);
exoMediaCryptoType
);
}
}
public
Format
copyWithExoMediaCryptoType
(
Class
<?
extends
ExoMediaCrypto
>
exoMediaCryptoType
)
{
public
Format
copyWithExoMediaCryptoType
(
@Nullable
Class
<?
extends
ExoMediaCrypto
>
exoMediaCryptoType
)
{
return
new
Format
(
return
new
Format
(
id
,
id
,
label
,
label
,
...
...
library/core/src/main/java/com/google/android/exoplayer2/util/Util.java
View file @
498a23e3
...
@@ -1239,9 +1239,9 @@ public final class Util {
...
@@ -1239,9 +1239,9 @@ public final class Util {
* @param codecs A codec sequence string, as defined in RFC 6381.
* @param codecs A codec sequence string, as defined in RFC 6381.
* @param trackType One of {@link C}{@code .TRACK_TYPE_*}.
* @param trackType One of {@link C}{@code .TRACK_TYPE_*}.
* @return A copy of {@code codecs} without the codecs whose track type doesn't match {@code
* @return A copy of {@code codecs} without the codecs whose track type doesn't match {@code
* trackType}.
* trackType}.
If this ends up empty, or {@code codecs} is null, return null.
*/
*/
public
static
@Nullable
String
getCodecsOfType
(
String
codecs
,
int
trackType
)
{
public
static
@Nullable
String
getCodecsOfType
(
@Nullable
String
codecs
,
int
trackType
)
{
String
[]
codecArray
=
splitCodecs
(
codecs
);
String
[]
codecArray
=
splitCodecs
(
codecs
);
if
(
codecArray
.
length
==
0
)
{
if
(
codecArray
.
length
==
0
)
{
return
null
;
return
null
;
...
@@ -1262,9 +1262,9 @@ public final class Util {
...
@@ -1262,9 +1262,9 @@ public final class Util {
* Splits a codecs sequence string, as defined in RFC 6381, into individual codec strings.
* Splits a codecs sequence string, as defined in RFC 6381, into individual codec strings.
*
*
* @param codecs A codec sequence string, as defined in RFC 6381.
* @param codecs A codec sequence string, as defined in RFC 6381.
* @return The split codecs, or an array of length zero if the input was empty.
* @return The split codecs, or an array of length zero if the input was empty
or null
.
*/
*/
public
static
String
[]
splitCodecs
(
String
codecs
)
{
public
static
String
[]
splitCodecs
(
@Nullable
String
codecs
)
{
if
(
TextUtils
.
isEmpty
(
codecs
))
{
if
(
TextUtils
.
isEmpty
(
codecs
))
{
return
new
String
[
0
];
return
new
String
[
0
];
}
}
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java
View file @
498a23e3
...
@@ -65,7 +65,9 @@ import java.util.HashSet;
...
@@ -65,7 +65,9 @@ import java.util.HashSet;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.Set
;
import
org.checkerframework.checker.nullness.compatqual.NullableType
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
import
org.checkerframework.checker.nullness.qual.RequiresNonNull
;
/**
/**
* Loads {@link HlsMediaChunk}s obtained from a {@link HlsChunkSource}, and provides
* Loads {@link HlsMediaChunk}s obtained from a {@link HlsChunkSource}, and provides
...
@@ -127,20 +129,20 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -127,20 +129,20 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private
int
[]
sampleQueueTrackIds
;
private
int
[]
sampleQueueTrackIds
;
private
Set
<
Integer
>
sampleQueueMappingDoneByType
;
private
Set
<
Integer
>
sampleQueueMappingDoneByType
;
private
SparseIntArray
sampleQueueIndicesByType
;
private
SparseIntArray
sampleQueueIndicesByType
;
private
TrackOutput
emsgUnwrappingTrackOutput
;
@MonotonicNonNull
private
TrackOutput
emsgUnwrappingTrackOutput
;
private
int
primarySampleQueueType
;
private
int
primarySampleQueueType
;
private
int
primarySampleQueueIndex
;
private
int
primarySampleQueueIndex
;
private
boolean
sampleQueuesBuilt
;
private
boolean
sampleQueuesBuilt
;
private
boolean
prepared
;
private
boolean
prepared
;
private
int
enabledTrackGroupCount
;
private
int
enabledTrackGroupCount
;
private
Format
upstreamTrackFormat
;
@MonotonicNonNull
private
Format
upstreamTrackFormat
;
private
Format
downstreamTrackFormat
;
@Nullable
private
Format
downstreamTrackFormat
;
private
boolean
released
;
private
boolean
released
;
// Tracks are complicated in HLS. See documentation of buildTracksFromSampleStreams for details.
// Tracks are complicated in HLS. See documentation of buildTracksFromSampleStreams for details.
// Indexed by track (as exposed by this source).
// Indexed by track (as exposed by this source).
private
TrackGroupArray
trackGroups
;
@MonotonicNonNull
private
TrackGroupArray
trackGroups
;
private
Set
<
TrackGroup
>
optionalTrackGroups
;
@MonotonicNonNull
private
Set
<
TrackGroup
>
optionalTrackGroups
;
// Indexed by track group.
// Indexed by track group.
private
int
[]
trackGroupToSampleQueueIndex
;
private
int
[]
trackGroupToSampleQueueIndex
;
private
int
primaryTrackGroupIndex
;
private
int
primaryTrackGroupIndex
;
...
@@ -294,15 +296,21 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -294,15 +296,21 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
* @return Whether this wrapper requires the parent {@link HlsMediaPeriod} to perform a seek as
* @return Whether this wrapper requires the parent {@link HlsMediaPeriod} to perform a seek as
* part of the track selection.
* part of the track selection.
*/
*/
public
boolean
selectTracks
(
TrackSelection
[]
selections
,
boolean
[]
mayRetainStreamFlags
,
public
boolean
selectTracks
(
SampleStream
[]
streams
,
boolean
[]
streamResetFlags
,
long
positionUs
,
boolean
forceReset
)
{
TrackSelection
[]
selections
,
boolean
[]
mayRetainStreamFlags
,
@NullableType
SampleStream
[]
streams
,
boolean
[]
streamResetFlags
,
long
positionUs
,
boolean
forceReset
)
{
Assertions
.
checkState
(
prepared
);
Assertions
.
checkState
(
prepared
);
int
oldEnabledTrackGroupCount
=
enabledTrackGroupCount
;
int
oldEnabledTrackGroupCount
=
enabledTrackGroupCount
;
// Deselect old tracks.
// Deselect old tracks.
for
(
int
i
=
0
;
i
<
selections
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
selections
.
length
;
i
++)
{
if
(
streams
[
i
]
!=
null
&&
(
selections
[
i
]
==
null
||
!
mayRetainStreamFlags
[
i
]))
{
HlsSampleStream
stream
=
(
HlsSampleStream
)
streams
[
i
];
if
(
stream
!=
null
&&
(
selections
[
i
]
==
null
||
!
mayRetainStreamFlags
[
i
]))
{
enabledTrackGroupCount
--;
enabledTrackGroupCount
--;
((
HlsSampleStream
)
streams
[
i
])
.
unbindSampleQueue
();
stream
.
unbindSampleQueue
();
streams
[
i
]
=
null
;
streams
[
i
]
=
null
;
}
}
}
}
...
@@ -536,7 +544,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -536,7 +544,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
sampleQueueReaders
[
sampleQueueIndex
].
read
(
sampleQueueReaders
[
sampleQueueIndex
].
read
(
formatHolder
,
buffer
,
requireFormat
,
loadingFinished
,
lastSeekPositionUs
);
formatHolder
,
buffer
,
requireFormat
,
loadingFinished
,
lastSeekPositionUs
);
if
(
result
==
C
.
RESULT_FORMAT_READ
)
{
if
(
result
==
C
.
RESULT_FORMAT_READ
)
{
Format
format
=
formatHolder
.
format
;
Format
format
=
Assertions
.
checkNotNull
(
formatHolder
.
format
)
;
if
(
sampleQueueIndex
==
primarySampleQueueIndex
)
{
if
(
sampleQueueIndex
==
primarySampleQueueIndex
)
{
// Fill in primary sample format with information from the track format.
// Fill in primary sample format with information from the track format.
int
chunkUid
=
sampleQueues
[
sampleQueueIndex
].
peekSourceId
();
int
chunkUid
=
sampleQueues
[
sampleQueueIndex
].
peekSourceId
();
...
@@ -945,7 +953,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -945,7 +953,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
// Internal methods.
// Internal methods.
private
void
updateSampleStreams
(
SampleStream
[]
streams
)
{
private
void
updateSampleStreams
(
@NullableType
SampleStream
[]
streams
)
{
hlsSampleStreams
.
clear
();
hlsSampleStreams
.
clear
();
for
(
SampleStream
stream
:
streams
)
{
for
(
SampleStream
stream
:
streams
)
{
if
(
stream
!=
null
)
{
if
(
stream
!=
null
)
{
...
@@ -998,6 +1006,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -998,6 +1006,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
}
}
}
}
@RequiresNonNull
(
"trackGroups"
)
private
void
mapSampleQueuesToMatchTrackGroups
()
{
private
void
mapSampleQueuesToMatchTrackGroups
()
{
int
trackGroupCount
=
trackGroups
.
length
;
int
trackGroupCount
=
trackGroups
.
length
;
trackGroupToSampleQueueIndex
=
new
int
[
trackGroupCount
];
trackGroupToSampleQueueIndex
=
new
int
[
trackGroupCount
];
...
@@ -1195,7 +1204,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -1195,7 +1204,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
* @return The derived track format.
* @return The derived track format.
*/
*/
private
static
Format
deriveFormat
(
private
static
Format
deriveFormat
(
Format
playlistFormat
,
Format
sampleFormat
,
boolean
propagateBitrate
)
{
@Nullable
Format
playlistFormat
,
Format
sampleFormat
,
boolean
propagateBitrate
)
{
if
(
playlistFormat
==
null
)
{
if
(
playlistFormat
==
null
)
{
return
sampleFormat
;
return
sampleFormat
;
}
}
...
@@ -1383,7 +1392,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
...
@@ -1383,7 +1392,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
int
size
,
int
size
,
int
offset
,
int
offset
,
@Nullable
CryptoData
cryptoData
)
{
@Nullable
CryptoData
cryptoData
)
{
Assertions
.
check
State
(
format
!=
null
);
Assertions
.
check
NotNull
(
format
);
ParsableByteArray
sample
=
getSampleAndTrimBuffer
(
size
,
offset
);
ParsableByteArray
sample
=
getSampleAndTrimBuffer
(
size
,
offset
);
ParsableByteArray
sampleForDelegate
;
ParsableByteArray
sampleForDelegate
;
if
(
Util
.
areEqual
(
format
.
sampleMimeType
,
delegateFormat
.
sampleMimeType
))
{
if
(
Util
.
areEqual
(
format
.
sampleMimeType
,
delegateFormat
.
sampleMimeType
))
{
...
...
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