视频APP可使用如下示例代码(以安卓平台为例)判断终端是否支持ChinaDRM:
public static boolean checkSupportChinaDRM(){
boolean isSupportCDRM = false;
byte[] sessionId = null;
MediaDrm mediaDrm = null;
String statusString = null;
UUID drmScheme = new UUID(0X3D5E6D359B9A41E8L, 0XB843DD3C6E72C42CL);//ChinaDRM UUID
try {
if (Util.SDK_INT < 18) {
statusString = "Protected content not supported on API levels below 18";
} else if (!MediaDrm.isCryptoSchemeSupported(drmScheme)) {
statusString = "This device does not support the required DRM scheme";
} else {
mediaDrm = new MediaDrm(drmScheme);
sessionId = mediaDrm.openSession();
isSupportCDRM = true;
statusString = "check ChinaDRM ok!";
}
} catch (NotProvisionedException e){
statusString = "drm certifate not found!";
}catch (Exception e) {
Log.i(TAG, "catched Exception:" + e.getMessage());
statusString = "exception:" + e.getMessage();
}
if (mediaDrm != null && sessionId != null) {
mediaDrm.closeSession(sessionId);
}
Log.i(TAG, statusString);
return isSupportCDRM;
}
安卓平台视频APP使用MediaDrm.getPropertyString(“securityLevel”)判断客户端的安全级别。DRM服务可判断DRM客户端发送的许可证请求中携带的DRM客户端证书体的Common Name字段标识的安全级别(SW标志软件安全级,HW标志硬件安全级,EH标志增强硬件级)从而确认终端设备的安全级别。