7#include <packager/app/crypto_flags.h>
13#include <absl/flags/flag.h>
18 "Specify a protection scheme, 'cenc' or 'cbc1' or pattern-based "
19 "protection schemes 'cens' or 'cbcs', or 'aes128' for HLS AES-128 "
20 "full-segment CBC encryption (TS/HLS only, no DRM system required).");
25 "Specify the count of the encrypted blocks in the protection pattern, "
26 "where block is of size 16-bytes. There are three common "
27 "patterns (crypt_byte_block:skip_byte_block): 1:9 (default), 5:5, 10:0. "
28 "Apply to video streams with 'cbcs' and 'cens' protection schemes only; "
29 "ignored otherwise.");
34 "Specify the count of the unencrypted blocks in the protection pattern. "
35 "Apply to video streams with 'cbcs' and 'cens' protection schemes only; "
36 "ignored otherwise.");
38 vp9_subsample_encryption,
40 "Enable VP9 subsample encryption.");
44 "Use CENC v1 (2012) instead of v3 (2016+) for encryption.");
46 playready_extra_header_data,
48 "Extra XML data to add to PlayReady headers.");
50bool ValueNotGreaterThanTen(
const char* flagname, int32_t value) {
52 fprintf(stderr,
"ERROR: %s must not be greater than 10.\n", flagname);
56 fprintf(stderr,
"ERROR: %s must be non-negative.\n", flagname);
62bool ValueIsXml(
const char* flagname,
const std::string& value) {
66 if (value[0] !=
'<' || value[value.size() - 1] !=
'>') {
67 fprintf(stderr,
"ERROR: %s must be valid XML.\n", flagname);
74bool ValidateCryptoFlags() {
77 auto cencv1 = absl::GetFlag(FLAGS_cencv1);
78 auto scheme = absl::GetFlag(FLAGS_protection_scheme);
79 if (cencv1 && scheme !=
"cenc") {
80 fprintf(stderr,
"ERROR: CENC v1 only supports 'cenc' scheme.\n");
84 auto crypt_byte_block = absl::GetFlag(FLAGS_crypt_byte_block);
85 if (!ValueNotGreaterThanTen(
"crypt_byte_block", crypt_byte_block)) {
89 auto skip_byte_block = absl::GetFlag(FLAGS_skip_byte_block);
90 if (!ValueNotGreaterThanTen(
"skip_byte_block", skip_byte_block)) {
94 auto playready_extra_header_data =
95 absl::GetFlag(FLAGS_playready_extra_header_data);
96 if (!ValueIsXml(
"playready_extra_header_data", playready_extra_header_data)) {
All the methods that are virtual are virtual for mocking.