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
67b29bbe
authored
Feb 28, 2020
by
olly
Committed by
Oliver Woodman
Feb 28, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Format.Builder: Finish migration
Issue: #5978 PiperOrigin-RevId: 297876336
parent
0649c7b9
Hide whitespace changes
Inline
Side-by-side
Showing
49 changed files
with
391 additions
and
465 deletions
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacExtractor.java
library/common/src/main/java/com/google/android/exoplayer2/Format.java
library/common/src/main/java/com/google/android/exoplayer2/audio/Ac3Util.java
library/common/src/main/java/com/google/android/exoplayer2/audio/Ac4Util.java
library/common/src/main/java/com/google/android/exoplayer2/audio/DtsUtil.java
library/common/src/main/java/com/google/android/exoplayer2/metadata/emsg/EventMessage.java
library/core/src/main/java/com/google/android/exoplayer2/BaseRenderer.java
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java
library/core/src/main/java/com/google/android/exoplayer2/source/SampleQueue.java
library/core/src/main/java/com/google/android/exoplayer2/source/SilenceMediaSource.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/offline/DownloadHelperTest.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/AdaptiveTrackSelectionTest.java
library/core/src/test/java/com/google/android/exoplayer2/video/SimpleDecoderVideoRendererTest.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/FlacStreamMetadata.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/amr/AmrExtractor.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/AudioTagPayloadReader.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/VideoTagPayloadReader.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.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/ogg/OpusReader.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/VorbisReader.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac3Reader.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac4Reader.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/DefaultTsPayloadReaderFactory.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/DvbSubtitleReader.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H262Reader.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H264Reader.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H265Reader.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/LatmReader.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/MpegAudioReader.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/main/java/com/google/android/exoplayer2/extractor/wav/WavExtractor.java
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4ExtractorTest.java
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/rawcc/RawCcExtractorTest.java
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ts/TsExtractorTest.java
testdata/src/test/assets/ogg/bear_vorbis.ogg.0.dump
testdata/src/test/assets/ogg/bear_vorbis.ogg.1.dump
testdata/src/test/assets/ogg/bear_vorbis.ogg.2.dump
testdata/src/test/assets/ogg/bear_vorbis.ogg.3.dump
testdata/src/test/assets/ogg/bear_vorbis.ogg.unklen.dump
extensions/flac/src/main/java/com/google/android/exoplayer2/ext/flac/FlacExtractor.java
View file @
67b29bbe
...
...
@@ -266,22 +266,16 @@ public final class FlacExtractor implements Extractor {
private
static
void
outputFormat
(
FlacStreamMetadata
streamMetadata
,
@Nullable
Metadata
metadata
,
TrackOutput
output
)
{
Format
mediaFormat
=
Format
.
createAudioSampleFormat
(
/* id= */
null
,
MimeTypes
.
AUDIO_RAW
,
/* codecs= */
null
,
streamMetadata
.
getDecodedBitrate
(),
streamMetadata
.
getMaxDecodedFrameSize
(),
streamMetadata
.
channels
,
streamMetadata
.
sampleRate
,
getPcmEncoding
(
streamMetadata
.
bitsPerSample
),
/* encoderDelay= */
0
,
/* encoderPadding= */
0
,
/* initializationData= */
null
,
/* drmInitData= */
null
,
/* selectionFlags= */
0
,
/* language= */
null
,
metadata
);
new
Format
.
Builder
()
.
setSampleMimeType
(
MimeTypes
.
AUDIO_RAW
)
.
setAverageBitrate
(
streamMetadata
.
getDecodedBitrate
())
.
setPeakBitrate
(
streamMetadata
.
getDecodedBitrate
())
.
setMaxInputSize
(
streamMetadata
.
getMaxDecodedFrameSize
())
.
setChannelCount
(
streamMetadata
.
channels
)
.
setSampleRate
(
streamMetadata
.
sampleRate
)
.
setPcmEncoding
(
getPcmEncoding
(
streamMetadata
.
bitsPerSample
))
.
setMetadata
(
metadata
)
.
build
();
output
.
format
(
mediaFormat
);
}
...
...
library/common/src/main/java/com/google/android/exoplayer2/Format.java
View file @
67b29bbe
...
...
@@ -1473,6 +1473,7 @@ public final class Format implements Parcelable {
return
buildUpon
().
setWidth
(
width
).
setHeight
(
height
).
build
();
}
/** Returns a copy of this format with the specified {@link #exoMediaCryptoType}. */
public
Format
copyWithExoMediaCryptoType
(
@Nullable
Class
<?
extends
ExoMediaCrypto
>
exoMediaCryptoType
)
{
return
buildUpon
().
setExoMediaCryptoType
(
exoMediaCryptoType
).
build
();
...
...
library/common/src/main/java/com/google/android/exoplayer2/audio/Ac3Util.java
View file @
67b29bbe
...
...
@@ -163,18 +163,14 @@ public final class Ac3Util {
if
((
nextByte
&
0x04
)
!=
0
)
{
// lfeon
channelCount
++;
}
return
Format
.
createAudioSampleFormat
(
trackId
,
MimeTypes
.
AUDIO_AC3
,
/* codecs= */
null
,
Format
.
NO_VALUE
,
Format
.
NO_VALUE
,
channelCount
,
sampleRate
,
/* initializationData= */
null
,
drmInitData
,
/* selectionFlags= */
0
,
language
);
return
new
Format
.
Builder
()
.
setId
(
trackId
)
.
setSampleMimeType
(
MimeTypes
.
AUDIO_AC3
)
.
setChannelCount
(
channelCount
)
.
setSampleRate
(
sampleRate
)
.
setDrmInitData
(
drmInitData
)
.
setLanguage
(
language
)
.
build
();
}
/**
...
...
@@ -218,18 +214,14 @@ public final class Ac3Util {
mimeType
=
MimeTypes
.
AUDIO_E_AC3_JOC
;
}
}
return
Format
.
createAudioSampleFormat
(
trackId
,
mimeType
,
/* codecs= */
null
,
Format
.
NO_VALUE
,
Format
.
NO_VALUE
,
channelCount
,
sampleRate
,
/* initializationData= */
null
,
drmInitData
,
/* selectionFlags= */
0
,
language
);
return
new
Format
.
Builder
()
.
setId
(
trackId
)
.
setSampleMimeType
(
mimeType
)
.
setChannelCount
(
channelCount
)
.
setSampleRate
(
sampleRate
)
.
setDrmInitData
(
drmInitData
)
.
setLanguage
(
language
)
.
build
();
}
/**
...
...
library/common/src/main/java/com/google/android/exoplayer2/audio/Ac4Util.java
View file @
67b29bbe
...
...
@@ -104,18 +104,14 @@ public final class Ac4Util {
ParsableByteArray
data
,
String
trackId
,
String
language
,
@Nullable
DrmInitData
drmInitData
)
{
data
.
skipBytes
(
1
);
// ac4_dsi_version, bitstream_version[0:5]
int
sampleRate
=
((
data
.
readUnsignedByte
()
&
0x20
)
>>
5
==
1
)
?
48000
:
44100
;
return
Format
.
createAudioSampleFormat
(
trackId
,
MimeTypes
.
AUDIO_AC4
,
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
/* maxInputSize= */
Format
.
NO_VALUE
,
CHANNEL_COUNT_2
,
sampleRate
,
/* initializationData= */
null
,
drmInitData
,
/* selectionFlags= */
0
,
language
);
return
new
Format
.
Builder
()
.
setId
(
trackId
)
.
setSampleMimeType
(
MimeTypes
.
AUDIO_AC4
)
.
setChannelCount
(
CHANNEL_COUNT_2
)
.
setSampleRate
(
sampleRate
)
.
setDrmInitData
(
drmInitData
)
.
setLanguage
(
language
)
.
build
();
}
/**
...
...
library/common/src/main/java/com/google/android/exoplayer2/audio/DtsUtil.java
View file @
67b29bbe
...
...
@@ -96,8 +96,15 @@ public final class DtsUtil {
:
TWICE_BITRATE_KBPS_BY_RATE
[
rate
]
*
1000
/
2
;
frameBits
.
skipBits
(
10
);
// MIX, DYNF, TIMEF, AUXF, HDCD, EXT_AUDIO_ID, EXT_AUDIO, ASPF
channelCount
+=
frameBits
.
readBits
(
2
)
>
0
?
1
:
0
;
// LFF
return
Format
.
createAudioSampleFormat
(
trackId
,
MimeTypes
.
AUDIO_DTS
,
null
,
bitrate
,
Format
.
NO_VALUE
,
channelCount
,
sampleRate
,
null
,
drmInitData
,
0
,
language
);
return
new
Format
.
Builder
()
.
setId
(
trackId
)
.
setSampleMimeType
(
MimeTypes
.
AUDIO_DTS
)
.
setAverageBitrate
(
bitrate
)
.
setChannelCount
(
channelCount
)
.
setSampleRate
(
sampleRate
)
.
setDrmInitData
(
drmInitData
)
.
setLanguage
(
language
)
.
build
();
}
/**
...
...
library/common/src/main/java/com/google/android/exoplayer2/metadata/emsg/EventMessage.java
View file @
67b29bbe
...
...
@@ -50,9 +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
);
new
Format
.
Builder
().
setSampleMimeType
(
MimeTypes
.
APPLICATION_ID3
).
build
(
);
private
static
final
Format
SCTE35_FORMAT
=
Format
.
createSampleFormat
(
/* id= */
null
,
MimeTypes
.
APPLICATION_SCTE35
);
new
Format
.
Builder
().
setSampleMimeType
(
MimeTypes
.
APPLICATION_SCTE35
).
build
(
);
/** The message scheme. */
public
final
String
schemeIdUri
;
...
...
library/core/src/main/java/com/google/android/exoplayer2/BaseRenderer.java
View file @
67b29bbe
...
...
@@ -361,7 +361,11 @@ public abstract class BaseRenderer implements Renderer, RendererCapabilities {
}
else
if
(
result
==
C
.
RESULT_FORMAT_READ
)
{
Format
format
=
formatHolder
.
format
;
if
(
format
.
subsampleOffsetUs
!=
Format
.
OFFSET_SAMPLE_RELATIVE
)
{
format
=
format
.
copyWithSubsampleOffsetUs
(
format
.
subsampleOffsetUs
+
streamOffsetUs
);
format
=
format
.
buildUpon
()
.
setSubsampleOffsetUs
(
format
.
subsampleOffsetUs
+
streamOffsetUs
)
.
build
();
formatHolder
.
format
=
format
;
}
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/ProgressiveMediaPeriod.java
View file @
67b29bbe
...
...
@@ -91,7 +91,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
private
static
final
Map
<
String
,
String
>
ICY_METADATA_HEADERS
=
createIcyMetadataHeaders
();
private
static
final
Format
ICY_FORMAT
=
Format
.
createSampleFormat
(
"icy"
,
MimeTypes
.
APPLICATION_ICY
);
new
Format
.
Builder
().
setId
(
"icy"
).
setSampleMimeType
(
MimeTypes
.
APPLICATION_ICY
).
build
(
);
private
final
Uri
uri
;
private
final
DataSource
dataSource
;
...
...
@@ -716,20 +716,21 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
boolean
[]
trackIsAudioVideoFlags
=
new
boolean
[
trackCount
];
for
(
int
i
=
0
;
i
<
trackCount
;
i
++)
{
Format
trackFormat
=
Assertions
.
checkNotNull
(
sampleQueues
[
i
].
getUpstreamFormat
());
String
mimeType
=
trackFormat
.
sampleMimeType
;
@Nullable
String
mimeType
=
trackFormat
.
sampleMimeType
;
boolean
isAudio
=
MimeTypes
.
isAudio
(
mimeType
);
boolean
isAudioVideo
=
isAudio
||
MimeTypes
.
isVideo
(
mimeType
);
trackIsAudioVideoFlags
[
i
]
=
isAudioVideo
;
haveAudioVideoTracks
|=
isAudioVideo
;
IcyHeaders
icyHeaders
=
this
.
icyHeaders
;
@Nullable
IcyHeaders
icyHeaders
=
this
.
icyHeaders
;
if
(
icyHeaders
!=
null
)
{
if
(
isAudio
||
sampleQueueTrackIds
[
i
].
isIcyTrack
)
{
Metadata
metadata
=
trackFormat
.
metadata
;
trackFormat
=
trackFormat
.
copyWithMetadata
(
metadata
==
null
?
new
Metadata
(
icyHeaders
)
:
metadata
.
copyWithAppendedEntries
(
icyHeaders
));
@Nullable
Metadata
metadata
=
trackFormat
.
metadata
;
if
(
metadata
==
null
)
{
metadata
=
new
Metadata
(
icyHeaders
);
}
else
{
metadata
=
metadata
.
copyWithAppendedEntries
(
icyHeaders
);
}
trackFormat
=
trackFormat
.
buildUpon
().
setMetadata
(
metadata
).
build
();
}
// Update the track format with the bitrate from the ICY header only if it declares neither
// an average or peak bitrate of its own.
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/SampleQueue.java
View file @
67b29bbe
...
...
@@ -521,7 +521,11 @@ public class SampleQueue implements TrackOutput {
@CallSuper
protected
Format
getAdjustedUpstreamFormat
(
Format
format
)
{
if
(
sampleOffsetUs
!=
0
&&
format
.
subsampleOffsetUs
!=
Format
.
OFFSET_SAMPLE_RELATIVE
)
{
format
=
format
.
copyWithSubsampleOffsetUs
(
format
.
subsampleOffsetUs
+
sampleOffsetUs
);
format
=
format
.
buildUpon
()
.
setSubsampleOffsetUs
(
format
.
subsampleOffsetUs
+
sampleOffsetUs
)
.
build
();
}
return
format
;
}
...
...
library/core/src/main/java/com/google/android/exoplayer2/source/SilenceMediaSource.java
View file @
67b29bbe
...
...
@@ -34,24 +34,17 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
public
final
class
SilenceMediaSource
extends
BaseMediaSource
{
private
static
final
int
SAMPLE_RATE_HZ
=
44100
;
@C
.
PcmEncoding
private
static
final
int
ENCODING
=
C
.
ENCODING_PCM_16BIT
;
@C
.
PcmEncoding
private
static
final
int
PCM_
ENCODING
=
C
.
ENCODING_PCM_16BIT
;
private
static
final
int
CHANNEL_COUNT
=
2
;
private
static
final
Format
FORMAT
=
Format
.
createAudioSampleFormat
(
/* id=*/
null
,
MimeTypes
.
AUDIO_RAW
,
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
/* maxInputSize= */
Format
.
NO_VALUE
,
CHANNEL_COUNT
,
SAMPLE_RATE_HZ
,
ENCODING
,
/* initializationData= */
null
,
/* drmInitData= */
null
,
/* selectionFlags= */
0
,
/* language= */
null
);
new
Format
.
Builder
()
.
setSampleMimeType
(
MimeTypes
.
AUDIO_RAW
)
.
setChannelCount
(
CHANNEL_COUNT
)
.
setSampleRate
(
SAMPLE_RATE_HZ
)
.
setPcmEncoding
(
PCM_ENCODING
)
.
build
();
private
static
final
byte
[]
SILENCE_SAMPLE
=
new
byte
[
Util
.
getPcmFrameSize
(
ENCODING
,
CHANNEL_COUNT
)
*
1024
];
new
byte
[
Util
.
getPcmFrameSize
(
PCM_
ENCODING
,
CHANNEL_COUNT
)
*
1024
];
private
final
long
durationUs
;
...
...
@@ -243,11 +236,11 @@ public final class SilenceMediaSource extends BaseMediaSource {
private
static
long
getAudioByteCount
(
long
durationUs
)
{
long
audioSampleCount
=
durationUs
*
SAMPLE_RATE_HZ
/
C
.
MICROS_PER_SECOND
;
return
Util
.
getPcmFrameSize
(
ENCODING
,
CHANNEL_COUNT
)
*
audioSampleCount
;
return
Util
.
getPcmFrameSize
(
PCM_
ENCODING
,
CHANNEL_COUNT
)
*
audioSampleCount
;
}
private
static
long
getAudioPositionUs
(
long
bytes
)
{
long
audioSampleCount
=
bytes
/
Util
.
getPcmFrameSize
(
ENCODING
,
CHANNEL_COUNT
);
long
audioSampleCount
=
bytes
/
Util
.
getPcmFrameSize
(
PCM_
ENCODING
,
CHANNEL_COUNT
);
return
audioSampleCount
*
C
.
MICROS_PER_SECOND
/
SAMPLE_RATE_HZ
;
}
}
library/core/src/test/java/com/google/android/exoplayer2/audio/SimpleDecoderAudioRendererTest.java
View file @
67b29bbe
...
...
@@ -46,7 +46,8 @@ import org.robolectric.annotation.Config;
@RunWith
(
AndroidJUnit4
.
class
)
public
class
SimpleDecoderAudioRendererTest
{
private
static
final
Format
FORMAT
=
Format
.
createSampleFormat
(
null
,
MimeTypes
.
AUDIO_RAW
);
private
static
final
Format
FORMAT
=
new
Format
.
Builder
().
setSampleMimeType
(
MimeTypes
.
AUDIO_RAW
).
build
();
@Mock
private
AudioSink
mockAudioSink
;
private
SimpleDecoderAudioRenderer
audioRenderer
;
...
...
library/core/src/test/java/com/google/android/exoplayer2/metadata/MetadataRendererTest.java
View file @
67b29bbe
...
...
@@ -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
);
new
Format
.
Builder
().
setSampleMimeType
(
MimeTypes
.
APPLICATION_EMSG
).
build
(
);
private
final
EventMessageEncoder
eventMessageEncoder
=
new
EventMessageEncoder
();
...
...
library/core/src/test/java/com/google/android/exoplayer2/offline/DownloadHelperTest.java
View file @
67b29bbe
...
...
@@ -454,40 +454,25 @@ public class DownloadHelperTest {
}
private
static
Format
createVideoFormat
(
int
bitrate
)
{
return
Format
.
createVideoSampleFormat
(
/* id= */
null
,
/* sampleMimeType= */
MimeTypes
.
VIDEO_H264
,
/* codecs= */
null
,
/* bitrate= */
bitrate
,
/* maxInputSize= */
Format
.
NO_VALUE
,
/* width= */
480
,
/* height= */
360
,
/* frameRate= */
Format
.
NO_VALUE
,
/* initializationData= */
null
,
/* drmInitData= */
null
);
return
new
Format
.
Builder
()
.
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
)
.
setAverageBitrate
(
bitrate
)
.
build
();
}
private
static
Format
createAudioFormat
(
String
language
)
{
return
Format
.
createAudioSampleFormat
(
/* id= */
null
,
/* sampleMimeType= */
MimeTypes
.
AUDIO_AAC
,
/* codecs= */
null
,
/* bitrate= */
48000
,
/* maxInputSize= */
Format
.
NO_VALUE
,
/* channelCount= */
2
,
/* sampleRate */
44100
,
/* initializationData= */
null
,
/* drmInitData= */
null
,
/* selectionFlags= */
C
.
SELECTION_FLAG_DEFAULT
,
/* language= */
language
);
return
new
Format
.
Builder
()
.
setSampleMimeType
(
MimeTypes
.
AUDIO_AAC
)
.
setLanguage
(
language
)
.
build
();
}
private
static
Format
createTextFormat
(
String
language
)
{
return
Format
.
createTextSampleFormat
(
/* id= */
null
,
/* sampleMimeType= */
MimeTypes
.
TEXT_VTT
,
/* selectionFlags= */
C
.
SELECTION_FLAG_DEFAULT
,
/* language= */
language
);
return
new
Format
.
Builder
()
.
setSampleMimeType
(
MimeTypes
.
TEXT_VTT
)
.
setSelectionFlags
(
C
.
SELECTION_FLAG_DEFAULT
)
.
setLanguage
(
language
)
.
build
(
);
}
private
static
void
assertSingleTrackSelectionEquals
(
...
...
library/core/src/test/java/com/google/android/exoplayer2/source/SampleQueueTest.java
View file @
67b29bbe
...
...
@@ -58,17 +58,12 @@ public final class SampleQueueTest {
private
static
final
int
ALLOCATION_SIZE
=
16
;
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_1
=
buildFormat
(
/* id= */
"1"
);
private
static
final
Format
FORMAT_2
=
buildFormat
(
/* id= */
"2"
);
private
static
final
Format
FORMAT_1_COPY
=
buildFormat
(
/* id= */
"1"
);
private
static
final
Format
FORMAT_SPLICED
=
buildFormat
(
/* id= */
"spliced"
);
private
static
final
Format
FORMAT_ENCRYPTED
=
Format
.
createSampleFormat
(
/* id= */
"encrypted"
,
"mimeType"
)
.
copyWithDrmInitData
(
new
DrmInitData
());
new
Format
.
Builder
().
setId
(
/* id= */
"encrypted"
).
setDrmInitData
(
new
DrmInitData
()).
build
();
private
static
final
byte
[]
DATA
=
TestUtil
.
buildTestData
(
ALLOCATION_SIZE
*
10
);
/*
...
...
@@ -914,7 +909,8 @@ public final class SampleQueueTest {
// We expect to read the format adjusted to account for the sample offset, followed by the final
// sample and then the end of stream.
assertReadFormat
(
/* formatRequired= */
false
,
FORMAT_2
.
copyWithSubsampleOffsetUs
(
sampleOffsetUs
));
/* formatRequired= */
false
,
FORMAT_2
.
buildUpon
().
setSubsampleOffsetUs
(
sampleOffsetUs
).
build
());
assertReadSample
(
unadjustedTimestampUs
+
sampleOffsetUs
,
/* isKeyFrame= */
false
,
...
...
@@ -932,12 +928,12 @@ public final class SampleQueueTest {
new
SampleQueue
(
allocator
,
mockDrmSessionManager
)
{
@Override
public
Format
getAdjustedUpstreamFormat
(
Format
format
)
{
return
super
.
getAdjustedUpstreamFormat
(
format
.
copyWithLabel
(
label
));
return
super
.
getAdjustedUpstreamFormat
(
copyWithLabel
(
format
,
label
));
}
};
writeFormat
(
FORMAT_1
);
assertReadFormat
(
/* formatRequired= */
false
,
FORMAT_1
.
copyWithLabel
(
label
));
assertReadFormat
(
/* formatRequired= */
false
,
copyWithLabel
(
FORMAT_1
,
label
));
assertReadEndOfStream
(
/* formatRequired= */
false
);
}
...
...
@@ -948,7 +944,7 @@ public final class SampleQueueTest {
new
SampleQueue
(
allocator
,
mockDrmSessionManager
)
{
@Override
public
Format
getAdjustedUpstreamFormat
(
Format
format
)
{
return
super
.
getAdjustedUpstreamFormat
(
format
.
copyWithLabel
(
label
.
get
()));
return
super
.
getAdjustedUpstreamFormat
(
copyWithLabel
(
format
,
label
.
get
()));
}
};
...
...
@@ -961,7 +957,7 @@ public final class SampleQueueTest {
writeSample
(
DATA
,
/* timestampUs= */
1
,
/* sampleFlags= */
0
);
assertReadFormat
(
/* formatRequired= */
false
,
FORMAT_1
.
copyWithLabel
(
"label1"
));
assertReadFormat
(
/* formatRequired= */
false
,
copyWithLabel
(
FORMAT_1
,
"label1"
));
assertReadSample
(
/* timeUs= */
0
,
/* isKeyFrame= */
true
,
...
...
@@ -969,7 +965,7 @@ public final class SampleQueueTest {
DATA
,
/* offset= */
0
,
DATA
.
length
);
assertReadFormat
(
/* formatRequired= */
false
,
FORMAT_1
.
copyWithLabel
(
"label2"
));
assertReadFormat
(
/* formatRequired= */
false
,
copyWithLabel
(
FORMAT_1
,
"label2"
));
assertReadSample
(
/* timeUs= */
1
,
/* isKeyFrame= */
false
,
...
...
@@ -1029,7 +1025,8 @@ public final class SampleQueueTest {
writeFormat
(
FORMAT_SPLICED
);
writeSample
(
DATA
,
spliceSampleTimeUs
,
C
.
BUFFER_FLAG_KEY_FRAME
);
assertReadTestData
(
null
,
0
,
4
,
sampleOffsetUs
);
assertReadFormat
(
false
,
FORMAT_SPLICED
.
copyWithSubsampleOffsetUs
(
sampleOffsetUs
));
assertReadFormat
(
false
,
FORMAT_SPLICED
.
buildUpon
().
setSubsampleOffsetUs
(
sampleOffsetUs
).
build
());
assertReadSample
(
spliceSampleTimeUs
+
sampleOffsetUs
,
true
,
/* isEncrypted= */
false
,
DATA
,
0
,
DATA
.
length
);
assertReadEndOfStream
(
false
);
...
...
@@ -1351,6 +1348,14 @@ public final class SampleQueueTest {
private
static
Format
adjustFormat
(
@Nullable
Format
format
,
long
sampleOffsetUs
)
{
return
format
==
null
||
sampleOffsetUs
==
0
?
format
:
format
.
copyWithSubsampleOffsetUs
(
sampleOffsetUs
);
:
format
.
buildUpon
().
setSubsampleOffsetUs
(
sampleOffsetUs
).
build
();
}
private
static
Format
buildFormat
(
String
id
)
{
return
new
Format
.
Builder
().
setId
(
id
).
setSubsampleOffsetUs
(
0
).
build
();
}
private
static
Format
copyWithLabel
(
Format
format
,
String
label
)
{
return
format
.
buildUpon
().
setLabel
(
label
).
build
();
}
}
library/core/src/test/java/com/google/android/exoplayer2/source/TrackGroupArrayTest.java
View file @
67b29bbe
...
...
@@ -30,9 +30,10 @@ public final class TrackGroupArrayTest {
@Test
public
void
parcelable
()
{
Format
format1
=
Format
.
createSampleFormat
(
"1"
,
MimeTypes
.
VIDEO_H264
);
Format
format2
=
Format
.
createSampleFormat
(
"2"
,
MimeTypes
.
AUDIO_AAC
);
Format
format3
=
Format
.
createSampleFormat
(
"3"
,
MimeTypes
.
VIDEO_H264
);
Format
.
Builder
formatBuilder
=
new
Format
.
Builder
();
Format
format1
=
formatBuilder
.
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
).
build
();
Format
format2
=
formatBuilder
.
setSampleMimeType
(
MimeTypes
.
AUDIO_AAC
).
build
();
Format
format3
=
formatBuilder
.
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
).
build
();
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 @
67b29bbe
...
...
@@ -30,8 +30,9 @@ public final class TrackGroupTest {
@Test
public
void
parcelable
()
{
Format
format1
=
Format
.
createSampleFormat
(
"1"
,
MimeTypes
.
VIDEO_H264
);
Format
format2
=
Format
.
createSampleFormat
(
"2"
,
MimeTypes
.
AUDIO_AAC
);
Format
.
Builder
formatBuilder
=
new
Format
.
Builder
();
Format
format1
=
formatBuilder
.
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
).
build
();
Format
format2
=
formatBuilder
.
setSampleMimeType
(
MimeTypes
.
AUDIO_AAC
).
build
();
TrackGroup
trackGroupToParcel
=
new
TrackGroup
(
format1
,
format2
);
...
...
library/core/src/test/java/com/google/android/exoplayer2/trackselection/AdaptiveTrackSelectionTest.java
View file @
67b29bbe
...
...
@@ -406,17 +406,11 @@ public final class AdaptiveTrackSelectionTest {
}
private
static
Format
videoFormat
(
int
bitrate
,
int
width
,
int
height
)
{
return
Format
.
createVideoSampleFormat
(
/* id= */
null
,
/* sampleMimeType= */
MimeTypes
.
VIDEO_H264
,
/* codecs= */
null
,
/* bitrate= */
bitrate
,
/* maxInputSize= */
Format
.
NO_VALUE
,
/* width= */
width
,
/* height= */
height
,
/* frameRate= */
Format
.
NO_VALUE
,
/* initializationData= */
null
,
/* drmInitData= */
null
);
return
new
Format
.
Builder
()
.
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
)
.
setAverageBitrate
(
bitrate
)
.
setWidth
(
width
)
.
setHeight
(
height
)
.
build
();
}
}
library/core/src/test/java/com/google/android/exoplayer2/video/SimpleDecoderVideoRendererTest.java
View file @
67b29bbe
...
...
@@ -49,20 +49,12 @@ import org.mockito.junit.MockitoRule;
public
final
class
SimpleDecoderVideoRendererTest
{
@Rule
public
final
MockitoRule
mockito
=
MockitoJUnit
.
rule
();
private
static
final
Format
BASIC_MP4_1080
=
Format
.
createVideoSampleFormat
(
/* id= */
null
,
/* sampleMimeType= */
MimeTypes
.
VIDEO_MP4
,
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
/* maxInputSize= */
Format
.
NO_VALUE
,
/* width= */
1920
,
/* height= */
1080
,
/* frameRate= */
Format
.
NO_VALUE
,
/* initializationData= */
null
,
/* rotationDegrees= */
0
,
/* pixelWidthHeightRatio= */
1
f
,
/* drmInitData= */
null
);
private
static
final
Format
H264_FORMAT
=
new
Format
.
Builder
()
.
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
)
.
setWidth
(
1920
)
.
setHeight
(
1080
)
.
build
();
private
SimpleDecoderVideoRenderer
renderer
;
@Mock
private
VideoRendererEventListener
eventListener
;
...
...
@@ -142,7 +134,7 @@ public final class SimpleDecoderVideoRendererTest {
public
void
enable_withMayRenderStartOfStream_rendersFirstFrameBeforeStart
()
throws
Exception
{
FakeSampleStream
fakeSampleStream
=
new
FakeSampleStream
(
/* format= */
BASIC_MP4_1080
,
/* format= */
H264_FORMAT
,
/* eventDispatcher= */
null
,
/* firstSampleTimeUs= */
0
,
/* timeUsIncrement= */
50
,
...
...
@@ -150,7 +142,7 @@ public final class SimpleDecoderVideoRendererTest {
renderer
.
enable
(
RendererConfiguration
.
DEFAULT
,
new
Format
[]
{
BASIC_MP4_1080
},
new
Format
[]
{
H264_FORMAT
},
fakeSampleStream
,
/* positionUs= */
0
,
/* joining= */
false
,
...
...
@@ -168,7 +160,7 @@ public final class SimpleDecoderVideoRendererTest {
throws
Exception
{
FakeSampleStream
fakeSampleStream
=
new
FakeSampleStream
(
/* format= */
BASIC_MP4_1080
,
/* format= */
H264_FORMAT
,
/* eventDispatcher= */
null
,
/* firstSampleTimeUs= */
0
,
/* timeUsIncrement= */
50
,
...
...
@@ -176,7 +168,7 @@ public final class SimpleDecoderVideoRendererTest {
renderer
.
enable
(
RendererConfiguration
.
DEFAULT
,
new
Format
[]
{
BASIC_MP4_1080
},
new
Format
[]
{
H264_FORMAT
},
fakeSampleStream
,
/* positionUs= */
0
,
/* joining= */
false
,
...
...
@@ -193,7 +185,7 @@ public final class SimpleDecoderVideoRendererTest {
public
void
enable_withoutMayRenderStartOfStream_rendersFirstFrameAfterStart
()
throws
Exception
{
FakeSampleStream
fakeSampleStream
=
new
FakeSampleStream
(
/* format= */
BASIC_MP4_1080
,
/* format= */
H264_FORMAT
,
/* eventDispatcher= */
null
,
/* firstSampleTimeUs= */
0
,
/* timeUsIncrement= */
50
,
...
...
@@ -201,7 +193,7 @@ public final class SimpleDecoderVideoRendererTest {
renderer
.
enable
(
RendererConfiguration
.
DEFAULT
,
new
Format
[]
{
BASIC_MP4_1080
},
new
Format
[]
{
H264_FORMAT
},
fakeSampleStream
,
/* positionUs= */
0
,
/* joining= */
false
,
...
...
@@ -221,7 +213,7 @@ public final class SimpleDecoderVideoRendererTest {
public
void
replaceStream_whenStarted_rendersFirstFrameOfNewStream
()
throws
Exception
{
FakeSampleStream
fakeSampleStream1
=
new
FakeSampleStream
(
/* format= */
BASIC_MP4_1080
,
/* format= */
H264_FORMAT
,
/* eventDispatcher= */
null
,
/* firstSampleTimeUs= */
0
,
/* timeUsIncrement= */
50
,
...
...
@@ -229,7 +221,7 @@ public final class SimpleDecoderVideoRendererTest {
FakeSampleStreamItem
.
END_OF_STREAM_ITEM
);
FakeSampleStream
fakeSampleStream2
=
new
FakeSampleStream
(
/* format= */
BASIC_MP4_1080
,
/* format= */
H264_FORMAT
,
/* eventDispatcher= */
null
,
/* firstSampleTimeUs= */
0
,
/* timeUsIncrement= */
50
,
...
...
@@ -237,7 +229,7 @@ public final class SimpleDecoderVideoRendererTest {
FakeSampleStreamItem
.
END_OF_STREAM_ITEM
);
renderer
.
enable
(
RendererConfiguration
.
DEFAULT
,
new
Format
[]
{
BASIC_MP4_1080
},
new
Format
[]
{
H264_FORMAT
},
fakeSampleStream1
,
/* positionUs= */
0
,
/* joining= */
false
,
...
...
@@ -249,8 +241,7 @@ public final class SimpleDecoderVideoRendererTest {
for
(
int
i
=
0
;
i
<
200
;
i
+=
10
)
{
renderer
.
render
(
/* positionUs= */
i
*
10
,
SystemClock
.
elapsedRealtime
()
*
1000
);
if
(!
replacedStream
&&
renderer
.
hasReadStreamToEnd
())
{
renderer
.
replaceStream
(
new
Format
[]
{
BASIC_MP4_1080
},
fakeSampleStream2
,
/* offsetUs= */
100
);
renderer
.
replaceStream
(
new
Format
[]
{
H264_FORMAT
},
fakeSampleStream2
,
/* offsetUs= */
100
);
replacedStream
=
true
;
}
}
...
...
@@ -262,7 +253,7 @@ public final class SimpleDecoderVideoRendererTest {
public
void
replaceStream_whenNotStarted_doesNotRenderFirstFrameOfNewStream
()
throws
Exception
{
FakeSampleStream
fakeSampleStream1
=
new
FakeSampleStream
(
/* format= */
BASIC_MP4_1080
,
/* format= */
H264_FORMAT
,
/* eventDispatcher= */
null
,
/* firstSampleTimeUs= */
0
,
/* timeUsIncrement= */
50
,
...
...
@@ -270,7 +261,7 @@ public final class SimpleDecoderVideoRendererTest {
FakeSampleStreamItem
.
END_OF_STREAM_ITEM
);
FakeSampleStream
fakeSampleStream2
=
new
FakeSampleStream
(
/* format= */
BASIC_MP4_1080
,
/* format= */
H264_FORMAT
,
/* eventDispatcher= */
null
,
/* firstSampleTimeUs= */
0
,
/* timeUsIncrement= */
50
,
...
...
@@ -278,7 +269,7 @@ public final class SimpleDecoderVideoRendererTest {
FakeSampleStreamItem
.
END_OF_STREAM_ITEM
);
renderer
.
enable
(
RendererConfiguration
.
DEFAULT
,
new
Format
[]
{
BASIC_MP4_1080
},
new
Format
[]
{
H264_FORMAT
},
fakeSampleStream1
,
/* positionUs= */
0
,
/* joining= */
false
,
...
...
@@ -289,8 +280,7 @@ public final class SimpleDecoderVideoRendererTest {
for
(
int
i
=
0
;
i
<
200
;
i
+=
10
)
{
renderer
.
render
(
/* positionUs= */
i
*
10
,
SystemClock
.
elapsedRealtime
()
*
1000
);
if
(!
replacedStream
&&
renderer
.
hasReadStreamToEnd
())
{
renderer
.
replaceStream
(
new
Format
[]
{
BASIC_MP4_1080
},
fakeSampleStream2
,
/* offsetUs= */
100
);
renderer
.
replaceStream
(
new
Format
[]
{
H264_FORMAT
},
fakeSampleStream2
,
/* offsetUs= */
100
);
replacedStream
=
true
;
}
}
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/FlacStreamMetadata.java
View file @
67b29bbe
...
...
@@ -239,23 +239,14 @@ public final class FlacStreamMetadata {
streamMarkerAndInfoBlock
[
4
]
=
(
byte
)
0x80
;
int
maxInputSize
=
maxFrameSize
>
0
?
maxFrameSize
:
Format
.
NO_VALUE
;
@Nullable
Metadata
metadataWithId3
=
getMetadataCopyWithAppendedEntriesFrom
(
id3Metadata
);
return
Format
.
createAudioSampleFormat
(
/* id= */
null
,
MimeTypes
.
AUDIO_FLAC
,
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
maxInputSize
,
channels
,
sampleRate
,
/* pcmEncoding= */
Format
.
NO_VALUE
,
/* encoderDelay= */
0
,
/* encoderPadding= */
0
,
/* initializationData= */
Collections
.
singletonList
(
streamMarkerAndInfoBlock
),
/* drmInitData= */
null
,
/* selectionFlags= */
0
,
/* language= */
null
,
metadataWithId3
);
return
new
Format
.
Builder
()
.
setSampleMimeType
(
MimeTypes
.
AUDIO_FLAC
)
.
setMaxInputSize
(
maxInputSize
)
.
setChannelCount
(
channels
)
.
setSampleRate
(
sampleRate
)
.
setInitializationData
(
Collections
.
singletonList
(
streamMarkerAndInfoBlock
))
.
setMetadata
(
metadataWithId3
)
.
build
();
}
/** Returns a copy of the content metadata with entries from {@code other} appended. */
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/amr/AmrExtractor.java
View file @
67b29bbe
...
...
@@ -256,19 +256,12 @@ public final class AmrExtractor implements Extractor {
String
mimeType
=
isWideBand
?
MimeTypes
.
AUDIO_AMR_WB
:
MimeTypes
.
AUDIO_AMR_NB
;
int
sampleRate
=
isWideBand
?
SAMPLE_RATE_WB
:
SAMPLE_RATE_NB
;
trackOutput
.
format
(
Format
.
createAudioSampleFormat
(
/* id= */
null
,
mimeType
,
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
MAX_FRAME_SIZE_BYTES
,
/* channelCount= */
1
,
sampleRate
,
/* pcmEncoding= */
Format
.
NO_VALUE
,
/* initializationData= */
null
,
/* drmInitData= */
null
,
/* selectionFlags= */
0
,
/* language= */
null
));
new
Format
.
Builder
()
.
setSampleMimeType
(
mimeType
)
.
setMaxInputSize
(
MAX_FRAME_SIZE_BYTES
)
.
setChannelCount
(
1
)
.
setSampleRate
(
sampleRate
)
.
build
());
}
}
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/AudioTagPayloadReader.java
View file @
67b29bbe
...
...
@@ -61,27 +61,23 @@ import java.util.Collections;
if
(
audioFormat
==
AUDIO_FORMAT_MP3
)
{
int
sampleRateIndex
=
(
header
>>
2
)
&
0x03
;
int
sampleRate
=
AUDIO_SAMPLING_RATE_TABLE
[
sampleRateIndex
];
Format
format
=
Format
.
createAudioSampleFormat
(
null
,
MimeTypes
.
AUDIO_MPEG
,
null
,
Format
.
NO_VALUE
,
Format
.
NO_VALUE
,
1
,
sampleRate
,
null
,
null
,
0
,
null
);
Format
format
=
new
Format
.
Builder
()
.
setSampleMimeType
(
MimeTypes
.
AUDIO_MPEG
)
.
setChannelCount
(
1
)
.
setSampleRate
(
sampleRate
)
.
build
();
output
.
format
(
format
);
hasOutputFormat
=
true
;
}
else
if
(
audioFormat
==
AUDIO_FORMAT_ALAW
||
audioFormat
==
AUDIO_FORMAT_ULAW
)
{
String
type
=
audioFormat
==
AUDIO_FORMAT_ALAW
?
MimeTypes
.
AUDIO_ALAW
:
MimeTypes
.
AUDIO_MLAW
;
String
mimeType
=
audioFormat
==
AUDIO_FORMAT_ALAW
?
MimeTypes
.
AUDIO_ALAW
:
MimeTypes
.
AUDIO_MLAW
;
Format
format
=
Format
.
createAudioSampleFormat
(
/* id= */
null
,
/* sampleMimeType= */
type
,
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
/* maxInputSize= */
Format
.
NO_VALUE
,
/* channelCount= */
1
,
/* sampleRate= */
8000
,
/* pcmEncoding= */
Format
.
NO_VALUE
,
/* initializationData= */
null
,
/* drmInitData= */
null
,
/* selectionFlags= */
0
,
/* language= */
null
);
new
Format
.
Builder
()
.
setSampleMimeType
(
mimeType
)
.
setChannelCount
(
1
)
.
setSampleRate
(
8000
)
.
build
();
output
.
format
(
format
);
hasOutputFormat
=
true
;
}
else
if
(
audioFormat
!=
AUDIO_FORMAT_AAC
)
{
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/flv/VideoTagPayloadReader.java
View file @
67b29bbe
...
...
@@ -90,9 +90,14 @@ import com.google.android.exoplayer2.video.AvcConfig;
AvcConfig
avcConfig
=
AvcConfig
.
parse
(
videoSequence
);
nalUnitLengthFieldLength
=
avcConfig
.
nalUnitLengthFieldLength
;
// Construct and output the format.
Format
format
=
Format
.
createVideoSampleFormat
(
null
,
MimeTypes
.
VIDEO_H264
,
null
,
Format
.
NO_VALUE
,
Format
.
NO_VALUE
,
avcConfig
.
width
,
avcConfig
.
height
,
Format
.
NO_VALUE
,
avcConfig
.
initializationData
,
Format
.
NO_VALUE
,
avcConfig
.
pixelWidthAspectRatio
,
null
);
Format
format
=
new
Format
.
Builder
()
.
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
)
.
setWidth
(
avcConfig
.
width
)
.
setHeight
(
avcConfig
.
height
)
.
setPixelWidthHeightRatio
(
avcConfig
.
pixelWidthAspectRatio
)
.
setInitializationData
(
avcConfig
.
initializationData
)
.
build
();
output
.
format
(
format
);
hasOutputFormat
=
true
;
return
false
;
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp3/Mp3Extractor.java
View file @
67b29bbe
...
...
@@ -252,22 +252,15 @@ public final class Mp3Extractor implements Extractor {
seeker
=
computeSeeker
(
input
);
extractorOutput
.
seekMap
(
seeker
);
currentTrackOutput
.
format
(
Format
.
createAudioSampleFormat
(
/* id= */
null
,
synchronizedHeader
.
mimeType
,
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
MpegAudioUtil
.
MAX_FRAME_SIZE_BYTES
,
synchronizedHeader
.
channels
,
synchronizedHeader
.
sampleRate
,
/* pcmEncoding= */
Format
.
NO_VALUE
,
gaplessInfoHolder
.
encoderDelay
,
gaplessInfoHolder
.
encoderPadding
,
/* initializationData= */
null
,
/* drmInitData= */
null
,
/* selectionFlags= */
0
,
/* language= */
null
,
(
flags
&
FLAG_DISABLE_ID3_METADATA
)
!=
0
?
null
:
metadata
));
new
Format
.
Builder
()
.
setSampleMimeType
(
synchronizedHeader
.
mimeType
)
.
setMaxInputSize
(
MpegAudioUtil
.
MAX_FRAME_SIZE_BYTES
)
.
setChannelCount
(
synchronizedHeader
.
channels
)
.
setSampleRate
(
synchronizedHeader
.
sampleRate
)
.
setEncoderDelay
(
gaplessInfoHolder
.
encoderDelay
)
.
setEncoderPadding
(
gaplessInfoHolder
.
encoderPadding
)
.
setMetadata
((
flags
&
FLAG_DISABLE_ID3_METADATA
)
!=
0
?
null
:
metadata
)
.
build
());
firstSamplePosition
=
input
.
getPosition
();
}
else
if
(
firstSamplePosition
!=
0
)
{
long
inputPosition
=
input
.
getPosition
();
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/AtomParsers.java
View file @
67b29bbe
...
...
@@ -815,8 +815,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
language
,
out
);
}
else
if
(
childAtomType
==
Atom
.
TYPE_camm
)
{
out
.
format
=
Format
.
createSampleFormat
(
Integer
.
toString
(
trackId
),
MimeTypes
.
APPLICATION_CAMERA_MOTION
);
new
Format
.
Builder
()
.
setId
(
trackId
)
.
setSampleMimeType
(
MimeTypes
.
APPLICATION_CAMERA_MOTION
)
.
build
();
}
stsd
.
setPosition
(
childStartPosition
+
childAtomSize
);
}
...
...
@@ -861,14 +863,13 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
}
out
.
format
=
Format
.
createTextSampleFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
/* selectionFlags= */
0
,
language
,
/* accessibilityChannel= */
Format
.
NO_VALUE
,
subsampleOffsetUs
,
initializationData
);
new
Format
.
Builder
()
.
setId
(
trackId
)
.
setSampleMimeType
(
mimeType
)
.
setLanguage
(
language
)
.
setSubsampleOffsetUs
(
subsampleOffsetUs
)
.
setInitializationData
(
initializationData
)
.
build
();
}
private
static
void
parseVideoSampleEntry
(
...
...
@@ -1003,22 +1004,19 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
}
out
.
format
=
Format
.
createVideoSampleFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
codecs
,
/* bitrate= */
Format
.
NO_VALUE
,
/* maxInputSize= */
Format
.
NO_VALUE
,
width
,
height
,
/* frameRate= */
Format
.
NO_VALUE
,
initializationData
,
rotationDegrees
,
pixelWidthHeightRatio
,
projectionData
,
stereoMode
,
/* colorInfo= */
null
,
drmInitData
);
new
Format
.
Builder
()
.
setId
(
trackId
)
.
setSampleMimeType
(
mimeType
)
.
setCodecs
(
codecs
)
.
setWidth
(
width
)
.
setHeight
(
height
)
.
setPixelWidthHeightRatio
(
pixelWidthHeightRatio
)
.
setRotationDegrees
(
rotationDegrees
)
.
setProjectionData
(
projectionData
)
.
setStereoMode
(
stereoMode
)
.
setInitializationData
(
initializationData
)
.
setDrmInitData
(
drmInitData
)
.
build
();
}
/**
...
...
@@ -1203,9 +1201,15 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
out
.
format
=
Ac4Util
.
parseAc4AnnexEFormat
(
parent
,
Integer
.
toString
(
trackId
),
language
,
drmInitData
);
}
else
if
(
childAtomType
==
Atom
.
TYPE_ddts
)
{
out
.
format
=
Format
.
createAudioSampleFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
null
,
Format
.
NO_VALUE
,
Format
.
NO_VALUE
,
channelCount
,
sampleRate
,
null
,
drmInitData
,
0
,
language
);
out
.
format
=
new
Format
.
Builder
()
.
setId
(
trackId
)
.
setSampleMimeType
(
mimeType
)
.
setChannelCount
(
channelCount
)
.
setSampleRate
(
sampleRate
)
.
setDrmInitData
(
drmInitData
)
.
setLanguage
(
language
)
.
build
();
}
else
if
(
childAtomType
==
Atom
.
TYPE_dOps
)
{
// Build an Opus Identification Header (defined in RFC-7845) by concatenating the Opus Magic
// Signature and the body of the dOps atom.
...
...
@@ -1241,7 +1245,7 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
if
(
out
.
format
==
null
&&
mimeType
!=
null
)
{
out
.
format
=
new
Format
.
Builder
()
.
setId
(
Integer
.
toString
(
trackId
)
)
.
setId
(
trackId
)
.
setSampleMimeType
(
mimeType
)
.
setCodecs
(
codecs
)
.
setChannelCount
(
channelCount
)
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4Extractor.java
View file @
67b29bbe
...
...
@@ -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
);
new
Format
.
Builder
().
setSampleMimeType
(
MimeTypes
.
APPLICATION_EMSG
).
build
(
);
// Parser states.
private
static
final
int
STATE_READING_ATOM_HEADER
=
0
;
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/OpusReader.java
View file @
67b29bbe
...
...
@@ -77,18 +77,12 @@ import java.util.List;
putNativeOrderLong
(
initializationData
,
DEFAULT_SEEK_PRE_ROLL_SAMPLES
);
setupData
.
format
=
Format
.
createAudioSampleFormat
(
null
,
MimeTypes
.
AUDIO_OPUS
,
/* codecs= */
null
,
Format
.
NO_VALUE
,
Format
.
NO_VALUE
,
channelCount
,
SAMPLE_RATE
,
initializationData
,
/* drmInitData= */
null
,
/* selectionFlags= */
0
,
/* language= */
null
);
new
Format
.
Builder
()
.
setSampleMimeType
(
MimeTypes
.
AUDIO_OPUS
)
.
setChannelCount
(
channelCount
)
.
setSampleRate
(
SAMPLE_RATE
)
.
setInitializationData
(
initializationData
)
.
build
();
headerRead
=
true
;
}
else
{
boolean
headerPacket
=
packet
.
readInt
()
==
OPUS_CODE
;
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ogg/VorbisReader.java
View file @
67b29bbe
...
...
@@ -99,23 +99,21 @@ import java.util.ArrayList;
return
true
;
}
ArrayList
<
byte
[]>
codecInitialisationData
=
new
ArrayList
<>();
codecInitialisationData
.
add
(
vorbisSetup
.
idHeader
.
data
);
codecInitialisationData
.
add
(
vorbisSetup
.
setupHeaderData
);
VorbisUtil
.
VorbisIdHeader
idHeader
=
vorbisSetup
.
idHeader
;
ArrayList
<
byte
[]>
codecInitializationData
=
new
ArrayList
<>();
codecInitializationData
.
add
(
idHeader
.
data
);
codecInitializationData
.
add
(
vorbisSetup
.
setupHeaderData
);
setupData
.
format
=
Format
.
createAudioSampleFormat
(
null
,
MimeTypes
.
AUDIO_VORBIS
,
/* codecs= */
null
,
vorbisSetup
.
idHeader
.
bitrateNominal
,
Format
.
NO_VALUE
,
vorbisSetup
.
idHeader
.
channels
,
(
int
)
this
.
vorbisSetup
.
idHeader
.
sampleRate
,
codecInitialisationData
,
null
,
/* selectionFlags= */
0
,
/* language= */
null
);
new
Format
.
Builder
()
.
setSampleMimeType
(
MimeTypes
.
AUDIO_VORBIS
)
.
setAverageBitrate
(
idHeader
.
bitrateNominal
)
.
setPeakBitrate
(
idHeader
.
bitrateMaximum
)
.
setChannelCount
(
idHeader
.
channels
)
.
setSampleRate
(
idHeader
.
sampleRate
)
.
setInitializationData
(
codecInitializationData
)
.
build
();
return
true
;
}
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac3Reader.java
View file @
67b29bbe
...
...
@@ -201,18 +201,13 @@ public final class Ac3Reader implements ElementaryStreamReader {
||
frameInfo
.
sampleRate
!=
format
.
sampleRate
||
!
Util
.
areEqual
(
frameInfo
.
mimeType
,
format
.
sampleMimeType
))
{
format
=
Format
.
createAudioSampleFormat
(
formatId
,
frameInfo
.
mimeType
,
null
,
Format
.
NO_VALUE
,
Format
.
NO_VALUE
,
frameInfo
.
channelCount
,
frameInfo
.
sampleRate
,
null
,
null
,
0
,
language
);
new
Format
.
Builder
()
.
setId
(
formatId
)
.
setSampleMimeType
(
frameInfo
.
mimeType
)
.
setChannelCount
(
frameInfo
.
channelCount
)
.
setSampleRate
(
frameInfo
.
sampleRate
)
.
setLanguage
(
language
)
.
build
();
output
.
format
(
format
);
}
sampleSize
=
frameInfo
.
frameSize
;
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Ac4Reader.java
View file @
67b29bbe
...
...
@@ -199,18 +199,13 @@ public final class Ac4Reader implements ElementaryStreamReader {
||
frameInfo
.
sampleRate
!=
format
.
sampleRate
||
!
MimeTypes
.
AUDIO_AC4
.
equals
(
format
.
sampleMimeType
))
{
format
=
Format
.
createAudioSampleFormat
(
formatId
,
MimeTypes
.
AUDIO_AC4
,
/* codecs= */
null
,
/* bitrate= */
Format
.
NO_VALUE
,
/* maxInputSize= */
Format
.
NO_VALUE
,
frameInfo
.
channelCount
,
frameInfo
.
sampleRate
,
/* initializationData= */
null
,
/* drmInitData= */
null
,
/* selectionFlags= */
0
,
language
);
new
Format
.
Builder
()
.
setId
(
formatId
)
.
setSampleMimeType
(
MimeTypes
.
AUDIO_AC4
)
.
setChannelCount
(
frameInfo
.
channelCount
)
.
setSampleRate
(
frameInfo
.
sampleRate
)
.
setLanguage
(
language
)
.
build
();
output
.
format
(
format
);
}
sampleSize
=
frameInfo
.
frameSize
;
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/AdtsReader.java
View file @
67b29bbe
...
...
@@ -140,7 +140,10 @@ public final class AdtsReader implements ElementaryStreamReader {
idGenerator
.
generateNewId
();
id3Output
=
extractorOutput
.
track
(
idGenerator
.
getTrackId
(),
C
.
TRACK_TYPE_METADATA
);
id3Output
.
format
(
Format
.
createSampleFormat
(
idGenerator
.
getFormatId
(),
MimeTypes
.
APPLICATION_ID3
));
new
Format
.
Builder
()
.
setId
(
idGenerator
.
getFormatId
())
.
setSampleMimeType
(
MimeTypes
.
APPLICATION_ID3
)
.
build
());
}
else
{
id3Output
=
new
DummyTrackOutput
();
}
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/DefaultTsPayloadReaderFactory.java
View file @
67b29bbe
...
...
@@ -115,7 +115,7 @@ public final class DefaultTsPayloadReaderFactory implements TsPayloadReader.Fact
this
(
flags
,
Collections
.
singletonList
(
Format
.
createTextSampleFormat
(
null
,
MimeTypes
.
APPLICATION_CEA608
,
0
,
null
)));
new
Format
.
Builder
().
setSampleMimeType
(
MimeTypes
.
APPLICATION_CEA608
).
build
(
)));
}
/**
...
...
@@ -264,14 +264,12 @@ public final class DefaultTsPayloadReaderFactory implements TsPayloadReader.Fact
}
closedCaptionFormats
.
add
(
Format
.
createTextSampleFormat
(
/* id= */
null
,
mimeType
,
/* selectionFlags= */
0
,
language
,
accessibilityChannel
,
Format
.
OFFSET_SAMPLE_RELATIVE
,
initializationData
));
new
Format
.
Builder
()
.
setSampleMimeType
(
mimeType
)
.
setLanguage
(
language
)
.
setAccessibilityChannel
(
accessibilityChannel
)
.
setInitializationData
(
initializationData
)
.
build
());
}
}
else
{
// Unknown descriptor. Ignore.
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/DvbSubtitleReader.java
View file @
67b29bbe
...
...
@@ -61,12 +61,12 @@ public final class DvbSubtitleReader implements ElementaryStreamReader {
idGenerator
.
generateNewId
();
TrackOutput
output
=
extractorOutput
.
track
(
idGenerator
.
getTrackId
(),
C
.
TRACK_TYPE_TEXT
);
output
.
format
(
Format
.
createImageSampleFormat
(
idGenerator
.
getFormatId
(),
MimeTypes
.
APPLICATION_DVBSUBS
,
/* selectionFlags= */
0
,
Collections
.
singletonList
(
subtitleInfo
.
initializationData
),
subtitleInfo
.
language
));
new
Format
.
Builder
()
.
setId
(
idGenerator
.
getFormatId
())
.
setSampleMimeType
(
MimeTypes
.
APPLICATION_DVBSUBS
)
.
setInitializationData
(
Collections
.
singletonList
(
subtitleInfo
.
initializationData
))
.
setLanguage
(
subtitleInfo
.
language
)
.
build
(
));
outputs
[
i
]
=
output
;
}
}
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H262Reader.java
View file @
67b29bbe
...
...
@@ -245,9 +245,15 @@ public final class H262Reader implements ElementaryStreamReader {
break
;
}
Format
format
=
Format
.
createVideoSampleFormat
(
formatId
,
MimeTypes
.
VIDEO_MPEG2
,
null
,
Format
.
NO_VALUE
,
Format
.
NO_VALUE
,
width
,
height
,
Format
.
NO_VALUE
,
Collections
.
singletonList
(
csdData
),
Format
.
NO_VALUE
,
pixelWidthHeightRatio
,
null
);
Format
format
=
new
Format
.
Builder
()
.
setId
(
formatId
)
.
setSampleMimeType
(
MimeTypes
.
VIDEO_MPEG2
)
.
setWidth
(
width
)
.
setHeight
(
height
)
.
setPixelWidthHeightRatio
(
pixelWidthHeightRatio
)
.
setInitializationData
(
Collections
.
singletonList
(
csdData
))
.
build
();
long
frameDurationUs
=
0
;
int
frameRateCodeMinusOne
=
(
csdData
[
7
]
&
0x0F
)
-
1
;
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H264Reader.java
View file @
67b29bbe
...
...
@@ -201,23 +201,21 @@ public final class H264Reader implements ElementaryStreamReader {
initializationData
.
add
(
Arrays
.
copyOf
(
pps
.
nalData
,
pps
.
nalLength
));
NalUnitUtil
.
SpsData
spsData
=
NalUnitUtil
.
parseSpsNalUnit
(
sps
.
nalData
,
3
,
sps
.
nalLength
);
NalUnitUtil
.
PpsData
ppsData
=
NalUnitUtil
.
parsePpsNalUnit
(
pps
.
nalData
,
3
,
pps
.
nalLength
);
String
codecs
=
CodecSpecificDataUtil
.
buildAvcCodecString
(
spsData
.
profileIdc
,
spsData
.
constraintsFlagsAndReservedZero2Bits
,
spsData
.
levelIdc
);
output
.
format
(
Format
.
createVideoSampleFormat
(
formatId
,
MimeTypes
.
VIDEO_H264
,
CodecSpecificDataUtil
.
buildAvcCodecString
(
spsData
.
profileIdc
,
spsData
.
constraintsFlagsAndReservedZero2Bits
,
spsData
.
levelIdc
),
/* bitrate= */
Format
.
NO_VALUE
,
/* maxInputSize= */
Format
.
NO_VALUE
,
spsData
.
width
,
spsData
.
height
,
/* frameRate= */
Format
.
NO_VALUE
,
initializationData
,
/* rotationDegrees= */
Format
.
NO_VALUE
,
spsData
.
pixelWidthAspectRatio
,
/* drmInitData= */
null
));
new
Format
.
Builder
()
.
setId
(
formatId
)
.
setSampleMimeType
(
MimeTypes
.
VIDEO_H264
)
.
setCodecs
(
codecs
)
.
setWidth
(
spsData
.
width
)
.
setHeight
(
spsData
.
height
)
.
setPixelWidthHeightRatio
(
spsData
.
pixelWidthAspectRatio
)
.
setInitializationData
(
initializationData
)
.
build
());
hasOutputFormat
=
true
;
sampleReader
.
putSps
(
spsData
);
sampleReader
.
putPps
(
ppsData
);
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/H265Reader.java
View file @
67b29bbe
...
...
@@ -233,10 +233,10 @@ public final class H265Reader implements ElementaryStreamReader {
NalUnitTargetBuffer
sps
,
NalUnitTargetBuffer
pps
)
{
// Build codec-specific data.
byte
[]
csd
=
new
byte
[
vps
.
nalLength
+
sps
.
nalLength
+
pps
.
nalLength
];
System
.
arraycopy
(
vps
.
nalData
,
0
,
csd
,
0
,
vps
.
nalLength
);
System
.
arraycopy
(
sps
.
nalData
,
0
,
csd
,
vps
.
nalLength
,
sps
.
nalLength
);
System
.
arraycopy
(
pps
.
nalData
,
0
,
csd
,
vps
.
nalLength
+
sps
.
nalLength
,
pps
.
nalLength
);
byte
[]
csd
Data
=
new
byte
[
vps
.
nalLength
+
sps
.
nalLength
+
pps
.
nalLength
];
System
.
arraycopy
(
vps
.
nalData
,
0
,
csd
Data
,
0
,
vps
.
nalLength
);
System
.
arraycopy
(
sps
.
nalData
,
0
,
csd
Data
,
vps
.
nalLength
,
sps
.
nalLength
);
System
.
arraycopy
(
pps
.
nalData
,
0
,
csd
Data
,
vps
.
nalLength
+
sps
.
nalLength
,
pps
.
nalLength
);
// Parse the SPS NAL unit, as per H.265/HEVC (2014) 7.3.2.2.1.
ParsableNalUnitBitArray
bitArray
=
new
ParsableNalUnitBitArray
(
sps
.
nalData
,
0
,
sps
.
nalLength
);
...
...
@@ -336,9 +336,14 @@ public final class H265Reader implements ElementaryStreamReader {
}
}
return
Format
.
createVideoSampleFormat
(
formatId
,
MimeTypes
.
VIDEO_H265
,
null
,
Format
.
NO_VALUE
,
Format
.
NO_VALUE
,
picWidthInLumaSamples
,
picHeightInLumaSamples
,
Format
.
NO_VALUE
,
Collections
.
singletonList
(
csd
),
Format
.
NO_VALUE
,
pixelWidthHeightRatio
,
null
);
return
new
Format
.
Builder
()
.
setId
(
formatId
)
.
setSampleMimeType
(
MimeTypes
.
VIDEO_H265
)
.
setWidth
(
picWidthInLumaSamples
)
.
setHeight
(
picHeightInLumaSamples
)
.
setPixelWidthHeightRatio
(
pixelWidthHeightRatio
)
.
setInitializationData
(
Collections
.
singletonList
(
csdData
))
.
build
();
}
/**
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/Id3Reader.java
View file @
67b29bbe
...
...
@@ -61,7 +61,11 @@ 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
));
output
.
format
(
new
Format
.
Builder
()
.
setId
(
idGenerator
.
getFormatId
())
.
setSampleMimeType
(
MimeTypes
.
APPLICATION_ID3
)
.
build
());
}
@Override
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/LatmReader.java
View file @
67b29bbe
...
...
@@ -71,6 +71,7 @@ public final class LatmReader implements ElementaryStreamReader {
private
int
sampleRateHz
;
private
long
sampleDurationUs
;
private
int
channelCount
;
@Nullable
private
String
codecs
;
/**
* @param language Track language.
...
...
@@ -202,18 +203,15 @@ public final class LatmReader implements ElementaryStreamReader {
byte
[]
initData
=
new
byte
[(
readBits
+
7
)
/
8
];
data
.
readBits
(
initData
,
0
,
readBits
);
Format
format
=
Format
.
createAudioSampleFormat
(
formatId
,
MimeTypes
.
AUDIO_AAC
,
/* codecs= */
null
,
Format
.
NO_VALUE
,
Format
.
NO_VALUE
,
channelCount
,
sampleRateHz
,
Collections
.
singletonList
(
initData
),
/* drmInitData= */
null
,
/* selectionFlags= */
0
,
language
);
new
Format
.
Builder
()
.
setId
(
formatId
)
.
setSampleMimeType
(
MimeTypes
.
AUDIO_AAC
)
.
setCodecs
(
codecs
)
.
setChannelCount
(
channelCount
)
.
setSampleRate
(
sampleRateHz
)
.
setInitializationData
(
Collections
.
singletonList
(
initData
))
.
setLanguage
(
language
)
.
build
();
if
(!
format
.
equals
(
this
.
format
))
{
this
.
format
=
format
;
sampleDurationUs
=
(
C
.
MICROS_PER_SECOND
*
1024
)
/
format
.
sampleRate
;
...
...
@@ -273,6 +271,7 @@ public final class LatmReader implements ElementaryStreamReader {
private
int
parseAudioSpecificConfig
(
ParsableBitArray
data
)
throws
ParserException
{
int
bitsLeft
=
data
.
bitsLeft
();
AacUtil
.
Config
config
=
AacUtil
.
parseAudioSpecificConfig
(
data
,
/* forceReadToEnd= */
true
);
codecs
=
config
.
codecs
;
sampleRateHz
=
config
.
sampleRateHz
;
channelCount
=
config
.
channelCount
;
return
bitsLeft
-
data
.
bitsLeft
();
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/MpegAudioReader.java
View file @
67b29bbe
...
...
@@ -188,18 +188,14 @@ public final class MpegAudioReader implements ElementaryStreamReader {
if
(!
hasOutputFormat
)
{
frameDurationUs
=
(
C
.
MICROS_PER_SECOND
*
header
.
samplesPerFrame
)
/
header
.
sampleRate
;
Format
format
=
Format
.
createAudioSampleFormat
(
formatId
,
header
.
mimeType
,
null
,
Format
.
NO_VALUE
,
MpegAudioUtil
.
MAX_FRAME_SIZE_BYTES
,
header
.
channels
,
header
.
sampleRate
,
null
,
null
,
0
,
language
);
new
Format
.
Builder
()
.
setId
(
formatId
)
.
setSampleMimeType
(
header
.
mimeType
)
.
setMaxInputSize
(
MpegAudioUtil
.
MAX_FRAME_SIZE_BYTES
)
.
setChannelCount
(
header
.
channels
)
.
setSampleRate
(
header
.
sampleRate
)
.
setLanguage
(
language
)
.
build
();
output
.
format
(
format
);
hasOutputFormat
=
true
;
}
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/SeiReader.java
View file @
67b29bbe
...
...
@@ -52,14 +52,14 @@ public final class SeiReader {
"Invalid closed caption mime type provided: "
+
channelMimeType
);
String
formatId
=
channelFormat
.
id
!=
null
?
channelFormat
.
id
:
idGenerator
.
getFormatId
();
output
.
format
(
Format
.
createTextSampleFormat
(
formatId
,
channelMimeType
,
channelFormat
.
selectionFlags
,
channelFormat
.
language
,
channelFormat
.
accessibilityChannel
,
Format
.
OFFSET_SAMPLE_RELATIVE
,
channelFormat
.
initializationData
));
new
Format
.
Builder
()
.
setId
(
formatId
)
.
setSampleMimeType
(
channelMimeType
)
.
setSelectionFlags
(
channelFormat
.
selectionFlags
)
.
setLanguage
(
channelFormat
.
language
)
.
setAccessibilityChannel
(
channelFormat
.
accessibilityChannel
)
.
setInitializationData
(
channelFormat
.
initializationData
)
.
build
(
));
outputs
[
i
]
=
output
;
}
}
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/ts/UserDataReader.java
View file @
67b29bbe
...
...
@@ -51,14 +51,14 @@ import java.util.List;
||
MimeTypes
.
APPLICATION_CEA708
.
equals
(
channelMimeType
),
"Invalid closed caption mime type provided: "
+
channelMimeType
);
output
.
format
(
Format
.
createTextSampleFormat
(
idGenerator
.
getFormatId
(),
channelMimeType
,
channelFormat
.
selectionFlags
,
channelFormat
.
language
,
channelFormat
.
accessibilityChannel
,
Format
.
OFFSET_SAMPLE_RELATIVE
,
channelFormat
.
initializationData
));
new
Format
.
Builder
()
.
setId
(
idGenerator
.
getFormatId
())
.
setSampleMimeType
(
channelMimeType
)
.
setSelectionFlags
(
channelFormat
.
selectionFlags
)
.
setLanguage
(
channelFormat
.
language
)
.
setAccessibilityChannel
(
channelFormat
.
accessibilityChannel
)
.
setInitializationData
(
channelFormat
.
initializationData
)
.
build
(
));
outputs
[
i
]
=
output
;
}
}
...
...
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/wav/WavExtractor.java
View file @
67b29bbe
...
...
@@ -223,22 +223,19 @@ public final class WavExtractor implements Extractor {
"Expected block size: "
+
bytesPerFrame
+
"; got: "
+
header
.
blockSize
);
}
int
constantBitrate
=
header
.
frameRateHz
*
bytesPerFrame
*
8
;
targetSampleSizeBytes
=
Math
.
max
(
bytesPerFrame
,
header
.
frameRateHz
*
bytesPerFrame
/
TARGET_SAMPLES_PER_SECOND
);
format
=
Format
.
createAudioSampleFormat
(
/* id= */
null
,
mimeType
,
/* codecs= */
null
,
/* bitrate= */
header
.
frameRateHz
*
bytesPerFrame
*
8
,
/* maxInputSize= */
targetSampleSizeBytes
,
header
.
numChannels
,
header
.
frameRateHz
,
pcmEncoding
,
/* initializationData= */
null
,
/* drmInitData= */
null
,
/* selectionFlags= */
0
,
/* language= */
null
);
new
Format
.
Builder
()
.
setSampleMimeType
(
mimeType
)
.
setAverageBitrate
(
constantBitrate
)
.
setPeakBitrate
(
constantBitrate
)
.
setMaxInputSize
(
targetSampleSizeBytes
)
.
setChannelCount
(
header
.
numChannels
)
.
setSampleRate
(
header
.
frameRateHz
)
.
setPcmEncoding
(
pcmEncoding
)
.
build
();
}
@Override
...
...
@@ -371,21 +368,17 @@ public final class WavExtractor implements Extractor {
// Create the format. We calculate the bitrate of the data before decoding, since this is the
// bitrate of the stream itself.
int
b
itrate
=
header
.
frameRateHz
*
header
.
blockSize
*
8
/
framesPerBlock
;
int
constantB
itrate
=
header
.
frameRateHz
*
header
.
blockSize
*
8
/
framesPerBlock
;
format
=
Format
.
createAudioSampleFormat
(
/* id= */
null
,
MimeTypes
.
AUDIO_RAW
,
/* codecs= */
null
,
bitrate
,
/* maxInputSize= */
numOutputFramesToBytes
(
targetSampleSizeFrames
,
numChannels
),
header
.
numChannels
,
header
.
frameRateHz
,
C
.
ENCODING_PCM_16BIT
,
/* initializationData= */
null
,
/* drmInitData= */
null
,
/* selectionFlags= */
0
,
/* language= */
null
);
new
Format
.
Builder
()
.
setSampleMimeType
(
MimeTypes
.
AUDIO_RAW
)
.
setAverageBitrate
(
constantBitrate
)
.
setPeakBitrate
(
constantBitrate
)
.
setMaxInputSize
(
numOutputFramesToBytes
(
targetSampleSizeFrames
,
numChannels
))
.
setChannelCount
(
header
.
numChannels
)
.
setSampleRate
(
header
.
frameRateHz
)
.
setPcmEncoding
(
C
.
ENCODING_PCM_16BIT
)
.
build
();
}
@Override
...
...
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/mp4/FragmentedMp4ExtractorTest.java
View file @
67b29bbe
...
...
@@ -48,11 +48,7 @@ public final class FragmentedMp4ExtractorTest {
ExtractorFactory
extractorFactory
=
getExtractorFactory
(
Collections
.
singletonList
(
Format
.
createTextSampleFormat
(
null
,
MimeTypes
.
APPLICATION_CEA608
,
/* selectionFlags= */
0
,
/* language= */
null
)));
new
Format
.
Builder
().
setSampleMimeType
(
MimeTypes
.
APPLICATION_CEA608
).
build
()));
ExtractorAsserts
.
assertBehavior
(
extractorFactory
,
"mp4/sample_fragmented_sei.mp4"
);
}
...
...
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/rawcc/RawCcExtractorTest.java
View file @
67b29bbe
...
...
@@ -28,20 +28,12 @@ public final class RawCcExtractorTest {
@Test
public
void
testRawCcSample
()
throws
Exception
{
ExtractorAsserts
.
assertBehavior
(
()
->
new
RawCcExtractor
(
Format
.
createTextContainerFormat
(
/* id= */
null
,
/* label= */
null
,
/* containerMimeType= */
null
,
/* sampleMimeType= */
MimeTypes
.
APPLICATION_CEA608
,
/* codecs= */
"cea608"
,
/* bitrate= */
Format
.
NO_VALUE
,
/* selectionFlags= */
0
,
/* roleFlags= */
0
,
/* language= */
null
,
/* accessibilityChannel= */
1
)),
"rawcc/sample.rawcc"
);
Format
format
=
new
Format
.
Builder
()
.
setSampleMimeType
(
MimeTypes
.
APPLICATION_CEA608
)
.
setCodecs
(
"cea608"
)
.
setAccessibilityChannel
(
1
)
.
build
();
ExtractorAsserts
.
assertBehavior
(()
->
new
RawCcExtractor
(
format
),
"rawcc/sample.rawcc"
);
}
}
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/ts/TsExtractorTest.java
View file @
67b29bbe
...
...
@@ -102,7 +102,12 @@ public final class TsExtractorTest {
TrackOutput
trackOutput
=
reader
.
getTrackOutput
();
assertThat
(
trackOutput
==
output
.
trackOutputs
.
get
(
257
/* PID of audio track. */
)).
isTrue
();
assertThat
(((
FakeTrackOutput
)
trackOutput
).
lastFormat
)
.
isEqualTo
(
Format
.
createTextSampleFormat
(
"1/257"
,
"mime"
,
/* selectionFlags= */
0
,
"und"
));
.
isEqualTo
(
new
Format
.
Builder
()
.
setId
(
"1/257"
)
.
setSampleMimeType
(
"mime"
)
.
setLanguage
(
"und"
)
.
build
());
}
@Test
...
...
@@ -188,8 +193,11 @@ public final class TsExtractorTest {
idGenerator
.
generateNewId
();
output
=
extractorOutput
.
track
(
idGenerator
.
getTrackId
(),
C
.
TRACK_TYPE_UNKNOWN
);
output
.
format
(
Format
.
createTextSampleFormat
(
idGenerator
.
getFormatId
(),
"mime"
,
/* selectionFlags= */
0
,
language
));
new
Format
.
Builder
()
.
setId
(
idGenerator
.
getFormatId
())
.
setSampleMimeType
(
"mime"
)
.
setLanguage
(
language
)
.
build
());
}
@Override
...
...
testdata/src/test/assets/ogg/bear_vorbis.ogg.0.dump
View file @
67b29bbe
...
...
@@ -11,7 +11,6 @@ track 0:
sample count = 180
format 0:
averageBitrate = 112000
peakBitrate = 112000
sampleMimeType = audio/vorbis
channelCount = 2
sampleRate = 48000
...
...
testdata/src/test/assets/ogg/bear_vorbis.ogg.1.dump
View file @
67b29bbe
...
...
@@ -11,7 +11,6 @@ track 0:
sample count = 109
format 0:
averageBitrate = 112000
peakBitrate = 112000
sampleMimeType = audio/vorbis
channelCount = 2
sampleRate = 48000
...
...
testdata/src/test/assets/ogg/bear_vorbis.ogg.2.dump
View file @
67b29bbe
...
...
@@ -11,7 +11,6 @@ track 0:
sample count = 49
format 0:
averageBitrate = 112000
peakBitrate = 112000
sampleMimeType = audio/vorbis
channelCount = 2
sampleRate = 48000
...
...
testdata/src/test/assets/ogg/bear_vorbis.ogg.3.dump
View file @
67b29bbe
...
...
@@ -11,7 +11,6 @@ track 0:
sample count = 0
format 0:
averageBitrate = 112000
peakBitrate = 112000
sampleMimeType = audio/vorbis
channelCount = 2
sampleRate = 48000
...
...
testdata/src/test/assets/ogg/bear_vorbis.ogg.unklen.dump
View file @
67b29bbe
...
...
@@ -8,7 +8,6 @@ track 0:
sample count = 180
format 0:
averageBitrate = 112000
peakBitrate = 112000
sampleMimeType = audio/vorbis
channelCount = 2
sampleRate = 48000
...
...
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