androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.59k stars 377 forks source link

Media does not support uuid: e2719d58-a985-b3c9-781a-b030af78d30e #1496

Closed clankedz closed 3 months ago

clankedz commented 3 months ago

Version

Media3 main branch

More version details

d833d59124d795afc146322fe488b2c0d4b9af6a

Devices that reproduce the issue

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps

  1. Try to play stream with clearkey.

Expected result

Stream playing normally.

Actual result

Get DRM error "Media does not support uuid: e2719d58-a985-b3c9-781a-b030af78d30e"

Media

Url: https://live-ftc-na-south-2.media.starott.com/gru1/va01/starplus/event/2024/06/24/Albion_FC_vs_Oriental_20240624_1719245724022/ctr-all-complete.m3u8

Clearkey: "{\"keys\":[{\"kty\":\"oct\",\"kid\":\"e6N31LPlQVq9DjcckLFX5g\",\"k\":\"WbekDaxwq6ekMscafqjMtw\"}],\"type\":\"temporary\"}"

Im aware that the error is because the manifest does not have clearkey encoding, but Shaka-Player plays it with no problem (with m3u8/drm player chrome extension) using the same drm configuration. Am i missing something or should i modify some part the source-code?

Bug Report

icbaker commented 3 months ago

This looks like a duplicate of https://github.com/androidx/media/issues/1045

clankedz commented 3 months ago

If anyone is wondering i fixed this by adding this to HlsPlaylistParser.java L1164

 } else if (KEYFORMAT_PRMNAGRA.equals(keyFormat) && "1".equals(keyFormatVersions)) {
    String uriString = parseStringAttr(line, REGEX_URI, variableDefinitions);
    byte[] data = Base64.decode(uriString.substring(uriString.indexOf(',')), Base64.DEFAULT);
    String str = new String(data, StandardCharsets.UTF_8);
    JSONObject json = new JSONObject(str);
    String defaultKid = (String) json.get("key-id");
    if (!TextUtils.isEmpty(defaultKid)
            && !"00000000-0000-0000-0000-000000000000".equals(defaultKid)) {
        String[] defaultKidStrings = defaultKid.split("\\s+");
        UUID[] defaultKids = new UUID[defaultKidStrings.length];
        for (int i = 0; i < defaultKidStrings.length; i++) {
            defaultKids[i] = UUID.fromString(defaultKidStrings[i]);
        }
        byte[] psshData = PsshAtomUtil.buildPsshAtom(C.COMMON_PSSH_UUID, defaultKids, null);
        return new SchemeData(C.COMMON_PSSH_UUID, MimeTypes.VIDEO_MP4, psshData);
    }
    return null;
}