|
|
|
|
@ -40,6 +40,7 @@ public class Drm { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private UUID getUUID() { |
|
|
|
|
if (getType().contains("playready")) return C.PLAYREADY_UUID; |
|
|
|
|
if (getType().contains("widevine")) return C.WIDEVINE_UUID; |
|
|
|
|
if (getType().contains("clearkey")) return C.CLEARKEY_UUID; |
|
|
|
|
return C.UUID_NIL; |
|
|
|
|
@ -47,21 +48,9 @@ public class Drm { |
|
|
|
|
|
|
|
|
|
private String getUri() { |
|
|
|
|
if (getKey().startsWith("http")) return getKey(); |
|
|
|
|
if (!getKey().startsWith("{") && getKey().contains(":")) convert(); |
|
|
|
|
return Server.get().getAddress("license/") + Util.base64(getKey()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void convert() { |
|
|
|
|
String[] split = getKey().split(":"); |
|
|
|
|
String kid = getBase64(split[0]); |
|
|
|
|
String key = getBase64(split[1]); |
|
|
|
|
setKey(String.format("{ \"keys\":[ { \"kty\":\"oct\", \"k\":\"%s\", \"kid\":\"%s\" } ], \"type\":\"temporary\" }", key, kid)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String getBase64(String s) { |
|
|
|
|
return Util.base64(Util.hex2byte(s)).replace("=", ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public MediaItem.DrmConfiguration get() { |
|
|
|
|
return new MediaItem.DrmConfiguration.Builder(getUUID()).setLicenseUri(getUri()).build(); |
|
|
|
|
} |
|
|
|
|
|