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
3a702cf5
authored
Feb 03, 2020
by
olly
Committed by
Oliver Woodman
Feb 03, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Change Format.createTextSampleFormat for common uses cases
PiperOrigin-RevId: 292863614
parent
d7551f97
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
29 additions
and
90 deletions
library/common/src/main/java/com/google/android/exoplayer2/Format.java
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaPeriod.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/DefaultTsPayloadReaderFactory.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SeiReader.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/UserDataReader.java
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ts/TsExtractorTest.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/WebvttExtractor.java
library/common/src/main/java/com/google/android/exoplayer2/Format.java
View file @
3a702cf5
...
...
@@ -550,24 +550,12 @@ public final class Format implements Parcelable {
@Nullable
String
sampleMimeType
,
@C
.
SelectionFlags
int
selectionFlags
,
@Nullable
String
language
)
{
return
createTextSampleFormat
(
id
,
sampleMimeType
,
selectionFlags
,
language
,
null
);
}
public
static
Format
createTextSampleFormat
(
@Nullable
String
id
,
@Nullable
String
sampleMimeType
,
@C
.
SelectionFlags
int
selectionFlags
,
@Nullable
String
language
,
@Nullable
DrmInitData
drmInitData
)
{
return
createTextSampleFormat
(
id
,
sampleMimeType
,
/* codecs= */
null
,
/* bitrate= */
NO_VALUE
,
selectionFlags
,
language
,
NO_VALUE
,
drmInitData
,
OFFSET_SAMPLE_RELATIVE
,
Collections
.
emptyList
());
}
...
...
@@ -575,56 +563,9 @@ public final class Format implements Parcelable {
public
static
Format
createTextSampleFormat
(
@Nullable
String
id
,
@Nullable
String
sampleMimeType
,
@Nullable
String
codecs
,
int
bitrate
,
@C
.
SelectionFlags
int
selectionFlags
,
@Nullable
String
language
,
int
accessibilityChannel
,
@Nullable
DrmInitData
drmInitData
)
{
return
createTextSampleFormat
(
id
,
sampleMimeType
,
codecs
,
bitrate
,
selectionFlags
,
language
,
accessibilityChannel
,
drmInitData
,
OFFSET_SAMPLE_RELATIVE
,
Collections
.
emptyList
());
}
public
static
Format
createTextSampleFormat
(
@Nullable
String
id
,
@Nullable
String
sampleMimeType
,
@Nullable
String
codecs
,
int
bitrate
,
@C
.
SelectionFlags
int
selectionFlags
,
@Nullable
String
language
,
@Nullable
DrmInitData
drmInitData
,
long
subsampleOffsetUs
)
{
return
createTextSampleFormat
(
id
,
sampleMimeType
,
codecs
,
bitrate
,
selectionFlags
,
language
,
/* accessibilityChannel= */
NO_VALUE
,
drmInitData
,
subsampleOffsetUs
,
Collections
.
emptyList
());
}
public
static
Format
createTextSampleFormat
(
@Nullable
String
id
,
@Nullable
String
sampleMimeType
,
@Nullable
String
codecs
,
int
bitrate
,
@C
.
SelectionFlags
int
selectionFlags
,
@Nullable
String
language
,
int
accessibilityChannel
,
@Nullable
DrmInitData
drmInitData
,
long
subsampleOffsetUs
,
@Nullable
List
<
byte
[]>
initializationData
)
{
return
new
Format
(
...
...
@@ -632,14 +573,14 @@ public final class Format implements Parcelable {
/* label= */
null
,
selectionFlags
,
/* roleFlags= */
0
,
bitrate
,
codecs
,
/* bitrate= */
NO_VALUE
,
/* codecs= */
null
,
/* metadata= */
null
,
/* containerMimeType= */
null
,
sampleMimeType
,
/* maxInputSize= */
NO_VALUE
,
initializationData
,
drmInitData
,
/* drmInitData= */
null
,
subsampleOffsetUs
,
/* width= */
NO_VALUE
,
/* height= */
NO_VALUE
,
...
...
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaPeriod.java
View file @
3a702cf5
...
...
@@ -533,8 +533,9 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
continue
;
}
adaptationSetUsedFlags
[
i
]
=
true
;
Descriptor
adaptationSetSwitchingProperty
=
findAdaptationSetSwitchingProperty
(
adaptationSets
.
get
(
i
).
supplementalProperties
);
@Nullable
Descriptor
adaptationSetSwitchingProperty
=
findAdaptationSetSwitchingProperty
(
adaptationSets
.
get
(
i
).
supplementalProperties
);
if
(
adaptationSetSwitchingProperty
==
null
)
{
groupedAdaptationSetIndices
[
groupCount
++]
=
new
int
[]
{
i
};
}
else
{
...
...
@@ -737,6 +738,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
return
stream
;
}
@Nullable
private
static
Descriptor
findAdaptationSetSwitchingProperty
(
List
<
Descriptor
>
descriptors
)
{
for
(
int
i
=
0
;
i
<
descriptors
.
size
();
i
++)
{
Descriptor
descriptor
=
descriptors
.
get
(
i
);
...
...
@@ -769,7 +771,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
for
(
int
j
=
0
;
j
<
descriptors
.
size
();
j
++)
{
Descriptor
descriptor
=
descriptors
.
get
(
j
);
if
(
"urn:scte:dash:cc:cea-608:2015"
.
equals
(
descriptor
.
schemeIdUri
))
{
String
value
=
descriptor
.
value
;
@Nullable
String
value
=
descriptor
.
value
;
if
(
value
==
null
)
{
// There are embedded CEA-608 tracks, but service information is not declared.
return
new
Format
[]
{
buildCea608TrackFormat
(
adaptationSet
.
id
)};
...
...
@@ -801,18 +803,15 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
}
private
static
Format
buildCea608TrackFormat
(
int
adaptationSetId
,
String
language
,
int
accessibilityChannel
)
{
int
adaptationSetId
,
@Nullable
String
language
,
int
accessibilityChannel
)
{
return
Format
.
createTextSampleFormat
(
adaptationSetId
+
":cea608"
+
(
accessibilityChannel
!=
Format
.
NO_VALUE
?
":"
+
accessibilityChannel
:
""
),
MimeTypes
.
APPLICATION_CEA608
,
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
/* selectionFlags= */
0
,
language
,
accessibilityChannel
,
/* drmInitData= */
null
,
Format
.
OFFSET_SAMPLE_RELATIVE
,
/* initializationData= */
null
);
}
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mkv/MatroskaExtractor.java
View file @
3a702cf5
...
...
@@ -2136,16 +2136,25 @@ public class MatroskaExtractor implements Extractor {
drmInitData
);
}
else
if
(
MimeTypes
.
APPLICATION_SUBRIP
.
equals
(
mimeType
))
{
type
=
C
.
TRACK_TYPE_TEXT
;
format
=
Format
.
createTextSampleFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
selectionFlags
,
language
,
drmInitData
);
format
=
Format
.
createTextSampleFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
selectionFlags
,
language
)
.
copyWithDrmInitData
(
drmInitData
);
}
else
if
(
MimeTypes
.
TEXT_SSA
.
equals
(
mimeType
))
{
type
=
C
.
TRACK_TYPE_TEXT
;
initializationData
=
new
ArrayList
<>(
2
);
initializationData
.
add
(
SSA_DIALOGUE_FORMAT
);
initializationData
.
add
(
codecPrivate
);
format
=
Format
.
createTextSampleFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
null
,
Format
.
NO_VALUE
,
selectionFlags
,
language
,
Format
.
NO_VALUE
,
drmInitData
,
Format
.
OFFSET_SAMPLE_RELATIVE
,
initializationData
);
format
=
Format
.
createTextSampleFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
selectionFlags
,
language
,
/* accessibilityChannel= */
Format
.
NO_VALUE
,
Format
.
OFFSET_SAMPLE_RELATIVE
,
initializationData
)
.
copyWithDrmInitData
(
drmInitData
);
}
else
if
(
MimeTypes
.
APPLICATION_VOBSUB
.
equals
(
mimeType
)
||
MimeTypes
.
APPLICATION_PGS
.
equals
(
mimeType
)
||
MimeTypes
.
APPLICATION_DVBSUBS
.
equals
(
mimeType
))
{
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java
View file @
3a702cf5
...
...
@@ -863,12 +863,9 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
Format
.
createTextSampleFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
/* selectionFlags= */
0
,
language
,
/* accessibilityChannel= */
Format
.
NO_VALUE
,
/* drmInitData= */
null
,
subsampleOffsetUs
,
initializationData
);
}
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/DefaultTsPayloadReaderFactory.java
View file @
3a702cf5
...
...
@@ -261,12 +261,9 @@ public final class DefaultTsPayloadReaderFactory implements TsPayloadReader.Fact
Format
.
createTextSampleFormat
(
/* id= */
null
,
mimeType
,
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
/* selectionFlags= */
0
,
language
,
accessibilityChannel
,
/* drmInitData= */
null
,
Format
.
OFFSET_SAMPLE_RELATIVE
,
initializationData
));
}
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SeiReader.java
View file @
3a702cf5
...
...
@@ -55,12 +55,9 @@ public final class SeiReader {
Format
.
createTextSampleFormat
(
formatId
,
channelMimeType
,
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
channelFormat
.
selectionFlags
,
channelFormat
.
language
,
channelFormat
.
accessibilityChannel
,
/* drmInitData= */
null
,
Format
.
OFFSET_SAMPLE_RELATIVE
,
channelFormat
.
initializationData
));
outputs
[
i
]
=
output
;
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/UserDataReader.java
View file @
3a702cf5
...
...
@@ -54,12 +54,9 @@ import java.util.List;
Format
.
createTextSampleFormat
(
idGenerator
.
getFormatId
(),
channelMimeType
,
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
channelFormat
.
selectionFlags
,
channelFormat
.
language
,
channelFormat
.
accessibilityChannel
,
/* drmInitData= */
null
,
Format
.
OFFSET_SAMPLE_RELATIVE
,
channelFormat
.
initializationData
));
outputs
[
i
]
=
output
;
...
...
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ts/TsExtractorTest.java
View file @
3a702cf5
...
...
@@ -107,7 +107,7 @@ public final class TsExtractorTest {
TrackOutput
trackOutput
=
reader
.
getTrackOutput
();
assertThat
(
trackOutput
==
output
.
trackOutputs
.
get
(
257
/* PID of audio track. */
)).
isTrue
();
assertThat
(((
FakeTrackOutput
)
trackOutput
).
format
)
.
isEqualTo
(
Format
.
createTextSampleFormat
(
"1/257"
,
"mime"
,
null
,
0
,
0
,
"und"
,
null
,
0
));
.
isEqualTo
(
Format
.
createTextSampleFormat
(
"1/257"
,
"mime"
,
/* selectionFlags= */
0
,
"und"
));
}
@Test
...
...
@@ -204,7 +204,7 @@ public final class TsExtractorTest {
output
=
extractorOutput
.
track
(
idGenerator
.
getTrackId
(),
C
.
TRACK_TYPE_UNKNOWN
);
output
.
format
(
Format
.
createTextSampleFormat
(
idGenerator
.
getFormatId
(),
"mime"
,
null
,
0
,
0
,
language
,
null
,
0
));
idGenerator
.
getFormatId
(),
"mime"
,
/* selectionFlags= */
0
,
language
));
}
@Override
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/WebvttExtractor.java
View file @
3a702cf5
...
...
@@ -186,8 +186,10 @@ public final class WebvttExtractor implements Extractor {
@RequiresNonNull
(
"output"
)
private
TrackOutput
buildTrackOutput
(
long
subsampleOffsetUs
)
{
TrackOutput
trackOutput
=
output
.
track
(
0
,
C
.
TRACK_TYPE_TEXT
);
trackOutput
.
format
(
Format
.
createTextSampleFormat
(
null
,
MimeTypes
.
TEXT_VTT
,
null
,
Format
.
NO_VALUE
,
0
,
language
,
null
,
subsampleOffsetUs
));
trackOutput
.
format
(
Format
.
createTextSampleFormat
(
/* id= */
null
,
MimeTypes
.
TEXT_VTT
,
/* selectionFlags= */
0
,
language
)
.
copyWithSubsampleOffsetUs
(
subsampleOffsetUs
));
output
.
endTracks
();
return
trackOutput
;
}
...
...
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