Commit 8c1592af authored by John Rummell's avatar John Rummell Committed by Commit Bot

Use cdm_platform_specific_path from cdm_paths.gni

Rather than duplicate the logic in cdm_paths.cc, pass
cdm_platform_specific_path from cdm_paths.gni using BUILDFLAGS.

Bug: 971433
Test: EME browser_tests pass
Change-Id: I0cdfb768b36e991fc407291093ee00bf3cd5cffa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1747197
Commit-Queue: John Rummell <jrummell@chromium.org>
Reviewed-by: default avatarXiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#687369}
parent f479e8d7
......@@ -8,6 +8,7 @@ import("//build/config/arm.gni")
import("//build/config/features.gni")
import("//build/config/linux/pkg_config.gni")
import("//build/config/ui.gni")
import("//media/cdm/library_cdm/cdm_paths.gni")
import("//media/media_options.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//testing/test.gni")
......@@ -17,7 +18,8 @@ buildflag_header("media_buildflags") {
header = "media_buildflags.h"
flags = [
"ALTERNATE_CDM_STORAGE_ID_KEY=$alternate_cdm_storage_id_key",
"ALTERNATE_CDM_STORAGE_ID_KEY=\"$alternate_cdm_storage_id_key\"",
"CDM_PLATFORM_SPECIFIC_PATH=\"$cdm_platform_specific_path\"",
"ENABLE_AC3_EAC3_AUDIO_DEMUXING=$enable_ac3_eac3_audio_demuxing",
"ENABLE_CBCS_ENCRYPTION_SCHEME=$enable_cbcs_encryption_scheme",
"ENABLE_CDM_HOST_VERIFICATION=$enable_cdm_host_verification",
......
......@@ -113,6 +113,7 @@ static_library("cdm_paths") {
]
deps = [
"//base",
"//media:media_buildflags",
]
}
......@@ -148,6 +149,7 @@ source_set("unit_tests") {
if (enable_library_cdms) {
sources += [
"cdm_adapter_unittest.cc",
"cdm_paths_unittest.cc",
"external_clear_key_test_helper.cc",
"external_clear_key_test_helper.h",
"mock_helpers.cc",
......
......@@ -6,7 +6,7 @@
#include <string>
#include "build/build_config.h"
#include "media/media_buildflags.h"
namespace media {
......@@ -24,60 +24,16 @@ const base::Token kClearKeyCdmDifferentGuid{0xc3914773474bdb02ull,
// this ID is based on the pepper plugin MIME type.
const char kClearKeyCdmFileSystemId[] = "application_x-ppapi-clearkey-cdm";
// Note: This file must be in sync with cdm_paths.gni.
// TODO(xhwang): Improve how we enable platform specific path. See
// http://crbug.com/468584
#if (defined(OS_MACOSX) || defined(OS_WIN)) && \
(defined(ARCH_CPU_X86) || defined(ARCH_CPU_X86_64))
#define CDM_USE_PLATFORM_SPECIFIC_PATH
#endif
#if defined(CDM_USE_PLATFORM_SPECIFIC_PATH)
// Special path used in chrome components.
const char kPlatformSpecific[] = "_platform_specific";
// Name of the component platform in the manifest.
const char kComponentPlatform[] =
#if defined(OS_MACOSX)
"mac";
#elif defined(OS_WIN)
"win";
#elif defined(OS_CHROMEOS)
"cros";
#elif defined(OS_LINUX)
"linux";
#else
"unsupported_platform";
#endif
// Name of the component architecture in the manifest.
const char kComponentArch[] =
#if defined(ARCH_CPU_X86)
"x86";
#elif defined(ARCH_CPU_X86_64)
"x64";
#elif defined(ARCH_CPU_ARMEL)
"arm";
#else
"unsupported_arch";
#endif
base::FilePath GetPlatformSpecificDirectory(const std::string& cdm_base_path) {
base::FilePath path;
const std::string kPlatformArch =
std::string(kComponentPlatform) + "_" + kComponentArch;
return path.AppendASCII(cdm_base_path)
.AppendASCII(kPlatformSpecific)
.AppendASCII(kPlatformArch);
}
#else // defined(CDM_USE_PLATFORM_SPECIFIC_PATH)
// CDM_PLATFORM_SPECIFIC_PATH is specified in cdm_paths.gni.
const std::string kPlatformSpecific = BUILDFLAG(CDM_PLATFORM_SPECIFIC_PATH);
if (kPlatformSpecific.empty())
return base::FilePath();
base::FilePath GetPlatformSpecificDirectory(const std::string& cdm_base_path) {
return base::FilePath();
return base::FilePath()
.AppendASCII(cdm_base_path)
.AppendASCII(kPlatformSpecific)
.NormalizePathSeparators();
}
#endif // defined(CDM_USE_PLATFORM_SPECIFIC_PATH)
} // namespace media
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/cdm/cdm_paths.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "media/media_buildflags.h"
#include "testing/gtest/include/gtest/gtest.h"
// Only verify platform specific path where CDMs are Chrome components.
#if (defined(OS_MACOSX) || defined(OS_WIN)) && \
(defined(ARCH_CPU_X86) || defined(ARCH_CPU_X86_64))
#define CDM_USE_PLATFORM_SPECIFIC_PATH
#endif
namespace media {
namespace {
#if defined(CDM_USE_PLATFORM_SPECIFIC_PATH)
// Special path used in chrome components.
const char kPlatformSpecific[] = "_platform_specific";
// Name of the component platform.
const char kComponentPlatform[] =
#if defined(OS_MACOSX)
"mac";
#elif defined(OS_WIN)
"win";
#elif defined(OS_CHROMEOS)
"cros";
#elif defined(OS_LINUX)
"linux";
#else
"unsupported_platform";
#endif
// Name of the component architecture.
const char kComponentArch[] =
#if defined(ARCH_CPU_X86)
"x86";
#elif defined(ARCH_CPU_X86_64)
"x64";
#elif defined(ARCH_CPU_ARMEL)
"arm";
#else
"unsupported_arch";
#endif
base::FilePath GetExpectedPlatformSpecificDirectory(
const std::string& base_path) {
base::FilePath path;
const std::string kPlatformArch =
std::string(kComponentPlatform) + "_" + kComponentArch;
return path.AppendASCII(base_path)
.AppendASCII(kPlatformSpecific)
.AppendASCII(kPlatformArch);
}
#else
// If the CDM is not a component, it has no platform specific path.
base::FilePath GetExpectedPlatformSpecificDirectory(
const std::string& base_path) {
return base::FilePath();
}
#endif // defined(CDM_USE_PLATFORM_SPECIFIC_PATH)
std::string GetFlag() {
return BUILDFLAG(CDM_PLATFORM_SPECIFIC_PATH);
}
} // namespace
TEST(CdmPathsTest, FlagSpecified) {
#if defined(CDM_USE_PLATFORM_SPECIFIC_PATH)
EXPECT_FALSE(GetFlag().empty());
#else
EXPECT_TRUE(GetFlag().empty());
#endif
}
TEST(CdmPathsTest, Prefix) {
const char kPrefix[] = "prefix";
auto path = GetPlatformSpecificDirectory(kPrefix);
#if defined(CDM_USE_PLATFORM_SPECIFIC_PATH)
EXPECT_TRUE(base::StartsWith(path.MaybeAsASCII(), kPrefix,
base::CompareCase::SENSITIVE));
#else
EXPECT_TRUE(path.MaybeAsASCII().empty());
#endif
}
TEST(CdmPathsTest, Expected) {
const char kPrefix[] = "cdm";
EXPECT_EQ(GetExpectedPlatformSpecificDirectory(kPrefix),
GetPlatformSpecificDirectory(kPrefix));
}
} // namespace media
......@@ -7,8 +7,6 @@
# Naming and folder structure below are following the recommendation for Chrome
# components. Component-updated CDMs must follow the same recommendation.
# Note: This file must be in sync with cdm_paths.cc
# OS name for components is close to "target_os" but has some differences.
# Explicitly define what we use to avoid confusion.
if (is_chromeos) {
......@@ -29,21 +27,21 @@ if (current_cpu == "x86" || current_cpu == "x64" || current_cpu == "arm") {
component_arch = "unsupported_arch"
}
# Only enable platform specific path for Win and Mac, where CDMs are Chrome
# components.
# TODO(xhwang): Improve how we enable platform specific path. See
# http://crbug.com/468584
# Only enable platform specific path where CDMs are Chrome components.
# Note: |cdm_platform_specific_path| is exported as a BUILDFLAG to cdm_paths.cc.
if ((is_win || is_mac) && (current_cpu == "x86" || current_cpu == "x64")) {
_platform_specific_path =
cdm_platform_specific_path =
"_platform_specific/$component_os" + "_" + "$component_arch"
# Path of Clear Key and Widevine CDMs relative to the output dir.
clearkey_cdm_path = "ClearKeyCdm/$_platform_specific_path"
widevine_cdm_path = "WidevineCdm/$_platform_specific_path"
clearkey_cdm_path = "ClearKeyCdm/$cdm_platform_specific_path"
widevine_cdm_path = "WidevineCdm/$cdm_platform_specific_path"
} else if (is_fuchsia) {
cdm_platform_specific_path = ""
clearkey_cdm_path = "lib"
widevine_cdm_path = "lib"
} else {
cdm_platform_specific_path = ""
clearkey_cdm_path = "."
widevine_cdm_path = "."
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment