Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v1.4.0 #3

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 48 additions & 20 deletions cpp/PallyConCpixClient/CpixClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
namespace pallycon {
#define UUID_SIZE_INCLUDING_NULL_CHAR 37

#define WIDEVINE_SYSMTE_ID "EDEF8BA9-79D6-4ACE-A3C8-27DCD51D21ED"
#define PLAYREADY_SYSMTE_ID "9A04F079-9840-4286-AB92-E65BE0885F95"
#define FAIRPLAY_SYSMTE_ID "94CE86FB-07FF-4F43-ADB8-93D2FA968CA2"
#define NCG_SYSMTE_ID "D9E4411A-E886-4909-A380-A77F28D52335"
#define HLS_NCG_SYSMTE_ID "48582A1D-1FF4-426E-8CD5-06424FCC578C"
#define WIDEVINE_SYSTEM_ID "EDEF8BA9-79D6-4ACE-A3C8-27DCD51D21ED"
#define PLAYREADY_SYSTEM_ID "9A04F079-9840-4286-AB92-E65BE0885F95"
#define FAIRPLAY_SYSTEM_ID "94CE86FB-07FF-4F43-ADB8-93D2FA968CA2"
#define NCG_SYSTEM_ID "D9E4411A-E886-4909-A380-A77F28D52335"
#define HLS_NCG_SYSTEM_ID "48582A1D-1FF4-426E-8CD5-06424FCC578C"
#define WISEPLAY_SYSTEM_ID "3D5E6D35-9B9A-41E8-B843-DD3C6E72C42C"

static const char* __encryption_scheme_str[] = { "cenc", "cbc1", "cens", "cbcs" };
static const TrackType AllTrackTypes[] = { AUDIO, SD, HD, UHD1, UHD2 };
Expand Down Expand Up @@ -165,39 +166,47 @@ namespace pallycon {
XMLNode reqWidevineNode = reqDRMList.addChild("cpix:DRMSystem");

reqWidevineNode.addAttribute("kid", map.second.c_str());
reqWidevineNode.addAttribute("systemId", WIDEVINE_SYSMTE_ID);
reqWidevineNode.addAttribute("systemId", WIDEVINE_SYSTEM_ID);
}

if (drmType & PLAYREADY)
{
XMLNode reqPlayReadyNode = reqDRMList.addChild("cpix:DRMSystem");

reqPlayReadyNode.addAttribute("kid", map.second.c_str());
reqPlayReadyNode.addAttribute("systemId", PLAYREADY_SYSMTE_ID);
reqPlayReadyNode.addAttribute("systemId", PLAYREADY_SYSTEM_ID);
}

if (drmType & FAIRPLAY)
{
XMLNode reqFairPlayNode = reqDRMList.addChild("cpix:DRMSystem");

reqFairPlayNode.addAttribute("kid", map.second.c_str());
reqFairPlayNode.addAttribute("systemId", FAIRPLAY_SYSMTE_ID);
reqFairPlayNode.addAttribute("systemId", FAIRPLAY_SYSTEM_ID);
}

if (drmType & NCG)
{
XMLNode reqNcgNode = reqDRMList.addChild("cpix:DRMSystem");

reqNcgNode.addAttribute("kid", map.second.c_str());
reqNcgNode.addAttribute("systemId", NCG_SYSMTE_ID);
reqNcgNode.addAttribute("systemId", NCG_SYSTEM_ID);
}

if (drmType & HLS_NCG)
{
XMLNode reqHlsNcgNode = reqDRMList.addChild("cpix:DRMSystem");

reqHlsNcgNode.addAttribute("kid", map.second.c_str());
reqHlsNcgNode.addAttribute("systemId", HLS_NCG_SYSMTE_ID);
reqHlsNcgNode.addAttribute("systemId", HLS_NCG_SYSTEM_ID);
}

if (drmType & WISEPLAY)
{
XMLNode reqWisePlayNode = reqDRMList.addChild("cpix:DRMSystem");

reqWisePlayNode.addAttribute("kid", map.second.c_str());
reqWisePlayNode.addAttribute("systemId", WISEPLAY_SYSTEM_ID);
}
}

