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
d287e13d
authored
Jan 31, 2020
by
olly
Committed by
Oliver Woodman
Jan 31, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add Format.createSampleFormat for common use case
PiperOrigin-RevId: 292562678
parent
04218bde
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
62 additions
and
57 deletions
library/common/src/main/java/com/google/android/exoplayer2/Format.java
library/common/src/main/java/com/google/android/exoplayer2/metadata/emsg/EventMessage.java
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java
library/core/src/test/java/com/google/android/exoplayer2/audio/SimpleDecoderAudioRendererTest.java
library/core/src/test/java/com/google/android/exoplayer2/metadata/MetadataRendererTest.java
library/core/src/test/java/com/google/android/exoplayer2/source/SampleQueueTest.java
library/core/src/test/java/com/google/android/exoplayer2/source/TrackGroupArrayTest.java
library/core/src/test/java/com/google/android/exoplayer2/source/TrackGroupTest.java
library/core/src/test/java/com/google/android/exoplayer2/trackselection/MappingTrackSelectorTest.java
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaPeriod.java
library/dash/src/test/java/com/google/android/exoplayer2/source/dash/EventSampleStreamTest.java
library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestTest.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/AdtsReader.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Id3Reader.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SpliceInfoSectionReader.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/HlsSampleStreamWrapper.java
library/common/src/main/java/com/google/android/exoplayer2/Format.java
View file @
d287e13d
...
...
@@ -746,6 +746,17 @@ public final class Format implements Parcelable {
/* exoMediaCryptoType= */
null
);
}
@SuppressWarnings
(
"deprecation"
)
public
static
Format
createSampleFormat
(
@Nullable
String
id
,
@Nullable
String
sampleMimeType
)
{
return
createSampleFormat
(
id
,
sampleMimeType
,
OFFSET_SAMPLE_RELATIVE
);
}
/**
* @deprecated Use {@link #createSampleFormat(String, String)} and (for values of {@link
* #subsampleOffsetUs} other than {@link #OFFSET_SAMPLE_RELATIVE}) {@link
* #copyWithSubsampleOffsetUs(long)}.
*/
@Deprecated
public
static
Format
createSampleFormat
(
@Nullable
String
id
,
@Nullable
String
sampleMimeType
,
long
subsampleOffsetUs
)
{
return
new
Format
(
...
...
@@ -780,6 +791,11 @@ public final class Format implements Parcelable {
/* exoMediaCryptoType= */
null
);
}
/**
* @deprecated Most usages should use one of the {@link #createVideoSampleFormat} or {@link
* #createAudioSampleFormat} methods.
*/
@Deprecated
public
static
Format
createSampleFormat
(
@Nullable
String
id
,
@Nullable
String
sampleMimeType
,
...
...
library/common/src/main/java/com/google/android/exoplayer2/metadata/emsg/EventMessage.java
View file @
d287e13d
...
...
@@ -50,11 +50,9 @@ public final class EventMessage implements Metadata.Entry {
@VisibleForTesting
public
static
final
String
SCTE35_SCHEME_ID
=
"urn:scte:scte35:2014:bin"
;
private
static
final
Format
ID3_FORMAT
=
Format
.
createSampleFormat
(
/* id= */
null
,
MimeTypes
.
APPLICATION_ID3
,
Format
.
OFFSET_SAMPLE_RELATIVE
);
Format
.
createSampleFormat
(
/* id= */
null
,
MimeTypes
.
APPLICATION_ID3
);
private
static
final
Format
SCTE35_FORMAT
=
Format
.
createSampleFormat
(
/* id= */
null
,
MimeTypes
.
APPLICATION_SCTE35
,
Format
.
OFFSET_SAMPLE_RELATIVE
);
Format
.
createSampleFormat
(
/* id= */
null
,
MimeTypes
.
APPLICATION_SCTE35
);
/** The message scheme. */
public
final
String
schemeIdUri
;
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java
View file @
d287e13d
...
...
@@ -94,7 +94,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
private
static
final
Map
<
String
,
String
>
ICY_METADATA_HEADERS
=
createIcyMetadataHeaders
();
private
static
final
Format
ICY_FORMAT
=
Format
.
createSampleFormat
(
"icy"
,
MimeTypes
.
APPLICATION_ICY
,
Format
.
OFFSET_SAMPLE_RELATIVE
);
Format
.
createSampleFormat
(
"icy"
,
MimeTypes
.
APPLICATION_ICY
);
private
final
Uri
uri
;
private
final
DataSource
dataSource
;
...
...
library/core/src/test/java/com/google/android/exoplayer2/audio/SimpleDecoderAudioRendererTest.java
View file @
d287e13d
...
...
@@ -47,7 +47,7 @@ import org.robolectric.annotation.Config;
@RunWith
(
AndroidJUnit4
.
class
)
public
class
SimpleDecoderAudioRendererTest
{
private
static
final
Format
FORMAT
=
Format
.
createSampleFormat
(
null
,
MimeTypes
.
AUDIO_RAW
,
0
);
private
static
final
Format
FORMAT
=
Format
.
createSampleFormat
(
null
,
MimeTypes
.
AUDIO_RAW
);
@Mock
private
AudioSink
mockAudioSink
;
private
SimpleDecoderAudioRenderer
audioRenderer
;
...
...
library/core/src/test/java/com/google/android/exoplayer2/metadata/MetadataRendererTest.java
View file @
d287e13d
...
...
@@ -64,7 +64,7 @@ public class MetadataRendererTest {
0x00
,
0x00
,
0x00
,
0x00
));
// CRC_32 (ignored, check happens at extraction).
private
static
final
Format
EMSG_FORMAT
=
Format
.
createSampleFormat
(
null
,
MimeTypes
.
APPLICATION_EMSG
,
Format
.
OFFSET_SAMPLE_RELATIVE
);
Format
.
createSampleFormat
(
null
,
MimeTypes
.
APPLICATION_EMSG
);
private
final
EventMessageEncoder
eventMessageEncoder
=
new
EventMessageEncoder
();
...
...
library/core/src/test/java/com/google/android/exoplayer2/source/SampleQueueTest.java
View file @
d287e13d
...
...
@@ -56,17 +56,17 @@ public final class SampleQueueTest {
private
static
final
int
ALLOCATION_SIZE
=
16
;
private
static
final
Format
FORMAT_1
=
Format
.
createSampleFormat
(
"1"
,
"mimeType"
,
0
);
private
static
final
Format
FORMAT_2
=
Format
.
createSampleFormat
(
"2"
,
"mimeType"
,
0
);
private
static
final
Format
FORMAT_1_COPY
=
Format
.
createSampleFormat
(
"1"
,
"mimeType"
,
0
);
private
static
final
Format
FORMAT_SPLICED
=
Format
.
createSampleFormat
(
"spliced"
,
"mimeType"
,
0
);
private
static
final
Format
FORMAT_1
=
Format
.
createSampleFormat
(
"1"
,
"mimeType"
).
copyWithSubsampleOffsetUs
(
0
);
private
static
final
Format
FORMAT_2
=
Format
.
createSampleFormat
(
"2"
,
"mimeType"
).
copyWithSubsampleOffsetUs
(
0
);
private
static
final
Format
FORMAT_1_COPY
=
Format
.
createSampleFormat
(
"1"
,
"mimeType"
).
copyWithSubsampleOffsetUs
(
0
);
private
static
final
Format
FORMAT_SPLICED
=
Format
.
createSampleFormat
(
"spliced"
,
"mimeType"
).
copyWithSubsampleOffsetUs
(
0
);
private
static
final
Format
FORMAT_ENCRYPTED
=
Format
.
createSampleFormat
(
/* id= */
"encrypted"
,
"mimeType"
,
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
new
DrmInitData
());
Format
.
createSampleFormat
(
/* id= */
"encrypted"
,
"mimeType"
)
.
copyWithDrmInitData
(
new
DrmInitData
());
private
static
final
byte
[]
DATA
=
TestUtil
.
buildTestData
(
ALLOCATION_SIZE
*
10
);
/*
...
...
library/core/src/test/java/com/google/android/exoplayer2/source/TrackGroupArrayTest.java
View file @
d287e13d
...
...
@@ -30,9 +30,9 @@ public final class TrackGroupArrayTest {
@Test
public
void
testParcelable
()
{
Format
format1
=
Format
.
createSampleFormat
(
"1"
,
MimeTypes
.
VIDEO_H264
,
0
);
Format
format2
=
Format
.
createSampleFormat
(
"2"
,
MimeTypes
.
AUDIO_AAC
,
0
);
Format
format3
=
Format
.
createSampleFormat
(
"3"
,
MimeTypes
.
VIDEO_H264
,
0
);
Format
format1
=
Format
.
createSampleFormat
(
"1"
,
MimeTypes
.
VIDEO_H264
);
Format
format2
=
Format
.
createSampleFormat
(
"2"
,
MimeTypes
.
AUDIO_AAC
);
Format
format3
=
Format
.
createSampleFormat
(
"3"
,
MimeTypes
.
VIDEO_H264
);
TrackGroup
trackGroup1
=
new
TrackGroup
(
format1
,
format2
);
TrackGroup
trackGroup2
=
new
TrackGroup
(
format3
);
...
...
library/core/src/test/java/com/google/android/exoplayer2/source/TrackGroupTest.java
View file @
d287e13d
...
...
@@ -30,8 +30,8 @@ public final class TrackGroupTest {
@Test
public
void
testParcelable
()
{
Format
format1
=
Format
.
createSampleFormat
(
"1"
,
MimeTypes
.
VIDEO_H264
,
0
);
Format
format2
=
Format
.
createSampleFormat
(
"2"
,
MimeTypes
.
AUDIO_AAC
,
0
);
Format
format1
=
Format
.
createSampleFormat
(
"1"
,
MimeTypes
.
VIDEO_H264
);
Format
format2
=
Format
.
createSampleFormat
(
"2"
,
MimeTypes
.
AUDIO_AAC
);
TrackGroup
trackGroupToParcel
=
new
TrackGroup
(
format1
,
format2
);
...
...
library/core/src/test/java/com/google/android/exoplayer2/trackselection/MappingTrackSelectorTest.java
View file @
d287e13d
...
...
@@ -75,9 +75,7 @@ public final class MappingTrackSelectorTest {
/* selectionFlags= */
0
,
/* language= */
null
));
private
static
final
TrackGroup
METADATA_TRACK_GROUP
=
new
TrackGroup
(
Format
.
createSampleFormat
(
"metadata"
,
MimeTypes
.
APPLICATION_ID3
,
/* subsampleOffsetUs= */
0
));
new
TrackGroup
(
Format
.
createSampleFormat
(
"metadata"
,
MimeTypes
.
APPLICATION_ID3
));
private
static
final
Timeline
TIMELINE
=
new
FakeTimeline
(
/* windowCount= */
1
);
...
...
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DashMediaPeriod.java
View file @
d287e13d
...
...
@@ -640,8 +640,8 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
eventMessageTrackGroupIndex
,
cea608TrackGroupIndex
);
if
(
eventMessageTrackGroupIndex
!=
C
.
INDEX_UNSET
)
{
Format
format
=
Format
.
createSampleFormat
(
firstAdaptationSet
.
id
+
":emsg"
,
MimeTypes
.
APPLICATION_EMSG
,
null
,
Format
.
NO_VALUE
,
null
);
Format
format
=
Format
.
createSampleFormat
(
firstAdaptationSet
.
id
+
":emsg"
,
MimeTypes
.
APPLICATION_EMSG
);
trackGroups
[
eventMessageTrackGroupIndex
]
=
new
TrackGroup
(
format
);
trackGroupInfos
[
eventMessageTrackGroupIndex
]
=
TrackGroupInfo
.
embeddedEmsgTrack
(
adaptationSetIndices
,
primaryTrackGroupIndex
);
...
...
@@ -659,8 +659,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
TrackGroup
[]
trackGroups
,
TrackGroupInfo
[]
trackGroupInfos
,
int
existingTrackGroupCount
)
{
for
(
int
i
=
0
;
i
<
eventStreams
.
size
();
i
++)
{
EventStream
eventStream
=
eventStreams
.
get
(
i
);
Format
format
=
Format
.
createSampleFormat
(
eventStream
.
id
(),
MimeTypes
.
APPLICATION_EMSG
,
null
,
Format
.
NO_VALUE
,
null
);
Format
format
=
Format
.
createSampleFormat
(
eventStream
.
id
(),
MimeTypes
.
APPLICATION_EMSG
);
trackGroups
[
existingTrackGroupCount
]
=
new
TrackGroup
(
format
);
trackGroupInfos
[
existingTrackGroupCount
++]
=
TrackGroupInfo
.
mpdEventTrack
(
i
);
}
...
...
library/dash/src/test/java/com/google/android/exoplayer2/source/dash/EventSampleStreamTest.java
View file @
d287e13d
...
...
@@ -37,8 +37,8 @@ public final class EventSampleStreamTest {
private
static
final
String
SCHEME_ID
=
"urn:test"
;
private
static
final
String
VALUE
=
"123"
;
private
static
final
Format
FORMAT
=
Format
.
createSampleFormat
(
"urn:test/123"
,
MimeTypes
.
APPLICATION_EMSG
,
null
,
Format
.
NO_VALUE
,
null
);
private
static
final
Format
FORMAT
=
Format
.
createSampleFormat
(
"urn:test/123"
,
MimeTypes
.
APPLICATION_EMSG
);
private
static
final
byte
[]
MESSAGE_DATA
=
new
byte
[]
{
1
,
2
,
3
,
4
};
private
static
final
long
DURATION_MS
=
3000
;
private
static
final
long
TIME_SCALE
=
1000
;
...
...
library/dash/src/test/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestTest.java
View file @
d287e13d
...
...
@@ -35,10 +35,11 @@ public class DashManifestTest {
private
static
final
UtcTimingElement
DUMMY_UTC_TIMING
=
new
UtcTimingElement
(
""
,
""
);
private
static
final
SingleSegmentBase
DUMMY_SEGMENT_BASE
=
new
SingleSegmentBase
();
private
static
final
Format
DUMMY_FORMAT
=
Format
.
createSampleFormat
(
""
,
""
,
0
);
private
static
final
Format
DUMMY_FORMAT
=
Format
.
createSampleFormat
(
/* id= */
""
,
/* sampleMimeType= */
""
);
@Test
public
void
testCopy
()
throws
Exception
{
public
void
testCopy
()
{
Representation
[][][]
representations
=
newRepresentations
(
3
,
2
,
3
);
DashManifest
sourceManifest
=
newDashManifest
(
...
...
@@ -97,7 +98,7 @@ public class DashManifestTest {
}
@Test
public
void
testCopySameAdaptationIndexButDifferentPeriod
()
throws
Exception
{
public
void
testCopySameAdaptationIndexButDifferentPeriod
()
{
Representation
[][][]
representations
=
newRepresentations
(
2
,
1
,
1
);
DashManifest
sourceManifest
=
newDashManifest
(
...
...
@@ -117,7 +118,7 @@ public class DashManifestTest {
}
@Test
public
void
testCopySkipPeriod
()
throws
Exception
{
public
void
testCopySkipPeriod
()
{
Representation
[][][]
representations
=
newRepresentations
(
3
,
2
,
3
);
DashManifest
sourceManifest
=
newDashManifest
(
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java
View file @
d287e13d
...
...
@@ -813,8 +813,9 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
parseTextSampleEntry
(
stsd
,
childAtomType
,
childStartPosition
,
childAtomSize
,
trackId
,
language
,
out
);
}
else
if
(
childAtomType
==
Atom
.
TYPE_camm
)
{
out
.
format
=
Format
.
createSampleFormat
(
Integer
.
toString
(
trackId
),
MimeTypes
.
APPLICATION_CAMERA_MOTION
,
null
,
Format
.
NO_VALUE
,
null
);
out
.
format
=
Format
.
createSampleFormat
(
Integer
.
toString
(
trackId
),
MimeTypes
.
APPLICATION_CAMERA_MOTION
);
}
stsd
.
setPosition
(
childStartPosition
+
childAtomSize
);
}
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java
View file @
d287e13d
...
...
@@ -114,7 +114,7 @@ public class FragmentedMp4Extractor implements Extractor {
private
static
final
byte
[]
PIFF_SAMPLE_ENCRYPTION_BOX_EXTENDED_TYPE
=
new
byte
[]
{-
94
,
57
,
79
,
82
,
90
,
-
101
,
79
,
20
,
-
94
,
68
,
108
,
66
,
124
,
100
,
-
115
,
-
12
};
private
static
final
Format
EMSG_FORMAT
=
Format
.
createSampleFormat
(
null
,
MimeTypes
.
APPLICATION_EMSG
,
Format
.
OFFSET_SAMPLE_RELATIVE
);
Format
.
createSampleFormat
(
null
,
MimeTypes
.
APPLICATION_EMSG
);
// Parser states.
private
static
final
int
STATE_READING_ATOM_HEADER
=
0
;
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/AdtsReader.java
View file @
d287e13d
...
...
@@ -140,8 +140,8 @@ public final class AdtsReader implements ElementaryStreamReader {
if
(
exposeId3
)
{
idGenerator
.
generateNewId
();
id3Output
=
extractorOutput
.
track
(
idGenerator
.
getTrackId
(),
C
.
TRACK_TYPE_METADATA
);
id3Output
.
format
(
Format
.
createSampleFormat
(
idGenerator
.
getFormatId
(),
MimeTypes
.
APPLICATION_ID3
,
null
,
Format
.
NO_VALUE
,
null
));
id3Output
.
format
(
Format
.
createSampleFormat
(
idGenerator
.
getFormatId
(),
MimeTypes
.
APPLICATION_ID3
));
}
else
{
id3Output
=
new
DummyTrackOutput
();
}
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Id3Reader.java
View file @
d287e13d
...
...
@@ -61,8 +61,7 @@ public final class Id3Reader implements ElementaryStreamReader {
public
void
createTracks
(
ExtractorOutput
extractorOutput
,
TrackIdGenerator
idGenerator
)
{
idGenerator
.
generateNewId
();
output
=
extractorOutput
.
track
(
idGenerator
.
getTrackId
(),
C
.
TRACK_TYPE_METADATA
);
output
.
format
(
Format
.
createSampleFormat
(
idGenerator
.
getFormatId
(),
MimeTypes
.
APPLICATION_ID3
,
null
,
Format
.
NO_VALUE
,
null
));
output
.
format
(
Format
.
createSampleFormat
(
idGenerator
.
getFormatId
(),
MimeTypes
.
APPLICATION_ID3
));
}
@Override
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SpliceInfoSectionReader.java
View file @
d287e13d
...
...
@@ -42,8 +42,8 @@ public final class SpliceInfoSectionReader implements SectionPayloadReader {
this
.
timestampAdjuster
=
timestampAdjuster
;
idGenerator
.
generateNewId
();
output
=
extractorOutput
.
track
(
idGenerator
.
getTrackId
(),
C
.
TRACK_TYPE_METADATA
);
output
.
format
(
Format
.
createSampleFormat
(
idGenerator
.
getFormatId
(),
MimeTypes
.
APPLICATION_SCTE35
,
null
,
Format
.
NO_VALUE
,
null
));
output
.
format
(
Format
.
createSampleFormat
(
idGenerator
.
getFormatId
(),
MimeTypes
.
APPLICATION_SCTE35
));
}
@Override
...
...
@@ -54,8 +54,9 @@ public final class SpliceInfoSectionReader implements SectionPayloadReader {
// There is not enough information to initialize the timestamp adjuster.
return
;
}
output
.
format
(
Format
.
createSampleFormat
(
null
,
MimeTypes
.
APPLICATION_SCTE35
,
timestampAdjuster
.
getTimestampOffsetUs
()));
output
.
format
(
Format
.
createSampleFormat
(
null
,
MimeTypes
.
APPLICATION_SCTE35
)
.
copyWithSubsampleOffsetUs
(
timestampAdjuster
.
getTimestampOffsetUs
()));
formatDeclared
=
true
;
}
int
sampleSize
=
sectionData
.
bytesLeft
();
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaPeriod.java
View file @
d287e13d
...
...
@@ -659,13 +659,7 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsSampleStreamWrapper
}
TrackGroup
id3TrackGroup
=
new
TrackGroup
(
Format
.
createSampleFormat
(
/* id= */
"ID3"
,
MimeTypes
.
APPLICATION_ID3
,
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
/* drmInitData= */
null
));
new
TrackGroup
(
Format
.
createSampleFormat
(
/* id= */
"ID3"
,
MimeTypes
.
APPLICATION_ID3
));
muxedTrackGroups
.
add
(
id3TrackGroup
);
sampleStreamWrapper
.
prepareWithMasterPlaylistInfo
(
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/HlsSampleStreamWrapper.java
View file @
d287e13d
...
...
@@ -1401,11 +1401,9 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
// TODO(ibaker): Create a Formats util class with common constants like this.
private
static
final
Format
ID3_FORMAT
=
Format
.
createSampleFormat
(
/* id= */
null
,
MimeTypes
.
APPLICATION_ID3
,
Format
.
OFFSET_SAMPLE_RELATIVE
);
Format
.
createSampleFormat
(
/* id= */
null
,
MimeTypes
.
APPLICATION_ID3
);
private
static
final
Format
EMSG_FORMAT
=
Format
.
createSampleFormat
(
/* id= */
null
,
MimeTypes
.
APPLICATION_EMSG
,
Format
.
OFFSET_SAMPLE_RELATIVE
);
Format
.
createSampleFormat
(
/* id= */
null
,
MimeTypes
.
APPLICATION_EMSG
);
private
final
EventMessageDecoder
emsgDecoder
;
private
final
TrackOutput
delegate
;
...
...
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