Create a WvCasStatus to be used as return type of libraries in media_cas_packager_sdk.
Following example: []/video/widevine/export/provisioning_sdk/public/provisioning_status.h and []/video/widevine/export/exported_root/util/status.h ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=218918745
This commit is contained in:
Binary file not shown.
@@ -12,6 +12,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "media_cas_packager_sdk/public/wv_cas_ecm.h"
|
#include "media_cas_packager_sdk/public/wv_cas_ecm.h"
|
||||||
|
#include "media_cas_packager_sdk/public/wv_cas_status.h"
|
||||||
|
|
||||||
const int kContentIvSize = 16;
|
const int kContentIvSize = 16;
|
||||||
const bool kKeyRotationEnabled = true;
|
const bool kKeyRotationEnabled = true;
|
||||||
@@ -27,17 +28,21 @@ const char kEntitlementKey[] = "entitlement_key................."; // 32 bytes
|
|||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
widevine::cas::WvCasEcm wv_cas_ecm;
|
widevine::cas::WvCasEcm wv_cas_ecm;
|
||||||
bool status =
|
widevine::cas::WvCasStatus status =
|
||||||
wv_cas_ecm.Initialize(kContentIvSize, kKeyRotationEnabled, kCryptoMode);
|
wv_cas_ecm.Initialize(kContentIvSize, kKeyRotationEnabled, kCryptoMode);
|
||||||
if (!status) {
|
if (status != widevine::cas::OK) {
|
||||||
std::cerr << "Failed to initialize WV CAS ECM, error." << std::endl;
|
std::cerr << "Failed to initialize WV CAS ECM, error: "
|
||||||
|
<< widevine::cas::GetWvCasStatusMessage(status)
|
||||||
|
<< std::endl;
|
||||||
}
|
}
|
||||||
std::string ecm;
|
std::string ecm;
|
||||||
status = wv_cas_ecm.GenerateEcm(kEvenKey, kEvenContentIv16Bytes, kOddKey,
|
status = wv_cas_ecm.GenerateEcm(kEvenKey, kEvenContentIv16Bytes, kOddKey,
|
||||||
kOddContentIv16Bytes, kEntitlementKeyId,
|
kOddContentIv16Bytes, kEntitlementKeyId,
|
||||||
kEntitlementKey, &ecm);
|
kEntitlementKey, &ecm);
|
||||||
if (!status) {
|
if (status != widevine::cas::OK) {
|
||||||
std::cerr << "Failed to generate WV CAS ECM, error" << std::endl;
|
std::cerr << "Failed to generate WV CAS ECM, error: "
|
||||||
|
<< widevine::cas::GetWvCasStatusMessage(status)
|
||||||
|
<< std::endl;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "ECM size: " << ecm.size() << std::endl;
|
std::cout << "ECM size: " << ecm.size() << std::endl;
|
||||||
std::cout << "ECM bytes: ";
|
std::cout << "ECM bytes: ";
|
||||||
|
|||||||
Binary file not shown.
@@ -16,7 +16,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "util/status.h"
|
#include "media_cas_packager_sdk/public/wv_cas_status.h"
|
||||||
|
|
||||||
namespace widevine {
|
namespace widevine {
|
||||||
namespace cas {
|
namespace cas {
|
||||||
@@ -47,11 +47,11 @@ class WvCasEcm {
|
|||||||
// only CTR is supported by Widevine CAS plugin for now
|
// only CTR is supported by Widevine CAS plugin for now
|
||||||
//
|
//
|
||||||
// Returns:
|
// Returns:
|
||||||
// - A boolean indicating whether there was any error during initialization
|
// - A status indicating whether there was any error during initialization
|
||||||
//
|
//
|
||||||
// Note:
|
// Note:
|
||||||
// - 'even'/'odd' key in the ECM will be be encrypted using AEC_CBC
|
// - 'even'/'odd' key in the ECM will be be encrypted using AEC_CBC
|
||||||
virtual bool Initialize(int content_iv_size, bool key_rotation_enabled,
|
virtual WvCasStatus Initialize(int content_iv_size, bool key_rotation_enabled,
|
||||||
int crypto_mode);
|
int crypto_mode);
|
||||||
|
|
||||||
// Generate an ECM containing two keys (even and odd). Can be called when
|
// Generate an ECM containing two keys (even and odd). Can be called when
|
||||||
@@ -67,18 +67,20 @@ class WvCasEcm {
|
|||||||
// - |ecm| for returning the generated ECM, must not be nullptr
|
// - |ecm| for returning the generated ECM, must not be nullptr
|
||||||
//
|
//
|
||||||
// Returns:
|
// Returns:
|
||||||
// - A boolean indicating whether there was any error during processing
|
// - A status indicating whether there was any error during processing
|
||||||
//
|
//
|
||||||
// Note:
|
// Note:
|
||||||
// - The same |entitlement_key| will be used to encrypt both |even_key|
|
// - The same |entitlement_key| will be used to encrypt both |even_key|
|
||||||
// and |odd_key| in the ECM
|
// and |odd_key| in the ECM
|
||||||
// - Size of |even_content_iv| and |odd_content_iv| must match
|
// - Size of |even_content_iv| and |odd_content_iv| must match
|
||||||
// |content_iv_size| set during initialization
|
// |content_iv_size| set during initialization
|
||||||
virtual bool GenerateEcm(const std::string& even_key,
|
virtual WvCasStatus GenerateEcm(const std::string& even_key,
|
||||||
const std::string& even_content_iv, const std::string& odd_key,
|
const std::string& even_content_iv,
|
||||||
|
const std::string& odd_key,
|
||||||
const std::string& odd_content_iv,
|
const std::string& odd_content_iv,
|
||||||
const std::string& entitlement_key_id,
|
const std::string& entitlement_key_id,
|
||||||
const std::string& entitlement_key, std::string* ecm) const;
|
const std::string& entitlement_key,
|
||||||
|
std::string* ecm) const;
|
||||||
|
|
||||||
// Generate an ECM containing only a singe even key. Can be called when
|
// Generate an ECM containing only a singe even key. Can be called when
|
||||||
// |key_rotation_enabled| is initialized to 'false'.
|
// |key_rotation_enabled| is initialized to 'false'.
|
||||||
@@ -91,12 +93,12 @@ class WvCasEcm {
|
|||||||
// - |ecm| for returning the generated ECM, must not be nullptr
|
// - |ecm| for returning the generated ECM, must not be nullptr
|
||||||
//
|
//
|
||||||
// Returns:
|
// Returns:
|
||||||
// - A boolean indicating whether there was any error during processing
|
// - A status indicating whether there was any error during processing
|
||||||
//
|
//
|
||||||
// Note:
|
// Note:
|
||||||
// - Size of |even_content_iv| and |odd_content_iv| must match
|
// - Size of |even_content_iv| and |odd_content_iv| must match
|
||||||
// |content_iv_size| set during initialization
|
// |content_iv_size| set during initialization
|
||||||
virtual bool GenerateSingleKeyEcm(const std::string& even_key,
|
virtual WvCasStatus GenerateSingleKeyEcm(const std::string& even_key,
|
||||||
const std::string& even_content_iv,
|
const std::string& even_content_iv,
|
||||||
const std::string& entitlement_key_id,
|
const std::string& entitlement_key_id,
|
||||||
const std::string& entitlement_key,
|
const std::string& entitlement_key,
|
||||||
|
|||||||
56
media_cas_packager_sdk/public/wv_cas_status.h
Normal file
56
media_cas_packager_sdk/public/wv_cas_status.h
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// 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_WV_CAS_STATUS_H_
|
||||||
|
#define MEDIA_CAS_PACKAGER_SDK_PUBLIC_WV_CAS_STATUS_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace widevine {
|
||||||
|
namespace cas {
|
||||||
|
|
||||||
|
enum WvCasStatus {
|
||||||
|
// Success.
|
||||||
|
OK = 0,
|
||||||
|
|
||||||
|
// Client specified an invalid argument.
|
||||||
|
INVALID_ARGUMENT = 3,
|
||||||
|
|
||||||
|
// Some requested entity (e.g., file or directory) was not found.
|
||||||
|
NOT_FOUND = 5,
|
||||||
|
|
||||||
|
// Some entity that we attempted to create (e.g., file or directory)
|
||||||
|
// already exists.
|
||||||
|
ALREADY_EXISTS = 6,
|
||||||
|
|
||||||
|
// The caller does not have permission to execute the specified
|
||||||
|
// operation.
|
||||||
|
PERMISSION_DENIED = 7,
|
||||||
|
|
||||||
|
// Operation is not implemented or not supported/enabled in this service.
|
||||||
|
UNIMPLEMENTED = 12,
|
||||||
|
|
||||||
|
// Internal errors. Means some invariants expected by underlying
|
||||||
|
// system has been broken. If you see one of these errors,
|
||||||
|
// something is very broken.
|
||||||
|
INTERNAL = 13,
|
||||||
|
|
||||||
|
// Operation is not implemented or not supported/enabled in this service.
|
||||||
|
UNAVAILABLE = 14,
|
||||||
|
|
||||||
|
// Number of errors.
|
||||||
|
NUM_WV_CAS_STATUS,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Returns the message std::string for the given WvCasStatus.
|
||||||
|
std::string GetWvCasStatusMessage(WvCasStatus status);
|
||||||
|
|
||||||
|
} // namespace cas
|
||||||
|
} // namespace widevine
|
||||||
|
|
||||||
|
#endif // MEDIA_CAS_PACKAGER_SDK_PUBLIC_WV_CAS_STATUS_H_
|
||||||
Reference in New Issue
Block a user