Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: webkit/media/crypto/ppapi_decryptor.cc

Issue 10704241: Add PpapiDecryptor which wraps a CDM plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "webkit/media/crypto/ppapi_decryptor.h"
6
7 #include "base/logging.h"
8 #include "media/base/decoder_buffer.h"
9 #include "media/base/decryptor_client.h"
10 #include "webkit/media/crypto/key_systems.h"
11 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
12
13 namespace webkit_media {
14
15 PpapiDecryptor::PpapiDecryptor(media::DecryptorClient* client,
16 const CreatePluginCB& create_plugin_cb)
17 : client_(client),
18 create_plugin_cb_(create_plugin_cb) {
19 }
20
21 PpapiDecryptor::~PpapiDecryptor() {
22 }
23
24 void PpapiDecryptor::GenerateKeyRequest(const std::string& key_system,
25 const uint8* init_data,
26 int init_data_length) {
27 const char* plugin_name = GetPluginName(key_system);
28 DCHECK(plugin_name);
29
30 cdm_plugin_ = create_plugin_cb_.Run(plugin_name);
ddorwin 2012/07/17 21:31:28 I think we should try to do this at creation time
xhwang 2012/07/18 19:43:17 Moved plugin creation into PpapiDecryptor::Init().
31 // TODO(xhwang): Enable the following once we have updated PluginInstance.
32 //if (!cdm_plugin_ ||
33 // !cdm_plugin_->GenerateKeyRequest(key_system,
xhwang 2012/07/17 00:57:23 This call (and call to AddKey, CancelKeyRequest) a
34 // init_data, init_data_length)) {
35 // client_->KeyError(key_system, "", media::Decryptor::kUnknownError, 0);
36 //}
37 }
38
39 void PpapiDecryptor::AddKey(const std::string& key_system,
40 const uint8* key,
41 int key_length,
42 const uint8* init_data,
43 int init_data_length,
44 const std::string& session_id) {
45 DCHECK(cdm_plugin_);
46 // TODO(xhwang): Enable the following once we have updated PluginInstance.
47 //if (!cdm_plugin_->AddKey(key_system, key, key_length,
48 // init_data, init_data_length, session_id)) {
49 // client_->KeyError(key_system, session_id, Decryptor::kUnknownError, 0);
50 //}
51 }
52
53 void PpapiDecryptor::CancelKeyRequest(const std::string& key_system,
54 const std::string& session_id) {
55 DCHECK(cdm_plugin_);
56 // TODO(xhwang): Enable the following once we have updated PluginInstance.
57 //if (!cdm_plugin_->CancelKeyRequest(key_system, session_id))
58 // client_->KeyError(key_system, session_id, Decryptor::kUnknownError, 0);
59 }
60
61 void PpapiDecryptor::Decrypt(
62 const scoped_refptr<media::DecoderBuffer>& encrypted,
63 const DecryptCB& decrypt_cb) {
64 // TODO(xhwang): Enable the following once we have updated PluginInstance.
65 // TODO(xhwang): Need to figure out thread safety about PPP calls.
xhwang 2012/07/17 00:57:23 I'll need to find a way to post this function to t
66 //if (!cdm_plugin_->Decrypt(
67 // encrypted, base::Bind(&PpapiDecryptor::DataReady, this, decrypt_cb))) {
ddorwin 2012/07/17 21:31:28 indentation?
xhwang 2012/07/18 19:43:17 Done.
68 // decrypt_cb.Run(kError, NULL);
69 //}
70 }
71
72 void PpapiDecryptor::DataReady(const DecryptCB& decrypt_cb,
73 const uint8* data, int data_size ) {
74 // convert to DecoderBuffer or VideoFrame. then fire the callback!
75 DCHECK(!decrypt_cb.is_null());
76 scoped_refptr<media::DecoderBuffer> decrypted =
77 media::DecoderBuffer::CopyFrom(data, data_size);
78 decrypt_cb.Run(kSuccess, decrypted);
79 }
80
81 } // namespace webkit_media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698