Skip to content

Commit

Permalink
Add the Widevine CDM to Chrome.
Browse files Browse the repository at this point in the history
This CL adds the key system and enables the media stack to find the CDM.

BUG=149772
TEST=Play content that uses this key system.


Review URL: https://chromiumcodereview.appspot.com/11099059

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161455 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
ddorwin@chromium.org committed Oct 12, 2012
1 parent b97d349 commit a9cde19
Show file tree
Hide file tree
Showing 10 changed files with 114 additions and 9 deletions.
1 change: 1 addition & 0 deletions chrome/chrome_common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
'<(DEPTH)/third_party/mt19937ar/mt19937ar.gyp:mt19937ar',
'<(DEPTH)/third_party/re2/re2.gyp:re2',
'<(DEPTH)/third_party/sqlite/sqlite.gyp:sqlite',
'<(DEPTH)/third_party/widevine/cdm/widevine_cdm.gyp:widevine_cdm_version_h',
'<(DEPTH)/third_party/zlib/zlib.gyp:zlib',
'<(DEPTH)/ui/ui.gyp:ui_resources',
'<(DEPTH)/webkit/support/webkit_support.gyp:glue',
Expand Down
6 changes: 5 additions & 1 deletion chrome/chrome_tests.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -4277,7 +4277,7 @@
'product_name': 'app_mode_app_tests',
'dependencies': [
'../base/base.gyp:test_support_base',
'../chrome/common_constants.gyp:common_constants',
'../chrome/common_constants.gyp:common_constants',
'../testing/gtest.gyp:gtest',
'chrome.gyp:chrome', # run time dependency
'app_mode_app_support',
Expand All @@ -4303,6 +4303,9 @@
{
'target_name': 'perf_tests',
'type': 'executable',
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)', # Needed by key_systems.cc.
],
'dependencies': [
'browser',
'chrome_resources.gyp:chrome_resources',
Expand All @@ -4317,6 +4320,7 @@
'../skia/skia.gyp:skia',
'../testing/gtest.gyp:gtest',
'../webkit/support/webkit_support.gyp:glue',
'../third_party/widevine/cdm/widevine_cdm.gyp:widevine_cdm_version_h',
],
'sources': [
'browser/net/sqlite_persistent_cookie_store_perftest.cc',
Expand Down
34 changes: 32 additions & 2 deletions chrome/common/chrome_content_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "webkit/user_agent/user_agent_util.h"

#include "flapper_version.h" // In SHARED_INTERMEDIATE_DIR.
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.

#if defined(OS_WIN)
#include "base/win/registry.h"
Expand Down Expand Up @@ -79,8 +80,11 @@ const char kGTalkPluginDescription[] = "Google Talk Plugin";
const uint32 kGTalkPluginPermissions = ppapi::PERMISSION_PRIVATE |
ppapi::PERMISSION_DEV;

const char kInterposeLibraryPath[] =
"@executable_path/../../../libplugin_carbon_interpose.dylib";
#if defined(WIDEVINE_CDM_AVAILABLE)
const char kWidevineCdmPluginExtension[] = "";
const uint32 kWidevineCdmPluginPermissions = ppapi::PERMISSION_PRIVATE |
ppapi::PERMISSION_DEV;
#endif // WIDEVINE_CDM_AVAILABLE

#if defined(ENABLE_REMOTING)
#if defined(GOOGLE_CHROME_BUILD)
Expand All @@ -102,6 +106,9 @@ const char kRemotingViewerPluginMimeExtension[] = "";
const char kRemotingViewerPluginMimeDescription[] = "";
#endif // defined(ENABLE_REMOTING)

const char kInterposeLibraryPath[] =
"@executable_path/../../../libplugin_carbon_interpose.dylib";

// Appends the known built-in plugins to the given vector. Some built-in
// plugins are "internal" which means they are compiled into the Chrome binary,
// and some are extra shared libraries distributed with the browser (these are
Expand Down Expand Up @@ -196,6 +203,29 @@ void ComputeBuiltInPlugins(std::vector<content::PepperPluginInfo>* plugins) {
}
}

