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