//////////////////////////////////////////////////////////////////////////////// // 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. //////////////////////////////////////////////////////////////////////////////// // Example of how to use the wv_cas_ecm library. #include #include "gflags/gflags.h" #include "glog/logging.h" #include "absl/strings/escaping.h" #include "absl/strings/str_cat.h" #include "util/status.h" #include "media_cas_packager_sdk/public/wv_cas_ecm.h" const char kEvenKey[] = "even_content_key"; // 16 bytes const char kEvenContentIv8Bytes[] = "evencont"; // 8 bytes const char kOddKey[] = "odd_content_key."; // 16 bytes const char kOddContentIv8Bytes[] = "oddcont."; // 8 bytes const char kEntitlementKeyId[] = "ent_key_id......"; // 16 bytes const char kEntitlementKey[] = "entitlement_key................."; // 32 bytes int main(int argc, char **argv) { gflags::ParseCommandLineFlags(&argc, &argv, true); widevine::cas::WvCasEcm wv_cas_ecm; auto status = wv_cas_ecm.Initialize(/* content_iv_size= */ 16, /* key_rotation_enabled= */ true, /* crypto_mode= */ 1); if (!status.ok()) { LOG(FATAL) << "Failed to initialize WV CAS ECM, error: " << status; } std::string ecm; status = wv_cas_ecm.GenerateEcm( /* even_key= */ kEvenKey, /* even_content_iv= */ absl::StrCat(kEvenContentIv8Bytes, kEvenContentIv8Bytes), /* odd_key= */ kOddKey, /* odd_content_iv= */ absl::StrCat(kOddContentIv8Bytes, kOddContentIv8Bytes), /* entitlement_key_id= */ kEntitlementKeyId, /* entitlement_key= */ kEntitlementKey, &ecm); if (!status.ok()) { LOG(FATAL) << "Failed to generate WV CAS ECM, error: " << status; } else { LOG(INFO) << "Generated WV CAS ECM (in hex): " << absl::BytesToHexString(ecm); } return 0; }