Export media_cas_packager_sdk
This commit is contained in:
BIN
libmedia_cas_packager_sdk.so
Executable file
BIN
libmedia_cas_packager_sdk.so
Executable file
Binary file not shown.
95
media_cas_packager_sdk/public/ecm_generator.h
Normal file
95
media_cas_packager_sdk/public/ecm_generator.h
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright 2018 Google LLC.
|
||||||
|
//
|
||||||
|
// This software is licensed under the terms defined in the Widevine Master
|
||||||
|
// License Agreement. For a copy of this agreement, please contact
|
||||||
|
// widevine-licensing@google.com.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef MEDIA_CAS_PACKAGER_SDK_PUBLIC_ECM_GENERATOR_H_
|
||||||
|
#define MEDIA_CAS_PACKAGER_SDK_PUBLIC_ECM_GENERATOR_H_
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include "util/status.h"
|
||||||
|
#include "media_cas_packager_sdk/internal/ecm.h"
|
||||||
|
|
||||||
|
namespace widevine {
|
||||||
|
namespace cas {
|
||||||
|
|
||||||
|
// KeyParameters carries key information for a single encryption key.
|
||||||
|
// Instances of this struct are owned by an EcmParameters struct.
|
||||||
|
struct KeyParameters {
|
||||||
|
std::string key_id;
|
||||||
|
std::string key_data;
|
||||||
|
std::string wrapped_key_data;
|
||||||
|
std::string wrapped_key_iv;
|
||||||
|
std::vector<std::string> content_ivs;
|
||||||
|
};
|
||||||
|
|
||||||
|
// EcmParameters holds information that is needed by the EcmGenerator. It is
|
||||||
|
// partially set up with data from a KeyGenerator (obtained via GenerateKey()).
|
||||||
|
// IVs are added later.
|
||||||
|
// TODO(user): may need a starting crypto period index.
|
||||||
|
struct EcmParameters {
|
||||||
|
static constexpr int kDefaultIVSize = 8;
|
||||||
|
int iv_size = kDefaultIVSize;
|
||||||
|
bool current_key_even = true;
|
||||||
|
uint32_t current_key_index = 0;
|
||||||
|
std::string entitlement_key_id;
|
||||||
|
bool rotation_enabled = true;
|
||||||
|
uint32_t rotation_periods;
|
||||||
|
std::vector<KeyParameters> key_params;
|
||||||
|
uint16_t program_id;
|
||||||
|
uint64_t rotation_period_microseconds;
|
||||||
|
// For video, this is zero. For audio, this is the size of the audio frame,
|
||||||
|
// which is a constant in the audio track.
|
||||||
|
uint16_t offset = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ECM Generator for Widevine/MediaCAS entitled keys.
|
||||||
|
class CasEcmGenerator {
|
||||||
|
public:
|
||||||
|
CasEcmGenerator() = default;
|
||||||
|
virtual ~CasEcmGenerator() = default;
|
||||||
|
|
||||||
|
virtual std::string GenerateEcm(const EcmParameters& params);
|
||||||
|
|
||||||
|
// Query the state of this ECM Generator
|
||||||
|
bool initialized() { return initialized_; }
|
||||||
|
bool rotation_enabled() { return rotation_enabled_; }
|
||||||
|
|
||||||
|
void set_ecm(std::unique_ptr<CasEcm> ecm) { ecm_ = std::move(ecm); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class CasEcmGeneratorTest;
|
||||||
|
|
||||||
|
util::Status ProcessEcmParameters(const EcmParameters& ecm_params,
|
||||||
|
std::vector<EntitledKeyInfo>* keys);
|
||||||
|
|
||||||
|
util::Status ProcessEcmParameters(const EcmParameters& ecm_params);
|
||||||
|
util::Status ValidateKeyId(const std::string& id);
|
||||||
|
util::Status ValidateKeyData(const std::string& key_data);
|
||||||
|
util::Status ValidateWrappedKeyIv(const std::string& iv);
|
||||||
|
util::Status ValidateIv(const std::string& iv, size_t required_size);
|
||||||
|
util::Status ValidateContentIv(const std::string& iv);
|
||||||
|
util::Status ValidateKeyParameters(const KeyParameters& key_params);
|
||||||
|
|
||||||
|
bool initialized_ = false;
|
||||||
|
uint32_t generation_ = 0;
|
||||||
|
bool rotation_enabled_ = false;
|
||||||
|
uint32_t current_key_index_ = 0;
|
||||||
|
bool current_key_even_ = true;
|
||||||
|
uint32_t content_iv_size_ = 0;
|
||||||
|
std::unique_ptr<CasEcm> ecm_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace cas
|
||||||
|
} // namespace widevine
|
||||||
|
|
||||||
|
#endif // MEDIA_CAS_PACKAGER_SDK_PUBLIC_ECM_GENERATOR_H_
|
||||||
Reference in New Issue
Block a user