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
88a637bc
authored
Aug 13, 2021
by
olly
Committed by
Oliver Woodman
Aug 13, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Move format util classes to extractor package
PiperOrigin-RevId: 390577072
parent
149958fb
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
36 additions
and
39 deletions
library/common/src/main/java/com/google/android/exoplayer2/util/MimeTypes.java
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java
library/common/src/main/java/com/google/android/exoplayer2/audio/AacUtil.java → library/extractor/src/main/java/com/google/android/exoplayer2/audio/AacUtil.java
library/common/src/main/java/com/google/android/exoplayer2/audio/Ac3Util.java → library/extractor/src/main/java/com/google/android/exoplayer2/audio/Ac3Util.java
library/common/src/main/java/com/google/android/exoplayer2/audio/Ac4Util.java → library/extractor/src/main/java/com/google/android/exoplayer2/audio/Ac4Util.java
library/common/src/main/java/com/google/android/exoplayer2/audio/DtsUtil.java → library/extractor/src/main/java/com/google/android/exoplayer2/audio/DtsUtil.java
library/common/src/main/java/com/google/android/exoplayer2/audio/MpegAudioUtil.java → library/extractor/src/main/java/com/google/android/exoplayer2/audio/MpegAudioUtil.java
library/common/src/main/java/com/google/android/exoplayer2/audio/OpusUtil.java → library/extractor/src/main/java/com/google/android/exoplayer2/audio/OpusUtil.java
library/common/src/main/java/com/google/android/exoplayer2/audio/WavUtil.java → library/extractor/src/main/java/com/google/android/exoplayer2/audio/WavUtil.java
library/common/src/main/java/com/google/android/exoplayer2/video/AvcConfig.java → library/extractor/src/main/java/com/google/android/exoplayer2/video/AvcConfig.java
library/common/src/main/java/com/google/android/exoplayer2/video/DolbyVisionConfig.java → library/extractor/src/main/java/com/google/android/exoplayer2/video/DolbyVisionConfig.java
library/common/src/main/java/com/google/android/exoplayer2/video/HevcConfig.java → library/extractor/src/main/java/com/google/android/exoplayer2/video/HevcConfig.java
library/common/src/test/java/com/google/android/exoplayer2/audio/Ac3UtilTest.java → library/extractor/src/test/java/com/google/android/exoplayer2/audio/Ac3UtilTest.java
library/common/src/test/java/com/google/android/exoplayer2/audio/OpusUtilTest.java → library/extractor/src/test/java/com/google/android/exoplayer2/audio/OpusUtilTest.java
library/common/src/test/java/com/google/android/exoplayer2/video/HevcConfigTest.java → library/extractor/src/test/java/com/google/android/exoplayer2/video/HevcConfigTest.java
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylistParser.java
library/common/src/main/java/com/google/android/exoplayer2/util/MimeTypes.java
View file @
88a637bc
...
@@ -19,8 +19,6 @@ import android.text.TextUtils;
...
@@ -19,8 +19,6 @@ import android.text.TextUtils;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.VisibleForTesting
;
import
androidx.annotation.VisibleForTesting
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.audio.AacUtil
;
import
com.google.android.exoplayer2.audio.Ac3Util
;
import
com.google.common.base.Ascii
;
import
com.google.common.base.Ascii
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.regex.Matcher
;
import
java.util.regex.Matcher
;
...
@@ -120,6 +118,14 @@ public final class MimeTypes {
...
@@ -120,6 +118,14 @@ public final class MimeTypes {
public
static
final
String
IMAGE_JPEG
=
BASE_TYPE_IMAGE
+
"/jpeg"
;
public
static
final
String
IMAGE_JPEG
=
BASE_TYPE_IMAGE
+
"/jpeg"
;
/**
* A non-standard codec string for E-AC3-JOC. Use of this constant allows for disambiguation
* between regular E-AC3 ("ec-3") and E-AC3-JOC ("ec+3") streams from the codec string alone. The
* standard is to use "ec-3" for both, as per the <a href="https://mp4ra.org/#/codecs">MP4RA
* registered codec types</a>.
*/
public
static
final
String
CODEC_E_AC3_JOC
=
"ec+3"
;
private
static
final
ArrayList
<
CustomMimeType
>
customMimeTypes
=
new
ArrayList
<>();
private
static
final
ArrayList
<
CustomMimeType
>
customMimeTypes
=
new
ArrayList
<>();
private
static
final
Pattern
MP4A_RFC_6381_CODEC_PATTERN
=
private
static
final
Pattern
MP4A_RFC_6381_CODEC_PATTERN
=
...
@@ -214,8 +220,7 @@ public final class MimeTypes {
...
@@ -214,8 +220,7 @@ public final class MimeTypes {
if
(
objectType
==
null
)
{
if
(
objectType
==
null
)
{
return
false
;
return
false
;
}
}
@C
.
Encoding
@C
.
Encoding
int
encoding
=
objectType
.
getEncoding
();
int
encoding
=
AacUtil
.
getEncodingForAudioObjectType
(
objectType
.
audioObjectTypeIndication
);
// xHE-AAC is an exception in which it's not true that all samples will be sync samples.
// xHE-AAC is an exception in which it's not true that all samples will be sync samples.
// Also return false for ENCODING_INVALID, which indicates we weren't able to parse the
// Also return false for ENCODING_INVALID, which indicates we weren't able to parse the
// encoding from the codec string.
// encoding from the codec string.
...
@@ -377,7 +382,7 @@ public final class MimeTypes {
...
@@ -377,7 +382,7 @@ public final class MimeTypes {
return
MimeTypes
.
AUDIO_AC3
;
return
MimeTypes
.
AUDIO_AC3
;
}
else
if
(
codec
.
startsWith
(
"ec-3"
)
||
codec
.
startsWith
(
"dec3"
))
{
}
else
if
(
codec
.
startsWith
(
"ec-3"
)
||
codec
.
startsWith
(
"dec3"
))
{
return
MimeTypes
.
AUDIO_E_AC3
;
return
MimeTypes
.
AUDIO_E_AC3
;
}
else
if
(
codec
.
startsWith
(
Ac3Util
.
E_AC3_JOC_CODEC_STRING
))
{
}
else
if
(
codec
.
startsWith
(
CODEC_E_AC3_JOC
))
{
return
MimeTypes
.
AUDIO_E_AC3_JOC
;
return
MimeTypes
.
AUDIO_E_AC3_JOC
;
}
else
if
(
codec
.
startsWith
(
"ac-4"
)
||
codec
.
startsWith
(
"dac4"
))
{
}
else
if
(
codec
.
startsWith
(
"ac-4"
)
||
codec
.
startsWith
(
"dac4"
))
{
return
MimeTypes
.
AUDIO_AC4
;
return
MimeTypes
.
AUDIO_AC4
;
...
@@ -514,7 +519,7 @@ public final class MimeTypes {
...
@@ -514,7 +519,7 @@ public final class MimeTypes {
if
(
objectType
==
null
)
{
if
(
objectType
==
null
)
{
return
C
.
ENCODING_INVALID
;
return
C
.
ENCODING_INVALID
;
}
}
return
AacUtil
.
getEncodingForAudioObjectType
(
objectType
.
audioObjectTypeIndication
);
return
objectType
.
getEncoding
(
);
case
MimeTypes
.
AUDIO_AC3
:
case
MimeTypes
.
AUDIO_AC3
:
return
C
.
ENCODING_AC3
;
return
C
.
ENCODING_AC3
;
case
MimeTypes
.
AUDIO_E_AC3
:
case
MimeTypes
.
AUDIO_E_AC3
:
...
@@ -665,12 +670,34 @@ public final class MimeTypes {
...
@@ -665,12 +670,34 @@ public final class MimeTypes {
/** The Object Type Indication of the MP4A codec. */
/** The Object Type Indication of the MP4A codec. */
public
final
int
objectTypeIndication
;
public
final
int
objectTypeIndication
;
/** The Audio Object Type Indication of the MP4A codec, or 0 if it is absent. */
/** The Audio Object Type Indication of the MP4A codec, or 0 if it is absent. */
@AacUtil
.
AacAudioObjectType
public
final
int
audioObjectTypeIndication
;
public
final
int
audioObjectTypeIndication
;
public
Mp4aObjectType
(
int
objectTypeIndication
,
int
audioObjectTypeIndication
)
{
public
Mp4aObjectType
(
int
objectTypeIndication
,
int
audioObjectTypeIndication
)
{
this
.
objectTypeIndication
=
objectTypeIndication
;
this
.
objectTypeIndication
=
objectTypeIndication
;
this
.
audioObjectTypeIndication
=
audioObjectTypeIndication
;
this
.
audioObjectTypeIndication
=
audioObjectTypeIndication
;
}
}
/** Returns the encoding for {@link #audioObjectTypeIndication}. */
@C
.
Encoding
public
int
getEncoding
()
{
// See AUDIO_OBJECT_TYPE_AAC_* constants in AacUtil.
switch
(
audioObjectTypeIndication
)
{
case
2
:
return
C
.
ENCODING_AAC_LC
;
case
5
:
return
C
.
ENCODING_AAC_HE_V1
;
case
29
:
return
C
.
ENCODING_AAC_HE_V2
;
case
42
:
return
C
.
ENCODING_AAC_XHE
;
case
23
:
return
C
.
ENCODING_AAC_ELD
;
case
22
:
return
C
.
ENCODING_AAC_ER_BSAC
;
default
:
return
C
.
ENCODING_INVALID
;
}
}
}
}
private
static
final
class
CustomMimeType
{
private
static
final
class
CustomMimeType
{
...
...
library/dash/src/main/java/com/google/android/exoplayer2/source/dash/manifest/DashManifestParser.java
View file @
88a637bc
...
@@ -24,7 +24,6 @@ import androidx.annotation.Nullable;
...
@@ -24,7 +24,6 @@ import androidx.annotation.Nullable;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.ParserException
;
import
com.google.android.exoplayer2.ParserException
;
import
com.google.android.exoplayer2.audio.Ac3Util
;
import
com.google.android.exoplayer2.drm.DrmInitData
;
import
com.google.android.exoplayer2.drm.DrmInitData
;
import
com.google.android.exoplayer2.drm.DrmInitData.SchemeData
;
import
com.google.android.exoplayer2.drm.DrmInitData.SchemeData
;
import
com.google.android.exoplayer2.extractor.mp4.PsshAtomUtil
;
import
com.google.android.exoplayer2.extractor.mp4.PsshAtomUtil
;
...
@@ -776,7 +775,7 @@ public class DashManifestParser extends DefaultHandler
...
@@ -776,7 +775,7 @@ public class DashManifestParser extends DefaultHandler
if
(
MimeTypes
.
AUDIO_E_AC3
.
equals
(
sampleMimeType
))
{
if
(
MimeTypes
.
AUDIO_E_AC3
.
equals
(
sampleMimeType
))
{
sampleMimeType
=
parseEac3SupplementalProperties
(
supplementalProperties
);
sampleMimeType
=
parseEac3SupplementalProperties
(
supplementalProperties
);
if
(
MimeTypes
.
AUDIO_E_AC3_JOC
.
equals
(
sampleMimeType
))
{
if
(
MimeTypes
.
AUDIO_E_AC3_JOC
.
equals
(
sampleMimeType
))
{
codecs
=
Ac3Util
.
E_AC3_JOC_CODEC_STRING
;
codecs
=
MimeTypes
.
CODEC_E_AC3_JOC
;
}
}
}
}
@C
.
SelectionFlags
int
selectionFlags
=
parseSelectionFlagsFromRoleDescriptors
(
roleDescriptors
);
@C
.
SelectionFlags
int
selectionFlags
=
parseSelectionFlagsFromRoleDescriptors
(
roleDescriptors
);
...
...
library/
common
/src/main/java/com/google/android/exoplayer2/audio/AacUtil.java
→
library/
extractor
/src/main/java/com/google/android/exoplayer2/audio/AacUtil.java
View file @
88a637bc
...
@@ -300,27 +300,6 @@ public final class AacUtil {
...
@@ -300,27 +300,6 @@ public final class AacUtil {
return
specificConfig
;
return
specificConfig
;
}
}
/** Returns the encoding for a given AAC audio object type. */
@C
.
Encoding
public
static
int
getEncodingForAudioObjectType
(
@AacAudioObjectType
int
audioObjectType
)
{
switch
(
audioObjectType
)
{
case
AUDIO_OBJECT_TYPE_AAC_LC:
return
C
.
ENCODING_AAC_LC
;
case
AUDIO_OBJECT_TYPE_AAC_SBR:
return
C
.
ENCODING_AAC_HE_V1
;
case
AUDIO_OBJECT_TYPE_AAC_PS:
return
C
.
ENCODING_AAC_HE_V2
;
case
AUDIO_OBJECT_TYPE_AAC_XHE:
return
C
.
ENCODING_AAC_XHE
;
case
AUDIO_OBJECT_TYPE_AAC_ELD:
return
C
.
ENCODING_AAC_ELD
;
case
AUDIO_OBJECT_TYPE_AAC_ER_BSAC:
return
C
.
ENCODING_AAC_ER_BSAC
;
default
:
return
C
.
ENCODING_INVALID
;
}
}
/**
/**
* Returns the AAC audio object type as specified in 14496-3 (2005) Table 1.14.
* Returns the AAC audio object type as specified in 14496-3 (2005) Table 1.14.
*
*
...
...
library/
common
/src/main/java/com/google/android/exoplayer2/audio/Ac3Util.java
→
library/
extractor
/src/main/java/com/google/android/exoplayer2/audio/Ac3Util.java
View file @
88a637bc
...
@@ -91,13 +91,6 @@ public final class Ac3Util {
...
@@ -91,13 +91,6 @@ public final class Ac3Util {
}
}
}
}
/**
* A non-standard codec string for E-AC3-JOC. Use of this constant allows for disambiguation
* between regular E-AC3 ("ec-3") and E-AC3-JOC ("ec+3") streams from the codec string alone. The
* standard is to use "ec-3" for both, as per the <a href="https://mp4ra.org/#/codecs">MP4RA
* registered codec types</a>.
*/
public
static
final
String
E_AC3_JOC_CODEC_STRING
=
"ec+3"
;
/** Maximum rate for an AC-3 audio stream, in bytes per second. */
/** Maximum rate for an AC-3 audio stream, in bytes per second. */
public
static
final
int
AC3_MAX_RATE_BYTES_PER_SECOND
=
640
*
1000
/
8
;
public
static
final
int
AC3_MAX_RATE_BYTES_PER_SECOND
=
640
*
1000
/
8
;
/** Maximum rate for an E-AC-3 audio stream, in bytes per second. */
/** Maximum rate for an E-AC-3 audio stream, in bytes per second. */
...
...
library/
common
/src/main/java/com/google/android/exoplayer2/audio/Ac4Util.java
→
library/
extractor
/src/main/java/com/google/android/exoplayer2/audio/Ac4Util.java
View file @
88a637bc
File moved
library/
common
/src/main/java/com/google/android/exoplayer2/audio/DtsUtil.java
→
library/
extractor
/src/main/java/com/google/android/exoplayer2/audio/DtsUtil.java
View file @
88a637bc
File moved
library/
common
/src/main/java/com/google/android/exoplayer2/audio/MpegAudioUtil.java
→
library/
extractor
/src/main/java/com/google/android/exoplayer2/audio/MpegAudioUtil.java
View file @
88a637bc
File moved
library/
common
/src/main/java/com/google/android/exoplayer2/audio/OpusUtil.java
→
library/
extractor
/src/main/java/com/google/android/exoplayer2/audio/OpusUtil.java
View file @
88a637bc
File moved
library/
common
/src/main/java/com/google/android/exoplayer2/audio/WavUtil.java
→
library/
extractor
/src/main/java/com/google/android/exoplayer2/audio/WavUtil.java
View file @
88a637bc
File moved
library/
common
/src/main/java/com/google/android/exoplayer2/video/AvcConfig.java
→
library/
extractor
/src/main/java/com/google/android/exoplayer2/video/AvcConfig.java
View file @
88a637bc
File moved
library/
common
/src/main/java/com/google/android/exoplayer2/video/DolbyVisionConfig.java
→
library/
extractor
/src/main/java/com/google/android/exoplayer2/video/DolbyVisionConfig.java
View file @
88a637bc
File moved
library/
common
/src/main/java/com/google/android/exoplayer2/video/HevcConfig.java
→
library/
extractor
/src/main/java/com/google/android/exoplayer2/video/HevcConfig.java
View file @
88a637bc
File moved
library/
common
/src/test/java/com/google/android/exoplayer2/audio/Ac3UtilTest.java
→
library/
extractor
/src/test/java/com/google/android/exoplayer2/audio/Ac3UtilTest.java
View file @
88a637bc
File moved
library/
common
/src/test/java/com/google/android/exoplayer2/audio/OpusUtilTest.java
→
library/
extractor
/src/test/java/com/google/android/exoplayer2/audio/OpusUtilTest.java
View file @
88a637bc
File moved
library/
common
/src/test/java/com/google/android/exoplayer2/video/HevcConfigTest.java
→
library/
extractor
/src/test/java/com/google/android/exoplayer2/video/HevcConfigTest.java
View file @
88a637bc
File moved
library/hls/src/main/java/com/google/android/exoplayer2/source/hls/playlist/HlsPlaylistParser.java
View file @
88a637bc
...
@@ -26,7 +26,6 @@ import androidx.annotation.Nullable;
...
@@ -26,7 +26,6 @@ import androidx.annotation.Nullable;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.ParserException
;
import
com.google.android.exoplayer2.ParserException
;
import
com.google.android.exoplayer2.audio.Ac3Util
;
import
com.google.android.exoplayer2.drm.DrmInitData
;
import
com.google.android.exoplayer2.drm.DrmInitData
;
import
com.google.android.exoplayer2.drm.DrmInitData.SchemeData
;
import
com.google.android.exoplayer2.drm.DrmInitData.SchemeData
;
import
com.google.android.exoplayer2.extractor.mp4.PsshAtomUtil
;
import
com.google.android.exoplayer2.extractor.mp4.PsshAtomUtil
;
...
@@ -518,7 +517,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
...
@@ -518,7 +517,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
formatBuilder
.
setChannelCount
(
channelCount
);
formatBuilder
.
setChannelCount
(
channelCount
);
if
(
MimeTypes
.
AUDIO_E_AC3
.
equals
(
sampleMimeType
)
&&
channelsString
.
endsWith
(
"/JOC"
))
{
if
(
MimeTypes
.
AUDIO_E_AC3
.
equals
(
sampleMimeType
)
&&
channelsString
.
endsWith
(
"/JOC"
))
{
sampleMimeType
=
MimeTypes
.
AUDIO_E_AC3_JOC
;
sampleMimeType
=
MimeTypes
.
AUDIO_E_AC3_JOC
;
formatBuilder
.
setCodecs
(
Ac3Util
.
E_AC3_JOC_CODEC_STRING
);
formatBuilder
.
setCodecs
(
MimeTypes
.
CODEC_E_AC3_JOC
);
}
}
}
}
formatBuilder
.
setSampleMimeType
(
sampleMimeType
);
formatBuilder
.
setSampleMimeType
(
sampleMimeType
);
...
...
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