#if defined(WIDEVINE_CDM_AVAILABLE)
static bool skip_widevine_cdm_file_check = false;
if (PathService::Get(chrome::FILE_WIDEVINE_CDM_PLUGIN, &path)) {
if (skip_widevine_cdm_file_check || file_util::PathExists(path)) {
content::PepperPluginInfo widevine_cdm;
widevine_cdm.is_out_of_process = true;
widevine_cdm.path = path;
widevine_cdm.name = kWidevineCdmPluginName;
widevine_cdm.description = kWidevineCdmPluginDescription;
widevine_cdm.version = WIDEVINE_CDM_VERSION_STRING;
webkit::WebPluginMimeType widevine_cdm_mime_type(
kWidevineCdmPluginMimeType,
kWidevineCdmPluginExtension,
kWidevineCdmPluginMimeTypeDescription);
widevine_cdm.mime_types.push_back(widevine_cdm_mime_type);
widevine_cdm.permissions = kWidevineCdmPluginPermissions;
plugins->push_back(widevine_cdm);

skip_widevine_cdm_file_check = true;
}
}
#endif // WIDEVINE_CDM_AVAILABLE

// The Remoting Viewer plugin is built-in.
#if defined(ENABLE_REMOTING)
content::PepperPluginInfo info;
Expand Down
17 changes: 13 additions & 4 deletions chrome/common/chrome_paths.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#include "base/mac/mac_util.h"
#endif

#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.

