diff --git a/src/decrypters/Helpers.cpp b/src/decrypters/Helpers.cpp index 10c1cf979..8cf1300fa 100644 --- a/src/decrypters/Helpers.cpp +++ b/src/decrypters/Helpers.cpp @@ -23,6 +23,16 @@ namespace constexpr uint8_t PSSHBOX_HEADER_PSSH[4] = {0x70, 0x73, 0x73, 0x68}; constexpr uint8_t PSSHBOX_HEADER_VER0[4] = {0x00, 0x00, 0x00, 0x00}; +// Protection scheme identifying the encryption algorithm. The protection +// scheme is represented as a uint32 value. The uint32 contains 4 bytes each +// representing a single ascii character in one of the 4CC protection scheme values. +enum class WIDEVINE_PROT_SCHEME { + CENC = 0x63656E63, + CBC1 = 0x63626331, + CENS = 0x63656E73, + CBCS = 0x63626373 +}; + /*! * \brief Make a protobuf tag. * \param fieldNumber The field number @@ -38,8 +48,8 @@ int MakeProtobufTag(int fieldNumber, int wireType) return (fieldNumber << 3) | wireType; } -// \brief Write the size value to the data as varint format -void WriteProtobufVarintSize(std::vector& data, int size) +// \brief Write a protobuf varint value to the data +void WriteProtobufVarint(std::vector& data, int size) { do { @@ -220,7 +230,7 @@ bool DRM::MakeWidevinePsshData(const std::vector& kid, // Create "key_id" field, id: 2 (can be repeated if multiples) wvPsshData.push_back(MakeProtobufTag(2, 2)); - WriteProtobufVarintSize(wvPsshData, static_cast(kid.size())); + WriteProtobufVarint(wvPsshData, static_cast(kid.size())); // Write data size wvPsshData.insert(wvPsshData.end(), kid.begin(), kid.end()); // Prepare "content_id" data @@ -241,9 +251,13 @@ bool DRM::MakeWidevinePsshData(const std::vector& kid, // Create "content_id" field, id: 4 wvPsshData.push_back(MakeProtobufTag(4, 2)); - WriteProtobufVarintSize(wvPsshData, static_cast(contentIdData.size())); + WriteProtobufVarint(wvPsshData, static_cast(contentIdData.size())); // Write data size wvPsshData.insert(wvPsshData.end(), contentIdData.begin(), contentIdData.end()); + // Create "protection_scheme" field, id: 9 + // wvPsshData.push_back(MakeProtobufTag(9, 0)); + // WriteProtobufVarint(wvPsshData, static_cast(WIDEVINE_PROT_SCHEME::CENC)); + return true; }