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
02cc495f
authored
Oct 27, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Cleanup following #884
parent
e252ddde
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
158 additions
and
166 deletions
gradlew.bat
library/src/androidTest/java/com/google/android/exoplayer/MediaFormatTest.java
library/src/main/java/com/google/android/exoplayer/FrameworkSampleSource.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/mp3/Mp3Extractor.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/webm/WebmExtractor.java
library/src/main/java/com/google/android/exoplayer/hls/HlsSampleSource.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/main/java/com/google/android/exoplayer/util/MimeTypes.java
gradlew.bat
View file @
02cc495f
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
library/src/androidTest/java/com/google/android/exoplayer/MediaFormatTest.java
View file @
02cc495f
...
...
@@ -15,11 +15,11 @@
*/
package
com
.
google
.
android
.
exoplayer
;
import
com.google.android.exoplayer.util.Util
;
import
android.annotation.SuppressLint
;
import
android.annotation.TargetApi
;
import
com.google.android.exoplayer.util.Util
;
import
junit.framework.TestCase
;
import
java.nio.ByteBuffer
;
...
...
@@ -47,19 +47,16 @@ public final class MediaFormatTest extends TestCase {
testConversionToFrameworkFormatV16
(
MediaFormat
.
createVideoFormat
(
null
,
"video/xyz"
,
5000
,
102400
,
1000L
,
1280
,
720
,
initData
));
testConversionToFrameworkFormatV16
(
MediaFormat
.
createVideoFormat
(
null
,
"video/xyz"
,
5000
,
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
,
1280
,
720
,
null
));
null
,
"video/xyz"
,
5000
,
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
,
1280
,
720
,
null
));
testConversionToFrameworkFormatV16
(
MediaFormat
.
createAudioFormat
(
null
,
"audio/xyz"
,
500
,
128
,
1000L
,
5
,
44100
,
initData
,
null
));
testConversionToFrameworkFormatV16
(
MediaFormat
.
createAudioFormat
(
null
,
"audio/xyz"
,
500
,
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
,
5
,
44100
,
null
,
null
));
null
,
"audio/xyz"
,
500
,
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
,
5
,
44100
,
null
,
null
));
testConversionToFrameworkFormatV16
(
MediaFormat
.
createTextFormat
(
null
,
"text/xyz"
,
MediaFormat
.
NO_VALUE
,
1000L
,
"eng"
));
MediaFormat
.
createTextFormat
(
null
,
"text/xyz"
,
MediaFormat
.
NO_VALUE
,
1000L
,
"eng"
));
testConversionToFrameworkFormatV16
(
MediaFormat
.
createTextFormat
(
null
,
"text/xyz"
,
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
,
null
));
MediaFormat
.
createTextFormat
(
null
,
"text/xyz"
,
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
,
null
));
}
@SuppressLint
(
"InlinedApi"
)
...
...
library/src/main/java/com/google/android/exoplayer/FrameworkSampleSource.java
View file @
02cc495f
...
...
@@ -315,10 +315,10 @@ public final class FrameworkSampleSource implements SampleSource, SampleSourceRe
}
long
durationUs
=
format
.
containsKey
(
android
.
media
.
MediaFormat
.
KEY_DURATION
)
?
format
.
getLong
(
android
.
media
.
MediaFormat
.
KEY_DURATION
)
:
C
.
UNKNOWN_TIME_US
;
MediaFormat
mediaFormat
=
new
MediaFormat
(
null
,
mimeType
,
MediaFormat
.
NO_VALUE
,
maxInputSize
,
durationUs
,
width
,
height
,
rotationDegrees
,
MediaFormat
.
NO_VALUE
,
channelCount
,
sampleRate
,
language
,
MediaFormat
.
OFFSET_SAMPLE_RELATIVE
,
initializationData
,
false
,
MediaFormat
.
NO_VALUE
,
MediaFormat
.
NO_VALUE
);
MediaFormat
mediaFormat
=
new
MediaFormat
(
null
,
mimeType
,
MediaFormat
.
NO_VALUE
,
maxInputSize
,
durationUs
,
width
,
height
,
rotationDegrees
,
MediaFormat
.
NO_VALUE
,
channelCount
,
sampleRate
,
language
,
MediaFormat
.
OFFSET_SAMPLE_RELATIVE
,
initializationData
,
false
,
MediaFormat
.
NO_VALUE
,
MediaFormat
.
NO_VALUE
);
mediaFormat
.
setFrameworkFormatV16
(
format
);
return
mediaFormat
;
}
...
...
library/src/main/java/com/google/android/exoplayer/MediaFormat.java
View file @
02cc495f
...
...
@@ -15,12 +15,12 @@
*/
package
com
.
google
.
android
.
exoplayer
;
import
android.annotation.SuppressLint
;
import
android.annotation.TargetApi
;
import
com.google.android.exoplayer.util.Assertions
;
import
com.google.android.exoplayer.util.Util
;
import
android.annotation.SuppressLint
;
import
android.annotation.TargetApi
;
import
java.nio.ByteBuffer
;
import
java.util.Arrays
;
import
java.util.Collections
;
...
...
@@ -40,8 +40,7 @@ public final class MediaFormat {
public
static
final
long
OFFSET_SAMPLE_RELATIVE
=
Long
.
MAX_VALUE
;
/**
* The identifier for the track represented by the format, or null if unknown or not
* applicable.
* The identifier for the track represented by the format, or null if unknown or not applicable.
*/
public
final
String
trackId
;
/**
...
...
@@ -229,8 +228,8 @@ public final class MediaFormat {
subsampleOffsetUs
,
initializationData
,
adaptive
,
maxWidth
,
maxHeight
);
}
public
MediaFormat
copyAsAdaptive
()
{
return
new
MediaFormat
(
null
,
mimeType
,
NO_VALUE
,
NO_VALUE
,
durationUs
,
NO_VALUE
,
NO_VALUE
,
public
MediaFormat
copyAsAdaptive
(
String
trackId
)
{
return
new
MediaFormat
(
trackId
,
mimeType
,
NO_VALUE
,
NO_VALUE
,
durationUs
,
NO_VALUE
,
NO_VALUE
,
NO_VALUE
,
NO_VALUE
,
NO_VALUE
,
NO_VALUE
,
null
,
OFFSET_SAMPLE_RELATIVE
,
null
,
true
,
maxWidth
,
maxHeight
);
}
...
...
library/src/main/java/com/google/android/exoplayer/dash/DashChunkSource.java
View file @
02cc495f
...
...
@@ -567,7 +567,7 @@ public class DashChunkSource implements ChunkSource, Output {
Log
.
w
(
TAG
,
"Skipped adaptive track (unknown media format)"
);
return
;
}
tracks
.
add
(
new
ExposedTrack
(
trackFormat
.
copyAsAdaptive
(),
adaptationSetIndex
,
tracks
.
add
(
new
ExposedTrack
(
trackFormat
.
copyAsAdaptive
(
null
),
adaptationSetIndex
,
representationFormats
,
maxWidth
,
maxHeight
));
}
...
...
library/src/main/java/com/google/android/exoplayer/extractor/mp3/Mp3Extractor.java
View file @
02cc495f
...
...
@@ -332,10 +332,9 @@ public final class Mp3Extractor implements Extractor {
if
(
seeker
==
null
)
{
setupSeeker
(
extractorInput
,
headerPosition
);
extractorOutput
.
seekMap
(
seeker
);
trackOutput
.
format
(
MediaFormat
.
createAudioFormat
(
null
,
synchronizedHeader
.
mimeType
,
MediaFormat
.
NO_VALUE
,
MpegAudioHeader
.
MAX_FRAME_SIZE_BYTES
,
seeker
.
getDurationUs
(),
synchronizedHeader
.
channels
,
synchronizedHeader
.
sampleRate
,
null
,
null
));
trackOutput
.
format
(
MediaFormat
.
createAudioFormat
(
null
,
synchronizedHeader
.
mimeType
,
MediaFormat
.
NO_VALUE
,
MpegAudioHeader
.
MAX_FRAME_SIZE_BYTES
,
seeker
.
getDurationUs
(),
synchronizedHeader
.
channels
,
synchronizedHeader
.
sampleRate
,
null
,
null
));
}
return
headerPosition
;
...
...
library/src/main/java/com/google/android/exoplayer/extractor/mp4/AtomParsers.java
View file @
02cc495f
...
...
@@ -744,17 +744,20 @@ import java.util.List;
// TODO: Choose the right AC-3 track based on the contents of dac3/dec3.
// TODO: Add support for encryption (by setting out.trackEncryptionBoxes).
parent
.
setPosition
(
Atom
.
HEADER_SIZE
+
childStartPosition
);
out
.
mediaFormat
=
Ac3Util
.
parseAnnexFAc3Format
(
parent
,
trackId
,
durationUs
,
language
);
out
.
mediaFormat
=
Ac3Util
.
parseAnnexFAc3Format
(
parent
,
Integer
.
toString
(
trackId
),
durationUs
,
language
);
return
;
}
else
if
(
atomType
==
Atom
.
TYPE_ec_3
&&
childAtomType
==
Atom
.
TYPE_dec3
)
{
parent
.
setPosition
(
Atom
.
HEADER_SIZE
+
childStartPosition
);
out
.
mediaFormat
=
Ac3Util
.
parseAnnexFEAc3Format
(
parent
,
trackId
,
durationUs
,
language
);
out
.
mediaFormat
=
Ac3Util
.
parseAnnexFEAc3Format
(
parent
,
Integer
.
toString
(
trackId
),
durationUs
,
language
);
return
;
}
else
if
((
atomType
==
Atom
.
TYPE_dtsc
||
atomType
==
Atom
.
TYPE_dtse
||
atomType
==
Atom
.
TYPE_dtsh
||
atomType
==
Atom
.
TYPE_dtsl
)
&&
childAtomType
==
Atom
.
TYPE_ddts
)
{
out
.
mediaFormat
=
MediaFormat
.
createAudioFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
MediaFormat
.
NO_VALUE
,
MediaFormat
.
NO_VALUE
,
durationUs
,
channelCount
,
sampleRate
,
null
,
language
);
out
.
mediaFormat
=
MediaFormat
.
createAudioFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
MediaFormat
.
NO_VALUE
,
MediaFormat
.
NO_VALUE
,
durationUs
,
channelCount
,
sampleRate
,
null
,
language
);
return
;
}
childPosition
+=
childAtomSize
;
...
...
library/src/main/java/com/google/android/exoplayer/extractor/ts/Ac3Reader.java
View file @
02cc495f
...
...
@@ -155,8 +155,7 @@ import com.google.android.exoplayer.util.ParsableByteArray;
sampleSize
=
Ac3Util
.
parseFrameSize
(
headerScratchBits
);
if
(
mediaFormat
==
null
)
{
headerScratchBits
.
setPosition
(
0
);
mediaFormat
=
Ac3Util
.
parseFrameAc3Format
(
headerScratchBits
,
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
,
null
);
mediaFormat
=
Ac3Util
.
parseFrameAc3Format
(
headerScratchBits
,
null
,
C
.
UNKNOWN_TIME_US
,
null
);
output
.
format
(
mediaFormat
);
bitrate
=
Ac3Util
.
getBitrate
(
sampleSize
,
mediaFormat
.
sampleRate
);
}
...
...
library/src/main/java/com/google/android/exoplayer/extractor/ts/AdtsReader.java
View file @
02cc495f
...
...
@@ -170,10 +170,9 @@ import java.util.Collections;
Pair
<
Integer
,
Integer
>
audioParams
=
CodecSpecificDataUtil
.
parseAacAudioSpecificConfig
(
audioSpecificConfig
);
MediaFormat
mediaFormat
=
MediaFormat
.
createAudioFormat
(
null
,
MimeTypes
.
AUDIO_AAC
,
MediaFormat
.
NO_VALUE
,
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
,
audioParams
.
second
,
audioParams
.
first
,
Collections
.
singletonList
(
audioSpecificConfig
),
null
);
MediaFormat
mediaFormat
=
MediaFormat
.
createAudioFormat
(
null
,
MimeTypes
.
AUDIO_AAC
,
MediaFormat
.
NO_VALUE
,
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
,
audioParams
.
second
,
audioParams
.
first
,
Collections
.
singletonList
(
audioSpecificConfig
),
null
);
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 @
02cc495f
...
...
@@ -210,10 +210,9 @@ import java.util.List;
SpsData
parsedSpsData
=
CodecSpecificDataUtil
.
parseSpsNalUnit
(
bitArray
);
// Construct and output the format.
output
.
format
(
MediaFormat
.
createVideoFormat
(
null
,
MimeTypes
.
VIDEO_H264
,
MediaFormat
.
NO_VALUE
,
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
,
parsedSpsData
.
width
,
parsedSpsData
.
height
,
initializationData
,
MediaFormat
.
NO_VALUE
,
parsedSpsData
.
pixelWidthAspectRatio
));
output
.
format
(
MediaFormat
.
createVideoFormat
(
null
,
MimeTypes
.
VIDEO_H264
,
MediaFormat
.
NO_VALUE
,
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 @
02cc495f
...
...
@@ -294,10 +294,9 @@ import java.util.Collections;
}
}
output
.
format
(
MediaFormat
.
createVideoFormat
(
null
,
MimeTypes
.
VIDEO_H265
,
MediaFormat
.
NO_VALUE
,
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
,
picWidthInLumaSamples
,
picHeightInLumaSamples
,
Collections
.
singletonList
(
csd
),
MediaFormat
.
NO_VALUE
,
pixelWidthHeightRatio
));
output
.
format
(
MediaFormat
.
createVideoFormat
(
null
,
MimeTypes
.
VIDEO_H265
,
MediaFormat
.
NO_VALUE
,
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 @
02cc495f
...
...
@@ -35,8 +35,8 @@ import com.google.android.exoplayer.util.ParsableByteArray;
public
Id3Reader
(
TrackOutput
output
)
{
super
(
output
);
output
.
format
(
MediaFormat
.
createFormatForMimeType
(
null
,
M
imeTypes
.
APPLICATION_ID3
,
M
ediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
));
output
.
format
(
MediaFormat
.
createFormatForMimeType
(
null
,
MimeTypes
.
APPLICATION_ID3
,
MediaFormat
.
NO_VALUE
,
C
.
UNKNOWN_TIME_US
));
}
@Override
...
...
library/src/main/java/com/google/android/exoplayer/extractor/webm/WebmExtractor.java
View file @
02cc495f
...
...
@@ -1227,17 +1227,18 @@ public final class WebmExtractor implements Extractor {
}
MediaFormat
format
;
// TODO:
Read the name of the track from the header of the webm container and
//
supply this as id instead of trackId?
// TODO:
Consider reading the name elements of the tracks and, if present, incorporating them
//
into the trackId passed when creating the formats.
if
(
MimeTypes
.
isAudio
(
mimeType
))
{
format
=
MediaFormat
.
createAudioFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
MediaFormat
.
NO_VALUE
,
maxInputSize
,
durationUs
,
channelCount
,
sampleRate
,
initializationData
,
language
);
format
=
MediaFormat
.
createAudioFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
MediaFormat
.
NO_VALUE
,
maxInputSize
,
durationUs
,
channelCount
,
sampleRate
,
initializationData
,
language
);
}
else
if
(
MimeTypes
.
isVideo
(
mimeType
))
{
format
=
MediaFormat
.
createVideoFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
MediaFormat
.
NO_VALUE
,
maxInputSize
,
durationUs
,
width
,
height
,
initializationData
);
format
=
MediaFormat
.
createVideoFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
MediaFormat
.
NO_VALUE
,
maxInputSize
,
durationUs
,
width
,
height
,
initializationData
);
}
else
if
(
MimeTypes
.
APPLICATION_SUBRIP
.
equals
(
mimeType
))
{
format
=
MediaFormat
.
createTextFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
MediaFormat
.
NO_VALUE
,
durationUs
,
language
);
format
=
MediaFormat
.
createTextFormat
(
Integer
.
toString
(
trackId
),
mimeType
,
MediaFormat
.
NO_VALUE
,
durationUs
,
language
);
}
else
{
throw
new
ParserException
(
"Unexpected MIME type."
);
}
...
...
library/src/main/java/com/google/android/exoplayer/hls/HlsSampleSource.java
View file @
02cc495f
...
...
@@ -144,7 +144,7 @@ public final class HlsSampleSource implements SampleSource, SampleSourceReader,
for
(
int
i
=
0
;
i
<
trackCount
;
i
++)
{
MediaFormat
format
=
extractor
.
getMediaFormat
(
i
).
copyWithDurationUs
(
durationUs
);
if
(
MimeTypes
.
isVideo
(
format
.
mimeType
))
{
format
=
format
.
copyAsAdaptive
();
format
=
format
.
copyAsAdaptive
(
null
);
}
trackFormat
[
i
]
=
format
;
}
...
...
library/src/main/java/com/google/android/exoplayer/smoothstreaming/SmoothStreamingChunkSource.java
View file @
02cc495f
...
...
@@ -368,7 +368,7 @@ public class SmoothStreamingChunkSource implements ChunkSource,
maxHeight
=
Math
.
max
(
maxHeight
,
mediaFormat
.
height
);
}
Arrays
.
sort
(
formats
,
new
DecreasingBandwidthComparator
());
MediaFormat
adaptiveMediaFormat
=
maxHeightMediaFormat
.
copyAsAdaptive
();
MediaFormat
adaptiveMediaFormat
=
maxHeightMediaFormat
.
copyAsAdaptive
(
null
);
tracks
.
add
(
new
ExposedTrack
(
adaptiveMediaFormat
,
element
,
formats
,
maxWidth
,
maxHeight
));
}
...
...
@@ -398,9 +398,8 @@ public class SmoothStreamingChunkSource implements ChunkSource,
int
mp4TrackType
;
switch
(
element
.
type
)
{
case
StreamElement
.
TYPE_VIDEO
:
mediaFormat
=
MediaFormat
.
createVideoFormat
(
format
.
id
,
format
.
mimeType
,
format
.
bitrate
,
MediaFormat
.
NO_VALUE
,
durationUs
,
format
.
width
,
format
.
height
,
Arrays
.
asList
(
csdArray
));
mediaFormat
=
MediaFormat
.
createVideoFormat
(
format
.
id
,
format
.
mimeType
,
format
.
bitrate
,
MediaFormat
.
NO_VALUE
,
durationUs
,
format
.
width
,
format
.
height
,
Arrays
.
asList
(
csdArray
));
mp4TrackType
=
Track
.
TYPE_vide
;
break
;
case
StreamElement
.
TYPE_AUDIO
:
...
...
@@ -411,14 +410,14 @@ public class SmoothStreamingChunkSource implements ChunkSource,
csd
=
Collections
.
singletonList
(
CodecSpecificDataUtil
.
buildAacAudioSpecificConfig
(
format
.
audioSamplingRate
,
format
.
audioChannels
));
}
mediaFormat
=
MediaFormat
.
createAudioFormat
(
format
.
id
,
format
.
mimeType
,
format
.
bitrate
,
MediaFormat
.
NO_VALUE
,
durationUs
,
format
.
audioChannels
,
format
.
audioSamplingRate
,
csd
,
format
.
language
);
mediaFormat
=
MediaFormat
.
createAudioFormat
(
format
.
id
,
format
.
mimeType
,
format
.
bitrate
,
MediaFormat
.
NO_VALUE
,
durationUs
,
format
.
audioChannels
,
format
.
audioSamplingRate
,
csd
,
format
.
language
);
mp4TrackType
=
Track
.
TYPE_soun
;
break
;
case
StreamElement
.
TYPE_TEXT
:
mediaFormat
=
MediaFormat
.
createTextFormat
(
format
.
id
,
format
.
mimeType
,
format
.
bitrate
,
durationUs
,
format
.
language
);
mediaFormat
=
MediaFormat
.
createTextFormat
(
format
.
id
,
format
.
mimeType
,
format
.
bitrate
,
durationUs
,
format
.
language
);
mp4TrackType
=
Track
.
TYPE_text
;
break
;
default
:
...
...
library/src/main/java/com/google/android/exoplayer/util/Ac3Util.java
View file @
02cc495f
...
...
@@ -38,12 +38,12 @@ public final class Ac3Util {
* ETSI TS 102 366 Annex F.
*
* @param data The AC3SpecificBox.
* @param trackId The
identifier for the track in its container, or {@link MediaFormat#NO_VALUE}
.
* @param trackId The
track identifier to set on the format, or null
.
* @param durationUs The duration to set on the format, in microseconds.
* @param language The language to set on the format.
* @return The AC-3 format parsed from data in the header.
*/
public
static
MediaFormat
parseAnnexFAc3Format
(
ParsableByteArray
data
,
int
trackId
,
public
static
MediaFormat
parseAnnexFAc3Format
(
ParsableByteArray
data
,
String
trackId
,
long
durationUs
,
String
language
)
{
// fscod (sample rate code)
int
fscod
=
(
data
.
readUnsignedByte
()
&
0xC0
)
>>
6
;
...
...
@@ -55,7 +55,7 @@ public final class Ac3Util {
if
((
nextByte
&
0x04
)
!=
0
)
{
channelCount
++;
}
return
MediaFormat
.
createAudioFormat
(
Integer
.
toString
(
trackId
)
,
MimeTypes
.
AUDIO_AC3
,
MediaFormat
.
NO_VALUE
,
return
MediaFormat
.
createAudioFormat
(
trackId
,
MimeTypes
.
AUDIO_AC3
,
MediaFormat
.
NO_VALUE
,
MediaFormat
.
NO_VALUE
,
durationUs
,
channelCount
,
sampleRate
,
null
,
language
);
}
...
...
@@ -64,12 +64,12 @@ public final class Ac3Util {
* ETSI TS 102 366 Annex F.
*
* @param data The EC3SpecificBox.
* @param trackId The
identifier for the track in its container, or {@link MediaFormat#NO_VALUE}
.
* @param trackId The
track identifier to set on the format, or null
.
* @param durationUs The duration to set on the format, in microseconds.
* @param language The language to set on the format.
* @return The E-AC-3 format parsed from data in the header.
*/
public
static
MediaFormat
parseAnnexFEAc3Format
(
ParsableByteArray
data
,
int
trackId
,
public
static
MediaFormat
parseAnnexFEAc3Format
(
ParsableByteArray
data
,
String
trackId
,
long
durationUs
,
String
language
)
{
data
.
skipBytes
(
2
);
// Skip data_rate and num_ind_sub.
...
...
@@ -85,7 +85,7 @@ public final class Ac3Util {
if
((
nextByte
&
0x01
)
!=
0
)
{
channelCount
++;
}
return
MediaFormat
.
createAudioFormat
(
Integer
.
toString
(
trackId
)
,
MimeTypes
.
AUDIO_EC3
,
MediaFormat
.
NO_VALUE
,
return
MediaFormat
.
createAudioFormat
(
trackId
,
MimeTypes
.
AUDIO_EC3
,
MediaFormat
.
NO_VALUE
,
MediaFormat
.
NO_VALUE
,
durationUs
,
channelCount
,
sampleRate
,
null
,
language
);
}
...
...
@@ -94,13 +94,13 @@ public final class Ac3Util {
* word.
*
* @param data Data to parse, positioned at the start of the syncword.
* @param trackId The
identifier for the track in its container, or {@link MediaFormat#NO_VALUE}
.
* @param trackId The
track identifier to set on the format, or null
.
* @param durationUs The duration to set on the format, in microseconds.
* @param language The language to set on the format.
* @return The AC-3 format parsed from data in the header.
*/
public
static
MediaFormat
parseFrameAc3Format
(
ParsableBitArray
data
,
int
trackId
,
long
durationUs
,
String
language
)
{
public
static
MediaFormat
parseFrameAc3Format
(
ParsableBitArray
data
,
String
trackId
,
long
durationUs
,
String
language
)
{
// Skip syncword and crc1.
data
.
skipBits
(
4
*
8
);
...
...
@@ -117,7 +117,7 @@ public final class Ac3Util {
data
.
skipBits
(
2
);
// dsurmod
}
boolean
lfeon
=
data
.
readBit
();
return
MediaFormat
.
createAudioFormat
(
Integer
.
toString
(
trackId
)
,
MimeTypes
.
AUDIO_AC3
,
MediaFormat
.
NO_VALUE
,
return
MediaFormat
.
createAudioFormat
(
trackId
,
MimeTypes
.
AUDIO_AC3
,
MediaFormat
.
NO_VALUE
,
MediaFormat
.
NO_VALUE
,
durationUs
,
CHANNEL_COUNTS
[
acmod
]
+
(
lfeon
?
1
:
0
),
SAMPLE_RATES
[
fscod
],
null
,
language
);
}
...
...
library/src/main/java/com/google/android/exoplayer/util/MimeTypes.java
View file @
02cc495f
...
...
@@ -15,8 +15,6 @@
*/
package
com
.
google
.
android
.
exoplayer
.
util
;
import
android.text.TextUtils
;
/**
* Defines common MIME types and helper methods.
*/
...
...
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