Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
CastagnaIT committed Aug 18, 2024
1 parent a53797f commit df38035
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
7 changes: 7 additions & 0 deletions src/decrypters/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ constexpr std::string_view KS_CLEARKEY = "org.w3.clearkey";

// DRM UUIDs

constexpr uint8_t UUID_WIDEVINE[16] = {0xed, 0xef, 0x8b, 0xa9, 0x79, 0xd6, 0x4a, 0xce,
0xa3, 0xc8, 0x27, 0xdc, 0xd5, 0x1d, 0x21, 0xed};

constexpr uint8_t UUID_PLAYREADY[16] = {0x9a, 0x04, 0xf0, 0x79, 0x98, 0x40, 0x42, 0x86,
0xab, 0x92, 0xe6, 0x5b, 0xe0, 0x88, 0x5f, 0x95};


constexpr std::string_view URN_WIDEVINE = "urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";
constexpr std::string_view URN_PLAYREADY = "urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95";
constexpr std::string_view URN_WISEPLAY = "urn:uuid:3d5e6d35-9b9a-41e8-b843-dd3c6e72c42c";
Expand Down
38 changes: 30 additions & 8 deletions src/decrypters/widevineandroid/WVCencSingleSampleDecrypter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ CWVCencSingleSampleDecrypterA::CWVCencSingleSampleDecrypterA(CWVCdmAdapterA& drm
return;
}

if (CSrvBroker::GetSettings().IsDebugLicense())
{
std::string debugFilePath =
FILESYS::PathCombine(m_host->GetLibraryPath(), "EDEF8BA9-79D6-4ACE-A3C8-27DCD51D21ED.init");
std::string data{reinterpret_cast<const char*>(pssh.data()), pssh.size()};
FILESYS::SaveFile(debugFilePath, data, true);
}

m_pssh = pssh;
// No cenc init data with PSSH box format, create one
if (memcmp(pssh.data() + 4, "pssh", 4) != 0)
Expand All @@ -66,6 +58,26 @@ CWVCencSingleSampleDecrypterA::CWVCencSingleSampleDecrypterA(CWVCdmAdapterA& drm
0x73, 0x68, 0x00, 0x00, 0x00, 0x00};

std::vector<uint8_t> psshAtom;

psshAtom.assign(atomHeader, atomHeader + 12); // PSSH Box header
psshAtom.insert(psshAtom.end(), playreadySystemId, playreadySystemId + 16); // System ID

// Add data size (4 bytes)
psshAtom.emplace_back(static_cast<uint8_t>((pssh.size() >> 24) & 0xFF));
psshAtom.emplace_back(static_cast<uint8_t>((pssh.size() >> 16) & 0xFF));
psshAtom.emplace_back(static_cast<uint8_t>((pssh.size() >> 8) & 0xFF));
psshAtom.emplace_back(static_cast<uint8_t>(pssh.size() & 0xFF));

psshAtom.insert(psshAtom.end(), pssh.begin(), pssh.end()); // Data

// Update box PSSH size on first 4 bytes
const uint32_t boxSize = static_cast<uint32_t>(psshAtom.size());
psshAtom[0] = static_cast<uint8_t>((boxSize >> 24) & 0xFF);
psshAtom[1] = static_cast<uint8_t>((boxSize >> 16) & 0xFF);
psshAtom[2] = static_cast<uint8_t>((boxSize >> 8) & 0xFF);
psshAtom[3] = static_cast<uint8_t>(boxSize & 0xFF);

/*
psshAtom.assign(atomHeader, atomHeader + 12); // PSSH Box header
psshAtom.insert(psshAtom.end(), m_mediaDrm.GetKeySystem(), m_mediaDrm.GetKeySystem() + 16); // System ID
// Add data size bytes
Expand All @@ -77,8 +89,18 @@ CWVCencSingleSampleDecrypterA::CWVCencSingleSampleDecrypterA(CWVCdmAdapterA& drm
// Update box size
psshAtom[2] = static_cast<uint8_t>(psshAtom.size() >> 8);
psshAtom[3] = static_cast<uint8_t>(psshAtom.size());
*/
m_pssh = psshAtom;
}

if (CSrvBroker::GetSettings().IsDebugLicense())
{
std::string debugFilePath =
FILESYS::PathCombine(m_host->GetLibraryPath(), "EDEF8BA9-79D6-4ACE-A3C8-27DCD51D21ED.init");
std::string data{reinterpret_cast<const char*>(m_pssh.data()), m_pssh.size()};
FILESYS::SaveFile(debugFilePath, data, true);
}

m_initialPssh = m_pssh;

if (!optionalKeyParameter.empty())
Expand Down

0 comments on commit df38035

Please sign in to comment.