In-line DashTestRunner.MediaDrmBuilder

This commit is contained in:
Ian Baker 2024-02-13 17:11:03 +00:00
parent 868d2fedcb
commit b82f341007

View File

@ -105,17 +105,15 @@ import java.util.List;
@SuppressWarnings("ResourceType")
public static boolean isL1WidevineAvailable(String mimeType) {
try {
try (MediaDrm mediaDrm = new MediaDrm(WIDEVINE_UUID)) {
// Force L3 if secure decoder is not available.
if (MediaCodecUtil.getDecoderInfo(mimeType, /* secure= */ true, /* tunneling= */ false)
== null) {
return false;
}
MediaDrm mediaDrm = MediaDrmBuilder.build();
String securityProperty = mediaDrm.getPropertyString(SECURITY_LEVEL_PROPERTY);
mediaDrm.release();
return WIDEVINE_SECURITY_LEVEL_1.equals(securityProperty);
} catch (MediaCodecUtil.DecoderQueryException e) {
} catch (UnsupportedSchemeException | MediaCodecUtil.DecoderQueryException e) {
throw new IllegalStateException(e);
}
}
@ -503,19 +501,4 @@ import java.util.List;
return RendererCapabilities.getFormatSupport(formatSupport) == C.FORMAT_HANDLED;
}
}
/**
* Creates a new {@code MediaDrm} object. The encapsulation ensures that the tests can be executed
* for API level < 18.
*/
private static final class MediaDrmBuilder {
public static MediaDrm build() {
try {
return new MediaDrm(WIDEVINE_UUID);
} catch (UnsupportedSchemeException e) {
throw new IllegalStateException(e);
}
}
}
}