7 #include <packager/app/crypto_flags.h>
11 #include <absl/flags/flag.h>
13 ABSL_FLAG(std::string,
16 "Specify a protection scheme, 'cenc' or 'cbc1' or pattern-based "
17 "protection schemes 'cens' or 'cbcs'.");
22 "Specify the count of the encrypted blocks in the protection pattern, "
23 "where block is of size 16-bytes. There are three common "
24 "patterns (crypt_byte_block:skip_byte_block): 1:9 (default), 5:5, 10:0. "
25 "Apply to video streams with 'cbcs' and 'cens' protection schemes only; "
26 "ignored otherwise.");
31 "Specify the count of the unencrypted blocks in the protection pattern. "
32 "Apply to video streams with 'cbcs' and 'cens' protection schemes only; "
33 "ignored otherwise.");
35 vp9_subsample_encryption,
37 "Enable VP9 subsample encryption.");
38 ABSL_FLAG(std::string,
39 playready_extra_header_data,
41 "Extra XML data to add to PlayReady headers.");
43 bool ValueNotGreaterThanTen(
const char* flagname, int32_t value) {
45 fprintf(stderr,
"ERROR: %s must not be greater than 10.\n", flagname);
49 fprintf(stderr,
"ERROR: %s must be non-negative.\n", flagname);
55 bool ValueIsXml(
const char* flagname,
const std::string& value) {
59 if (value[0] !=
'<' || value[value.size() - 1] !=
'>') {
60 fprintf(stderr,
"ERROR: %s must be valid XML.\n", flagname);
67 bool ValidateCryptoFlags() {
70 auto crypt_byte_block = absl::GetFlag(FLAGS_crypt_byte_block);
71 if (!ValueNotGreaterThanTen(
"crypt_byte_block", crypt_byte_block)) {
75 auto skip_byte_block = absl::GetFlag(FLAGS_skip_byte_block);
76 if (!ValueNotGreaterThanTen(
"skip_byte_block", skip_byte_block)) {
80 auto playready_extra_header_data =
81 absl::GetFlag(FLAGS_playready_extra_header_data);
82 if (!ValueIsXml(
"playready_extra_header_data", playready_extra_header_data)) {
All the methods that are virtual are virtual for mocking.