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
eeaa6171
authored
Nov 01, 2021
by
olly
Committed by
tonihei
Nov 01, 2021
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Rename MediaFormatUtil constants
PiperOrigin-RevId: 406816023
parent
f45a8bc4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
13 deletions
library/common/src/main/java/com/google/android/exoplayer2/util/MediaFormatUtil.java
library/common/src/test/java/com/google/android/exoplayer2/util/MediaFormatUtilTest.java
library/common/src/main/java/com/google/android/exoplayer2/util/MediaFormatUtil.java
View file @
eeaa6171
...
...
@@ -32,17 +32,19 @@ public final class MediaFormatUtil {
* Custom {@link MediaFormat} key associated with a float representing the ratio between a pixel's
* width and height.
*/
public
static
final
String
KEY_EXO_PIXEL_WIDTH_HEIGHT_RATIO_FLOAT
=
// The constant value must not be changed, because it's also set by the framework MediaParser API.
public
static
final
String
KEY_PIXEL_WIDTH_HEIGHT_RATIO_FLOAT
=
"exo-pixel-width-height-ratio-float"
;
/**
* Custom {@link MediaFormat} key associated with an integer representing the PCM encoding.
*
* <p>Equivalent to {@link MediaFormat#KEY_PCM_ENCODING}, except it allows additional
*
ExoPlayer-specific values
including {@link C#ENCODING_PCM_16BIT_BIG_ENDIAN}, {@link
* <p>Equivalent to {@link MediaFormat#KEY_PCM_ENCODING}, except it allows additional
values
*
defined by {@link C.PcmEncoding},
including {@link C#ENCODING_PCM_16BIT_BIG_ENDIAN}, {@link
* C#ENCODING_PCM_24BIT}, and {@link C#ENCODING_PCM_32BIT}.
*/
public
static
final
String
KEY_EXO_PCM_ENCODING
=
"exo-pcm-encoding-int"
;
// The constant value must not be changed, because it's also set by the framework MediaParser API.
public
static
final
String
KEY_PCM_ENCODING_EXTENDED
=
"exo-pcm-encoding-int"
;
private
static
final
int
MAX_POWER_OF_TWO_INT
=
1
<<
30
;
...
...
@@ -52,8 +54,8 @@ public final class MediaFormatUtil {
* <p>May include the following custom keys:
*
* <ul>
* <li>{@link #KEY_
EXO_
PIXEL_WIDTH_HEIGHT_RATIO_FLOAT}.
* <li>{@link #KEY_
EXO_PCM_ENCODING
}.
* <li>{@link #KEY_PIXEL_WIDTH_HEIGHT_RATIO_FLOAT}.
* <li>{@link #KEY_
PCM_ENCODING_EXTENDED
}.
* </ul>
*/
@SuppressLint
(
"InlinedApi"
)
// Inlined MediaFormat keys.
...
...
@@ -184,7 +186,7 @@ public final class MediaFormatUtil {
@SuppressLint
(
"InlinedApi"
)
private
static
void
maybeSetPixelAspectRatio
(
MediaFormat
mediaFormat
,
float
pixelWidthHeightRatio
)
{
mediaFormat
.
setFloat
(
KEY_
EXO_
PIXEL_WIDTH_HEIGHT_RATIO_FLOAT
,
pixelWidthHeightRatio
);
mediaFormat
.
setFloat
(
KEY_PIXEL_WIDTH_HEIGHT_RATIO_FLOAT
,
pixelWidthHeightRatio
);
int
pixelAspectRatioWidth
=
1
;
int
pixelAspectRatioHeight
=
1
;
// ExoPlayer extractors output the pixel aspect ratio as a float. Do our best to recreate the
...
...
@@ -207,7 +209,7 @@ public final class MediaFormatUtil {
return
;
}
int
mediaFormatPcmEncoding
;
maybeSetInteger
(
mediaFormat
,
KEY_
EXO_PCM_ENCODING
,
exoPcmEncoding
);
maybeSetInteger
(
mediaFormat
,
KEY_
PCM_ENCODING_EXTENDED
,
exoPcmEncoding
);
switch
(
exoPcmEncoding
)
{
case
C
.
ENCODING_PCM_8BIT
:
mediaFormatPcmEncoding
=
AudioFormat
.
ENCODING_PCM_8BIT
;
...
...
library/common/src/test/java/com/google/android/exoplayer2/util/MediaFormatUtilTest.java
View file @
eeaa6171
...
...
@@ -37,7 +37,7 @@ public class MediaFormatUtilTest {
// Assert that no invalid keys are accidentally being populated.
assertThat
(
mediaFormat
.
getKeys
())
.
containsExactly
(
MediaFormatUtil
.
KEY_
EXO_
PIXEL_WIDTH_HEIGHT_RATIO_FLOAT
,
MediaFormatUtil
.
KEY_PIXEL_WIDTH_HEIGHT_RATIO_FLOAT
,
MediaFormat
.
KEY_ENCODER_DELAY
,
MediaFormat
.
KEY_ENCODER_PADDING
,
MediaFormat
.
KEY_PIXEL_ASPECT_RATIO_WIDTH
,
...
...
@@ -46,7 +46,7 @@ public class MediaFormatUtilTest {
MediaFormat
.
KEY_IS_FORCED_SUBTITLE
,
MediaFormat
.
KEY_IS_AUTOSELECT
,
MediaFormat
.
KEY_ROTATION
);
assertThat
(
mediaFormat
.
getFloat
(
MediaFormatUtil
.
KEY_
EXO_
PIXEL_WIDTH_HEIGHT_RATIO_FLOAT
))
assertThat
(
mediaFormat
.
getFloat
(
MediaFormatUtil
.
KEY_PIXEL_WIDTH_HEIGHT_RATIO_FLOAT
))
.
isEqualTo
(
1
.
f
);
assertThat
(
mediaFormat
.
getInteger
(
MediaFormat
.
KEY_ENCODER_DELAY
)).
isEqualTo
(
0
);
assertThat
(
mediaFormat
.
getInteger
(
MediaFormat
.
KEY_ENCODER_PADDING
)).
isEqualTo
(
0
);
...
...
@@ -116,7 +116,7 @@ public class MediaFormatUtilTest {
.
isEqualTo
(
format
.
initializationData
.
get
(
1
));
assertThat
(
mediaFormat
.
getInteger
(
MediaFormat
.
KEY_PCM_ENCODING
)).
isEqualTo
(
format
.
pcmEncoding
);
assertThat
(
mediaFormat
.
getInteger
(
MediaFormatUtil
.
KEY_
EXO_PCM_ENCODING
))
assertThat
(
mediaFormat
.
getInteger
(
MediaFormatUtil
.
KEY_
PCM_ENCODING_EXTENDED
))
.
isEqualTo
(
format
.
pcmEncoding
);
assertThat
(
mediaFormat
.
getString
(
MediaFormat
.
KEY_LANGUAGE
)).
isEqualTo
(
format
.
language
);
...
...
@@ -140,7 +140,7 @@ public class MediaFormatUtilTest {
(
float
)
mediaFormat
.
getInteger
(
MediaFormat
.
KEY_PIXEL_ASPECT_RATIO_WIDTH
)
/
mediaFormat
.
getInteger
(
MediaFormat
.
KEY_PIXEL_ASPECT_RATIO_HEIGHT
);
assertThat
(
calculatedPixelAspectRatio
).
isWithin
(.
0001
f
).
of
(
format
.
pixelWidthHeightRatio
);
assertThat
(
mediaFormat
.
getFloat
(
MediaFormatUtil
.
KEY_
EXO_
PIXEL_WIDTH_HEIGHT_RATIO_FLOAT
))
assertThat
(
mediaFormat
.
getFloat
(
MediaFormatUtil
.
KEY_PIXEL_WIDTH_HEIGHT_RATIO_FLOAT
))
.
isEqualTo
(
format
.
pixelWidthHeightRatio
);
}
...
...
@@ -148,7 +148,7 @@ public class MediaFormatUtilTest {
public
void
createMediaFormatFromFormat_withPcmEncoding_setsCustomPcmEncodingEntry
()
{
Format
format
=
new
Format
.
Builder
().
setPcmEncoding
(
C
.
ENCODING_PCM_32BIT
).
build
();
MediaFormat
mediaFormat
=
MediaFormatUtil
.
createMediaFormatFromFormat
(
format
);
assertThat
(
mediaFormat
.
getInteger
(
MediaFormatUtil
.
KEY_
EXO_PCM_ENCODING
))
assertThat
(
mediaFormat
.
getInteger
(
MediaFormatUtil
.
KEY_
PCM_ENCODING_EXTENDED
))
.
isEqualTo
(
C
.
ENCODING_PCM_32BIT
);
assertThat
(
mediaFormat
.
containsKey
(
MediaFormat
.
KEY_PCM_ENCODING
)).
isFalse
();
}
...
...
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