chore(android): change test logic for simplier code
This commit is contained in:
parent
0ff6d5f657
commit
2712069408
@ -33,42 +33,44 @@ public class VideoDecoderPropertiesModule extends ReactContextBaseJavaModule {
|
|||||||
public void getWidevineLevel(Promise p) {
|
public void getWidevineLevel(Promise p) {
|
||||||
int widevineLevel = 0;
|
int widevineLevel = 0;
|
||||||
|
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||||
final UUID WIDEVINE_UUID = new UUID(0xEDEF8BA979D64ACEL, 0xA3C827DCD51D21EDL);
|
p.resolve(widevineLevel);
|
||||||
final String WIDEVINE_SECURITY_LEVEL_1 = "L1";
|
return;
|
||||||
final String WIDEVINE_SECURITY_LEVEL_2 = "L2";
|
}
|
||||||
final String WIDEVINE_SECURITY_LEVEL_3 = "L3";
|
final UUID WIDEVINE_UUID = new UUID(0xEDEF8BA979D64ACEL, 0xA3C827DCD51D21EDL);
|
||||||
final String SECURITY_LEVEL_PROPERTY = "securityLevel";
|
final String WIDEVINE_SECURITY_LEVEL_1 = "L1";
|
||||||
|
final String WIDEVINE_SECURITY_LEVEL_2 = "L2";
|
||||||
|
final String WIDEVINE_SECURITY_LEVEL_3 = "L3";
|
||||||
|
final String SECURITY_LEVEL_PROPERTY = "securityLevel";
|
||||||
|
|
||||||
String securityProperty = null;
|
String securityProperty = null;
|
||||||
try {
|
try {
|
||||||
MediaDrm mediaDrm = new MediaDrm(WIDEVINE_UUID);
|
MediaDrm mediaDrm = new MediaDrm(WIDEVINE_UUID);
|
||||||
securityProperty = mediaDrm.getPropertyString(SECURITY_LEVEL_PROPERTY);
|
securityProperty = mediaDrm.getPropertyString(SECURITY_LEVEL_PROPERTY);
|
||||||
} catch (UnsupportedSchemeException e) {
|
} catch (UnsupportedSchemeException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (securityProperty == null) {
|
if (securityProperty == null) {
|
||||||
p.resolve(widevineLevel);
|
p.resolve(widevineLevel);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (securityProperty) {
|
switch (securityProperty) {
|
||||||
case WIDEVINE_SECURITY_LEVEL_1: {
|
case WIDEVINE_SECURITY_LEVEL_1: {
|
||||||
widevineLevel = 1;
|
widevineLevel = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WIDEVINE_SECURITY_LEVEL_2: {
|
case WIDEVINE_SECURITY_LEVEL_2: {
|
||||||
widevineLevel = 2;
|
widevineLevel = 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WIDEVINE_SECURITY_LEVEL_3: {
|
case WIDEVINE_SECURITY_LEVEL_3: {
|
||||||
widevineLevel = 3;
|
widevineLevel = 3;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
// widevineLevel 0
|
// widevineLevel 0
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.resolve(widevineLevel);
|
p.resolve(widevineLevel);
|
||||||
@ -77,17 +79,17 @@ public class VideoDecoderPropertiesModule extends ReactContextBaseJavaModule {
|
|||||||
@SuppressLint("ObsoleteSdkInt")
|
@SuppressLint("ObsoleteSdkInt")
|
||||||
@ReactMethod
|
@ReactMethod
|
||||||
public void isCodecSupported(String mimeType, int width, int height, Promise p) {
|
public void isCodecSupported(String mimeType, int width, int height, Promise p) {
|
||||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
|
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
|
||||||
MediaCodecList mRegularCodecs = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
|
|
||||||
MediaFormat format = MediaFormat.createVideoFormat(mimeType, width, height);
|
|
||||||
String codecName = mRegularCodecs.findDecoderForFormat(format);
|
|
||||||
if (codecName == null) {
|
|
||||||
p.resolve(false);
|
|
||||||
} else {
|
|
||||||
p.resolve(true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.resolve(false);
|
p.resolve(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MediaCodecList mRegularCodecs = new MediaCodecList(MediaCodecList.REGULAR_CODECS);
|
||||||
|
MediaFormat format = MediaFormat.createVideoFormat(mimeType, width, height);
|
||||||
|
String codecName = mRegularCodecs.findDecoderForFormat(format);
|
||||||
|
if (codecName == null) {
|
||||||
|
p.resolve(false);
|
||||||
|
} else {
|
||||||
|
p.resolve(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user