Files
android/libwvdrmengine/cdm/core/include/initialization_data.h
Rahul Frias cbde9109b6 Corrections to support HLS
[ Merge of https://go/wvgerrit/17055 ]

There are a few bugs that need to be addressed to get HLS to work.

* Content ID in json init data is base64 encoded and needs to be decoded
  before being added to the WidevineCencHeader proto.
* Protection scheme was not set in the WidevineCencHeader proto.
* HLS initialization data should be sent as a CENC content identification
  in a license request.

b/20630275

Change-Id: Ie0ac33ac061931df6f26c0afbf3e62e5d01e5041
2016-03-09 01:10:01 -08:00

80 lines
2.8 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_; }
std::vector<uint8_t> hls_iv() const { return hls_iv_; }
CdmHlsMethod hls_method() const { return hls_method_; }
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_