DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
packager_main.cc
1 // Copyright 2014 Google Inc. 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 #include <gflags/gflags.h>
8 #include <iostream>
9 
10 #include "packager/app/fixed_key_encryption_flags.h"
11 #include "packager/app/hls_flags.h"
12 #include "packager/app/libcrypto_threading.h"
13 #include "packager/app/mpd_flags.h"
14 #include "packager/app/muxer_flags.h"
15 #include "packager/app/packager_util.h"
16 #include "packager/app/playready_key_encryption_flags.h"
17 #include "packager/app/stream_descriptor.h"
18 #include "packager/app/vlog_flags.h"
19 #include "packager/app/widevine_encryption_flags.h"
20 #include "packager/base/at_exit.h"
21 #include "packager/base/command_line.h"
22 #include "packager/base/files/file_path.h"
23 #include "packager/base/logging.h"
24 #include "packager/base/path_service.h"
25 #include "packager/base/strings/string_split.h"
26 #include "packager/base/strings/stringprintf.h"
27 #include "packager/base/threading/simple_thread.h"
28 #include "packager/base/time/clock.h"
29 #include "packager/hls/base/hls_notifier.h"
30 #include "packager/hls/base/simple_hls_notifier.h"
31 #include "packager/media/base/container_names.h"
32 #include "packager/media/base/demuxer.h"
33 #include "packager/media/base/fourccs.h"
34 #include "packager/media/base/key_source.h"
35 #include "packager/media/base/muxer_options.h"
36 #include "packager/media/base/muxer_util.h"
37 #include "packager/media/chunking/chunking_handler.h"
38 #include "packager/media/event/hls_notify_muxer_listener.h"
39 #include "packager/media/event/mpd_notify_muxer_listener.h"
40 #include "packager/media/event/vod_media_info_dump_muxer_listener.h"
41 #include "packager/media/file/file.h"
42 #include "packager/media/formats/mp2t/ts_muxer.h"
43 #include "packager/media/formats/mp4/mp4_muxer.h"
44 #include "packager/media/formats/webm/webm_muxer.h"
45 #include "packager/mpd/base/dash_iop_mpd_notifier.h"
46 #include "packager/mpd/base/media_info.pb.h"
47 #include "packager/mpd/base/mpd_builder.h"
48 #include "packager/mpd/base/simple_mpd_notifier.h"
49 #include "packager/version/version.h"
50 
51 #if defined(OS_WIN)
52 #include <codecvt>
53 #include <functional>
54 #include <locale>
55 #endif // defined(OS_WIN)
56 
57 DEFINE_bool(use_fake_clock_for_muxer,
58  false,
59  "Set to true to use a fake clock for muxer. With this flag set, "
60  "creation time and modification time in outputs are set to 0. "
61  "Should only be used for testing.");
62 DEFINE_bool(override_version,
63  false,
64  "Override packager version in the generated outputs with "
65  "--test_version if it is set to true. Should be used for "
66  "testing only.");
67 DEFINE_string(test_version,
68  "",
69  "Packager version for testing. Ignored if --override_version is "
70  "false. Should be used for testing only.");
71 
72 namespace shaka {
73 namespace media {
74 namespace {
75 
76 const char kUsage[] =
77  "%s [flags] <stream_descriptor> ...\n\n"
78  " stream_descriptor consists of comma separated field_name/value pairs:\n"
79  " field_name=value,[field_name=value,]...\n"
80  " Supported field names are as follows:\n"
81  " - input (in): Required input/source media file path or network stream\n"
82  " URL.\n"
83  " - stream_selector (stream): Required field with value 'audio',\n"
84  " 'video', or stream number (zero based).\n"
85  " - output (out): Required output file (single file) or initialization\n"
86  " file path (multiple file).\n"
87  " - segment_template (segment): Optional value which specifies the\n"
88  " naming pattern for the segment files, and that the stream should be\n"
89  " split into multiple files. Its presence should be consistent across\n"
90  " streams.\n"
91  " - bandwidth (bw): Optional value which contains a user-specified\n"
92  " content bit rate for the stream, in bits/sec. If specified, this\n"
93  " value is propagated to the $Bandwidth$ template parameter for\n"
94  " segment names. If not specified, its value may be estimated.\n"
95  " - language (lang): Optional value which contains a user-specified\n"
96  " language tag. If specified, this value overrides any language\n"
97  " metadata in the input track.\n"
98  " - output_format (format): Optional value which specifies the format\n"
99  " of the output files (MP4 or WebM). If not specified, it will be\n"
100  " derived from the file extension of the output file.\n"
101  " - hls_name: Required for audio when outputting HLS.\n"
102  " name of the output stream. This is not (necessarily) the same as\n"
103  " output. This is used as the NAME attribute for EXT-X-MEDIA\n"
104  " - hls_group_id: Required for audio when outputting HLS.\n"
105  " The group ID for the output stream. For HLS this is used as the\n"
106  " GROUP-ID attribute for EXT-X-MEDIA.\n"
107  " - playlist_name: Required for HLS output.\n"
108  " Name of the playlist for the stream. Usually ends with '.m3u8'.\n";
109 
110 const char kMediaInfoSuffix[] = ".media_info";
111 
112 enum ExitStatus {
113  kSuccess = 0,
114  kArgumentValidationFailed,
115  kPackagingFailed,
116  kInternalError,
117 };
118 
119 // TODO(rkuroiwa): Write TTML and WebVTT parser (demuxing) for a better check
120 // and for supporting live/segmenting (muxing). With a demuxer and a muxer,
121 // CreateRemuxJobs() shouldn't treat text as a special case.
122 std::string DetermineTextFileFormat(const std::string& file) {
123  std::string content;
124  if (!File::ReadFileToString(file.c_str(), &content)) {
125  LOG(ERROR) << "Failed to open file " << file
126  << " to determine file format.";
127  return "";
128  }
129  MediaContainerName container_name = DetermineContainer(
130  reinterpret_cast<const uint8_t*>(content.data()), content.size());
131  if (container_name == CONTAINER_WEBVTT) {
132  return "vtt";
133  } else if (container_name == CONTAINER_TTML) {
134  return "ttml";
135  }
136 
137  return "";
138 }
139 
140 FourCC GetProtectionScheme(const std::string& protection_scheme) {
141  if (protection_scheme == "cenc") {
142  return FOURCC_cenc;
143  } else if (protection_scheme == "cens") {
144  return FOURCC_cens;
145  } else if (protection_scheme == "cbc1") {
146  return FOURCC_cbc1;
147  } else if (protection_scheme == "cbcs") {
148  return FOURCC_cbcs;
149  } else {
150  LOG(ERROR) << "Unknown protection scheme: " << protection_scheme;
151  return FOURCC_NULL;
152  }
153 }
154 
155 } // namespace
156 
157 // A fake clock that always return time 0 (epoch). Should only be used for
158 // testing.
159 class FakeClock : public base::Clock {
160  public:
161  base::Time Now() override { return base::Time(); }
162 };
163 
164 // Demux, Mux(es) and worker thread used to remux a source file/stream.
165 class RemuxJob : public base::SimpleThread {
166  public:
167  RemuxJob(std::unique_ptr<Demuxer> demuxer)
168  : SimpleThread("RemuxJob"), demuxer_(std::move(demuxer)) {}
169 
170  ~RemuxJob() override {}
171 
172  Demuxer* demuxer() { return demuxer_.get(); }
173  Status status() { return status_; }
174 
175  private:
176  void Run() override {
177  DCHECK(demuxer_);
178  status_ = demuxer_->Run();
179  }
180 
181  std::unique_ptr<Demuxer> demuxer_;
182  Status status_;
183 
184  DISALLOW_COPY_AND_ASSIGN(RemuxJob);
185 };
186 
187 bool StreamInfoToTextMediaInfo(const StreamDescriptor& stream_descriptor,
188  const MuxerOptions& stream_muxer_options,
189  MediaInfo* text_media_info) {
190  const std::string& language = stream_descriptor.language;
191  std::string format = DetermineTextFileFormat(stream_descriptor.input);
192  if (format.empty()) {
193  LOG(ERROR) << "Failed to determine the text file format for "
194  << stream_descriptor.input;
195  return false;
196  }
197 
198  if (!File::Copy(stream_descriptor.input.c_str(),
199  stream_muxer_options.output_file_name.c_str())) {
200  LOG(ERROR) << "Failed to copy the input file (" << stream_descriptor.input
201  << ") to output file (" << stream_muxer_options.output_file_name
202  << ").";
203  return false;
204  }
205 
206  text_media_info->set_media_file_name(stream_muxer_options.output_file_name);
207  text_media_info->set_container_type(MediaInfo::CONTAINER_TEXT);
208 
209  if (stream_muxer_options.bandwidth != 0) {
210  text_media_info->set_bandwidth(stream_muxer_options.bandwidth);
211  } else {
212  // Text files are usually small and since the input is one file; there's no
213  // way for the player to do ranged requests. So set this value to something
214  // reasonable.
215  text_media_info->set_bandwidth(256);
216  }
217 
218  MediaInfo::TextInfo* text_info = text_media_info->mutable_text_info();
219  text_info->set_format(format);
220  if (!language.empty())
221  text_info->set_language(language);
222 
223  return true;
224 }
225 
226 std::shared_ptr<Muxer> CreateOutputMuxer(const MuxerOptions& options,
227  MediaContainerName container) {
228  if (container == CONTAINER_WEBM) {
229  return std::shared_ptr<Muxer>(new webm::WebMMuxer(options));
230  } else if (container == CONTAINER_MPEG2TS) {
231  return std::shared_ptr<Muxer>(new mp2t::TsMuxer(options));
232  } else {
233  DCHECK_EQ(container, CONTAINER_MOV);
234  return std::shared_ptr<Muxer>(new mp4::MP4Muxer(options));
235  }
236 }
237 
238 bool CreateRemuxJobs(const StreamDescriptorList& stream_descriptors,
239  const ChunkingOptions& chunking_options,
240  const MuxerOptions& muxer_options,
241  FakeClock* fake_clock,
242  KeySource* key_source,
243  MpdNotifier* mpd_notifier,
244  hls::HlsNotifier* hls_notifier,
245  std::vector<std::unique_ptr<RemuxJob>>* remux_jobs) {
246  // No notifiers OR (mpd_notifier XOR hls_notifier); which is NAND.
247  DCHECK(!(mpd_notifier && hls_notifier));
248  DCHECK(remux_jobs);
249 
250  std::string previous_input;
251  int stream_number = 0;
252  for (StreamDescriptorList::const_iterator
253  stream_iter = stream_descriptors.begin();
254  stream_iter != stream_descriptors.end();
255  ++stream_iter, ++stream_number) {
256  // Process stream descriptor.
257  MuxerOptions stream_muxer_options(muxer_options);
258  stream_muxer_options.output_file_name = stream_iter->output;
259  if (!stream_iter->segment_template.empty()) {
260  if (!ValidateSegmentTemplate(stream_iter->segment_template)) {
261  LOG(ERROR) << "ERROR: segment template with '"
262  << stream_iter->segment_template << "' is invalid.";
263  return false;
264  }
265  stream_muxer_options.segment_template = stream_iter->segment_template;
266  }
267  stream_muxer_options.bandwidth = stream_iter->bandwidth;
268 
269  // Handle text input.
270  if (stream_iter->stream_selector == "text") {
271  MediaInfo text_media_info;
272  if (!StreamInfoToTextMediaInfo(*stream_iter, stream_muxer_options,
273  &text_media_info)) {
274  return false;
275  }
276 
277  if (mpd_notifier) {
278  uint32_t unused;
279  if (!mpd_notifier->NotifyNewContainer(text_media_info, &unused)) {
280  LOG(ERROR) << "Failed to process text file " << stream_iter->input;
281  } else {
282  mpd_notifier->Flush();
283  }
284  } else if (FLAGS_output_media_info) {
286  text_media_info,
287  stream_muxer_options.output_file_name + kMediaInfoSuffix);
288  } else {
289  NOTIMPLEMENTED()
290  << "--mpd_output or --output_media_info flags are "
291  "required for text output. Skipping manifest related output for "
292  << stream_iter->input;
293  }
294  continue;
295  }
296 
297  if (stream_iter->input != previous_input) {
298  // New remux job needed. Create demux and job thread.
299  std::unique_ptr<Demuxer> demuxer(new Demuxer(stream_iter->input));
300  demuxer->set_dump_stream_info(FLAGS_dump_stream_info);
301  if (FLAGS_enable_widevine_decryption ||
302  FLAGS_enable_fixed_key_decryption) {
303  std::unique_ptr<KeySource> key_source(CreateDecryptionKeySource());
304  if (!key_source)
305  return false;
306  demuxer->SetKeySource(std::move(key_source));
307  }
308  remux_jobs->emplace_back(new RemuxJob(std::move(demuxer)));
309  previous_input = stream_iter->input;
310  // Skip setting up muxers if output is not needed.
311  if (stream_iter->output.empty())
312  continue;
313  }
314  DCHECK(!remux_jobs->empty());
315 
316  std::shared_ptr<Muxer> muxer(
317  CreateOutputMuxer(stream_muxer_options, stream_iter->output_format));
318  if (FLAGS_use_fake_clock_for_muxer) muxer->set_clock(fake_clock);
319 
320  if (key_source) {
321  muxer->SetKeySource(key_source,
322  FLAGS_max_sd_pixels,
323  FLAGS_max_hd_pixels,
324  FLAGS_max_uhd1_pixels,
325  FLAGS_clear_lead,
326  FLAGS_crypto_period_duration,
327  GetProtectionScheme(FLAGS_protection_scheme));
328  }
329 
330  std::unique_ptr<MuxerListener> muxer_listener;
331  DCHECK(!(FLAGS_output_media_info && mpd_notifier));
332  if (FLAGS_output_media_info) {
333  const std::string output_media_info_file_name =
334  stream_muxer_options.output_file_name + kMediaInfoSuffix;
335  std::unique_ptr<VodMediaInfoDumpMuxerListener>
336  vod_media_info_dump_muxer_listener(
337  new VodMediaInfoDumpMuxerListener(output_media_info_file_name));
338  muxer_listener = std::move(vod_media_info_dump_muxer_listener);
339  }
340  if (mpd_notifier) {
341  std::unique_ptr<MpdNotifyMuxerListener> mpd_notify_muxer_listener(
342  new MpdNotifyMuxerListener(mpd_notifier));
343  muxer_listener = std::move(mpd_notify_muxer_listener);
344  }
345 
346  if (hls_notifier) {
347  // TODO(rkuroiwa): Do some smart stuff to group the audios, e.g. detect
348  // languages.
349  std::string group_id = stream_iter->hls_group_id;
350  std::string name = stream_iter->hls_name;
351  std::string hls_playlist_name = stream_iter->hls_playlist_name;
352  if (group_id.empty())
353  group_id = "audio";
354  if (name.empty())
355  name = base::StringPrintf("stream_%d", stream_number);
356  if (hls_playlist_name.empty())
357  hls_playlist_name = base::StringPrintf("stream_%d.m3u8", stream_number);
358 
359  muxer_listener.reset(new HlsNotifyMuxerListener(hls_playlist_name, name,
360  group_id, hls_notifier));
361  }
362 
363  if (muxer_listener)
364  muxer->SetMuxerListener(std::move(muxer_listener));
365 
366  auto chunking_handler = std::make_shared<ChunkingHandler>(chunking_options);
367  Status status = chunking_handler->SetHandler(0, std::move(muxer));
368 
369  auto* demuxer = remux_jobs->back()->demuxer();
370  const std::string& stream_selector = stream_iter->stream_selector;
371  status.Update(demuxer->SetHandler(stream_selector, chunking_handler));
372 
373  if (!status.ok()) {
374  LOG(ERROR) << "Failed to setup graph: " << status;
375  return false;
376  }
377  if (!stream_iter->language.empty())
378  demuxer->SetLanguageOverride(stream_selector, stream_iter->language);
379  }
380 
381  // Initialize processing graph.
382  for (const std::unique_ptr<RemuxJob>& job : *remux_jobs) {
383  Status status = job->demuxer()->Initialize();
384  if (!status.ok()) {
385  LOG(ERROR) << "Failed to initialize processing graph " << status;
386  return false;
387  }
388  }
389  return true;
390 }
391 
392 Status RunRemuxJobs(const std::vector<std::unique_ptr<RemuxJob>>& remux_jobs) {
393  // Start the job threads.
394  for (const std::unique_ptr<RemuxJob>& job : remux_jobs)
395  job->Start();
396 
397  // Wait for all jobs to complete or an error occurs.
398  Status status;
399  bool all_joined;
400  do {
401  all_joined = true;
402  for (const std::unique_ptr<RemuxJob>& job : remux_jobs) {
403  if (job->HasBeenJoined()) {
404  status = job->status();
405  if (!status.ok())
406  break;
407  } else {
408  all_joined = false;
409  job->Join();
410  }
411  }
412  } while (!all_joined && status.ok());
413 
414  return status;
415 }
416 
417 bool RunPackager(const StreamDescriptorList& stream_descriptors) {
418  const FourCC protection_scheme = GetProtectionScheme(FLAGS_protection_scheme);
419  if (protection_scheme == FOURCC_NULL)
420  return false;
421 
422  if (FLAGS_output_media_info && !FLAGS_mpd_output.empty()) {
423  NOTIMPLEMENTED() << "ERROR: --output_media_info and --mpd_output do not "
424  "work together.";
425  return false;
426  }
427 
428  // Since there isn't a muxer listener that can output both MPD and HLS,
429  // disallow specifying both MPD and HLS flags.
430  if (!FLAGS_mpd_output.empty() && !FLAGS_hls_master_playlist_output.empty()) {
431  LOG(ERROR) << "Cannot output both MPD and HLS.";
432  return false;
433  }
434 
435  ChunkingOptions chunking_options = GetChunkingOptions();
436  MuxerOptions muxer_options = GetMuxerOptions();
437 
438  DCHECK(!stream_descriptors.empty());
439  // On demand profile generates single file segment while live profile
440  // generates multiple segments specified using segment template.
441  const bool on_demand_dash_profile =
442  stream_descriptors.begin()->segment_template.empty();
443  for (const auto& stream_descriptor : stream_descriptors) {
444  if (on_demand_dash_profile != stream_descriptor.segment_template.empty()) {
445  LOG(ERROR) << "Inconsistent stream descriptor specification: "
446  "segment_template should be specified for none or all "
447  "stream descriptors.";
448  return false;
449  }
450  }
451  if (FLAGS_output_media_info && !on_demand_dash_profile) {
452  // TODO(rkuroiwa, kqyang): Support partial media info dump for live.
453  NOTIMPLEMENTED() << "ERROR: --output_media_info is only supported for "
454  "on-demand profile (not using segment_template).";
455  return false;
456  }
457 
458  MpdOptions mpd_options = GetMpdOptions(on_demand_dash_profile);
459 
460  // Create encryption key source if needed.
461  std::unique_ptr<KeySource> encryption_key_source;
462  if (FLAGS_enable_widevine_encryption || FLAGS_enable_fixed_key_encryption ||
463  FLAGS_enable_playready_encryption) {
464  encryption_key_source = CreateEncryptionKeySource();
465  if (!encryption_key_source)
466  return false;
467  }
468 
469  std::unique_ptr<MpdNotifier> mpd_notifier;
470  if (!FLAGS_mpd_output.empty()) {
471  std::vector<std::string> base_urls = base::SplitString(
472  FLAGS_base_urls, ",", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
473  if (FLAGS_generate_dash_if_iop_compliant_mpd) {
474  mpd_notifier.reset(
475  new DashIopMpdNotifier(mpd_options, base_urls, FLAGS_mpd_output));
476  } else {
477  mpd_notifier.reset(
478  new SimpleMpdNotifier(mpd_options, base_urls, FLAGS_mpd_output));
479  }
480  if (!mpd_notifier->Init()) {
481  LOG(ERROR) << "MpdNotifier failed to initialize.";
482  return false;
483  }
484  }
485 
486  std::unique_ptr<hls::HlsNotifier> hls_notifier;
487  if (!FLAGS_hls_master_playlist_output.empty()) {
488  base::FilePath master_playlist_path(
489  base::FilePath::FromUTF8Unsafe(FLAGS_hls_master_playlist_output));
490  base::FilePath master_playlist_name = master_playlist_path.BaseName();
491 
492  hls_notifier.reset(new hls::SimpleHlsNotifier(
493  hls::HlsNotifier::HlsProfile::kOnDemandProfile, FLAGS_hls_base_url,
494  master_playlist_path.DirName().AsEndingWithSeparator().AsUTF8Unsafe(),
495  master_playlist_name.AsUTF8Unsafe()));
496  }
497 
498  std::vector<std::unique_ptr<RemuxJob>> remux_jobs;
499  FakeClock fake_clock;
500  if (!CreateRemuxJobs(stream_descriptors, chunking_options, muxer_options,
501  &fake_clock, encryption_key_source.get(),
502  mpd_notifier.get(), hls_notifier.get(), &remux_jobs)) {
503  return false;
504  }
505 
506  Status status = RunRemuxJobs(remux_jobs);
507  if (!status.ok()) {
508  LOG(ERROR) << "Packaging Error: " << status.ToString();
509  return false;
510  }
511 
512  if (hls_notifier) {
513  if (!hls_notifier->Flush())
514  return false;
515  }
516  if (mpd_notifier) {
517  if (!mpd_notifier->Flush())
518  return false;
519  }
520 
521  printf("Packaging completed successfully.\n");
522  return true;
523 }
524 
525 int PackagerMain(int argc, char** argv) {
526  base::AtExitManager exit;
527  // Needed to enable VLOG/DVLOG through --vmodule or --v.
528  base::CommandLine::Init(argc, argv);
529 
530  // Set up logging.
531  logging::LoggingSettings log_settings;
532  log_settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
533  CHECK(logging::InitLogging(log_settings));
534 
535  google::SetVersionString(GetPackagerVersion());
536  google::SetUsageMessage(base::StringPrintf(kUsage, argv[0]));
537  google::ParseCommandLineFlags(&argc, &argv, true);
538  if (argc < 2) {
539  google::ShowUsageWithFlags("Usage");
540  return kSuccess;
541  }
542 
545  return kArgumentValidationFailed;
546  }
547 
548  if (FLAGS_override_version)
549  SetPackagerVersionForTesting(FLAGS_test_version);
550 
551  LibcryptoThreading libcrypto_threading;
552  // TODO(tinskip): Make InsertStreamDescriptor a member of
553  // StreamDescriptorList.
554  StreamDescriptorList stream_descriptors;
555  for (int i = 1; i < argc; ++i) {
556  if (!InsertStreamDescriptor(argv[i], &stream_descriptors))
557  return kArgumentValidationFailed;
558  }
559  return RunPackager(stream_descriptors) ? kSuccess : kPackagingFailed;
560 }
561 
562 } // namespace media
563 } // namespace shaka
564 
565 #if defined(OS_WIN)
566 // Windows wmain, which converts wide character arguments to UTF-8.
567 int wmain(int argc, wchar_t* argv[], wchar_t* envp[]) {
568  std::unique_ptr<char* [], std::function<void(char**)>> utf8_argv(
569  new char*[argc], [argc](char** utf8_args) {
570  // TODO(tinskip): This leaks, but if this code is enabled, it crashes.
571  // Figure out why. I suspect gflags does something funny with the
572  // argument array.
573  // for (int idx = 0; idx < argc; ++idx)
574  // delete[] utf8_args[idx];
575  delete[] utf8_args;
576  });
577  std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
578  for (int idx = 0; idx < argc; ++idx) {
579  std::string utf8_arg(converter.to_bytes(argv[idx]));
580  utf8_arg += '\0';
581  utf8_argv[idx] = new char[utf8_arg.size()];
582  memcpy(utf8_argv[idx], &utf8_arg[0], utf8_arg.size());
583  }
584  return shaka::media::PackagerMain(argc, utf8_argv.get());
585 }
586 #else
587 int main(int argc, char** argv) {
588  return shaka::media::PackagerMain(argc, argv);
589 }
590 #endif // defined(OS_WIN)
static bool Copy(const char *from_file_name, const char *to_file_name)
Definition: file.cc:203
bool ValidateWidevineCryptoFlags()
static bool WriteMediaInfoToFile(const MediaInfo &media_info, const std::string &output_file_path)
static bool ReadFileToString(const char *file_name, std::string *contents)
Definition: file.cc:185
bool ValidateFixedCryptoFlags()