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
c6a6e0d6
authored
Feb 27, 2020
by
olly
Committed by
kim-vde
Feb 27, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Migrate various call sites to Format.Builder
PiperOrigin-RevId: 297562889
parent
bfd8474e
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
80 additions
and
151 deletions
demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastUtils.java
extensions/ffmpeg/src/main/java/com/google/android/exoplayer2/ext/ffmpeg/FfmpegAudioRenderer.java
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/LibflacAudioRenderer.java
extensions/opus/src/main/java/com/google/android/exoplayer2/ext/opus/LibopusAudioRenderer.java
library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DashUtilTest.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylistParser.java
library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParser.java
library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaPeriodTest.java
library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestTest.java
testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoPlayerTestRunner.java
testutils/src/test/java/com/google/android/exoplayer2/testutil/FakeAdaptiveDataSetTest.java
demos/main/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
View file @
c6a6e0d6
...
@@ -442,11 +442,11 @@ public class PlayerActivity extends AppCompatActivity
...
@@ -442,11 +442,11 @@ public class PlayerActivity extends AppCompatActivity
return
Collections
.
emptyList
();
return
Collections
.
emptyList
();
}
}
Format
subtitleFormat
=
Format
subtitleFormat
=
Format
.
createTextSampleFormat
(
new
Format
.
Builder
()
/* id= */
null
,
.
setSampleMimeType
(
subtitleInfo
.
mimeType
)
subtitleInfo
.
mimeType
,
.
setSelectionFlags
(
C
.
SELECTION_FLAG_DEFAULT
)
C
.
SELECTION_FLAG_DEFAULT
,
.
setLanguage
(
subtitleInfo
.
language
)
subtitleInfo
.
language
);
.
build
(
);
MediaSource
subtitleMediaSource
=
MediaSource
subtitleMediaSource
=
new
SingleSampleMediaSource
.
Factory
(
dataSourceFactory
)
new
SingleSampleMediaSource
.
Factory
(
dataSourceFactory
)
.
createMediaSource
(
subtitleInfo
.
uri
,
subtitleFormat
,
C
.
TIME_UNSET
);
.
createMediaSource
(
subtitleInfo
.
uri
,
subtitleFormat
,
C
.
TIME_UNSET
);
...
...
extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastUtils.java
View file @
c6a6e0d6
...
@@ -104,16 +104,11 @@ import com.google.android.gms.cast.MediaTrack;
...
@@ -104,16 +104,11 @@ import com.google.android.gms.cast.MediaTrack;
* @return The equivalent {@link Format}.
* @return The equivalent {@link Format}.
*/
*/
public
static
Format
mediaTrackToFormat
(
MediaTrack
mediaTrack
)
{
public
static
Format
mediaTrackToFormat
(
MediaTrack
mediaTrack
)
{
return
Format
.
createContainerFormat
(
return
new
Format
.
Builder
()
mediaTrack
.
getContentId
(),
.
setId
(
mediaTrack
.
getContentId
())
/* label= */
null
,
.
setContainerMimeType
(
mediaTrack
.
getContentType
())
mediaTrack
.
getContentType
(),
.
setLanguage
(
mediaTrack
.
getLanguage
())
/* sampleMimeType= */
null
,
.
build
();
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
/* selectionFlags= */
0
,
/* roleFlags= */
0
,
mediaTrack
.
getLanguage
());
}
}
private
CastUtils
()
{}
private
CastUtils
()
{}
...
...
extensions/ffmpeg/src/main/java/com/google/android/exoplayer2/ext/ffmpeg/FfmpegAudioRenderer.java
View file @
c6a6e0d6
...
@@ -27,7 +27,6 @@ import com.google.android.exoplayer2.audio.SimpleDecoderAudioRenderer;
...
@@ -27,7 +27,6 @@ import com.google.android.exoplayer2.audio.SimpleDecoderAudioRenderer;
import
com.google.android.exoplayer2.drm.ExoMediaCrypto
;
import
com.google.android.exoplayer2.drm.ExoMediaCrypto
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
java.util.Collections
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
import
org.checkerframework.checker.nullness.qual.MonotonicNonNull
;
/**
/**
...
@@ -122,22 +121,12 @@ public final class FfmpegAudioRenderer extends SimpleDecoderAudioRenderer {
...
@@ -122,22 +121,12 @@ public final class FfmpegAudioRenderer extends SimpleDecoderAudioRenderer {
@Override
@Override
public
Format
getOutputFormat
()
{
public
Format
getOutputFormat
()
{
Assertions
.
checkNotNull
(
decoder
);
Assertions
.
checkNotNull
(
decoder
);
int
channelCount
=
decoder
.
getChannelCount
();
return
new
Format
.
Builder
()
int
sampleRate
=
decoder
.
getSampleRate
();
.
setSampleMimeType
(
MimeTypes
.
AUDIO_RAW
)
@C
.
PcmEncoding
int
encoding
=
decoder
.
getEncoding
();
.
setChannelCount
(
decoder
.
getChannelCount
())
return
Format
.
createAudioSampleFormat
(
.
setSampleRate
(
decoder
.
getSampleRate
())
/* id= */
null
,
.
setPcmEncoding
(
decoder
.
getEncoding
())
MimeTypes
.
AUDIO_RAW
,
.
build
();
/* codecs= */
null
,
Format
.
NO_VALUE
,
Format
.
NO_VALUE
,
channelCount
,
sampleRate
,
encoding
,
Collections
.
emptyList
(),
/* drmInitData= */
null
,
/* selectionFlags= */
0
,
/* language= */
null
);
}
}
private
boolean
isOutputSupported
(
Format
inputFormat
)
{
private
boolean
isOutputSupported
(
Format
inputFormat
)
{
...
...
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/LibflacAudioRenderer.java
View file @
c6a6e0d6
...
@@ -114,18 +114,11 @@ public final class LibflacAudioRenderer extends SimpleDecoderAudioRenderer {
...
@@ -114,18 +114,11 @@ public final class LibflacAudioRenderer extends SimpleDecoderAudioRenderer {
@Override
@Override
protected
Format
getOutputFormat
()
{
protected
Format
getOutputFormat
()
{
Assertions
.
checkNotNull
(
streamMetadata
);
Assertions
.
checkNotNull
(
streamMetadata
);
return
Format
.
createAudioSampleFormat
(
return
new
Format
.
Builder
()
/* id= */
null
,
.
setSampleMimeType
(
MimeTypes
.
AUDIO_RAW
)
MimeTypes
.
AUDIO_RAW
,
.
setChannelCount
(
streamMetadata
.
channels
)
/* codecs= */
null
,
.
setSampleRate
(
streamMetadata
.
sampleRate
)
/* bitrate= */
Format
.
NO_VALUE
,
.
setPcmEncoding
(
Util
.
getPcmEncoding
(
streamMetadata
.
bitsPerSample
))
/* maxInputSize= */
Format
.
NO_VALUE
,
.
build
();
streamMetadata
.
channels
,
streamMetadata
.
sampleRate
,
Util
.
getPcmEncoding
(
streamMetadata
.
bitsPerSample
),
/* initializationData= */
null
,
/* drmInitData= */
null
,
/* selectionFlags= */
0
,
/* language= */
null
);
}
}
}
}
extensions/opus/src/main/java/com/google/android/exoplayer2/ext/opus/LibopusAudioRenderer.java
View file @
c6a6e0d6
...
@@ -90,18 +90,11 @@ public class LibopusAudioRenderer extends SimpleDecoderAudioRenderer {
...
@@ -90,18 +90,11 @@ public class LibopusAudioRenderer extends SimpleDecoderAudioRenderer {
@Override
@Override
protected
Format
getOutputFormat
()
{
protected
Format
getOutputFormat
()
{
return
Format
.
createAudioSampleFormat
(
return
new
Format
.
Builder
()
/* id= */
null
,
.
setSampleMimeType
(
MimeTypes
.
AUDIO_RAW
)
MimeTypes
.
AUDIO_RAW
,
.
setChannelCount
(
channelCount
)
/* codecs= */
null
,
.
setSampleRate
(
sampleRate
)
Format
.
NO_VALUE
,
.
setPcmEncoding
(
C
.
ENCODING_PCM_16BIT
)
Format
.
NO_VALUE
,
.
build
();
channelCount
,
sampleRate
,
C
.
ENCODING_PCM_16BIT
,
/* initializationData= */
null
,
/* drmInitData= */
null
,
/* selectionFlags= */
0
,
/* language= */
null
);
}
}
}
}
library/dash/src/test/java/com/google/android/exoplayer2/source/dash/DashUtilTest.java
View file @
c6a6e0d6
...
@@ -77,10 +77,8 @@ public final class DashUtilTest {
...
@@ -77,10 +77,8 @@ public final class DashUtilTest {
new
Format
.
Builder
()
new
Format
.
Builder
()
.
setContainerMimeType
(
MimeTypes
.
VIDEO_MP4
)
.
setContainerMimeType
(
MimeTypes
.
VIDEO_MP4
)
.
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
)
.
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
)
.
setDrmInitData
(
drmInitData
)
.
build
();
.
build
();
if
(
drmInitData
!=
null
)
{
format
=
format
.
copyWithDrmInitData
(
drmInitData
);
}
return
Representation
.
newInstance
(
0
,
format
,
""
,
new
SingleSegmentBase
());
return
Representation
.
newInstance
(
0
,
format
,
""
,
new
SingleSegmentBase
());
}
}
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java
View file @
c6a6e0d6
...
@@ -1504,7 +1504,9 @@ public class FragmentedMp4Extractor implements Extractor {
...
@@ -1504,7 +1504,9 @@ public class FragmentedMp4Extractor implements Extractor {
TrackEncryptionBox
encryptionBox
=
TrackEncryptionBox
encryptionBox
=
track
.
getSampleDescriptionEncryptionBox
(
fragment
.
header
.
sampleDescriptionIndex
);
track
.
getSampleDescriptionEncryptionBox
(
fragment
.
header
.
sampleDescriptionIndex
);
@Nullable
String
schemeType
=
encryptionBox
!=
null
?
encryptionBox
.
schemeType
:
null
;
@Nullable
String
schemeType
=
encryptionBox
!=
null
?
encryptionBox
.
schemeType
:
null
;
output
.
format
(
track
.
format
.
copyWithDrmInitData
(
drmInitData
.
copyWithSchemeType
(
schemeType
)));
DrmInitData
updatedDrmInitData
=
drmInitData
.
copyWithSchemeType
(
schemeType
);
Format
format
=
track
.
format
.
buildUpon
().
setDrmInitData
(
updatedDrmInitData
).
build
();
output
.
format
(
format
);
}
}
/** Resets the current fragment and sample indices. */
/** Resets the current fragment and sample indices. */
...
...
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylistParser.java
View file @
c6a6e0d6
...
@@ -385,9 +385,9 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
...
@@ -385,9 +385,9 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
/* groupId= */
null
,
/* groupId= */
null
,
/* name= */
null
,
/* name= */
null
,
Assertions
.
checkNotNull
(
urlToVariantInfos
.
get
(
variant
.
url
)));
Assertions
.
checkNotNull
(
urlToVariantInfos
.
get
(
variant
.
url
)));
deduplicatedVariants
.
add
(
Metadata
metadata
=
new
Metadata
(
hlsMetadataEntry
);
variant
.
copyWithFormat
(
Format
format
=
variant
.
format
.
buildUpon
().
setMetadata
(
metadata
).
build
();
variant
.
format
.
copyWithMetadata
(
new
Metadata
(
hlsMetadataEntry
))
));
deduplicatedVariants
.
add
(
variant
.
copyWithFormat
(
format
));
}
}
}
}
...
...
library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParser.java
View file @
c6a6e0d6
...
@@ -386,7 +386,7 @@ public class SsManifestParser implements ParsingLoadable.Parser<SsManifest> {
...
@@ -386,7 +386,7 @@ public class SsManifestParser implements ParsingLoadable.Parser<SsManifest> {
if
(
type
==
C
.
TRACK_TYPE_VIDEO
||
type
==
C
.
TRACK_TYPE_AUDIO
)
{
if
(
type
==
C
.
TRACK_TYPE_VIDEO
||
type
==
C
.
TRACK_TYPE_AUDIO
)
{
Format
[]
formats
=
streamElement
.
formats
;
Format
[]
formats
=
streamElement
.
formats
;
for
(
int
i
=
0
;
i
<
formats
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
formats
.
length
;
i
++)
{
formats
[
i
]
=
formats
[
i
].
copyWithDrmInitData
(
drmInitData
);
formats
[
i
]
=
formats
[
i
].
buildUpon
().
setDrmInitData
(
drmInitData
).
build
(
);
}
}
}
}
}
}
...
...
library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/SsMediaPeriodTest.java
View file @
c6a6e0d6
...
@@ -82,41 +82,26 @@ public class SsMediaPeriodTest {
...
@@ -82,41 +82,26 @@ public class SsMediaPeriodTest {
}
}
private
static
Format
createVideoFormat
(
int
bitrate
)
{
private
static
Format
createVideoFormat
(
int
bitrate
)
{
return
Format
.
createContainerFormat
(
return
new
Format
.
Builder
()
/* id= */
null
,
.
setContainerMimeType
(
MimeTypes
.
VIDEO_MP4
)
/* label= */
null
,
.
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
)
MimeTypes
.
VIDEO_MP4
,
.
setAverageBitrate
(
bitrate
)
MimeTypes
.
VIDEO_H264
,
.
build
();
/* codecs= */
null
,
bitrate
,
/* selectionFlags= */
0
,
/* roleFlags= */
0
,
/* language= */
null
);
}
}
private
static
Format
createAudioFormat
(
int
bitrate
)
{
private
static
Format
createAudioFormat
(
int
bitrate
)
{
return
Format
.
createContainerFormat
(
return
new
Format
.
Builder
()
/* id= */
null
,
.
setContainerMimeType
(
MimeTypes
.
AUDIO_MP4
)
/* label= */
null
,
.
setSampleMimeType
(
MimeTypes
.
AUDIO_AAC
)
MimeTypes
.
AUDIO_MP4
,
.
setAverageBitrate
(
bitrate
)
MimeTypes
.
AUDIO_AAC
,
.
build
();
/* codecs= */
null
,
bitrate
,
/* selectionFlags= */
0
,
/* roleFlags= */
0
,
/* language= */
null
);
}
}
private
static
Format
createTextFormat
(
String
language
)
{
private
static
Format
createTextFormat
(
String
language
)
{
return
Format
.
createContainerFormat
(
return
new
Format
.
Builder
()
/* id= */
null
,
.
setContainerMimeType
(
MimeTypes
.
APPLICATION_MP4
)
/* label= */
null
,
.
setSampleMimeType
(
MimeTypes
.
TEXT_VTT
)
MimeTypes
.
APPLICATION_MP4
,
.
setLanguage
(
language
)
MimeTypes
.
TEXT_VTT
,
.
build
();
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
/* selectionFlags= */
0
,
/* roleFlags= */
0
,
language
);
}
}
}
}
library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestTest.java
View file @
c6a6e0d6
...
@@ -114,15 +114,10 @@ public class SsManifestTest {
...
@@ -114,15 +114,10 @@ public class SsManifestTest {
}
}
private
static
Format
newFormat
(
String
id
)
{
private
static
Format
newFormat
(
String
id
)
{
return
Format
.
createContainerFormat
(
return
new
Format
.
Builder
()
id
,
.
setId
(
id
)
/* label= */
null
,
.
setContainerMimeType
(
MimeTypes
.
VIDEO_MP4
)
MimeTypes
.
VIDEO_MP4
,
.
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
)
MimeTypes
.
VIDEO_H264
,
.
build
();
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
/* selectionFlags= */
0
,
/* roleFlags= */
0
,
/* language= */
null
);
}
}
}
}
testutils/src/main/java/com/google/android/exoplayer2/testutil/ExoPlayerTestRunner.java
View file @
c6a6e0d6
...
@@ -62,32 +62,21 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
...
@@ -62,32 +62,21 @@ public final class ExoPlayerTestRunner implements Player.EventListener, ActionSc
/** A generic video {@link Format} which can be used to set up media sources and renderers. */
/** A generic video {@link Format} which can be used to set up media sources and renderers. */
public
static
final
Format
VIDEO_FORMAT
=
public
static
final
Format
VIDEO_FORMAT
=
Format
.
createVideoSampleFormat
(
new
Format
.
Builder
()
/* id= */
null
,
.
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
)
/* sampleMimeType= */
MimeTypes
.
VIDEO_H264
,
.
setAverageBitrate
(
800_000
)
/* codecs= */
null
,
.
setWidth
(
1280
)
/* bitrate= */
800_000
,
.
setHeight
(
720
)
/* maxInputSize= */
Format
.
NO_VALUE
,
.
build
();
/* width= */
1280
,
/* height= */
720
,
/* frameRate= */
Format
.
NO_VALUE
,
/* initializationData= */
null
,
/* drmInitData= */
null
);
/** A generic audio {@link Format} which can be used to set up media sources and renderers. */
/** A generic audio {@link Format} which can be used to set up media sources and renderers. */
public
static
final
Format
AUDIO_FORMAT
=
public
static
final
Format
AUDIO_FORMAT
=
Format
.
createAudioSampleFormat
(
new
Format
.
Builder
()
/* id= */
null
,
.
setSampleMimeType
(
MimeTypes
.
AUDIO_AAC
)
/* sampleMimeType= */
MimeTypes
.
AUDIO_AAC
,
.
setAverageBitrate
(
100_000
)
/* codecs= */
null
,
.
setChannelCount
(
2
)
/* bitrate= */
100_000
,
.
setSampleRate
(
44100
)
/* maxInputSize= */
Format
.
NO_VALUE
,
.
build
();
/* channelCount= */
2
,
/* sampleRate= */
44100
,
/* initializationData=*/
null
,
/* drmInitData= */
null
,
/* selectionFlags= */
0
,
/* language= */
null
);
private
Clock
clock
;
private
Clock
clock
;
private
Timeline
timeline
;
private
Timeline
timeline
;
...
...
testutils/src/test/java/com/google/android/exoplayer2/testutil/FakeAdaptiveDataSetTest.java
View file @
c6a6e0d6
...
@@ -34,28 +34,18 @@ import org.junit.runner.RunWith;
...
@@ -34,28 +34,18 @@ import org.junit.runner.RunWith;
public
final
class
FakeAdaptiveDataSetTest
{
public
final
class
FakeAdaptiveDataSetTest
{
private
static
final
Format
[]
TEST_FORMATS
=
{
private
static
final
Format
[]
TEST_FORMATS
=
{
Format
.
createVideoSampleFormat
(
new
Format
.
Builder
()
null
,
.
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
)
MimeTypes
.
VIDEO_H264
,
.
setAverageBitrate
(
1_000_000
)
null
,
.
setWidth
(
1280
)
1000000
,
.
setHeight
(
720
)
Format
.
NO_VALUE
,
.
build
(),
1280
,
new
Format
.
Builder
()
720
,
.
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
)
Format
.
NO_VALUE
,
.
setAverageBitrate
(
300_000
)
null
,
.
setWidth
(
640
)
null
),
.
setHeight
(
360
)
Format
.
createVideoSampleFormat
(
.
build
()
null
,
MimeTypes
.
VIDEO_H264
,
null
,
300000
,
Format
.
NO_VALUE
,
640
,
360
,
Format
.
NO_VALUE
,
null
,
null
)
};
};
private
static
final
TrackGroup
TRACK_GROUP
=
new
TrackGroup
(
TEST_FORMATS
);
private
static
final
TrackGroup
TRACK_GROUP
=
new
TrackGroup
(
TEST_FORMATS
);
...
...
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