Expand All @@ -223,11 +232,12 @@ namespace pallycon {

packInfo.contentId = responseRoot.getAttribute("id");

std::string systemId_widevine = WIDEVINE_SYSMTE_ID;
std::string systemId_playready = PLAYREADY_SYSMTE_ID;
std::string systemId_fairplay = FAIRPLAY_SYSMTE_ID;
std::string systemId_ncg = NCG_SYSMTE_ID;
std::string systemId_hlsNcg = HLS_NCG_SYSMTE_ID;
std::string systemId_widevine = WIDEVINE_SYSTEM_ID;
std::string systemId_playready = PLAYREADY_SYSTEM_ID;
std::string systemId_fairplay = FAIRPLAY_SYSTEM_ID;
std::string systemId_ncg = NCG_SYSTEM_ID;
std::string systemId_hlsNcg = HLS_NCG_SYSTEM_ID;
std::string systemId_wiseplay = WISEPLAY_SYSTEM_ID;

XMLNode resContentKeyList = responseRoot.getChildNode("cpix:ContentKeyList");
XMLNode resContentKeyUsageRuleList = responseRoot.getChildNode("cpix:ContentKeyUsageRuleList");
Expand Down Expand Up @@ -284,7 +294,7 @@ namespace pallycon {
drmInfo.iv = resIv;
}

XMLNode resWidevineNode, resPlayReadyNode, resFairPlayNode, resNcgNode, reqHlsNcgNode;
XMLNode resWidevineNode, resPlayReadyNode, resFairPlayNode, resNcgNode, resHlsNcgNode, resWisePlayNode;
for (int i = 0; i < resDRMSystemList.nChildNode(); i++)
{
XMLNode resDrmNode = resDRMSystemList.getChildNode("cpix:DRMSystem", i);
Expand All @@ -309,7 +319,11 @@ namespace pallycon {
}
else if (0 == strcmp(resSystemId, systemId_hlsNcg.c_str()))
{
reqHlsNcgNode = resDrmNode.deepCopy();
resHlsNcgNode = resDrmNode.deepCopy();
}
else if (0 == strcmp(resSystemId, systemId_wiseplay.c_str()))
{
resWisePlayNode = resDrmNode.deepCopy();
}
}
}
Expand All @@ -318,20 +332,26 @@ namespace pallycon {
{
drmInfo.widevinePSSHpayload = resWidevineNode.getChildNode("cpix:ContentProtectionData").getText();
drmInfo.widevinePSSH = resWidevineNode.getChildNode("cpix:PSSH").getText();
drmInfo.widevineHlsSignalingDataMaster = resWidevineNode.getChildNodeWithAttribute("cpix:HLSSignalingData", "playlist", "master").getText();
drmInfo.widevineHlsSignalingDataMedia = resWidevineNode.getChildNodeWithAttribute("cpix:HLSSignalingData", "playlist", "media").getText();
}
if (!resPlayReadyNode.isEmpty())
{
drmInfo.playreadyPSSHpayload = resPlayReadyNode.getChildNode("cpix:ContentProtectionData").getText();
drmInfo.playreadyPSSH = resPlayReadyNode.getChildNode("cpix:PSSH").getText();
drmInfo.playreadySmoothStreamingData = resPlayReadyNode.getChildNode("cpix:SmoothStreamingProtectionHeaderData").getText();
drmInfo.playreadyHlsSignalingDataMaster = resPlayReadyNode.getChildNodeWithAttribute("cpix:HLSSignalingData", "playlist", "master").getText();
drmInfo.playreadyHlsSignalingDataMedia = resPlayReadyNode.getChildNodeWithAttribute("cpix:HLSSignalingData", "playlist", "media").getText();
}

if (!resFairPlayNode.isEmpty())
{
drmInfo.fairplayHlsSignalingData = resFairPlayNode.getChildNode("cpix:HLSSignalingData").getText();
int outputLength = 0;
std::shared_ptr<BYTE> keyUri = __Base64Decode(resFairPlayNode.getChildNode("cpix:URIExtXKey").getText(), &outputLength);
std::string strKeyUri(keyUri.get(), keyUri.get() + outputLength);
drmInfo.fairplayHlsKeyUri = strKeyUri;
drmInfo.fairplayHlsSignalingDataMaster = resFairPlayNode.getChildNodeWithAttribute("cpix:HLSSignalingData", "playlist", "master").getText();
drmInfo.fairplayHlsSignalingDataMedia = resFairPlayNode.getChildNodeWithAttribute("cpix:HLSSignalingData", "playlist", "media").getText();
}

if (!resNcgNode.isEmpty())
Expand All @@ -342,14 +362,22 @@ namespace pallycon {
drmInfo.ncgCek = strCek.c_str();
}

if (!reqHlsNcgNode.isEmpty())
if (!resHlsNcgNode.isEmpty())
{
int outputLength = 0;
std::shared_ptr<BYTE> keyUri = __Base64Decode(reqHlsNcgNode.getChildNode("cpix:URIExtXKey").getText(), &outputLength);
std::shared_ptr<BYTE> keyUri = __Base64Decode(resHlsNcgNode.getChildNode("cpix:URIExtXKey").getText(), &outputLength);
std::string strKeyUri(keyUri.get(), keyUri.get() + outputLength);
drmInfo.ncgHlsKeyUri = strKeyUri.c_str();
}

if (!resWisePlayNode.isEmpty())
{
drmInfo.wiseplayPSSHpayload = resWisePlayNode.getChildNode("cpix:ContentProtectionData").getText();
drmInfo.wiseplayPSSH = resWisePlayNode.getChildNode("cpix:PSSH").getText();
drmInfo.wiseplayHlsSignalingDataMaster = resWisePlayNode.getChildNodeWithAttribute("cpix:HLSSignalingData", "playlist", "master").getText();
drmInfo.wiseplayHlsSignalingDataMedia = resWisePlayNode.getChildNodeWithAttribute("cpix:HLSSignalingData", "playlist", "media").getText();
}

packInfo.multiDrmInfos.push_back(drmInfo);
}

