Shaka Packager SDK
retired_flags.cc
1 // Copyright 2017 Google LLC. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 //
7 // Defines retired / deprecated flags. These flags will be removed in later
8 // versions.
9 
10 #include <packager/app/retired_flags.h>
11 
12 #include <cstdio>
13 
14 ABSL_FLAG(std::string, profile, "", "This flag is deprecated. Do not use.");
15 ABSL_FLAG(bool, single_segment, true, "This flag is deprecated. Do not use.");
16 ABSL_FLAG(bool,
17  webm_subsample_encryption,
18  true,
19  "This flag is deprecated. Use vp9_subsample_encryption instead.");
20 ABSL_FLAG(double,
21  availability_time_offset,
22  0,
23  "This flag is deprecated. Use suggested_presentation_delay "
24  "instead which can achieve similar effect.");
25 ABSL_FLAG(std::string,
26  playready_key_id,
27  "",
28  "This flag is deprecated. Use --enable_raw_key_encryption with "
29  "--generate_playready_pssh to generate PlayReady PSSH.");
30 ABSL_FLAG(std::string,
31  playready_key,
32  "",
33  "This flag is deprecated. Use --enable_raw_key_encryption with "
34  "--generate_playready_pssh to generate PlayReady PSSH.");
35 ABSL_FLAG(bool,
36  mp4_use_decoding_timestamp_in_timeline,
37  false,
38  "This flag is deprecated. Do not use.");
39 ABSL_FLAG(
40  int32_t,
41  num_subsegments_per_sidx,
42  0,
43  "This flag is deprecated. Use --generate_sidx_in_media_segments instead.");
44 ABSL_FLAG(bool,
45  generate_widevine_pssh,
46  false,
47  "This flag is deprecated. Use --protection_systems instead.");
48 ABSL_FLAG(bool,
49  generate_playready_pssh,
50  false,
51  "This flag is deprecated. Use --protection_systems instead.");
52 ABSL_FLAG(bool,
53  generate_common_pssh,
54  false,
55  "This flag is deprecated. Use --protection_systems instead.");
56 ABSL_FLAG(bool,
57  generate_static_mpd,
58  false,
59  "This flag is deprecated. Use --generate_static_live_mpd instead.");
60 
61 // The current gflags library does not provide a way to check whether a flag is
62 // set in command line. If a flag has a different value to its default value,
63 // the flag must have been set. It is possible that the flag is set to the same
64 // value as its default value though.
65 bool InformRetiredStringFlag(const char* flagname, const std::string& value) {
66  if (!value.empty())
67  fprintf(stderr, "WARNING: %s is deprecated and ignored.\n", flagname);
68  return true;
69 }
70 
71 bool InformRetiredDefaultTrueFlag(const char* flagname, bool value) {
72  if (!value)
73  fprintf(stderr, "WARNING: %s is deprecated and ignored.\n", flagname);
74  return true;
75 }
76 
77 bool InformRetiredDefaultFalseFlag(const char* flagname, bool value) {
78  if (value)
79  fprintf(stderr, "WARNING: %s is deprecated and ignored.\n", flagname);
80  return true;
81 }
82 
83 bool InformRetiredDefaultDoubleFlag(const char* flagname, double value) {
84  if (value != 0)
85  fprintf(stderr, "WARNING: %s is deprecated and ignored.\n", flagname);
86  return true;
87 }
88 
89 bool InformRetiredDefaultInt32Flag(const char* flagname, int32_t value) {
90  if (value != 0)
91  fprintf(stderr, "WARNING: %s is deprecated and ignored.\n", flagname);
92  return true;
93 }
94 
95 bool InformRetiredPsshGenerationFlag(const char* flagname, bool value) {
96  if (value) {
97  fprintf(stderr,
98  "WARNING: %s is deprecated and ignored. Please switch to "
99  "--protection_systems.\n",
100  flagname);
101  }
102  return true;
103 }
104 
105 bool InformRetiredGenerateStaticMpdFlag(const char* flagname, bool value) {
106  if (value) {
107  fprintf(stderr,
108  "WARNING: %s is deprecated and ignored. Please switch to "
109  "--generate_static_live_mpd.\n",
110  flagname);
111  }
112  return true;
113 }
114 
115 namespace shaka {
116 bool ValidateRetiredFlags() {
117  bool success = true;
118 
119  auto profile = absl::GetFlag(FLAGS_profile);
120  if (!InformRetiredStringFlag("profile", profile)) {
121  success = false;
122  }
123 
124  auto single_segment = absl::GetFlag(FLAGS_single_segment);
125  if (!InformRetiredDefaultTrueFlag("single_segment", single_segment)) {
126  success = false;
127  }
128  auto webm_subsample_encryption =
129  absl::GetFlag(FLAGS_webm_subsample_encryption);
130  if (!InformRetiredDefaultTrueFlag("webm_subsample_encryption",
131  webm_subsample_encryption)) {
132  success = false;
133  }
134  auto availability_time_offset = absl::GetFlag(FLAGS_availability_time_offset);
135  if (!InformRetiredDefaultDoubleFlag("availability_time_offset",
136  availability_time_offset)) {
137  success = false;
138  }
139  auto playready_key_id = absl::GetFlag(FLAGS_playready_key_id);
140  if (!InformRetiredStringFlag("playready_key_id", playready_key_id)) {
141  success = false;
142  }
143  auto playready_key = absl::GetFlag(FLAGS_playready_key);
144  if (!InformRetiredStringFlag("playready_key", playready_key)) {
145  success = false;
146  }
147  auto mp4_use_decoding_timestamp_in_timeline =
148  absl::GetFlag(FLAGS_mp4_use_decoding_timestamp_in_timeline);
149  if (!InformRetiredDefaultFalseFlag("mp4_use_decoding_timestamp_in_timeline",
150  mp4_use_decoding_timestamp_in_timeline)) {
151  success = false;
152  }
153  auto num_subsegments_per_sidx = absl::GetFlag(FLAGS_num_subsegments_per_sidx);
154  if (!InformRetiredDefaultInt32Flag("num_subsegments_per_sidx",
155  num_subsegments_per_sidx)) {
156  success = false;
157  }
158  auto generate_widevine_pssh = absl::GetFlag(FLAGS_generate_widevine_pssh);
159  if (!InformRetiredPsshGenerationFlag("generate_widevine_pssh",
160  generate_widevine_pssh)) {
161  success = false;
162  }
163  auto generate_playready_pssh = absl::GetFlag(FLAGS_generate_playready_pssh);
164  if (!InformRetiredPsshGenerationFlag("generate_playready_pssh",
165  generate_playready_pssh)) {
166  success = false;
167  }
168  auto generate_common_pssh = absl::GetFlag(FLAGS_generate_common_pssh);
169  if (!InformRetiredPsshGenerationFlag("generate_common_pssh",
170  generate_common_pssh)) {
171  success = false;
172  }
173  auto generate_static_mpd = absl::GetFlag(FLAGS_generate_static_mpd);
174  if (!InformRetiredGenerateStaticMpdFlag("generate_static_mpd",
175  generate_static_mpd)) {
176  success = false;
177  }
178 
179  return success;
180 }
181 } // namespace shaka
All the methods that are virtual are virtual for mocking.
Definition: crypto_flags.cc:66