Modify initialization data to support HLS
[ Merge of http://go/wvgerrit/16290 ] HLS uses an EXT-X-KEY tag and attribute list in the media playlist to identify the key and method used to encrypt media segments. This allows for the attributes to be parsed and extracted. b/20630275 Change-Id: I2c4a419022f933b7b34b64dc48930f167abe65c6
This commit is contained in:
@@ -16,23 +16,49 @@ class InitializationData {
|
||||
InitializationData(const std::string& type = std::string(),
|
||||
const CdmInitData& data = CdmInitData());
|
||||
|
||||
bool is_supported() const { return is_cenc_ || is_webm_; }
|
||||
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_; }
|
||||
const CdmHlsData& hls_data() const { return hls_data_; }
|
||||
|
||||
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, CdmInitData* init_data);
|
||||
|
||||
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);
|
||||
|
||||
// For testing only:
|
||||
#if defined(UNIT_TEST)
|
||||
FRIEND_TEST(HlsAttributeExtractionTest, ExtractAttribute);
|
||||
FRIEND_TEST(HlsParseTest, Parse);
|
||||
FRIEND_TEST(HlsTest, ExtractHlsAttributes);
|
||||
FRIEND_TEST(HlsHexAttributeExtractionTest, ExtractHexAttribute);
|
||||
FRIEND_TEST(HlsQuotedAttributeExtractionTest, ExtractQuotedAttribute);
|
||||
#endif
|
||||
|
||||
std::string type_;
|
||||
CdmInitData data_;
|
||||
CdmHlsData hls_data_;
|
||||
bool is_cenc_;
|
||||
bool is_hls_;
|
||||
bool is_webm_;
|
||||
};
|
||||
|
||||
|
||||
@@ -80,8 +80,20 @@ static const std::string ISO_BMFF_AUDIO_MIME_TYPE = "audio/mp4";
|
||||
static const std::string WEBM_VIDEO_MIME_TYPE = "video/webm";
|
||||
static const std::string WEBM_AUDIO_MIME_TYPE = "audio/webm";
|
||||
static const std::string CENC_INIT_DATA_FORMAT = "cenc";
|
||||
static const std::string HLS_INIT_DATA_FORMAT = "hls";
|
||||
static const std::string WEBM_INIT_DATA_FORMAT = "webm";
|
||||
|
||||
static const std::string HLS_INITDATA_ATTRIBUTE = "X-WV-INITDATA";
|
||||
static const std::string HLS_KEYFORMAT_ATTRIBUTE = "KEYFORMAT";
|
||||
static const std::string HLS_KEYFORMAT_VERSION_ATTRIBUTE = "KEYFORMATVERSION";
|
||||
static const std::string HLS_KEYFORMAT_VERSION_VALUE_1 = "1";
|
||||
static const std::string HLS_METHOD_ATTRIBUTE = "METHOD";
|
||||
static const std::string HLS_METHOD_AES_128 = "AES-128";
|
||||
static const std::string HLS_METHOD_NONE = "NONE";
|
||||
static const std::string HLS_METHOD_SAMPLE_AES = "SAMPLE-AES";
|
||||
static const std::string HLS_IV_ATTRIBUTE = "IV";
|
||||
static const std::string HLS_URI_ATTRIBUTE = "URI";
|
||||
|
||||
static const char EMPTY_ORIGIN[] = "";
|
||||
} // namespace wvcdm
|
||||
|
||||
|
||||
@@ -209,6 +209,10 @@ enum CdmResponseType {
|
||||
EMPTY_PROVISIONING_CERTIFICATE_2,
|
||||
OFFLINE_LICENSE_PROHIBITED,
|
||||
STORAGE_PROHIBITED,
|
||||
EMPTY_KEYSET_ID_ENG_5,
|
||||
SESSION_NOT_FOUND_11,
|
||||
LOAD_USAGE_INFO_FILE_ERROR,
|
||||
LOAD_USAGE_INFO_MISSING,
|
||||
};
|
||||
|
||||
enum CdmKeyStatus {
|
||||
@@ -254,6 +258,19 @@ enum CdmCertificateType {
|
||||
kCertificateX509,
|
||||
};
|
||||
|
||||
enum CdmHlsMethod {
|
||||
kHlsMethodNone,
|
||||
kHlsMethodAes128,
|
||||
kHlsMethodSampleAes,
|
||||
};
|
||||
|
||||
struct CdmHlsData {
|
||||
CdmHlsData() : method(kHlsMethodNone) {}
|
||||
CdmHlsMethod method;
|
||||
std::vector<uint8_t> iv;
|
||||
std::string uri;
|
||||
};
|
||||
|
||||
struct CdmDecryptionParameters {
|
||||
bool is_encrypted;
|
||||
bool is_secure;
|
||||
|
||||
Reference in New Issue
Block a user