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
58d4fd93
authored
Aug 07, 2019
by
tonihei
Committed by
Oliver Woodman
Aug 09, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix HLS module API nullability issues and add package-level non-null-by-default
PiperOrigin-RevId: 262124441
parent
074b6f8e
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
90 additions
and
25 deletions
library/hls/build.gradle
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/Aes128DataSource.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/DefaultHlsExtractorFactory.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsChunkSource.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsExtractorFactory.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/WebvttExtractor.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/offline/package-info.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/package-info.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/DefaultHlsPlaylistTracker.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsMasterPlaylist.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsMediaPlaylist.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/package-info.java
library/hls/build.gradle
View file @
58d4fd93
...
...
@@ -41,6 +41,7 @@ android {
dependencies
{
implementation
'androidx.annotation:annotation:1.1.0'
compileOnly
'org.checkerframework:checker-qual:'
+
checkerframeworkVersion
compileOnly
'org.checkerframework:checker-compat-qual:'
+
checkerframeworkVersion
implementation
project
(
modulePrefix
+
'library-core'
)
testImplementation
project
(
modulePrefix
+
'testutils-robolectric'
)
}
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/Aes128DataSource.java
View file @
58d4fd93
...
...
@@ -105,7 +105,8 @@ import javax.crypto.spec.SecretKeySpec;
}
@Override
public
final
@Nullable
Uri
getUri
()
{
@Nullable
public
final
Uri
getUri
()
{
return
upstream
.
getUri
();
}
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/DefaultHlsExtractorFactory.java
View file @
58d4fd93
...
...
@@ -84,11 +84,11 @@ public final class DefaultHlsExtractorFactory implements HlsExtractorFactory {
@Override
public
Result
createExtractor
(
Extractor
previousExtractor
,
@Nullable
Extractor
previousExtractor
,
Uri
uri
,
Format
format
,
List
<
Format
>
muxedCaptionFormats
,
DrmInitData
drmInitData
,
@Nullable
List
<
Format
>
muxedCaptionFormats
,
@Nullable
DrmInitData
drmInitData
,
TimestampAdjuster
timestampAdjuster
,
Map
<
String
,
List
<
String
>>
responseHeaders
,
ExtractorInput
extractorInput
)
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsChunkSource.java
View file @
58d4fd93
...
...
@@ -59,10 +59,8 @@ import java.util.Map;
clear
();
}
/**
* The chunk to be loaded next.
*/
public
Chunk
chunk
;
/** The chunk to be loaded next. */
@Nullable
public
Chunk
chunk
;
/**
* Indicates that the end of the stream has been reached.
...
...
@@ -70,7 +68,7 @@ import java.util.Map;
public
boolean
endOfStream
;
/** Indicates that the chunk source is waiting for the referred playlist to be refreshed. */
public
Uri
playlistUrl
;
@Nullable
public
Uri
playlistUrl
;
/**
* Clears the holder.
...
...
@@ -138,7 +136,7 @@ import java.util.Map;
HlsDataSourceFactory
dataSourceFactory
,
@Nullable
TransferListener
mediaTransferListener
,
TimestampAdjusterProvider
timestampAdjusterProvider
,
List
<
Format
>
muxedCaptionFormats
)
{
@Nullable
List
<
Format
>
muxedCaptionFormats
)
{
this
.
extractorFactory
=
extractorFactory
;
this
.
playlistTracker
=
playlistTracker
;
this
.
playlistUrls
=
playlistUrls
;
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsExtractorFactory.java
View file @
58d4fd93
...
...
@@ -16,6 +16,7 @@
package
com
.
google
.
android
.
exoplayer2
.
source
.
hls
;
import
android.net.Uri
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.drm.DrmInitData
;
import
com.google.android.exoplayer2.extractor.Extractor
;
...
...
@@ -82,11 +83,11 @@ public interface HlsExtractorFactory {
* @throws IOException If an I/O error is encountered while sniffing.
*/
Result
createExtractor
(
Extractor
previousExtractor
,
@Nullable
Extractor
previousExtractor
,
Uri
uri
,
Format
format
,
List
<
Format
>
muxedCaptionFormats
,
DrmInitData
drmInitData
,
@Nullable
List
<
Format
>
muxedCaptionFormats
,
@Nullable
DrmInitData
drmInitData
,
TimestampAdjuster
timestampAdjuster
,
Map
<
String
,
List
<
String
>>
responseHeaders
,
ExtractorInput
sniffingExtractorInput
)
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java
View file @
58d4fd93
...
...
@@ -54,6 +54,7 @@ import java.util.HashSet;
import
java.util.IdentityHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.checkerframework.checker.nullness.compatqual.NullableType
;
/**
* A {@link MediaPeriod} that loads an HLS stream.
...
...
@@ -249,8 +250,12 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsSampleStreamWrapper
}
@Override
public
long
selectTracks
(
TrackSelection
[]
selections
,
boolean
[]
mayRetainStreamFlags
,
SampleStream
[]
streams
,
boolean
[]
streamResetFlags
,
long
positionUs
)
{
public
long
selectTracks
(
@NullableType
TrackSelection
[]
selections
,
boolean
[]
mayRetainStreamFlags
,
@NullableType
SampleStream
[]
streams
,
boolean
[]
streamResetFlags
,
long
positionUs
)
{
// Map each selection and stream onto a child period index.
int
[]
streamChildIndices
=
new
int
[
selections
.
length
];
int
[]
selectionChildIndices
=
new
int
[
selections
.
length
];
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java
View file @
58d4fd93
...
...
@@ -110,7 +110,7 @@ public final class HlsMediaSource extends BaseMediaSource
* @return This factory, for convenience.
* @throws IllegalStateException If one of the {@code create} methods has already been called.
*/
public
Factory
setTag
(
Object
tag
)
{
public
Factory
setTag
(
@Nullable
Object
tag
)
{
Assertions
.
checkState
(!
isCreateCalled
);
this
.
tag
=
tag
;
return
this
;
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/WebvttExtractor.java
View file @
58d4fd93
...
...
@@ -15,6 +15,7 @@
*/
package
com
.
google
.
android
.
exoplayer2
.
source
.
hls
;
import
androidx.annotation.Nullable
;
import
android.text.TextUtils
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
...
...
@@ -49,7 +50,7 @@ public final class WebvttExtractor implements Extractor {
private
static
final
int
HEADER_MIN_LENGTH
=
6
/* "WEBVTT" */
;
private
static
final
int
HEADER_MAX_LENGTH
=
3
/* optional Byte Order Mark */
+
HEADER_MIN_LENGTH
;
private
final
String
language
;
@Nullable
private
final
String
language
;
private
final
TimestampAdjuster
timestampAdjuster
;
private
final
ParsableByteArray
sampleDataWrapper
;
...
...
@@ -58,7 +59,7 @@ public final class WebvttExtractor implements Extractor {
private
byte
[]
sampleData
;
private
int
sampleSize
;
public
WebvttExtractor
(
String
language
,
TimestampAdjuster
timestampAdjuster
)
{
public
WebvttExtractor
(
@Nullable
String
language
,
TimestampAdjuster
timestampAdjuster
)
{
this
.
language
=
language
;
this
.
timestampAdjuster
=
timestampAdjuster
;
this
.
sampleDataWrapper
=
new
ParsableByteArray
();
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/offline/package-info.java
0 → 100644
View file @
58d4fd93
/*
* 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.
*/
@NonNullApi
package
com
.
google
.
android
.
exoplayer2
.
source
.
hls
.
offline
;
import
com.google.android.exoplayer2.util.NonNullApi
;
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/package-info.java
0 → 100644
View file @
58d4fd93
/*
* 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.
*/
@NonNullApi
package
com
.
google
.
android
.
exoplayer2
.
source
.
hls
;
import
com.google.android.exoplayer2.util.NonNullApi
;
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/DefaultHlsPlaylistTracker.java
View file @
58d4fd93
...
...
@@ -172,6 +172,7 @@ public final class DefaultHlsPlaylistTracker
}
@Override
@Nullable
public
HlsMediaPlaylist
getPlaylistSnapshot
(
Uri
url
,
boolean
isForPlayback
)
{
HlsMediaPlaylist
snapshot
=
playlistBundles
.
get
(
url
).
getPlaylistSnapshot
();
if
(
snapshot
!=
null
&&
isForPlayback
)
{
...
...
@@ -448,7 +449,7 @@ public final class DefaultHlsPlaylistTracker
private
final
Loader
mediaPlaylistLoader
;
private
final
ParsingLoadable
<
HlsPlaylist
>
mediaPlaylistLoadable
;
private
HlsMediaPlaylist
playlistSnapshot
;
@Nullable
private
HlsMediaPlaylist
playlistSnapshot
;
private
long
lastSnapshotLoadMs
;
private
long
lastSnapshotChangeMs
;
private
long
earliestNextLoadTimeMs
;
...
...
@@ -467,6 +468,7 @@ public final class DefaultHlsPlaylistTracker
mediaPlaylistParser
);
}
@Nullable
public
HlsMediaPlaylist
getPlaylistSnapshot
()
{
return
playlistSnapshot
;
}
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsMasterPlaylist.java
View file @
58d4fd93
...
...
@@ -174,7 +174,7 @@ public final class HlsMasterPlaylist extends HlsPlaylist {
* The format of the audio muxed in the variants. May be null if the playlist does not declare any
* muxed audio.
*/
public
final
Format
muxedAudioFormat
;
@Nullable
public
final
Format
muxedAudioFormat
;
/**
* The format of the closed captions declared by the playlist. May be empty if the playlist
* explicitly declares no captions are available, or null if the playlist does not declare any
...
...
@@ -208,7 +208,7 @@ public final class HlsMasterPlaylist extends HlsPlaylist {
List
<
Rendition
>
audios
,
List
<
Rendition
>
subtitles
,
List
<
Rendition
>
closedCaptions
,
Format
muxedAudioFormat
,
@Nullable
Format
muxedAudioFormat
,
List
<
Format
>
muxedCaptionFormats
,
boolean
hasIndependentSegments
,
Map
<
String
,
String
>
variableDefinitions
,
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsMediaPlaylist.java
View file @
58d4fd93
...
...
@@ -16,7 +16,6 @@
package
com
.
google
.
android
.
exoplayer2
.
source
.
hls
.
playlist
;
import
androidx.annotation.IntDef
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.drm.DrmInitData
;
...
...
@@ -95,8 +94,8 @@ public final class HlsMediaPlaylist extends HlsPlaylist {
String
uri
,
long
byterangeOffset
,
long
byterangeLength
,
String
fullSegmentEncryptionKeyUri
,
String
encryptionIV
)
{
@Nullable
String
fullSegmentEncryptionKeyUri
,
@Nullable
String
encryptionIV
)
{
this
(
uri
,
/* initializationSegment= */
null
,
...
...
@@ -154,7 +153,7 @@ public final class HlsMediaPlaylist extends HlsPlaylist {
}
@Override
public
int
compareTo
(
@NonNull
Long
relativeStartTimeUs
)
{
public
int
compareTo
(
Long
relativeStartTimeUs
)
{
return
this
.
relativeStartTimeUs
>
relativeStartTimeUs
?
1
:
(
this
.
relativeStartTimeUs
<
relativeStartTimeUs
?
-
1
:
0
);
}
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/package-info.java
0 → 100644
View file @
58d4fd93
/*
* 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.
*/
@NonNullApi
package
com
.
google
.
android
.
exoplayer2
.
source
.
hls
.
playlist
;
import
com.google.android.exoplayer2.util.NonNullApi
;
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