namespace {

// File name of the internal Flash plugin on different platforms.
Expand Down Expand Up @@ -322,15 +324,22 @@ bool PathProvider(int key, FilePath* result) {
cur = cur.Append(kInternalNaClHelperBootstrapFileName);
break;
case chrome::FILE_O3D_PLUGIN:
if (!PathService::Get(base::DIR_MODULE, &cur))
return false;
if (!PathService::Get(base::DIR_MODULE, &cur))
return false;
cur = cur.Append(kO3DPluginFileName);
break;
case chrome::FILE_GTALK_PLUGIN:
if (!PathService::Get(base::DIR_MODULE, &cur))
return false;
if (!PathService::Get(base::DIR_MODULE, &cur))
return false;
cur = cur.Append(kGTalkPluginFileName);
break;
#endif
#if defined(WIDEVINE_CDM_AVAILABLE)
case chrome::FILE_WIDEVINE_CDM_PLUGIN:
if (!PathService::Get(base::DIR_MODULE, &cur))
return false;
cur = cur.Append(kWidevineCdmPluginFileName);
break;
#endif
case chrome::FILE_RESOURCES_PACK:
#if defined(OS_MACOSX)
Expand Down
2 changes: 2 additions & 0 deletions chrome/common/chrome_paths.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ enum {
// (subdir of DIR_PNACL_BASE).
FILE_O3D_PLUGIN, // Full path to the O3D Pepper plugin file.
FILE_GTALK_PLUGIN, // Full path to the GTalk Pepper plugin file.
FILE_WIDEVINE_CDM_PLUGIN, // Full path to the Widevine CDM Pepper plugin
// file.
FILE_LIBAVCODEC, // Full path to libavcodec media decoding
// library.
FILE_LIBAVFORMAT, // Full path to libavformat media parsing
Expand Down
8 changes: 8 additions & 0 deletions chrome/common_constants.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@
{
'target_name': 'common_constants',
'type': 'static_library',
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)', # Needed by chrome_paths.cc.
],
'dependencies': [
'../base/base.gyp:base',
'../third_party/widevine/cdm/widevine_cdm.gyp:widevine_cdm_version_h',
],
'conditions': [
['toolkit_uses_gtk == 1', {
Expand All @@ -74,8 +78,12 @@
{
'target_name': 'common_constants_win64',
'type': 'static_library',
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)', # Needed by chrome_paths.cc.
],
'dependencies': [
'../base/base.gyp:base_nacl_win64',
'../third_party/widevine/cdm/widevine_cdm.gyp:widevine_cdm_version_h',
],
'defines': [
'<@(nacl_win64_defines)',
Expand Down
33 changes: 33 additions & 0 deletions third_party/widevine/cdm/widevine_cdm_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) 2012 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.

#ifndef WIDEVINE_CDM_COMMON_H_INCLUDED_
#define WIDEVINE_CDM_COMMON_H_INCLUDED_

#include "base/file_path.h"

// This file defines constants common to all Widevine CDM versions.

// "alpha" is a temporary name until a convention is defined.
const char kWidevineKeySystem[] = "com.widevine.alpha";

const char kWidevineCdmPluginName[] = "Widevine HTML CDM";
// Will be parsed as HTML.
const char kWidevineCdmPluginDescription[] =
"This plugin enables Widevine licenses for playback of HTML audio/video "
"content.";
const char kWidevineCdmPluginMimeType[] ="application/x-ppapi-widevine-cdm";
const char kWidevineCdmPluginMimeTypeDescription[] = "Widevine HTML CDM";

// File name of the plugin on different platforms.
const FilePath::CharType kWidevineCdmPluginFileName[] =
#if defined(OS_MACOSX)
FILE_PATH_LITERAL("widevinecdmplugin.plugin");
#elif defined(OS_WIN)
FILE_PATH_LITERAL("widevinecdmplugin.dll");
#else // OS_LINUX, etc.
FILE_PATH_LITERAL("libwidevinecdmplugin.so");
#endif

#endif // WIDEVINE_CDM_COMMON_H_INCLUDED_
3 changes: 2 additions & 1 deletion third_party/widevine/cdm/widevine_cdm_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
#ifndef WIDEVINE_CDM_VERSION_H_INCLUDED_
#define WIDEVINE_CDM_VERSION_H_INCLUDED_

// If the Widevine CDM were available, we'd define two things:
// If the Widevine CDM were available, we would include
// third_party/widevine/cdm/widevine_cdm_common.h and define two things:
// - WIDEVINE_CDM_AVAILABLE (to indicate availability), and
// - WIDEVINE_CDM_VERSION_STRING (with the version of the CDM that's available
// as a string, e.g., "1.0.123.456").
Expand Down
15 changes: 14 additions & 1 deletion webkit/media/crypto/key_systems.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"

#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.

namespace webkit_media {

// Convert a WebString to ASCII, falling back on an empty string in the case
Expand Down Expand Up @@ -44,16 +46,27 @@ struct KeySystemPluginTypePair {
// entries in KeySystems::key_system_map_.
static const MediaFormatAndKeySystem
supported_format_key_system_combinations[] = {
// Clear Key.
{ "video/webm", "vorbis,vp8,vp8.0,", kClearKeyKeySystem },
{ "audio/webm", "vorbis,", kClearKeyKeySystem },

// External Clear Key (used for testing).
{ "video/webm", "vorbis,vp8,vp8.0,", kExternalClearKeyKeySystem },
{ "audio/webm", "vorbis,", kExternalClearKeyKeySystem },

#if defined(WIDEVINE_CDM_AVAILABLE)
// Widevine.
{ "video/webm", "vorbis,vp8,vp8.0,", kWidevineKeySystem },
{ "audio/webm", "vorbis,", kWidevineKeySystem },
#endif // WIDEVINE_CDM_AVAILABLE
};

static const KeySystemPluginTypePair key_system_to_plugin_type_mapping[] = {
// TODO(xhwang): Update this with the real plugin name.
{ kExternalClearKeyKeySystem, "application/x-ppapi-clearkey-cdm" }
{ kExternalClearKeyKeySystem, "application/x-ppapi-clearkey-cdm" },
#if defined(WIDEVINE_CDM_AVAILABLE)
{ kWidevineKeySystem, kWidevineCdmPluginMimeType }
#endif // WIDEVINE_CDM_AVAILABLE
};

class KeySystems {
Expand Down
4 changes: 4 additions & 0 deletions webkit/media/webkit_media.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
'target_name': 'webkit_media',
'type': 'static_library',
'variables': { 'enable_wexit_time_destructors': 1, },
'include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)', # Needed by key_systems.cc.
],
'dependencies': [
'<(DEPTH)/base/base.gyp:base',
'<(DEPTH)/media/media.gyp:shared_memory_support',
'<(DEPTH)/media/media.gyp:yuv_convert',
'<(DEPTH)/skia/skia.gyp:skia',
'<(DEPTH)/third_party/widevine/cdm/widevine_cdm.gyp:widevine_cdm_version_h',
],
'sources': [
'android/audio_decoder_android.cc',
Expand Down

0 comments on commit a9cde19

Please sign in to comment.