Skip transform4K60 test if 4K decoding is not supported.

4K decoding is not supported (not required to be supported) on all
devices, e.g., Nexus 5 does not support it.

PiperOrigin-RevId: 450682519
This commit is contained in:
hschlueter 2022-05-24 15:01:32 +00:00 committed by Marc Baechinger
parent 9463efef4b
commit d840aa4dc1
2 changed files with 13 additions and 3 deletions

View File

@ -232,11 +232,11 @@ public final class AndroidTestUtil {
* @param context The {@link Context context}. * @param context The {@link Context context}.
* @param testId The test ID. * @param testId The test ID.
* @param decodingFormat The {@link Format format} to decode. * @param decodingFormat The {@link Format format} to decode.
* @param encodingFormat The {@link Format format} to encode. * @param encodingFormat The {@link Format format} to encode, optional.
* @return Whether the test should be skipped. * @return Whether the test should be skipped.
*/ */
public static boolean skipAndLogIfInsufficientCodecSupport( public static boolean skipAndLogIfInsufficientCodecSupport(
Context context, String testId, Format decodingFormat, Format encodingFormat) Context context, String testId, Format decodingFormat, @Nullable Format encodingFormat)
throws IOException, JSONException { throws IOException, JSONException {
boolean canDecode = false; boolean canDecode = false;
@Nullable MediaCodecUtil.DecoderQueryException queryException = null; @Nullable MediaCodecUtil.DecoderQueryException queryException = null;
@ -246,7 +246,7 @@ public final class AndroidTestUtil {
queryException = e; queryException = e;
} }
boolean canEncode = canEncode(encodingFormat); boolean canEncode = encodingFormat == null || canEncode(encodingFormat);
if (canDecode && canEncode) { if (canDecode && canEncode) {
return false; return false;

View File

@ -19,6 +19,7 @@ import static androidx.media3.transformer.AndroidTestUtil.FORCE_ENCODE_ENCODER_F
import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET_SEF_URI_STRING; import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET_SEF_URI_STRING;
import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET_URI_STRING; import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET_URI_STRING;
import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_URI_STRING; import static androidx.media3.transformer.AndroidTestUtil.MP4_ASSET_WITH_INCREASING_TIMESTAMPS_URI_STRING;
import static androidx.media3.transformer.AndroidTestUtil.MP4_REMOTE_4K60_PORTRAIT_FORMAT;
import static androidx.media3.transformer.AndroidTestUtil.MP4_REMOTE_4K60_PORTRAIT_URI_STRING; import static androidx.media3.transformer.AndroidTestUtil.MP4_REMOTE_4K60_PORTRAIT_URI_STRING;
import static androidx.media3.transformer.AndroidTestUtil.recordTestSkipped; import static androidx.media3.transformer.AndroidTestUtil.recordTestSkipped;
@ -90,6 +91,15 @@ public class TransformationTest {
public void transform4K60() throws Exception { public void transform4K60() throws Exception {
String testId = TAG + "_transform4K60"; String testId = TAG + "_transform4K60";
Context context = ApplicationProvider.getApplicationContext(); Context context = ApplicationProvider.getApplicationContext();
if (AndroidTestUtil.skipAndLogIfInsufficientCodecSupport(
context,
testId,
/* decodingFormat= */ MP4_REMOTE_4K60_PORTRAIT_FORMAT,
/* encodingFormat= */ null)) {
return;
}
Transformer transformer = Transformer transformer =
new Transformer.Builder(context).setEncoderFactory(FORCE_ENCODE_ENCODER_FACTORY).build(); new Transformer.Builder(context).setEncoderFactory(FORCE_ENCODE_ENCODER_FACTORY).build();
new TransformerAndroidTestRunner.Builder(context, transformer) new TransformerAndroidTestRunner.Builder(context, transformer)