Source release 15.2.0
This commit is contained in:
@@ -5,7 +5,8 @@
|
||||
#include "initialization_data.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <sstream>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "buffer_reader.h"
|
||||
#include "cdm_engine.h"
|
||||
@@ -56,6 +57,7 @@ InitializationData::InitializationData(const std::string& type,
|
||||
is_hls_(false),
|
||||
is_webm_(false),
|
||||
is_audio_(false),
|
||||
contains_entitled_keys_(false),
|
||||
hls_method_(kHlsMethodNone) {
|
||||
if (type == ISO_BMFF_VIDEO_MIME_TYPE || type == ISO_BMFF_AUDIO_MIME_TYPE ||
|
||||
type == CENC_INIT_DATA_FORMAT) {
|
||||
@@ -125,19 +127,20 @@ bool InitializationData::SelectWidevinePssh(const CdmInitData& init_data,
|
||||
return false;
|
||||
}
|
||||
|
||||
// If there are multiple PSSHs to choose from and this device prefers
|
||||
// entitlements, find the first |ENTITLED_KEY| PSSH, if present, and
|
||||
// select it.
|
||||
if (prefer_entitlements && pssh_payloads.size() > 1) {
|
||||
// If this device prefers entitlements, search through available PSSHs.
|
||||
// If present, select the first |ENTITLED_KEY| PSSH.
|
||||
if (prefer_entitlements && !pssh_payloads.empty()) {
|
||||
for (size_t i = 0; i < pssh_payloads.size(); ++i) {
|
||||
WidevinePsshData pssh;
|
||||
if (!pssh.ParseFromString(pssh_payloads[i])) {
|
||||
LOGE(
|
||||
"InitializationData::SelectWidevinePssh: Unable to parse PSSH data "
|
||||
"%lu into a protobuf.", i);
|
||||
"%lu into a protobuf.",
|
||||
i);
|
||||
continue;
|
||||
}
|
||||
if (pssh.type() == WidevinePsshData_Type_ENTITLED_KEY) {
|
||||
contains_entitled_keys_ = true;
|
||||
*output = pssh_payloads[i];
|
||||
return true;
|
||||
}
|
||||
@@ -163,8 +166,8 @@ bool InitializationData::SelectWidevinePssh(const CdmInitData& init_data,
|
||||
// 4 byte size of PSSH data, exclusive. (N)
|
||||
// N byte PSSH data.
|
||||
|
||||
bool InitializationData::ExtractWidevinePsshs(
|
||||
const CdmInitData& init_data, std::vector<CdmInitData>* psshs) {
|
||||
bool InitializationData::ExtractWidevinePsshs(const CdmInitData& init_data,
|
||||
std::vector<CdmInitData>* psshs) {
|
||||
if (psshs == NULL) {
|
||||
LOGE("InitializationData::ExtractWidevinePsshs: NULL psshs parameter");
|
||||
return false;
|
||||
@@ -172,7 +175,8 @@ bool InitializationData::ExtractWidevinePsshs(
|
||||
psshs->clear();
|
||||
psshs->reserve(2); // We expect 1 or 2 Widevine PSSHs
|
||||
|
||||
const uint8_t* data_start = reinterpret_cast<const uint8_t*>(init_data.data());
|
||||
const uint8_t* data_start =
|
||||
reinterpret_cast<const uint8_t*>(init_data.data());
|
||||
BufferReader reader(data_start, init_data.length());
|
||||
|
||||
while (!reader.IsEOF()) {
|
||||
@@ -242,8 +246,9 @@ bool InitializationData::ExtractWidevinePsshs(
|
||||
// Checks if the given reader contains a Widevine PSSH. If so, it extracts the
|
||||
// data from the box. Returns true if a PSSH was extracted, false if there was
|
||||
// an error or if the data is not a Widevine PSSH.
|
||||
bool InitializationData::ExtractWidevinePsshData(
|
||||
const uint8_t* data, size_t length, CdmInitData* output) {
|
||||
bool InitializationData::ExtractWidevinePsshData(const uint8_t* data,
|
||||
size_t length,
|
||||
CdmInitData* output) {
|
||||
BufferReader reader(data, length);
|
||||
|
||||
// Read the 32-bit size only so we can check if we need to expect a 64-bit
|
||||
@@ -266,8 +271,7 @@ bool InitializationData::ExtractWidevinePsshData(
|
||||
return false;
|
||||
}
|
||||
if (memcmp(&atom_type[0], "pssh", 4) != 0) {
|
||||
LOGV(
|
||||
"InitializationData::ExtractWidevinePsshData: Atom type is not PSSH.");
|
||||
LOGV("InitializationData::ExtractWidevinePsshData: Atom type is not PSSH.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -312,9 +316,8 @@ bool InitializationData::ExtractWidevinePsshData(
|
||||
"system ID.");
|
||||
return false;
|
||||
}
|
||||
if (memcmp(&system_id[0],
|
||||
kWidevineSystemId,
|
||||
sizeof(kWidevineSystemId)) != 0) {
|
||||
if (memcmp(&system_id[0], kWidevineSystemId, sizeof(kWidevineSystemId)) !=
|
||||
0) {
|
||||
LOGV(
|
||||
"InitializationData::ExtractWidevinePsshData: Found a non-Widevine "
|
||||
"PSSH.");
|
||||
@@ -721,13 +724,7 @@ bool InitializationData::DetectEntitlementPreference(
|
||||
if (oec_version_string.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t oec_version_int = 0;
|
||||
std::istringstream parse_int;
|
||||
parse_int.str(oec_version_string);
|
||||
parse_int >> oec_version_int;
|
||||
|
||||
return oec_version_int >= 14;
|
||||
return std::stoul(oec_version_string) >= 14;
|
||||
}
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
Reference in New Issue
Block a user