summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjrummell <jrummell@chromium.org>2015-04-03 17:52:42 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-04 00:53:20 +0000
commit534d59853e0803ee61e6c8a6a4ceacac44df6843 (patch)
treee513037a8b2a8925b645d48414adc0636693518a
parentcd408039e5f0c342c6568ccb79848c789664c22b (diff)
downloadchromium_src-534d59853e0803ee61e6c8a6a4ceacac44df6843.zip
chromium_src-534d59853e0803ee61e6c8a6a4ceacac44df6843.tar.gz
chromium_src-534d59853e0803ee61e6c8a6a4ceacac44df6843.tar.bz2
Allow widevinecdmadapter to be built in Chromium
Adds a stub CDM that is used to link widevinecdmadapter when enable_widevine=1. BUG=468567 TEST=Widevine EME browser tests run in Chromium with enable_widevine=1 Review URL: https://codereview.chromium.org/1043673002 Cr-Commit-Position: refs/heads/master@{#323862}
-rw-r--r--media/cdm/stub/stub_cdm.cc162
-rw-r--r--media/cdm/stub/stub_cdm.h80
-rw-r--r--third_party/widevine/cdm/stub/widevine_cdm_version.h15
-rw-r--r--third_party/widevine/cdm/widevine_cdm.gyp74
4 files changed, 315 insertions, 16 deletions
diff --git a/media/cdm/stub/stub_cdm.cc b/media/cdm/stub/stub_cdm.cc
new file mode 100644
index 0000000..0bfa25e
--- /dev/null
+++ b/media/cdm/stub/stub_cdm.cc
@@ -0,0 +1,162 @@
+// Copyright 2015 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/stub/stub_cdm.h"
+
+#include "base/logging.h"
+#include "base/strings/string_number_conversions.h"
+
+// Version number for this stub. The third number represents the
+// cdm::ContentDecryptionModule version.
+const char kStubCdmVersion[] = "1.4.8.0";
+
+void INITIALIZE_CDM_MODULE() {
+}
+
+void DeinitializeCdmModule() {
+}
+
+void* CreateCdmInstance(int cdm_interface_version,
+ const char* /* key_system */,
+ uint32_t /* key_system_size */,
+ GetCdmHostFunc get_cdm_host_func,
+ void* user_data) {
+ DVLOG(1) << "CreateCdmInstance()";
+
+ if (cdm_interface_version != media::StubCdmInterface::kVersion)
+ return nullptr;
+
+ media::StubCdmInterface::Host* host =
+ static_cast<media::StubCdmInterface::Host*>(get_cdm_host_func(
+ media::StubCdmInterface::Host::kVersion, user_data));
+ if (!host)
+ return nullptr;
+
+ return new media::StubCdm(host);
+}
+
+const char* GetCdmVersion() {
+ return kStubCdmVersion;
+}
+
+namespace media {
+
+StubCdm::StubCdm(Host* host) : host_(host), next_session_id_(0) {
+}
+
+StubCdm::~StubCdm() {
+}
+
+void StubCdm::Initialize(bool /* allow_distinctive_identifier */,
+ bool /* allow_persistent_state */) {
+}
+
+void StubCdm::CreateSessionAndGenerateRequest(
+ uint32 promise_id,
+ cdm::SessionType /* session_type */,
+ cdm::InitDataType /* init_data_type */,
+ const uint8* /* init_data */,
+ uint32 /* init_data_size */) {
+ // Provide a dummy message (with a trivial session ID) to enable some testing
+ // and be consistent with existing testing without a license server.
+ std::string session_id(base::UintToString(next_session_id_++));
+ host_->OnResolveNewSessionPromise(promise_id, session_id.data(),
+ session_id.length());
+ host_->OnSessionMessage(session_id.data(), session_id.length(),
+ cdm::kLicenseRequest, nullptr, 0, nullptr, 0);
+}
+
+void StubCdm::LoadSession(uint32 promise_id,
+ cdm::SessionType /* session_type */,
+ const char* /* session_id */,
+ uint32_t /* session_id_length */) {
+ FailRequest(promise_id);
+}
+
+void StubCdm::UpdateSession(uint32 promise_id,
+ const char* /* session_id */,
+ uint32_t /* session_id_length */,
+ const uint8* /* response */,
+ uint32 /* response_size */) {
+ FailRequest(promise_id);
+}
+
+void StubCdm::CloseSession(uint32 promise_id,
+ const char* /* session_id */,
+ uint32_t /* session_id_length */) {
+ FailRequest(promise_id);
+}
+
+void StubCdm::RemoveSession(uint32 promise_id,
+ const char* /* session_id */,
+ uint32_t /* session_id_length */) {
+ FailRequest(promise_id);
+}
+
+void StubCdm::SetServerCertificate(
+ uint32 promise_id,
+ const uint8_t* /* server_certificate_data */,
+ uint32_t /* server_certificate_data_size */) {
+ FailRequest(promise_id);
+}
+
+void StubCdm::TimerExpired(void* /* context */) {
+}
+
+cdm::Status StubCdm::Decrypt(const cdm::InputBuffer& /* encrypted_buffer */,
+ cdm::DecryptedBlock* /* decrypted_block */) {
+ return cdm::kDecryptError;
+}
+
+cdm::Status StubCdm::InitializeAudioDecoder(
+ const cdm::AudioDecoderConfig& /* audio_decoder_config */) {
+ return cdm::kDecryptError;
+}
+
+cdm::Status StubCdm::InitializeVideoDecoder(
+ const cdm::VideoDecoderConfig& /* video_decoder_config */) {
+ return cdm::kDecryptError;
+}
+
+void StubCdm::ResetDecoder(cdm::StreamType /* decoder_type */) {
+}
+
+void StubCdm::DeinitializeDecoder(cdm::StreamType /* decoder_type */) {
+}
+
+cdm::Status StubCdm::DecryptAndDecodeFrame(
+ const cdm::InputBuffer& /* encrypted_buffer */,
+ cdm::VideoFrame* /* decoded_frame */) {
+ return cdm::kDecryptError;
+}
+
+cdm::Status StubCdm::DecryptAndDecodeSamples(
+ const cdm::InputBuffer& /* encrypted_buffer */,
+ cdm::AudioFrames* /* audio_frames */) {
+ return cdm::kDecryptError;
+}
+
+void StubCdm::Destroy() {
+ delete this;
+}
+
+void StubCdm::OnPlatformChallengeResponse(
+ const cdm::PlatformChallengeResponse& /* response */) {
+ NOTREACHED();
+}
+
+void StubCdm::OnQueryOutputProtectionStatus(
+ cdm::QueryResult /* result */,
+ uint32_t /* link_mask */,
+ uint32_t /* output_protection_mask */) {
+ NOTREACHED();
+};
+
+void StubCdm::FailRequest(uint32 promise_id) {
+ std::string message("Operation not supported by stub CDM.");
+ host_->OnRejectPromise(promise_id, cdm::kInvalidAccessError, 0,
+ message.data(), message.length());
+}
+
+} // namespace media
diff --git a/media/cdm/stub/stub_cdm.h b/media/cdm/stub/stub_cdm.h
new file mode 100644
index 0000000..fc4d040
--- /dev/null
+++ b/media/cdm/stub/stub_cdm.h
@@ -0,0 +1,80 @@
+// Copyright 2015 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 MEDIA_CDM_STUB_STUB_CDM_H_
+#define MEDIA_CDM_STUB_STUB_CDM_H_
+
+#include "base/basictypes.h"
+#include "media/cdm/ppapi/api/content_decryption_module.h"
+
+namespace media {
+
+typedef cdm::ContentDecryptionModule_8 StubCdmInterface;
+
+// Dummy implementation of the cdm::ContentDecryptionModule interface.
+class StubCdm : public StubCdmInterface {
+ public:
+ explicit StubCdm(Host* host);
+ ~StubCdm() override;
+
+ // StubCdmInterface implementation.
+ void Initialize(bool allow_distinctive_identifier,
+ bool allow_persistent_state) override;
+ void CreateSessionAndGenerateRequest(uint32 promise_id,
+ cdm::SessionType session_type,
+ cdm::InitDataType init_data_type,
+ const uint8* init_data,
+ uint32 init_data_size) override;
+ void LoadSession(uint32 promise_id,
+ cdm::SessionType session_type,
+ const char* session_id,
+ uint32_t session_id_length) override;
+ void UpdateSession(uint32 promise_id,
+ const char* session_id,
+ uint32_t session_id_length,
+ const uint8* response,
+ uint32 response_size) override;
+ void CloseSession(uint32 promise_id,
+ const char* session_id,
+ uint32_t session_id_length) override;
+ void RemoveSession(uint32 promise_id,
+ const char* session_id,
+ uint32_t session_id_length) override;
+ void SetServerCertificate(uint32 promise_id,
+ const uint8_t* server_certificate_data,
+ uint32_t server_certificate_data_size) override;
+ void TimerExpired(void* context) override;
+ cdm::Status Decrypt(const cdm::InputBuffer& encrypted_buffer,
+ cdm::DecryptedBlock* decrypted_block) override;
+ cdm::Status InitializeAudioDecoder(
+ const cdm::AudioDecoderConfig& audio_decoder_config) override;
+ cdm::Status InitializeVideoDecoder(
+ const cdm::VideoDecoderConfig& video_decoder_config) override;
+ void DeinitializeDecoder(cdm::StreamType decoder_type) override;
+ void ResetDecoder(cdm::StreamType decoder_type) override;
+ cdm::Status DecryptAndDecodeFrame(const cdm::InputBuffer& encrypted_buffer,
+ cdm::VideoFrame* video_frame) override;
+ cdm::Status DecryptAndDecodeSamples(const cdm::InputBuffer& encrypted_buffer,
+ cdm::AudioFrames* audio_frames) override;
+ void Destroy() override;
+ void OnPlatformChallengeResponse(
+ const cdm::PlatformChallengeResponse& response) override;
+ void OnQueryOutputProtectionStatus(cdm::QueryResult result,
+ uint32_t link_mask,
+ uint32_t output_protection_mask) override;
+
+ private:
+ // Helper function that rejects the promise specified by |promise_id|.
+ void FailRequest(uint32 promise_id);
+
+ Host* host_;
+
+ uint32 next_session_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(StubCdm);
+};
+
+} // namespace media
+
+#endif // MEDIA_CDM_STUB_STUB_CDM_H_
diff --git a/third_party/widevine/cdm/stub/widevine_cdm_version.h b/third_party/widevine/cdm/stub/widevine_cdm_version.h
new file mode 100644
index 0000000..659683b
--- /dev/null
+++ b/third_party/widevine/cdm/stub/widevine_cdm_version.h
@@ -0,0 +1,15 @@
+// Copyright (c) 2015 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.
+
+// This is a stand-in for a generated file that is available when the
+// Widevine CDM is available.
+
+#ifndef WIDEVINE_CDM_VERSION_H_
+#define WIDEVINE_CDM_VERSION_H_
+
+#include "third_party/widevine/cdm/widevine_cdm_common.h"
+
+#define WIDEVINE_CDM_AVAILABLE
+
+#endif // WIDEVINE_CDM_VERSION_H_
diff --git a/third_party/widevine/cdm/widevine_cdm.gyp b/third_party/widevine/cdm/widevine_cdm.gyp
index eacbdb3..7161160 100644
--- a/third_party/widevine/cdm/widevine_cdm.gyp
+++ b/third_party/widevine/cdm/widevine_cdm.gyp
@@ -4,6 +4,11 @@
{
'variables': {
+ # Allow widevinecdmadapter to be built in Chromium.
+ 'variables': {
+ 'enable_widevine%': 0,
+ },
+ 'enable_widevine%': '<(enable_widevine)',
'widevine_cdm_version_h_file%': 'widevine_cdm_version.h',
'widevine_cdm_binary_files%': [],
'conditions': [
@@ -44,6 +49,13 @@
'widevine_cdm_version_h_file%':
'android/widevine_cdm_version.h',
}],
+ [ 'branding != "Chrome" and OS != "android" and enable_widevine == 1', {
+ # If enable_widevine==1 then create a dummy widevinecdm. On Win/Mac
+ # the component updater will get the latest version and use it.
+ # Other systems are not currently supported.
+ 'widevine_cdm_version_h_file%':
+ 'stub/widevine_cdm_version.h',
+ }],
],
},
'includes': [
@@ -86,12 +98,12 @@
'target_name': 'widevinecdmadapter',
'type': 'none',
'conditions': [
- [ 'branding == "Chrome" and enable_pepper_cdms==1', {
+ [ '(branding == "Chrome" or enable_widevine == 1) and enable_pepper_cdms == 1', {
'dependencies': [
'<(DEPTH)/ppapi/ppapi.gyp:ppapi_cpp',
'<(DEPTH)/media/media_cdm_adapter.gyp:cdmadapter',
'widevine_cdm_version_h',
- 'widevine_cdm_binaries',
+ 'widevinecdm',
'widevinecdmadapter_resources',
],
'sources': [
@@ -101,19 +113,19 @@
[ 'os_posix == 1 and OS != "mac"', {
'libraries': [
'-lrt',
- # Copied by widevine_cdm_binaries.
+ # Copied/created by widevinecdm.
'<(PRODUCT_DIR)/libwidevinecdm.so',
],
}],
[ 'OS == "win"', {
'libraries': [
- # Copied by widevine_cdm_binaries.
+ # Copied/created by widevinecdm.
'<(PRODUCT_DIR)/widevinecdm.dll.lib',
],
}],
[ 'OS == "mac"', {
'libraries': [
- # Copied by widevine_cdm_binaries.
+ # Copied/created by widevinecdm.
'<(PRODUCT_DIR)/libwidevinecdm.dylib',
],
}],
@@ -132,21 +144,51 @@
},
{
# GN version: //third_party/widevine/cdm:binaries
- 'target_name': 'widevine_cdm_binaries',
+ 'target_name': 'widevinecdm',
'type': 'none',
'conditions': [
- [ 'OS=="mac"', {
- 'xcode_settings': {
- 'COPY_PHASE_STRIP': 'NO',
- }
+ [ 'branding == "Chrome"', {
+ 'conditions': [
+ [ 'OS=="mac"', {
+ 'xcode_settings': {
+ 'COPY_PHASE_STRIP': 'NO',
+ }
+ }],
+ ],
+ 'copies': [{
+ # TODO(ddorwin): Do we need a sub-directory? We either need a
+ # sub-directory or to rename manifest.json before we can copy it.
+ 'destination': '<(PRODUCT_DIR)',
+ 'files': [ '<@(widevine_cdm_binary_files)' ],
+ }],
+ }],
+ [ 'branding != "Chrome" and enable_widevine == 1', {
+ 'conditions': [
+ ['os_posix == 1 and OS != "mac"', {
+ 'type': 'loadable_module',
+ # Note that this causes the binary to be put in PRODUCT_DIR
+ # instead of lib/. This matches what happens in the copy step
+ # above.
+ }],
+ ['OS == "mac" or OS == "win"', {
+ 'type': 'shared_library',
+ }],
+ ['OS == "mac"', {
+ 'xcode_settings': {
+ 'DYLIB_INSTALL_NAME_BASE': '@loader_path',
+ },
+ }],
+ ],
+ 'defines': ['CDM_IMPLEMENTATION'],
+ 'dependencies': [
+ '<(DEPTH)/base/base.gyp:base',
+ ],
+ 'sources': [
+ '<(DEPTH)/media/cdm/stub/stub_cdm.cc',
+ '<(DEPTH)/media/cdm/stub/stub_cdm.h',
+ ],
}],
],
- 'copies': [{
- # TODO(ddorwin): Do we need a sub-directory? We either need a
- # sub-directory or to rename manifest.json before we can copy it.
- 'destination': '<(PRODUCT_DIR)',
- 'files': [ '<@(widevine_cdm_binary_files)' ],
- }],
},
{
'target_name': 'widevine_test_license_server',