Skip to content

Commit

Permalink
Register WideVine keysystem for WebView.
Browse files Browse the repository at this point in the history
BUG=322395

Change-Id: I7b4a52824c0b82b3cf9d1e6b6d133bb741d0d96a

Review URL: https://codereview.chromium.org/82803002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237572 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
ycheo@chromium.org committed Nov 27, 2013
1 parent 2b7a0e9 commit 6853d16
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 0 deletions.
2 changes: 2 additions & 0 deletions android_webview/android_webview.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@
'public/browser/draw_gl.h',
'renderer/aw_content_renderer_client.cc',
'renderer/aw_content_renderer_client.h',
'renderer/aw_key_systems.cc',
'renderer/aw_key_systems.h',
'renderer/aw_render_process_observer.cc',
'renderer/aw_render_process_observer.h',
'renderer/aw_render_view_ext.cc',
Expand Down
2 changes: 2 additions & 0 deletions android_webview/renderer/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ include_rules = [
"+third_party/WebKit/public/platform",
"+third_party/WebKit/public/web",

"+third_party/widevine/cdm/widevine_cdm_common.h",

"+ui/gfx/size.h",
"+ui/gl/gpu_memory_buffer.h",
]
6 changes: 6 additions & 0 deletions android_webview/renderer/aw_content_renderer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "android_webview/common/aw_resource.h"
#include "android_webview/common/url_constants.h"
#include "android_webview/renderer/aw_key_systems.h"
#include "android_webview/renderer/aw_render_view_ext.h"
#include "base/message_loop/message_loop.h"
#include "base/strings/utf_string_conversions.h"
Expand Down Expand Up @@ -107,4 +108,9 @@ bool AwContentRendererClient::IsLinkVisited(unsigned long long link_hash) {
return visited_link_slave_->IsVisited(link_hash);
}

void AwContentRendererClient::AddKeySystems(
std::vector<content::KeySystemInfo>* key_systems) {
AwAddKeySystems(key_systems);
}

} // namespace android_webview
2 changes: 2 additions & 0 deletions android_webview/renderer/aw_content_renderer_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class AwContentRendererClient : public content::ContentRendererClient {
virtual unsigned long long VisitedLinkHash(const char* canonical_url,
size_t length) OVERRIDE;
virtual bool IsLinkVisited(unsigned long long link_hash) OVERRIDE;
virtual void AddKeySystems(
std::vector<content::KeySystemInfo>* key_systems) OVERRIDE;

private:
scoped_ptr<AwRenderProcessObserver> aw_render_process_observer_;
Expand Down
60 changes: 60 additions & 0 deletions android_webview/renderer/aw_key_systems.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright 2013 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 "android_webview/renderer/aw_key_systems.h"

#include <string>

#include "base/command_line.h"
#include "base/logging.h"
#include "base/strings/string_split.h"
#include "third_party/widevine/cdm/widevine_cdm_common.h"

using content::KeySystemInfo;

namespace {

const char kAudioMp4[] = "audio/mp4";
const char kVideoMp4[] = "video/mp4";
const char kMp4a[] = "mp4a";
const char kMp4aAvc1Avc3[] = "mp4a,avc1,avc3";

const uint8 kWidevineUuid[16] = {
0xED, 0xEF, 0x8B, 0xA9, 0x79, 0xD6, 0x4A, 0xCE,
0xA3, 0xC8, 0x27, 0xDC, 0xD5, 0x1D, 0x21, 0xED };

// Return |name|'s parent key system.
std::string GetDirectParentName(const std::string& name) {
int last_period = name.find_last_of('.');
DCHECK_GT(last_period, 0);
return name.substr(0, last_period);
}

void AddWidevineWithCodecs(
const std::string& key_system_name,
bool add_parent_name,
std::vector<KeySystemInfo>* concrete_key_systems) {
KeySystemInfo info(key_system_name);

if (add_parent_name)
info.parent_key_system = GetDirectParentName(key_system_name);

info.supported_types.push_back(std::make_pair(kAudioMp4, kMp4a));
info.supported_types.push_back(std::make_pair(kVideoMp4, kMp4aAvc1Avc3));

info.uuid.assign(kWidevineUuid, kWidevineUuid + arraysize(kWidevineUuid));

concrete_key_systems->push_back(info);
}

} // namespace

namespace android_webview {

void AwAddKeySystems(
std::vector<KeySystemInfo>* key_systems_info) {
AddWidevineWithCodecs(kWidevineKeySystem, true, key_systems_info);
}

} // namespace android_webview
16 changes: 16 additions & 0 deletions android_webview/renderer/aw_key_systems.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2013 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 ANDROID_WEBVIEW_RENDERER_AW_KEY_SYSTEMS_H_
#define ANDROID_WEBVIEW_RENDERER_AW_KEY_SYSTEMS_H_

#include "content/public/renderer/key_system_info.h"

namespace android_webview {

void AwAddKeySystems(std::vector<content::KeySystemInfo>* key_systems_info);

} // namespace android_webview

#endif // ANDROID_WEBVIEW_RENDERER_AW_KEY_SYSTEMS_H_

0 comments on commit 6853d16

Please sign in to comment.