Files
android/libwvdrmengine/cdm/core/include/initialization_data.h
Rahul Frias 355471c408 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
2016-01-07 13:06:42 -08:00

68 lines
2.2 KiB
C++

// Copyright 2014 Google Inc. All Rights Reserved.
#ifndef CORE_INCLUDE_INITIALIZATION_DATA_H_
#define CORE_INCLUDE_INITIALIZATION_DATA_H_
#include <string>
#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_; }
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_;
};
} // namespace wvcdm
#endif // CORE_INCLUDE_INITIALIZATION_DATA_H_