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.75k stars 418 forks source link

Add Support for HLS With ClearKey Encryption #1045

Open iamatomic77 opened 10 months ago

iamatomic77 commented 10 months ago

Can you add support for HLS with ClearKey encryption in ExoPlayer/Media3?

Here's an example of a HLS stream with ClearKey encryption (US Geoblocked): Stream Link: https://dfwlive-v1-c2p5-sponsored.akamaized.net/Content/HLS.cps/Live/channel(AMAXHD-4067.dfw.1080)/index.m3u8 ClearKey Key: 59c355414d0aae9388c00cc22b751c8c ClearKey Key ID: 1470fffc6a2ddfcea6db98995691b79a

icbaker commented 9 months ago

I had a look in the provided HLS manifest. I saw two #EXT-X-SESSION-KEY:METHOD=SAMPLE-AES lines.

The first one seems to be related to FairPlay (based on the KEYFORMAT="com.apple.streamingkeydelivery"), so not relevant to Android playback:

#EXT-X-SESSION-KEY:METHOD=SAMPLE-AES,URI="skd://1470fffc6a2ddfcea6db98995691b79a",KEYFORMAT="com.apple.streamingkeydelivery",KEYFORMATVERSIONS="1"

The second one seems to be widevine (based on KEYFORMAT="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed")

#EXT-X-SESSION-KEY:METHOD=SAMPLE-AES,URI="data:text/plain;base64,AAAAOHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABgSEBRw//xqLd/OptuYmVaRt5pI88aJmwY=",KEYID=0X1470fffc6a2ddfcea6db98995691b79a,KEYFORMAT="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",KEYFORMATVERSIONS="1"

In DASH, clearkey is included in the manifest: https://github.com/Dash-Industry-Forum/ClearKey-Content-Protection/blob/master/README.md#workflow

I was assuming that HLS clearkey content would also include some clearkey signalling in the playlist - but I don't see this in your example playlist. Please can you link to the spec that describes how clearkey content should be packaged in HLS?


I'm also curious why you want clearkey support? It's not a production-appropriate encryption/DRM scheme, since it's really inherently insecure.

iamatomic77 commented 9 months ago

This example stream is one that I found, so I don't really know how it works. I couldn't find any documentation regarding how ClearKey content should be packaged in HLS. However, if I put the stream information into this test player (https://developer-tools.jwplayer.com/stream-tester), it'll play in Chrome without any issue. At this moment, using a web browser, like Chrome, is the only way that I've found that can play HLS with ClearKey encryption. Is there something that allows this stream to play in Chrome but not in ExoPlayer/Media3?

I want Clearkey support because it'll allow me to play streams like this with Android apps that use ExoPlayer/Media3. I didn't make this stream, so the issues of it being insecure doesn't concern me.

RayvChan commented 9 months ago

#EXT-X-SESSION-KEY:METHOD=SAMPLE-AES,URI="[data:text/plain;base64,AAAAOHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABgSEBRw//xqLd/OptuYmVaRt5pI88aJmwY=](https://dfwlive-v1-c2p5-sponsored.akamaized.net/Content/HLS.cps/Live/channel(AMAXHD-4067.dfw.1080)/data:text/plain;base64,AAAAOHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABgSEBRw//xqLd/OptuYmVaRt5pI88aJmwY=)",KEYID=0X1470fffc6a2ddfcea6db98995691b79a,KEYFORMAT="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed",KEYFORMATVERSIONS="1"

THE KID: KEYID=0X1470fffc6a2ddfcea6db98995691b79a

spotanjo3 commented 8 months ago

The same thing with hallmark channel in mpd file through peacock US Live and there is a key too and it seems to run on VLC okay but a black screen and keep running without a key but with a key which I do have.. how do I package it to one link to make it run correctly ? An available all countries mpd clearkeys for restreaming live channels & restream pannels which can restream the live in real time with out any delay

Also available script for extracting all channels and vod mpd and keys for Peacock instantly & fully automatically. Is there a way I can run it properly on my VLC Player ?

Dragonball3 commented 6 months ago

Other alternatives on how to play HLS + clearkey on Android? Seems restreaming is the only solution I know, but no idea on how to find free server with drmstuff installable.