1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
media / cdm / supported_cdm_versions.cc [blame]
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/cdm/supported_cdm_versions.h"
#include <optional>
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
#include "media/base/media_switches.h"
namespace media {
namespace {
// Returns the overridden supported CDM interface version specified on command
// line, which can be null if not specified.
std::optional<int> GetSupportedCdmInterfaceVersionOverrideFromCommandLine() {
auto* command_line = base::CommandLine::ForCurrentProcess();
if (!command_line)
return std::nullopt;
auto version_string = command_line->GetSwitchValueASCII(
switches::kOverrideEnabledCdmInterfaceVersion);
int version = 0;
if (!base::StringToInt(version_string, &version))
return std::nullopt;
else
return version;
}
} // namespace
bool IsSupportedAndEnabledCdmInterfaceVersion(int version) {
if (!IsSupportedCdmInterfaceVersion(version))
return false;
auto version_override =
GetSupportedCdmInterfaceVersionOverrideFromCommandLine();
if (version_override)
return version == version_override;
return IsCdmInterfaceVersionEnabledByDefault(version);
}
} // namespace media