Expand Down
15 changes: 13 additions & 2 deletions cpp/PallyConCpixClient/CpixClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ namespace pallycon
PLAYREADY = (1 << 1), // 0000 0010 // 0x02
FAIRPLAY = (1 << 2), // 0000 0100 // 0x04
NCG = (1 << 3), // 0000 1000 // 0x08
HLS_NCG = (1 << 4), // 0001 0000 // 0x10
HLS_NCG = (1 << 4), // 0001 0000 // 0x16
WISEPLAY = (1 << 5), // 0010 0000 // 0x32
};

enum TrackType {
Expand Down Expand Up @@ -101,12 +102,22 @@ namespace pallycon
std::string periodIndex;
std::string widevinePSSH;
std::string widevinePSSHpayload;
std::string widevineHlsSignalingDataMaster;
std::string widevineHlsSignalingDataMedia;
std::string playreadyPSSH;
std::string playreadyPSSHpayload;
std::string fairplayHlsSignalingData;
std::string playreadySmoothStreamingData;
std::string playreadyHlsSignalingDataMaster;
std::string playreadyHlsSignalingDataMedia;
std::string fairplayHlsKeyUri;
std::string fairplayHlsSignalingDataMaster;
std::string fairplayHlsSignalingDataMedia;
std::string ncgCek;
std::string ncgHlsKeyUri;
std::string wiseplayPSSH;
std::string wiseplayPSSHpayload;
std::string wiseplayHlsSignalingDataMaster;
std::string wiseplayHlsSignalingDataMedia;
};

struct ContentPackagingInfo
Expand Down
12 changes: 11 additions & 1 deletion csharp-sample/PallyConCpixClientWrapper/CpixClientWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,22 @@ namespace PallyCon {
drmInfo.PeriodIndex = gcnew String(multiDrmInfo.periodIndex.c_str());
drmInfo.WidevinePSSH = gcnew String(multiDrmInfo.widevinePSSH.c_str());
drmInfo.WidevinePSSHpayload = gcnew String(multiDrmInfo.widevinePSSHpayload.c_str());
drmInfo.WidevineHlsSignalingDataMaster = gcnew String(multiDrmInfo.widevineHlsSignalingDataMaster.c_str());
drmInfo.WidevineHlsSignalingDataMedia = gcnew String(multiDrmInfo.widevineHlsSignalingDataMedia.c_str());
drmInfo.PlayReadyPSSH = gcnew String(multiDrmInfo.playreadyPSSH.c_str());
drmInfo.PlayReadyPSSHpayload = gcnew String(multiDrmInfo.playreadyPSSHpayload.c_str());
drmInfo.FairplayHlsSignalingData = gcnew String(multiDrmInfo.fairplayHlsSignalingData.c_str());
drmInfo.PlayReadySmoothStreamingData = gcnew String(multiDrmInfo.playreadySmoothStreamingData.c_str());
drmInfo.PlayReadyHlsSignalingDataMaster = gcnew String(multiDrmInfo.playreadyHlsSignalingDataMaster.c_str());
drmInfo.PlayReadyHlsSignalingDataMedia = gcnew String(multiDrmInfo.playreadyHlsSignalingDataMedia.c_str());
drmInfo.FairplayHlsKeyUri = gcnew String(multiDrmInfo.fairplayHlsKeyUri.c_str());
drmInfo.FairplayHlsSignalingDataMaster = gcnew String(multiDrmInfo.fairplayHlsSignalingDataMaster.c_str());
drmInfo.FairplayHlsSignalingDataMedia = gcnew String(multiDrmInfo.fairplayHlsSignalingDataMedia.c_str());
drmInfo.NcgCek = gcnew String(multiDrmInfo.ncgCek.c_str());
drmInfo.NcgHlsKeyUri = gcnew String(multiDrmInfo.ncgHlsKeyUri.c_str());
drmInfo.WiseplayPSSH = gcnew String(multiDrmInfo.wiseplayPSSH.c_str());
drmInfo.WiseplayPSSHpayload = gcnew String(multiDrmInfo.wiseplayPSSHpayload.c_str());
drmInfo.WiseplayHlsSignalingDataMaster = gcnew String(multiDrmInfo.wiseplayHlsSignalingDataMaster.c_str());
drmInfo.WiseplayHlsSignalingDataMedia = gcnew String(multiDrmInfo.wiseplayHlsSignalingDataMedia.c_str());

packInfos.DrmInfos->Add(drmInfo);
}
Expand Down
Loading