diff --git a/src/decrypters/Helpers.h b/src/decrypters/Helpers.h index db7e75f43..6063f85d0 100644 --- a/src/decrypters/Helpers.h +++ b/src/decrypters/Helpers.h @@ -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"; diff --git a/src/decrypters/widevineandroid/WVCencSingleSampleDecrypter.cpp b/src/decrypters/widevineandroid/WVCencSingleSampleDecrypter.cpp index caf0a9f0c..eeb615f34 100644 --- a/src/decrypters/widevineandroid/WVCencSingleSampleDecrypter.cpp +++ b/src/decrypters/widevineandroid/WVCencSingleSampleDecrypter.cpp @@ -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(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) @@ -66,6 +58,26 @@ CWVCencSingleSampleDecrypterA::CWVCencSingleSampleDecrypterA(CWVCdmAdapterA& drm 0x73, 0x68, 0x00, 0x00, 0x00, 0x00}; std::vector 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((pssh.size() >> 24) & 0xFF)); + psshAtom.emplace_back(static_cast((pssh.size() >> 16) & 0xFF)); + psshAtom.emplace_back(static_cast((pssh.size() >> 8) & 0xFF)); + psshAtom.emplace_back(static_cast(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(psshAtom.size()); + psshAtom[0] = static_cast((boxSize >> 24) & 0xFF); + psshAtom[1] = static_cast((boxSize >> 16) & 0xFF); + psshAtom[2] = static_cast((boxSize >> 8) & 0xFF); + psshAtom[3] = static_cast(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 @@ -77,8 +89,18 @@ CWVCencSingleSampleDecrypterA::CWVCencSingleSampleDecrypterA(CWVCdmAdapterA& drm // Update box size psshAtom[2] = static_cast(psshAtom.size() >> 8); psshAtom[3] = static_cast(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(m_pssh.data()), m_pssh.size()}; + FILESYS::SaveFile(debugFilePath, data, true); + } + m_initialPssh = m_pssh; if (!optionalKeyParameter.empty())