These are a set of CLs merged from the wv cdm repo to the android repo. * Resolve intermittent decrypt error. Author: Jeff Fore <jfore@google.com> [ Merge of http://go/wvgerrit/35720 ] The CdmSession's closed state was not properly initialized resulting in intermittent SESSION_NOT_FOUND_FOR_DECRYPT errors. In CdmEngine::Decrypt the session is looked up by the key id. A list of open sessions is acquired by calling CdmSessionMap::GetSessionList and each session in the list is queried to see if it has the key. In building the list in CdmSessionMap::GetSessionList, sessions are only added to the query list *if* the session is not closed. The closed status was not initialized and during testing the query list would not contain the session causing CdmEngine::Decrypt to return SESSION_NOT_FOUND_FOR_DECRYPT resulting in the ce cdm api returning widevine::Cdm::kNoKey. * No support for pre- C++11 compilation. Author: Gene Morgan <gmorgan@google.com> [ Merge of http://go/wvgerrit/35381 ] * Handle unaligned nonce pointer in RewrapDeviceRSAKey calls. Author: Gene Morgan <gmorgan@google.com> [ Merge of http://go/wvgerrit/35340 ] The pointer points into a message and it may not be aligned. Always copy the nonce into aligned memory before checking it. BUG: 38140370 Add note to CHANGELOG for this. * Compiler strictness: more checks and code cleanup. Author: Gene Morgan <gmorgan@google.com> [ Merge of http://go/wvgerrit/35300 ] Use the switches proposed in b/38033653 (as much as possible - some conflicts with protobufs and gtest prevent fully accepting them). Switch to clang for x32 build; ensure that both x86-64 and x86-32 builds compile and link cleanly. BUG: 38032429 BUG: 38033653 This partially resolves b/38458986 * Android build fixes Author: Rahul Frias <rfrias@google.com> [ Merge of http://go/wvgerrit/35102 ] These corrections address compile warnings and errors for android and unit tests. * Embedded License: Add sub license key sessions. Author: Jeff Fore <jfore@google.com> [ Merge of http://go/wvgerrit/33680 ] NOTE: this adds the AddSubSession() method, but it is not yet being used. Use and proper cleanup is in an upcoming CL. * Embedded license: Add track label field. Author: Jeff Fore <jfore@google.com> [ Merge of http://go/wvgerrit/33660 ] A new track label field (a string) is added to the key container and the sub session data objects. This field will be used in handling sub license requests. * Embedded license: extract keys from init_data. Author: Jeff Fore <jfore@google.com> [ Merge of http://go/wvgerrit/33621 ] * Embedded license: add protobuf messages. Author: Jeff Fore <jfore@google.com> [ Merge of http://go/wvgerrit/33620 ] also sync the widevine header definition with recent naming changes. * Improve handling of provisioning response errors. Author: Gene Morgan <gmorgan@google.com> [ Merge of http://go/wvgerrit/33600 ] Separate out the case of no response and the case where the message is believed to be a JSON+base64 message but it doesn't parse properly. BUG: 71650075 Test: Not currently passing. Will be addressed in a subsequent commit in the chain. Change-Id: I3c86f1c54980b071aec7461ac58541836551f896
82 lines
2.9 KiB
C++
82 lines
2.9 KiB
C++
// Copyright 2014 Google Inc. All Rights Reserved.
|
|
|
|
#ifndef CORE_INCLUDE_INITIALIZATION_DATA_H_
|
|
#define CORE_INCLUDE_INITIALIZATION_DATA_H_
|
|
|
|
#include <string>
|
|
|
|
#include "license_protocol.pb.h"
|
|
#include "wv_cdm_types.h"
|
|
|
|
namespace wvcdm {
|
|
|
|
class WvCdmEngineTest;
|
|
|
|
class InitializationData {
|
|
public:
|
|
InitializationData(const std::string& type = std::string(),
|
|
const CdmInitData& data = CdmInitData());
|
|
|
|
bool is_supported() const { return is_cenc_ || is_webm_ || is_hls_; }
|
|
bool is_cenc() const { return is_cenc_; }
|
|
bool is_hls() const { return is_hls_; }
|
|
bool is_webm() const { return is_webm_; }
|
|
|
|
bool IsEmpty() const { return data_.empty(); }
|
|
|
|
const std::string& type() const { return type_; }
|
|
const CdmInitData& data() const { return data_; }
|
|
std::vector<uint8_t> hls_iv() const { return hls_iv_; }
|
|
CdmHlsMethod hls_method() const { return hls_method_; }
|
|
std::vector<video_widevine::SubLicense> ExtractEmbeddedKeys() const;
|
|
|
|
private:
|
|
// Parse a blob of multiple concatenated PSSH atoms to extract the first
|
|
// Widevine PSSH.
|
|
bool ExtractWidevinePssh(const CdmInitData& init_data, CdmInitData* output);
|
|
|
|
bool ExtractHlsAttributes(const std::string& attribute_list,
|
|
CdmHlsMethod* method, std::vector<uint8_t>* iv,
|
|
std::string* uri);
|
|
static bool ConstructWidevineInitData(CdmHlsMethod method,
|
|
const std::string& uri,
|
|
CdmInitData* output);
|
|
static bool ExtractQuotedAttribute(const std::string& attribute_list,
|
|
const std::string& key,
|
|
std::string* value);
|
|
static bool ExtractHexAttribute(const std::string& attribute_list,
|
|
const std::string& key,
|
|
std::vector<uint8_t>* value);
|
|
static bool ExtractAttribute(const std::string& attribute_list,
|
|
const std::string& key, std::string* value);
|
|
|
|
static std::vector<std::string> ExtractKeyFormatVersions(
|
|
const std::string& key_format_versions);
|
|
|
|
// For testing only:
|
|
#if defined(UNIT_TEST)
|
|
FRIEND_TEST(HlsAttributeExtractionTest, ExtractAttribute);
|
|
FRIEND_TEST(HlsConstructionTest, InitData);
|
|
FRIEND_TEST(HlsInitDataConstructionTest, InvalidUriDataFormat);
|
|
FRIEND_TEST(HlsInitDataConstructionTest, InvalidUriBase64Encode);
|
|
FRIEND_TEST(HlsHexAttributeExtractionTest, ExtractHexAttribute);
|
|
FRIEND_TEST(HlsKeyFormatVersionsExtractionTest, ExtractKeyFormatVersions);
|
|
FRIEND_TEST(HlsParseTest, Parse);
|
|
FRIEND_TEST(HlsQuotedAttributeExtractionTest, ExtractQuotedAttribute);
|
|
FRIEND_TEST(HlsTest, ExtractHlsAttributes);
|
|
#endif
|
|
|
|
std::string type_;
|
|
CdmInitData data_;
|
|
bool is_cenc_;
|
|
bool is_hls_;
|
|
bool is_webm_;
|
|
|
|
std::vector<uint8_t> hls_iv_;
|
|
CdmHlsMethod hls_method_;
|
|
};
|
|
|
|
} // namespace wvcdm
|
|
|
|
#endif // CORE_INCLUDE_INITIALIZATION_DATA_H_
|