diff --git a/example/wv_cas_ecm_example b/example/wv_cas_ecm_example index 6df5af8..c0792ae 100644 Binary files a/example/wv_cas_ecm_example and b/example/wv_cas_ecm_example differ diff --git a/example/wv_cas_ecm_example.cc b/example/wv_cas_ecm_example.cc index 2d94154..4d65e34 100644 --- a/example/wv_cas_ecm_example.cc +++ b/example/wv_cas_ecm_example.cc @@ -12,6 +12,7 @@ #include #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 bool kKeyRotationEnabled = true; @@ -27,17 +28,21 @@ const char kEntitlementKey[] = "entitlement_key................."; // 32 bytes int main(int argc, char **argv) { widevine::cas::WvCasEcm wv_cas_ecm; - bool status = + widevine::cas::WvCasStatus status = wv_cas_ecm.Initialize(kContentIvSize, kKeyRotationEnabled, kCryptoMode); - if (!status) { - std::cerr << "Failed to initialize WV CAS ECM, error." << std::endl; + if (status != widevine::cas::OK) { + std::cerr << "Failed to initialize WV CAS ECM, error: " + << widevine::cas::GetWvCasStatusMessage(status) + << std::endl; } std::string ecm; status = wv_cas_ecm.GenerateEcm(kEvenKey, kEvenContentIv16Bytes, kOddKey, kOddContentIv16Bytes, kEntitlementKeyId, kEntitlementKey, &ecm); - if (!status) { - std::cerr << "Failed to generate WV CAS ECM, error" << std::endl; + if (status != widevine::cas::OK) { + std::cerr << "Failed to generate WV CAS ECM, error: " + << widevine::cas::GetWvCasStatusMessage(status) + << std::endl; } else { std::cout << "ECM size: " << ecm.size() << std::endl; std::cout << "ECM bytes: "; diff --git a/libmedia_cas_packager_sdk.so b/libmedia_cas_packager_sdk.so index 8c68942..d59bb45 100755 Binary files a/libmedia_cas_packager_sdk.so and b/libmedia_cas_packager_sdk.so differ diff --git a/media_cas_packager_sdk/public/wv_cas_ecm.h b/media_cas_packager_sdk/public/wv_cas_ecm.h index 020bffd..5b089b8 100644 --- a/media_cas_packager_sdk/public/wv_cas_ecm.h +++ b/media_cas_packager_sdk/public/wv_cas_ecm.h @@ -16,7 +16,7 @@ #include #include -#include "util/status.h" +#include "media_cas_packager_sdk/public/wv_cas_status.h" namespace widevine { namespace cas { @@ -47,12 +47,12 @@ class WvCasEcm { // only CTR is supported by Widevine CAS plugin for now // // Returns: - // - A boolean indicating whether there was any error during initialization + // - A status indicating whether there was any error during initialization // // Note: // - 'even'/'odd' key in the ECM will be be encrypted using AEC_CBC - virtual bool Initialize(int content_iv_size, bool key_rotation_enabled, - int crypto_mode); + virtual WvCasStatus Initialize(int content_iv_size, bool key_rotation_enabled, + int crypto_mode); // Generate an ECM containing two keys (even and odd). Can be called when // |key_rotation_enabled| is initialized to 'true'. @@ -67,18 +67,20 @@ class WvCasEcm { // - |ecm| for returning the generated ECM, must not be nullptr // // Returns: - // - A boolean indicating whether there was any error during processing + // - A status indicating whether there was any error during processing // // Note: // - The same |entitlement_key| will be used to encrypt both |even_key| // and |odd_key| in the ECM // - Size of |even_content_iv| and |odd_content_iv| must match // |content_iv_size| set during initialization - virtual bool GenerateEcm(const std::string& even_key, - const std::string& even_content_iv, const std::string& odd_key, - const std::string& odd_content_iv, - const std::string& entitlement_key_id, - const std::string& entitlement_key, std::string* ecm) const; + virtual WvCasStatus GenerateEcm(const std::string& even_key, + const std::string& even_content_iv, + const std::string& odd_key, + const std::string& odd_content_iv, + const std::string& entitlement_key_id, + const std::string& entitlement_key, + std::string* ecm) const; // Generate an ECM containing only a singe even key. Can be called when // |key_rotation_enabled| is initialized to 'false'. @@ -91,16 +93,16 @@ class WvCasEcm { // - |ecm| for returning the generated ECM, must not be nullptr // // Returns: - // - A boolean indicating whether there was any error during processing + // - A status indicating whether there was any error during processing // // Note: // - Size of |even_content_iv| and |odd_content_iv| must match // |content_iv_size| set during initialization - virtual bool GenerateSingleKeyEcm(const std::string& even_key, - const std::string& even_content_iv, - const std::string& entitlement_key_id, - const std::string& entitlement_key, - std::string* ecm) const; + virtual WvCasStatus GenerateSingleKeyEcm(const std::string& even_key, + const std::string& even_content_iv, + const std::string& entitlement_key_id, + const std::string& entitlement_key, + std::string* ecm) const; private: bool initialized_ = false; diff --git a/media_cas_packager_sdk/public/wv_cas_status.h b/media_cas_packager_sdk/public/wv_cas_status.h new file mode 100644 index 0000000..99e49f6 --- /dev/null +++ b/media_cas_packager_sdk/public/wv_cas_status.h @@ -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 + +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_