feat: Add PlayReady support in HLS. (#1011)
Co-authored-by: Cosmin Stejerean <cstejerean@meta.com>
This commit is contained in:
parent
4aa4b4b9aa
commit
96efc5aa70
|
@ -4,6 +4,7 @@
|
|||
#EXT-X-TARGETDURATION:2
|
||||
#EXT-X-PLAYLIST-TYPE:VOD
|
||||
#EXT-X-MAP:URI="bear-640x360-audio.mp4",BYTERANGE="1568@0"
|
||||
#EXT-X-KEY:METHOD=SAMPLE-AES-CTR,URI="data:text/plain;charset=UTF-16;base64,BgIAAAEAAQD8ATwAVwBSAE0ASABFAEEARABFAFIAIAB4AG0AbABuAHMAPQAiAGgAdAB0AHAAOgAvAC8AcwBjAGgAZQBtAGEAcwAuAG0AaQBjAHIAbwBzAG8AZgB0AC4AYwBvAG0ALwBEAFIATQAvADIAMAAwADcALwAwADMALwBQAGwAYQB5AFIAZQBhAGQAeQBIAGUAYQBkAGUAcgAiACAAdgBlAHIAcwBpAG8AbgA9ACIANAAuADAALgAwAC4AMAAiAD4APABEAEEAVABBAD4APABQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsARQBZAEwARQBOAD4AMQA2ADwALwBLAEUAWQBMAEUATgA+ADwAQQBMAEcASQBEAD4AQQBFAFMAQwBUAFIAPAAvAEEATABHAEkARAA+ADwALwBQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsASQBEAD4ATgBEAE0AeQBNAFQAWQAxAE8ARABjADUATQBEAEUAeQBNAHoAUQAxAE4AZwA9AD0APAAvAEsASQBEAD4APABDAEgARQBDAEsAUwBVAE0APgBsADUATABvAFUAZwBLADkASwBDAGcAPQA8AC8AQwBIAEUAQwBLAFMAVQBNAD4APAAvAEQAQQBUAEEAPgA8AC8AVwBSAE0ASABFAEEARABFAFIAPgA=",KEYFORMATVERSIONS="1",KEYFORMAT="com.microsoft.playready"
|
||||
#EXT-X-KEY:METHOD=SAMPLE-AES-CTR,URI="data:text/plain;base64,AAAAOHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABgSEDEyMzQ1Njc4OTAxMjM0NTZI49yVmwY=",KEYID=0x31323334353637383930313233343536,KEYFORMATVERSIONS="1",KEYFORMAT="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"
|
||||
#EXT-X-KEY:METHOD=SAMPLE-AES-CTR,URI="skd://www.license.com/getkey?KeyId=31323334-3536-3738-3930-313233343536",KEYFORMATVERSIONS="1",KEYFORMAT="com.apple.streamingkeydelivery"
|
||||
#EXTINF:1.022,
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#EXT-X-TARGETDURATION:2
|
||||
#EXT-X-PLAYLIST-TYPE:VOD
|
||||
#EXT-X-MAP:URI="bear-640x360-video.mp4",BYTERANGE="1692@0"
|
||||
#EXT-X-KEY:METHOD=SAMPLE-AES-CTR,URI="data:text/plain;charset=UTF-16;base64,BgIAAAEAAQD8ATwAVwBSAE0ASABFAEEARABFAFIAIAB4AG0AbABuAHMAPQAiAGgAdAB0AHAAOgAvAC8AcwBjAGgAZQBtAGEAcwAuAG0AaQBjAHIAbwBzAG8AZgB0AC4AYwBvAG0ALwBEAFIATQAvADIAMAAwADcALwAwADMALwBQAGwAYQB5AFIAZQBhAGQAeQBIAGUAYQBkAGUAcgAiACAAdgBlAHIAcwBpAG8AbgA9ACIANAAuADAALgAwAC4AMAAiAD4APABEAEEAVABBAD4APABQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsARQBZAEwARQBOAD4AMQA2ADwALwBLAEUAWQBMAEUATgA+ADwAQQBMAEcASQBEAD4AQQBFAFMAQwBUAFIAPAAvAEEATABHAEkARAA+ADwALwBQAFIATwBUAEUAQwBUAEkATgBGAE8APgA8AEsASQBEAD4ATgBEAE0AeQBNAFQAWQAxAE8ARABjADUATQBEAEUAeQBNAHoAUQAxAE4AZwA9AD0APAAvAEsASQBEAD4APABDAEgARQBDAEsAUwBVAE0APgBsADUATABvAFUAZwBLADkASwBDAGcAPQA8AC8AQwBIAEUAQwBLAFMAVQBNAD4APAAvAEQAQQBUAEEAPgA8AC8AVwBSAE0ASABFAEEARABFAFIAPgA=",KEYFORMATVERSIONS="1",KEYFORMAT="com.microsoft.playready"
|
||||
#EXT-X-KEY:METHOD=SAMPLE-AES-CTR,URI="data:text/plain;base64,AAAAOHBzc2gAAAAA7e+LqXnWSs6jyCfc1R0h7QAAABgSEDEyMzQ1Njc4OTAxMjM0NTZI49yVmwY=",KEYID=0x31323334353637383930313233343536,KEYFORMATVERSIONS="1",KEYFORMAT="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"
|
||||
#EXT-X-KEY:METHOD=SAMPLE-AES-CTR,URI="skd://www.license.com/getkey?KeyId=31323334-3536-3738-3930-313233343536",KEYFORMATVERSIONS="1",KEYFORMAT="com.apple.streamingkeydelivery"
|
||||
#EXTINF:1.001,
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace hls {
|
|||
namespace {
|
||||
|
||||
const char kUriBase64Prefix[] = "data:text/plain;base64,";
|
||||
const char kUriBase64Utf16Prefix[] = "data:text/plain;charset=UTF-16;base64,";
|
||||
const char kUriFairPlayPrefix[] = "skd://";
|
||||
const char kWidevineDashIfIopUUID[] =
|
||||
"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";
|
||||
|
@ -57,6 +58,12 @@ bool IsFairPlaySystemId(const std::vector<uint8_t>& system_id) {
|
|||
media::kFairPlaySystemId);
|
||||
}
|
||||
|
||||
bool IsPlayReadySystemId(const std::vector<uint8_t>& system_id) {
|
||||
return system_id.size() == std::size(media::kPlayReadySystemId) &&
|
||||
std::equal(system_id.begin(), system_id.end(),
|
||||
media::kPlayReadySystemId);
|
||||
}
|
||||
|
||||
std::string Base64EncodeData(const std::string& prefix,
|
||||
const std::string& data) {
|
||||
std::string data_base64;
|
||||
|
@ -471,6 +478,20 @@ bool SimpleHlsNotifier::NotifyEncryptionUpdate(
|
|||
"1", media_playlist.get());
|
||||
return true;
|
||||
}
|
||||
if (IsPlayReadySystemId(system_id)) {
|
||||
std::unique_ptr<media::PsshBoxBuilder> b =
|
||||
media::PsshBoxBuilder::ParseFromBox(
|
||||
protection_system_specific_data.data(),
|
||||
protection_system_specific_data.size());
|
||||
std::string pssh_data(reinterpret_cast<const char*>(b->pssh_data().data()),
|
||||
b->pssh_data().size());
|
||||
std::string key_uri_data_base64 =
|
||||
Base64EncodeData(kUriBase64Utf16Prefix, pssh_data);
|
||||
NotifyEncryptionToMediaPlaylist(encryption_method, key_uri_data_base64,
|
||||
empty_key_id, iv, "com.microsoft.playready",
|
||||
"1", media_playlist.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
LOG(WARNING) << "HLS: Ignore unknown or unsupported system ID: "
|
||||
<< absl::BytesToHexString(absl::string_view(
|
||||
|
|
Loading…
Reference in New Issue