9 #include "packager/app/widevine_encryption_flags.h"
11 #include "packager/app/validate_flag.h"
12 #include "packager/base/logging.h"
13 #include "packager/base/strings/string_piece.h"
14 #include "packager/base/strings/string_util.h"
16 DEFINE_bool(enable_widevine_encryption,
18 "Enable encryption with Widevine license server/proxy. User should "
19 "provide either AES signing key (--aes_signing_key, "
20 "--aes_signing_iv) or RSA signing key (--rsa_signing_key_path).");
21 DEFINE_bool(enable_widevine_decryption,
23 "Enable decryption with Widevine license server/proxy. User should "
24 "provide either AES signing key (--aes_signing_key, "
25 "--aes_signing_iv) or RSA signing key (--rsa_signing_key_path).");
26 DEFINE_bool(include_common_pssh,
28 "When using Widevine encryption, include an additional v1 PSSH box "
29 "for the common system ID that includes the key IDs. See: "
30 "http://goo.gl/PHZDAF");
31 DEFINE_string(key_server_url,
"",
"Key server url. Required for encryption and "
33 DEFINE_string(content_id,
"",
"Content Id (hex).");
36 "The name of a stored policy, which specifies DRM content "
38 DEFINE_int32(max_sd_pixels,
40 "If the video track has more pixels per frame than max_sd_pixels, "
41 "it is considered as HD, SD otherwise. Default: 768 * 576.");
42 DEFINE_string(signer,
"",
"The name of the signer.");
43 DEFINE_string(aes_signing_key,
45 "AES signing key in hex string. --aes_signing_iv is required. "
46 "Exclusive with --rsa_signing_key_path.");
47 DEFINE_string(aes_signing_iv,
49 "AES signing iv in hex string.");
50 DEFINE_string(rsa_signing_key_path,
52 "Stores PKCS#1 RSA private key for request signing. Exclusive "
53 "with --aes_signing_key.");
54 DEFINE_int32(crypto_period_duration,
56 "Crypto period duration in seconds. If it is non-zero, key "
57 "rotation is enabled.");
58 DEFINE_string(protection_scheme,
60 "Choose protection scheme. Currently support cenc and cbc1. "
63 namespace edash_packager {
68 const bool widevine_crypto =
69 FLAGS_enable_widevine_encryption || FLAGS_enable_widevine_decryption;
70 const char widevine_crypto_label[] =
71 "--enable_widevine_encryption/decryption";
78 widevine_crypto_label)) {
85 widevine_crypto_label)) {
88 if (widevine_crypto && FLAGS_signer.empty() &&
89 base::StartsWith(base::StringPiece(FLAGS_key_server_url),
"http",
90 base::CompareCase::INSENSITIVE_ASCII)) {
91 LOG(WARNING) <<
"--signer is likely required with "
92 "--enable_widevine_encryption/decryption.";
95 const char widevine_encryption_label[] =
"--enable_widevine_encryption";
100 FLAGS_enable_widevine_encryption,
102 widevine_encryption_label)) {
107 FLAGS_enable_widevine_encryption,
109 widevine_encryption_label)) {
112 if (FLAGS_include_common_pssh && !FLAGS_enable_widevine_encryption) {
113 PrintError(
"--include_common_pssh is only valid with "
114 "--enable_widevine_encryption");
118 if (FLAGS_max_sd_pixels <= 0) {
119 PrintError(
"--max_sd_pixels must be positive.");
123 const bool aes = !FLAGS_signer.empty() && FLAGS_rsa_signing_key_path.empty();
124 const char aes_label[] =
125 "--signer is specified and exclusive with --rsa_signing_key_path";
128 "aes_signing_key", FLAGS_aes_signing_key, aes,
true, aes_label)) {
132 "aes_signing_iv", FLAGS_aes_signing_iv, aes,
true, aes_label)) {
136 const bool rsa = !FLAGS_signer.empty() && FLAGS_aes_signing_key.empty() &&
137 FLAGS_aes_signing_iv.empty();
138 const char rsa_label[] =
139 "--signer is specified and exclusive with --aes_signing_key/iv";
142 FLAGS_rsa_signing_key_path,
149 if (!FLAGS_signer.empty() &&
150 (FLAGS_aes_signing_key.empty() || FLAGS_aes_signing_iv.empty()) &&
151 FLAGS_rsa_signing_key_path.empty()) {
153 "--aes_signing_key/iv or --rsa_signing_key_path is required with "
158 if (FLAGS_crypto_period_duration < 0) {
159 PrintError(
"--crypto_period_duration should not be negative.");
bool ValidateWidevineCryptoFlags()
bool ValidateFlag(const char *flag_name, const std::string &flag_value, bool condition, bool optional, const char *label)
void PrintError(const std::string &error_message)