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
924cfac9
authored
Jul 04, 2019
by
olly
Committed by
Toni
Jul 05, 2019
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Remove more low hanging fruit from nullness blacklist
PiperOrigin-RevId: 256573352
parent
b1790f9d
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
57 additions
and
28 deletions
library/core/src/main/java/com/google/android/exoplayer2/extractor/flv/ScriptTagPayloadReader.java
library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/Track.java
library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackEncryptionBox.java
library/core/src/main/java/com/google/android/exoplayer2/text/Cue.java
library/core/src/main/java/com/google/android/exoplayer2/text/SimpleSubtitleDecoder.java
library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleOutputBuffer.java
library/core/src/main/java/com/google/android/exoplayer2/text/pgs/PgsDecoder.java
library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaDecoder.java
library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaSubtitle.java
library/core/src/main/java/com/google/android/exoplayer2/text/subrip/SubripDecoder.java
library/core/src/main/java/com/google/android/exoplayer2/text/subrip/SubripSubtitle.java
library/core/src/main/java/com/google/android/exoplayer2/text/tx3g/Tx3gDecoder.java
library/core/src/main/java/com/google/android/exoplayer2/extractor/flv/ScriptTagPayloadReader.java
View file @
924cfac9
...
...
@@ -15,8 +15,10 @@
*/
package
com
.
google
.
android
.
exoplayer2
.
extractor
.
flv
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.ParserException
;
import
com.google.android.exoplayer2.extractor.DummyTrackOutput
;
import
com.google.android.exoplayer2.util.ParsableByteArray
;
import
java.util.ArrayList
;
import
java.util.Date
;
...
...
@@ -44,7 +46,7 @@ import java.util.Map;
private
long
durationUs
;
public
ScriptTagPayloadReader
()
{
super
(
n
ull
);
super
(
n
ew
DummyTrackOutput
()
);
durationUs
=
C
.
TIME_UNSET
;
}
...
...
@@ -138,7 +140,10 @@ import java.util.Map;
ArrayList
<
Object
>
list
=
new
ArrayList
<>(
count
);
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
int
type
=
readAmfType
(
data
);
list
.
add
(
readAmfData
(
data
,
type
));
Object
value
=
readAmfData
(
data
,
type
);
if
(
value
!=
null
)
{
list
.
add
(
value
);
}
}
return
list
;
}
...
...
@@ -157,7 +162,10 @@ import java.util.Map;
if
(
type
==
AMF_TYPE_END_MARKER
)
{
break
;
}
array
.
put
(
key
,
readAmfData
(
data
,
type
));
Object
value
=
readAmfData
(
data
,
type
);
if
(
value
!=
null
)
{
array
.
put
(
key
,
value
);
}
}
return
array
;
}
...
...
@@ -174,7 +182,10 @@ import java.util.Map;
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
String
key
=
readAmfString
(
data
);
int
type
=
readAmfType
(
data
);
array
.
put
(
key
,
readAmfData
(
data
,
type
));
Object
value
=
readAmfData
(
data
,
type
);
if
(
value
!=
null
)
{
array
.
put
(
key
,
value
);
}
}
return
array
;
}
...
...
@@ -191,6 +202,7 @@ import java.util.Map;
return
date
;
}
@Nullable
private
static
Object
readAmfData
(
ParsableByteArray
data
,
int
type
)
{
switch
(
type
)
{
case
AMF_TYPE_NUMBER:
...
...
@@ -208,8 +220,8 @@ import java.util.Map;
case
AMF_TYPE_DATE:
return
readAmfDate
(
data
);
default
:
// We don't log a warning because there are types that we knowingly don't support.
return
null
;
}
}
}
library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/Track.java
View file @
924cfac9
...
...
@@ -123,6 +123,7 @@ public final class Track {
* @return The {@link TrackEncryptionBox} for the given sample description index. Maybe null if no
* such entry exists.
*/
@Nullable
public
TrackEncryptionBox
getSampleDescriptionEncryptionBox
(
int
sampleDescriptionIndex
)
{
return
sampleDescriptionEncryptionBoxes
==
null
?
null
:
sampleDescriptionEncryptionBoxes
[
sampleDescriptionIndex
];
...
...
library/core/src/main/java/com/google/android/exoplayer2/extractor/mp4/TrackEncryptionBox.java
View file @
924cfac9
...
...
@@ -52,7 +52,7 @@ public final class TrackEncryptionBox {
* If {@link #perSampleIvSize} is 0, holds the default initialization vector as defined in the
* track encryption box or sample group description box. Null otherwise.
*/
public
final
byte
[]
defaultInitializationVector
;
@Nullable
public
final
byte
[]
defaultInitializationVector
;
/**
* @param isEncrypted See {@link #isEncrypted}.
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/Cue.java
View file @
924cfac9
...
...
@@ -29,9 +29,10 @@ import java.lang.annotation.RetentionPolicy;
*/
public
class
Cue
{
/**
* An unset position or width.
*/
/** The empty cue. */
public
static
final
Cue
EMPTY
=
new
Cue
(
""
);
/** An unset position or width. */
public
static
final
float
DIMEN_UNSET
=
Float
.
MIN_VALUE
;
/**
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/SimpleSubtitleDecoder.java
View file @
924cfac9
...
...
@@ -15,6 +15,7 @@
*/
package
com
.
google
.
android
.
exoplayer2
.
text
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.decoder.SimpleDecoder
;
import
java.nio.ByteBuffer
;
...
...
@@ -69,6 +70,7 @@ public abstract class SimpleSubtitleDecoder extends
@SuppressWarnings
(
"ByteBufferBackingArray"
)
@Override
@Nullable
protected
final
SubtitleDecoderException
decode
(
SubtitleInputBuffer
inputBuffer
,
SubtitleOutputBuffer
outputBuffer
,
boolean
reset
)
{
try
{
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/SubtitleOutputBuffer.java
View file @
924cfac9
...
...
@@ -18,6 +18,7 @@ package com.google.android.exoplayer2.text;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.decoder.OutputBuffer
;
import
com.google.android.exoplayer2.util.Assertions
;
import
java.util.List
;
/**
...
...
@@ -46,22 +47,22 @@ public abstract class SubtitleOutputBuffer extends OutputBuffer implements Subti
@Override
public
int
getEventTimeCount
()
{
return
subtitle
.
getEventTimeCount
();
return
Assertions
.
checkNotNull
(
subtitle
)
.
getEventTimeCount
();
}
@Override
public
long
getEventTime
(
int
index
)
{
return
subtitle
.
getEventTime
(
index
)
+
subsampleOffsetUs
;
return
Assertions
.
checkNotNull
(
subtitle
)
.
getEventTime
(
index
)
+
subsampleOffsetUs
;
}
@Override
public
int
getNextEventTimeIndex
(
long
timeUs
)
{
return
subtitle
.
getNextEventTimeIndex
(
timeUs
-
subsampleOffsetUs
);
return
Assertions
.
checkNotNull
(
subtitle
)
.
getNextEventTimeIndex
(
timeUs
-
subsampleOffsetUs
);
}
@Override
public
List
<
Cue
>
getCues
(
long
timeUs
)
{
return
subtitle
.
getCues
(
timeUs
-
subsampleOffsetUs
);
return
Assertions
.
checkNotNull
(
subtitle
)
.
getCues
(
timeUs
-
subsampleOffsetUs
);
}
@Override
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/pgs/PgsDecoder.java
View file @
924cfac9
...
...
@@ -16,6 +16,7 @@
package
com
.
google
.
android
.
exoplayer2
.
text
.
pgs
;
import
android.graphics.Bitmap
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.text.Cue
;
import
com.google.android.exoplayer2.text.SimpleSubtitleDecoder
;
import
com.google.android.exoplayer2.text.Subtitle
;
...
...
@@ -41,7 +42,7 @@ public final class PgsDecoder extends SimpleSubtitleDecoder {
private
final
ParsableByteArray
inflatedBuffer
;
private
final
CueBuilder
cueBuilder
;
private
Inflater
inflater
;
@Nullable
private
Inflater
inflater
;
public
PgsDecoder
()
{
super
(
"PgsDecoder"
);
...
...
@@ -76,6 +77,7 @@ public final class PgsDecoder extends SimpleSubtitleDecoder {
}
}
@Nullable
private
static
Cue
readNextSection
(
ParsableByteArray
buffer
,
CueBuilder
cueBuilder
)
{
int
limit
=
buffer
.
limit
();
int
sectionType
=
buffer
.
readUnsignedByte
();
...
...
@@ -197,6 +199,7 @@ public final class PgsDecoder extends SimpleSubtitleDecoder {
bitmapY
=
buffer
.
readUnsignedShort
();
}
@Nullable
public
Cue
build
()
{
if
(
planeWidth
==
0
||
planeHeight
==
0
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaDecoder.java
View file @
924cfac9
...
...
@@ -15,6 +15,7 @@
*/
package
com
.
google
.
android
.
exoplayer2
.
text
.
ssa
;
import
androidx.annotation.Nullable
;
import
android.text.TextUtils
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.text.Cue
;
...
...
@@ -50,7 +51,7 @@ public final class SsaDecoder extends SimpleSubtitleDecoder {
private
int
formatTextIndex
;
public
SsaDecoder
()
{
this
(
null
);
this
(
/* initializationData= */
null
);
}
/**
...
...
@@ -59,7 +60,7 @@ public final class SsaDecoder extends SimpleSubtitleDecoder {
* format line. The second must contain an SSA header that will be assumed common to all
* samples.
*/
public
SsaDecoder
(
List
<
byte
[]>
initializationData
)
{
public
SsaDecoder
(
@Nullable
List
<
byte
[]>
initializationData
)
{
super
(
"SsaDecoder"
);
if
(
initializationData
!=
null
&&
!
initializationData
.
isEmpty
())
{
haveInitializationData
=
true
;
...
...
@@ -202,7 +203,7 @@ public final class SsaDecoder extends SimpleSubtitleDecoder {
cues
.
add
(
new
Cue
(
text
));
cueTimesUs
.
add
(
startTimeUs
);
if
(
endTimeUs
!=
C
.
TIME_UNSET
)
{
cues
.
add
(
null
);
cues
.
add
(
Cue
.
EMPTY
);
cueTimesUs
.
add
(
endTimeUs
);
}
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/ssa/SsaSubtitle.java
View file @
924cfac9
...
...
@@ -32,7 +32,7 @@ import java.util.List;
private
final
long
[]
cueTimesUs
;
/**
* @param cues The cues in the subtitle.
Null entries may be used to represent empty cues.
* @param cues The cues in the subtitle.
* @param cueTimesUs The cue times, in microseconds.
*/
public
SsaSubtitle
(
Cue
[]
cues
,
long
[]
cueTimesUs
)
{
...
...
@@ -61,7 +61,7 @@ import java.util.List;
@Override
public
List
<
Cue
>
getCues
(
long
timeUs
)
{
int
index
=
Util
.
binarySearchFloor
(
cueTimesUs
,
timeUs
,
true
,
false
);
if
(
index
==
-
1
||
cues
[
index
]
==
null
)
{
if
(
index
==
-
1
||
cues
[
index
]
==
Cue
.
EMPTY
)
{
// timeUs is earlier than the start of the first cue, or we have an empty cue.
return
Collections
.
emptyList
();
}
else
{
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/subrip/SubripDecoder.java
View file @
924cfac9
...
...
@@ -112,11 +112,13 @@ public final class SubripDecoder extends SimpleSubtitleDecoder {
// Read and parse the text and tags.
textBuilder
.
setLength
(
0
);
tags
.
clear
();
while
(!
TextUtils
.
isEmpty
(
currentLine
=
subripData
.
readLine
()))
{
currentLine
=
subripData
.
readLine
();
while
(!
TextUtils
.
isEmpty
(
currentLine
))
{
if
(
textBuilder
.
length
()
>
0
)
{
textBuilder
.
append
(
"<br>"
);
}
textBuilder
.
append
(
processLine
(
currentLine
,
tags
));
currentLine
=
subripData
.
readLine
();
}
Spanned
text
=
Html
.
fromHtml
(
textBuilder
.
toString
());
...
...
@@ -133,7 +135,7 @@ public final class SubripDecoder extends SimpleSubtitleDecoder {
cues
.
add
(
buildCue
(
text
,
alignmentTag
));
if
(
haveEndTimecode
)
{
cues
.
add
(
null
);
cues
.
add
(
Cue
.
EMPTY
);
}
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/subrip/SubripSubtitle.java
View file @
924cfac9
...
...
@@ -32,7 +32,7 @@ import java.util.List;
private
final
long
[]
cueTimesUs
;
/**
* @param cues The cues in the subtitle.
Null entries may be used to represent empty cues.
* @param cues The cues in the subtitle.
* @param cueTimesUs The cue times, in microseconds.
*/
public
SubripSubtitle
(
Cue
[]
cues
,
long
[]
cueTimesUs
)
{
...
...
@@ -61,7 +61,7 @@ import java.util.List;
@Override
public
List
<
Cue
>
getCues
(
long
timeUs
)
{
int
index
=
Util
.
binarySearchFloor
(
cueTimesUs
,
timeUs
,
true
,
false
);
if
(
index
==
-
1
||
cues
[
index
]
==
null
)
{
if
(
index
==
-
1
||
cues
[
index
]
==
Cue
.
EMPTY
)
{
// timeUs is earlier than the start of the first cue, or we have an empty cue.
return
Collections
.
emptyList
();
}
else
{
...
...
library/core/src/main/java/com/google/android/exoplayer2/text/tx3g/Tx3gDecoder.java
View file @
924cfac9
...
...
@@ -65,6 +65,7 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
private
static
final
float
DEFAULT_VERTICAL_PLACEMENT
=
0.85f
;
private
final
ParsableByteArray
parsableByteArray
;
private
boolean
customVerticalPlacement
;
private
int
defaultFontFace
;
private
int
defaultColorRgba
;
...
...
@@ -80,10 +81,7 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
public
Tx3gDecoder
(
List
<
byte
[]>
initializationData
)
{
super
(
"Tx3gDecoder"
);
parsableByteArray
=
new
ParsableByteArray
();
decodeInitializationData
(
initializationData
);
}
private
void
decodeInitializationData
(
List
<
byte
[]>
initializationData
)
{
if
(
initializationData
!=
null
&&
initializationData
.
size
()
==
1
&&
(
initializationData
.
get
(
0
).
length
==
48
||
initializationData
.
get
(
0
).
length
==
53
))
{
byte
[]
initializationBytes
=
initializationData
.
get
(
0
);
...
...
@@ -151,8 +149,16 @@ public final class Tx3gDecoder extends SimpleSubtitleDecoder {
}
parsableByteArray
.
setPosition
(
position
+
atomSize
);
}
return
new
Tx3gSubtitle
(
new
Cue
(
cueText
,
null
,
verticalPlacement
,
Cue
.
LINE_TYPE_FRACTION
,
Cue
.
ANCHOR_TYPE_START
,
Cue
.
DIMEN_UNSET
,
Cue
.
TYPE_UNSET
,
Cue
.
DIMEN_UNSET
));
return
new
Tx3gSubtitle
(
new
Cue
(
cueText
,
/* textAlignment= */
null
,
verticalPlacement
,
Cue
.
LINE_TYPE_FRACTION
,
Cue
.
ANCHOR_TYPE_START
,
Cue
.
DIMEN_UNSET
,
Cue
.
TYPE_UNSET
,
Cue
.
DIMEN_UNSET
));
}
private
static
String
readSubtitleText
(
ParsableByteArray
parsableByteArray
)
...
...
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