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
72195671
authored
Sep 15, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Remove MediaFormat.create methods that don't take a duration.
parent
e7926145
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
35 additions
and
48 deletions
library/src/androidTest/java/com/google/android/exoplayer/MediaFormatTest.java
library/src/main/java/com/google/android/exoplayer/MediaFormat.java
library/src/main/java/com/google/android/exoplayer/dash/DashChunkSource.java
library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java
library/src/main/java/com/google/android/exoplayer/extractor/ts/Ac3Reader.java
library/src/main/java/com/google/android/exoplayer/extractor/ts/AdtsReader.java
library/src/main/java/com/google/android/exoplayer/extractor/ts/H264Reader.java
library/src/main/java/com/google/android/exoplayer/extractor/ts/H265Reader.java
library/src/main/java/com/google/android/exoplayer/extractor/ts/Id3Reader.java
library/src/main/java/com/google/android/exoplayer/extractor/ts/SeiReader.java
library/src/main/java/com/google/android/exoplayer/extractor/webm/WebmExtractor.java
library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingChunkSource.java
library/src/main/java/com/google/android/exoplayer/util/Ac3Util.java
library/src/androidTest/java/com/google/android/exoplayer/MediaFormatTest.java
View file @
72195671
...
...
@@ -45,9 +45,9 @@ public final class MediaFormatTest extends TestCase {
initData
.
add
(
initData2
);
testConversionToFrameworkFormatV16
(
MediaFormat
.
createVideoFormat
(
"video/xyz"
,
5000
,
102400
,
1000L
,
1280
,
720
,
1
,
initData
));
"video/xyz"
,
5000
,
102400
,
1000L
,
1280
,
720
,
initData
));
testConversionToFrameworkFormatV16
(
MediaFormat
.
createVideoFormat
(
"video/xyz"
,
5000
,
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
,
1280
,
720
,
1
,
null
));
"video/xyz"
,
5000
,
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
,
1280
,
720
,
null
));
testConversionToFrameworkFormatV16
(
MediaFormat
.
createAudioFormat
(
"audio/xyz"
,
500
,
128
,
1000L
,
5
,
44100
,
initData
));
testConversionToFrameworkFormatV16
(
MediaFormat
.
createAudioFormat
(
...
...
library/src/main/java/com/google/android/exoplayer/MediaFormat.java
View file @
72195671
...
...
@@ -135,43 +135,26 @@ public final class MediaFormat {
private
android
.
media
.
MediaFormat
frameworkMediaFormat
;
public
static
MediaFormat
createVideoFormat
(
String
mimeType
,
int
bitrate
,
int
maxInputSize
,
int
width
,
int
height
,
List
<
byte
[]>
initializationData
)
{
return
createVideoFormat
(
mimeType
,
bitrate
,
maxInputSize
,
C
.
UNKNOWN_TIME_US
,
width
,
height
,
NO_VALUE
,
initializationData
);
}
public
static
MediaFormat
createVideoFormat
(
String
mimeType
,
int
bitrate
,
int
maxInputSize
,
long
durationUs
,
int
width
,
int
height
,
int
rotationDegrees
,
List
<
byte
[]>
initializationData
)
{
long
durationUs
,
int
width
,
int
height
,
List
<
byte
[]>
initializationData
)
{
return
createVideoFormat
(
mimeType
,
bitrate
,
maxInputSize
,
durationUs
,
width
,
height
,
rotationDegrees
,
NO_VALUE
,
initializationData
);
initializationData
,
NO_VALUE
,
NO_VALUE
);
}
public
static
MediaFormat
createVideoFormat
(
String
mimeType
,
int
bitrate
,
int
maxInputSize
,
long
durationUs
,
int
width
,
int
height
,
int
rotationDegrees
,
float
pixelWidthHeightRatio
,
List
<
byte
[]>
initializationData
)
{
long
durationUs
,
int
width
,
int
height
,
List
<
byte
[]>
initializationData
,
int
rotationDegrees
,
float
pixelWidthHeightRatio
)
{
return
new
MediaFormat
(
mimeType
,
bitrate
,
maxInputSize
,
durationUs
,
width
,
height
,
rotationDegrees
,
pixelWidthHeightRatio
,
NO_VALUE
,
NO_VALUE
,
null
,
OFFSET_SAMPLE_RELATIVE
,
initializationData
,
false
,
NO_VALUE
,
NO_VALUE
);
}
public
static
MediaFormat
createAudioFormat
(
String
mimeType
,
int
bitrate
,
int
maxInputSize
,
int
channelCount
,
int
sampleRate
,
List
<
byte
[]>
initializationData
)
{
return
createAudioFormat
(
mimeType
,
bitrate
,
maxInputSize
,
C
.
UNKNOWN_TIME_US
,
channelCount
,
sampleRate
,
initializationData
);
}
public
static
MediaFormat
createAudioFormat
(
String
mimeType
,
int
bitrate
,
int
maxInputSize
,
long
durationUs
,
int
channelCount
,
int
sampleRate
,
List
<
byte
[]>
initializationData
)
{
return
new
MediaFormat
(
mimeType
,
bitrate
,
maxInputSize
,
durationUs
,
NO_VALUE
,
NO_VALUE
,
NO_VALUE
,
NO_VALUE
,
channelCount
,
sampleRate
,
null
,
OFFSET_SAMPLE_RELATIVE
,
initializationData
,
false
,
NO_VALUE
,
NO_VALUE
);
}
public
static
MediaFormat
createTextFormat
(
String
mimeType
,
int
bitrate
,
String
language
)
{
return
createTextFormat
(
mimeType
,
bitrate
,
language
,
C
.
UNKNOWN_TIME_US
);
}
public
static
MediaFormat
createTextFormat
(
String
mimeType
,
int
bitrate
,
String
language
,
long
durationUs
)
{
return
createTextFormat
(
mimeType
,
bitrate
,
language
,
durationUs
,
OFFSET_SAMPLE_RELATIVE
);
...
...
@@ -183,10 +166,6 @@ public final class MediaFormat {
NO_VALUE
,
NO_VALUE
,
NO_VALUE
,
language
,
subsampleOffsetUs
,
null
,
false
,
NO_VALUE
,
NO_VALUE
);
}
public
static
MediaFormat
createFormatForMimeType
(
String
mimeType
,
int
bitrate
)
{
return
createFormatForMimeType
(
mimeType
,
bitrate
,
C
.
UNKNOWN_TIME_US
);
}
public
static
MediaFormat
createFormatForMimeType
(
String
mimeType
,
int
bitrate
,
long
durationUs
)
{
return
new
MediaFormat
(
mimeType
,
bitrate
,
NO_VALUE
,
durationUs
,
NO_VALUE
,
NO_VALUE
,
NO_VALUE
,
NO_VALUE
,
NO_VALUE
,
NO_VALUE
,
null
,
OFFSET_SAMPLE_RELATIVE
,
null
,
false
,
NO_VALUE
,
...
...
library/src/main/java/com/google/android/exoplayer/dash/DashChunkSource.java
View file @
72195671
...
...
@@ -607,7 +607,7 @@ public class DashChunkSource implements ChunkSource, Output {
switch
(
adaptationSetType
)
{
case
AdaptationSet
.
TYPE_VIDEO
:
return
MediaFormat
.
createVideoFormat
(
mediaMimeType
,
format
.
bitrate
,
MediaFormat
.
NO_VALUE
,
durationUs
,
format
.
width
,
format
.
height
,
0
,
null
);
durationUs
,
format
.
width
,
format
.
height
,
null
);
case
AdaptationSet
.
TYPE_AUDIO
:
return
MediaFormat
.
createAudioFormat
(
mediaMimeType
,
format
.
bitrate
,
MediaFormat
.
NO_VALUE
,
durationUs
,
format
.
audioChannels
,
format
.
audioSamplingRate
,
null
);
...
...
@@ -716,9 +716,8 @@ public class DashChunkSource implements ChunkSource, Output {
long
sampleOffsetUs
=
periodHolder
.
startTimeUs
-
representation
.
presentationTimeOffsetUs
;
if
(
mimeTypeIsRawText
(
format
.
mimeType
))
{
return
new
SingleSampleMediaChunk
(
dataSource
,
dataSpec
,
Chunk
.
TRIGGER_INITIAL
,
format
,
startTimeUs
,
endTimeUs
,
segmentNum
,
MediaFormat
.
createTextFormat
(
format
.
mimeType
,
MediaFormat
.
NO_VALUE
,
format
.
language
),
null
,
periodHolder
.
localIndex
);
startTimeUs
,
endTimeUs
,
segmentNum
,
enabledTrack
.
trackFormat
,
null
,
periodHolder
.
localIndex
);
}
else
{
boolean
isMediaFormatFinal
=
(
mediaFormat
!=
null
);
return
new
ContainerMediaChunk
(
dataSource
,
dataSpec
,
trigger
,
format
,
startTimeUs
,
endTimeUs
,
...
...
library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java
View file @
72195671
...
...
@@ -456,8 +456,8 @@ import java.util.List;
}
out
.
mediaFormat
=
MediaFormat
.
createVideoFormat
(
mimeType
,
MediaFormat
.
NO_VALUE
,
MediaFormat
.
NO_VALUE
,
durationUs
,
width
,
height
,
rotationDegrees
,
pixelWidthHeightRatio
,
initializationData
);
MediaFormat
.
NO_VALUE
,
durationUs
,
width
,
height
,
initializationData
,
rotationDegrees
,
pixelWidthHeightRatio
);
}
private
static
AvcCData
parseAvcCFromParent
(
ParsableByteArray
parent
,
int
position
)
{
...
...
library/src/main/java/com/google/android/exoplayer/extractor/ts/Ac3Reader.java
View file @
72195671
...
...
@@ -155,7 +155,7 @@ import com.google.android.exoplayer.util.ParsableByteArray;
sampleSize
=
Ac3Util
.
parseFrameSize
(
headerScratchBits
);
if
(
mediaFormat
==
null
)
{
headerScratchBits
.
setPosition
(
0
);
mediaFormat
=
Ac3Util
.
parseFrameAc3Format
(
headerScratchBits
);
mediaFormat
=
Ac3Util
.
parseFrameAc3Format
(
headerScratchBits
,
C
.
UNKNOWN_TIME_US
);
output
.
format
(
mediaFormat
);
bitrate
=
Ac3Util
.
getBitrate
(
sampleSize
,
mediaFormat
.
sampleRate
);
}
...
...
library/src/main/java/com/google/android/exoplayer/extractor/ts/AdtsReader.java
View file @
72195671
...
...
@@ -171,8 +171,8 @@ import java.util.Collections;
audioSpecificConfig
);
MediaFormat
mediaFormat
=
MediaFormat
.
createAudioFormat
(
MimeTypes
.
AUDIO_AAC
,
MediaFormat
.
NO_VALUE
,
MediaFormat
.
NO_VALUE
,
audioParams
.
second
,
audioParams
.
first
,
Collections
.
singletonList
(
audioSpecificConfig
));
MediaFormat
.
NO_VALUE
,
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
,
audioParams
.
second
,
audioParams
.
first
,
Collections
.
singletonList
(
audioSpecificConfig
));
frameDurationUs
=
(
C
.
MICROS_PER_SECOND
*
1024L
)
/
mediaFormat
.
sampleRate
;
output
.
format
(
mediaFormat
);
hasOutputFormat
=
true
;
...
...
library/src/main/java/com/google/android/exoplayer/extractor/ts/H264Reader.java
View file @
72195671
...
...
@@ -211,8 +211,8 @@ import java.util.List;
// Construct and output the format.
output
.
format
(
MediaFormat
.
createVideoFormat
(
MimeTypes
.
VIDEO_H264
,
MediaFormat
.
NO_VALUE
,
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
,
parsedSpsData
.
width
,
parsedSpsData
.
height
,
0
,
parsedSpsData
.
pixelWidthAspectRatio
,
initializationData
));
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
,
parsedSpsData
.
width
,
parsedSpsData
.
height
,
initializationData
,
MediaFormat
.
NO_VALUE
,
parsedSpsData
.
pixelWidthAspectRatio
));
hasOutputFormat
=
true
;
}
...
...
library/src/main/java/com/google/android/exoplayer/extractor/ts/H265Reader.java
View file @
72195671
...
...
@@ -295,8 +295,8 @@ import java.util.Collections;
}
output
.
format
(
MediaFormat
.
createVideoFormat
(
MimeTypes
.
VIDEO_H265
,
MediaFormat
.
NO_VALUE
,
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
,
picWidthInLumaSamples
,
picHeightInLumaSamples
,
0
,
pixelWidthHeightRatio
,
Collections
.
singletonList
(
csd
)
));
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
,
picWidthInLumaSamples
,
picHeightInLumaSamples
,
Collections
.
singletonList
(
csd
),
MediaFormat
.
NO_VALUE
,
pixelWidthHeightRatio
));
hasOutputFormat
=
true
;
}
...
...
library/src/main/java/com/google/android/exoplayer/extractor/ts/Id3Reader.java
View file @
72195671
...
...
@@ -36,7 +36,7 @@ import com.google.android.exoplayer.util.ParsableByteArray;
public
Id3Reader
(
TrackOutput
output
)
{
super
(
output
);
output
.
format
(
MediaFormat
.
createFormatForMimeType
(
MimeTypes
.
APPLICATION_ID3
,
MediaFormat
.
NO_VALUE
));
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
));
}
@Override
...
...
library/src/main/java/com/google/android/exoplayer/extractor/ts/SeiReader.java
View file @
72195671
...
...
@@ -33,7 +33,7 @@ import com.google.android.exoplayer.util.ParsableByteArray;
public
SeiReader
(
TrackOutput
output
)
{
super
(
output
);
output
.
format
(
MediaFormat
.
createTextFormat
(
MimeTypes
.
APPLICATION_EIA608
,
MediaFormat
.
NO_VALUE
,
null
));
null
,
C
.
UNKNOWN_TIME_US
));
}
@Override
...
...
library/src/main/java/com/google/android/exoplayer/extractor/webm/WebmExtractor.java
View file @
72195671
...
...
@@ -1213,7 +1213,7 @@ public final class WebmExtractor implements Extractor {
durationUs
,
channelCount
,
sampleRate
,
initializationData
);
}
else
if
(
MimeTypes
.
isVideo
(
mimeType
))
{
format
=
MediaFormat
.
createVideoFormat
(
mimeType
,
MediaFormat
.
NO_VALUE
,
maxInputSize
,
durationUs
,
width
,
height
,
0
,
initializationData
);
durationUs
,
width
,
height
,
initializationData
);
}
else
if
(
MimeTypes
.
APPLICATION_SUBRIP
.
equals
(
mimeType
))
{
format
=
MediaFormat
.
createTextFormat
(
mimeType
,
MediaFormat
.
NO_VALUE
,
language
,
durationUs
);
}
else
{
...
...
library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingChunkSource.java
View file @
72195671
...
...
@@ -399,8 +399,7 @@ public class SmoothStreamingChunkSource implements ChunkSource,
switch
(
element
.
type
)
{
case
StreamElement
.
TYPE_VIDEO
:
mediaFormat
=
MediaFormat
.
createVideoFormat
(
format
.
mimeType
,
format
.
bitrate
,
MediaFormat
.
NO_VALUE
,
durationUs
,
format
.
width
,
format
.
height
,
0
,
Arrays
.
asList
(
csdArray
));
MediaFormat
.
NO_VALUE
,
durationUs
,
format
.
width
,
format
.
height
,
Arrays
.
asList
(
csdArray
));
mp4TrackType
=
Track
.
TYPE_vide
;
break
;
case
StreamElement
.
TYPE_AUDIO
:
...
...
library/src/main/java/com/google/android/exoplayer/util/Ac3Util.java
View file @
72195671
...
...
@@ -36,6 +36,10 @@ public final class Ac3Util {
/**
* Returns the AC-3 format given {@code data} containing the AC3SpecificBox according to
* ETSI TS 102 366 Annex F.
*
* @param data The AC3SpecificBox.
* @param durationUs The duration to set on the format, in microseconds.
* @return The FAc3 format parsed from data in the header.
*/
public
static
MediaFormat
parseAnnexFAc3Format
(
ParsableByteArray
data
,
long
durationUs
)
{
// fscod (sample rate code)
...
...
@@ -55,6 +59,10 @@ public final class Ac3Util {
/**
* Returns the AC-3 format given {@code data} containing the EC3SpecificBox according to
* ETSI TS 102 366 Annex F.
*
* @param data The EC3SpecificBox.
* @param durationUs The duration to set on the format, in microseconds.
* @return The FEAc3 format parsed from data in the header.
*/
public
static
MediaFormat
parseAnnexFEAc3Format
(
ParsableByteArray
data
,
long
durationUs
)
{
data
.
skipBytes
(
2
);
// Skip data_rate and num_ind_sub.
...
...
@@ -80,9 +88,10 @@ public final class Ac3Util {
* word.
*
* @param data Data to parse, positioned at the start of the syncword.
* @return AC-3 format parsed from data in the header.
* @param durationUs The duration to set on the format, in microseconds.
* @return The AC-3 format parsed from data in the header.
*/
public
static
MediaFormat
parseFrameAc3Format
(
ParsableBitArray
data
)
{
public
static
MediaFormat
parseFrameAc3Format
(
ParsableBitArray
data
,
long
durationUs
)
{
// Skip syncword and crc1.
data
.
skipBits
(
4
*
8
);
...
...
@@ -100,7 +109,8 @@ public final class Ac3Util {
}
boolean
lfeon
=
data
.
readBit
();
return
MediaFormat
.
createAudioFormat
(
MimeTypes
.
AUDIO_AC3
,
MediaFormat
.
NO_VALUE
,
MediaFormat
.
NO_VALUE
,
CHANNEL_COUNTS
[
acmod
]
+
(
lfeon
?
1
:
0
),
SAMPLE_RATES
[
fscod
],
null
);
MediaFormat
.
NO_VALUE
,
durationUs
,
CHANNEL_COUNTS
[
acmod
]
+
(
lfeon
?
1
:
0
),
SAMPLE_RATES
[
fscod
],
null
);
}
/**
...
...
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