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
bd4a5ecf
authored
Feb 17, 2023
by
andrewlewis
Committed by
Andrew Lewis
Feb 24, 2023
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Align test codec caps check with real implementation
PiperOrigin-RevId: 510437262
parent
241364b9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
28 deletions
library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/AndroidTestUtil.java
library/transformer/src/androidTest/java/com/google/android/exoplayer2/transformer/AndroidTestUtil.java
View file @
bd4a5ecf
...
...
@@ -23,13 +23,14 @@ import static com.google.android.exoplayer2.util.MimeTypes.VIDEO_H265;
import
android.content.Context
;
import
android.media.MediaFormat
;
import
android.os.Build
;
import
android.util.Pair
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.C
;
import
com.google.android.exoplayer2.Format
;
import
com.google.android.exoplayer2.MediaItem
;
import
com.google.android.exoplayer2.mediacodec.MediaCodecInfo
;
import
com.google.android.exoplayer2.mediacodec.MediaCodecUtil
;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.MediaFormatUtil
;
import
com.google.android.exoplayer2.util.MimeTypes
;
import
com.google.android.exoplayer2.util.Util
;
import
com.google.android.exoplayer2.video.ColorInfo
;
...
...
@@ -596,13 +597,7 @@ public final class AndroidTestUtil {
public
static
boolean
skipAndLogIfFormatsUnsupported
(
Context
context
,
String
testId
,
Format
inputFormat
,
@Nullable
Format
outputFormat
)
throws
IOException
,
JSONException
{
boolean
canDecode
=
false
;
@Nullable
MediaCodecUtil
.
DecoderQueryException
queryException
=
null
;
try
{
canDecode
=
canDecode
(
inputFormat
);
}
catch
(
MediaCodecUtil
.
DecoderQueryException
e
)
{
queryException
=
e
;
}
boolean
canDecode
=
canDecode
(
inputFormat
);
boolean
canEncode
=
outputFormat
==
null
||
canEncode
(
outputFormat
);
boolean
canMux
=
outputFormat
==
null
||
canMux
(
outputFormat
);
...
...
@@ -613,12 +608,9 @@ public final class AndroidTestUtil {
StringBuilder
skipReasonBuilder
=
new
StringBuilder
();
if
(!
canDecode
)
{
skipReasonBuilder
.
append
(
"Cannot decode "
).
append
(
inputFormat
).
append
(
'\n'
);
if
(
queryException
!=
null
)
{
skipReasonBuilder
.
append
(
queryException
).
append
(
'\n'
);
}
}
if
(!
canEncode
)
{
skipReasonBuilder
.
append
(
"Cannot encode "
).
append
(
outputFormat
);
skipReasonBuilder
.
append
(
"Cannot encode "
).
append
(
outputFormat
)
.
append
(
'\n'
)
;
}
if
(!
canMux
)
{
skipReasonBuilder
.
append
(
"Cannot mux "
).
append
(
outputFormat
);
...
...
@@ -705,25 +697,18 @@ public final class AndroidTestUtil {
}
}
private
static
boolean
canDecode
(
Format
format
)
throws
MediaCodecUtil
.
DecoderQueryException
{
private
static
boolean
canDecode
(
Format
format
)
{
// Check decoding capability in the same way as the default decoder factory.
MediaFormat
mediaFormat
=
MediaFormatUtil
.
createMediaFormatFromFormat
(
format
);
@Nullable
MediaCodecInfo
decoderInfo
=
MediaCodecUtil
.
getDecoderInfo
(
checkNotNull
(
format
.
sampleMimeType
),
/* secure= */
false
,
/* tunneling= */
false
);
if
(
decoderInfo
==
null
)
{
return
false
;
Pair
<
Integer
,
Integer
>
codecProfileAndLevel
=
MediaCodecUtil
.
getCodecProfileAndLevel
(
format
);
if
(
codecProfileAndLevel
!=
null
)
{
MediaFormatUtil
.
maybeSetInteger
(
mediaFormat
,
MediaFormat
.
KEY_PROFILE
,
codecProfileAndLevel
.
first
);
}
// Use Format.NO_VALUE for frame rate to only check whether size is supported.
return
decoderInfo
.
isVideoSizeAndRateSupportedV21
(
format
.
width
,
format
.
height
,
/* frameRate= */
Format
.
NO_VALUE
);
return
EncoderUtil
.
findCodecForFormat
(
mediaFormat
,
/* isDecoder= */
true
)
!=
null
;
}
/**
* Returns whether the top ranked encoder from {@link EncoderUtil#getSupportedEncoders} supports
* the given resolution and {@linkplain Format#averageBitrate bitrate}.
*
* <p>Assumes support encoding if the {@link Format#averageBitrate bitrate} is not set.
*/
private
static
boolean
canEncode
(
Format
format
)
{
String
mimeType
=
checkNotNull
(
format
.
sampleMimeType
);
ImmutableList
<
android
.
media
.
MediaCodecInfo
>
supportedEncoders
=
...
...
@@ -742,7 +727,6 @@ public final class AndroidTestUtil {
return
sizeSupported
&&
bitrateSupported
;
}
/** Returns whether the specified format can be muxed via the default muxer. */
private
static
boolean
canMux
(
Format
format
)
{
String
mimeType
=
checkNotNull
(
format
.
sampleMimeType
);
return
new
DefaultMuxer
.
Factory
()
...
...
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