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

Side by Side Diff: webkit/plugins/ppapi/content_decryptor_delegate.cc

Issue 11226019: Encrypted Media: Replace DecryptorClient with key event callbacks. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: add spec link Created 8 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/plugins/ppapi/content_decryptor_delegate.h" 5 #include "webkit/plugins/ppapi/content_decryptor_delegate.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "media/base/audio_decoder_config.h" 10 #include "media/base/audio_decoder_config.h"
11 #include "media/base/bind_to_loop.h" 11 #include "media/base/bind_to_loop.h"
12 #include "media/base/channel_layout.h" 12 #include "media/base/channel_layout.h"
13 #include "media/base/data_buffer.h" 13 #include "media/base/data_buffer.h"
14 #include "media/base/decoder_buffer.h" 14 #include "media/base/decoder_buffer.h"
15 #include "media/base/decryptor_client.h"
16 #include "media/base/video_decoder_config.h" 15 #include "media/base/video_decoder_config.h"
17 #include "media/base/video_frame.h" 16 #include "media/base/video_frame.h"
18 #include "media/base/video_util.h" 17 #include "media/base/video_util.h"
19 #include "ppapi/shared_impl/scoped_pp_resource.h" 18 #include "ppapi/shared_impl/scoped_pp_resource.h"
20 #include "ppapi/shared_impl/var.h" 19 #include "ppapi/shared_impl/var.h"
21 #include "ppapi/shared_impl/var_tracker.h" 20 #include "ppapi/shared_impl/var_tracker.h"
22 #include "ppapi/thunk/enter.h" 21 #include "ppapi/thunk/enter.h"
23 #include "ppapi/thunk/ppb_buffer_api.h" 22 #include "ppapi/thunk/ppb_buffer_api.h"
24 #include "ui/gfx/rect.h" 23 #include "ui/gfx/rect.h"
25 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" 24 #include "webkit/plugins/ppapi/ppb_buffer_impl.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 } 264 }
266 } 265 }
267 266
268 } // namespace 267 } // namespace
269 268
270 ContentDecryptorDelegate::ContentDecryptorDelegate( 269 ContentDecryptorDelegate::ContentDecryptorDelegate(
271 PP_Instance pp_instance, 270 PP_Instance pp_instance,
272 const PPP_ContentDecryptor_Private* plugin_decryption_interface) 271 const PPP_ContentDecryptor_Private* plugin_decryption_interface)
273 : pp_instance_(pp_instance), 272 : pp_instance_(pp_instance),
274 plugin_decryption_interface_(plugin_decryption_interface), 273 plugin_decryption_interface_(plugin_decryption_interface),
275 decryptor_client_(NULL),
276 next_decryption_request_id_(1), 274 next_decryption_request_id_(1),
277 pending_audio_decrypt_request_id_(0), 275 pending_audio_decrypt_request_id_(0),
278 pending_video_decrypt_request_id_(0), 276 pending_video_decrypt_request_id_(0),
279 pending_audio_decoder_init_request_id_(0), 277 pending_audio_decoder_init_request_id_(0),
280 pending_video_decoder_init_request_id_(0), 278 pending_video_decoder_init_request_id_(0),
281 pending_audio_decode_request_id_(0), 279 pending_audio_decode_request_id_(0),
282 pending_video_decode_request_id_(0), 280 pending_video_decode_request_id_(0),
283 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), 281 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)),
284 weak_this_(weak_ptr_factory_.GetWeakPtr()) { 282 weak_this_(weak_ptr_factory_.GetWeakPtr()) {
285 } 283 }
286 284
287 void ContentDecryptorDelegate::set_decrypt_client( 285 void ContentDecryptorDelegate::SetKeyEventCallbacks(
288 media::DecryptorClient* decryptor_client) { 286 const media::KeyAddedCB& key_added_cb,
289 decryptor_client_ = decryptor_client; 287 const media::KeyErrorCB& key_error_cb,
288 const media::KeyMessageCB& key_message_cb,
289 const media::NeedKeyCB& need_key_cb) {
290 key_added_cb_ = key_added_cb;
291 key_error_cb_ = key_error_cb;
292 key_message_cb_ = key_message_cb;
293 need_key_cb_ = need_key_cb;
290 } 294 }
291 295
292 bool ContentDecryptorDelegate::GenerateKeyRequest(const std::string& key_system, 296 bool ContentDecryptorDelegate::GenerateKeyRequest(const std::string& key_system,
293 const std::string& type, 297 const std::string& type,
294 const uint8* init_data, 298 const uint8* init_data,
295 int init_data_length) { 299 int init_data_length) {
296 if (key_system.empty()) 300 if (key_system.empty())
297 return false; 301 return false;
298 302
299 PP_Var init_data_array = 303 PP_Var init_data_array =
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 } 626 }
623 627
624 void ContentDecryptorDelegate::NeedKey(PP_Var key_system_var, 628 void ContentDecryptorDelegate::NeedKey(PP_Var key_system_var,
625 PP_Var session_id_var, 629 PP_Var session_id_var,
626 PP_Var init_data_var) { 630 PP_Var init_data_var) {
627 // TODO(tomfinegan): send the data to media stack. 631 // TODO(tomfinegan): send the data to media stack.
628 } 632 }
629 633
630 void ContentDecryptorDelegate::KeyAdded(PP_Var key_system_var, 634 void ContentDecryptorDelegate::KeyAdded(PP_Var key_system_var,
631 PP_Var session_id_var) { 635 PP_Var session_id_var) {
632 if (!decryptor_client_) 636 if (key_added_cb_.is_null())
ddorwin 2012/12/21 04:19:06 In what scenarios can this occur? Should there be
xhwang 2012/12/21 05:50:07 hmm, I guess this comes from my paranoid about not
633 return; 637 return;
634 638
635 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); 639 StringVar* key_system_string = StringVar::FromPPVar(key_system_var);
636 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); 640 StringVar* session_id_string = StringVar::FromPPVar(session_id_var);
637 if (!key_system_string || !session_id_string) { 641 if (!key_system_string || !session_id_string) {
638 decryptor_client_->KeyError("", "", media::Decryptor::kUnknownError, 0); 642 key_error_cb_.Run("", "", media::Decryptor::kUnknownError, 0);
639 return; 643 return;
640 } 644 }
641 645
642 decryptor_client_->KeyAdded(key_system_string->value(), 646 key_added_cb_.Run(key_system_string->value(), session_id_string->value());
643 session_id_string->value());
644 } 647 }
645 648
646 void ContentDecryptorDelegate::KeyMessage(PP_Var key_system_var, 649 void ContentDecryptorDelegate::KeyMessage(PP_Var key_system_var,
647 PP_Var session_id_var, 650 PP_Var session_id_var,
648 PP_Var message_var, 651 PP_Var message_var,
649 PP_Var default_url_var) { 652 PP_Var default_url_var) {
650 if (!decryptor_client_) 653 if (key_message_cb_.is_null())
651 return; 654 return;
652 655
653 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); 656 StringVar* key_system_string = StringVar::FromPPVar(key_system_var);
654 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); 657 StringVar* session_id_string = StringVar::FromPPVar(session_id_var);
655 658
656 ArrayBufferVar* message_array_buffer = 659 ArrayBufferVar* message_array_buffer =
657 ArrayBufferVar::FromPPVar(message_var); 660 ArrayBufferVar::FromPPVar(message_var);
658 661
659 std::string message; 662 std::string message;
660 if (message_array_buffer) { 663 if (message_array_buffer) {
661 const char* data = static_cast<const char*>(message_array_buffer->Map()); 664 const char* data = static_cast<const char*>(message_array_buffer->Map());
662 message.assign(data, message_array_buffer->ByteLength()); 665 message.assign(data, message_array_buffer->ByteLength());
663 } 666 }
664 667
665 StringVar* default_url_string = StringVar::FromPPVar(default_url_var); 668 StringVar* default_url_string = StringVar::FromPPVar(default_url_var);
666 669
667 if (!key_system_string || !session_id_string || !default_url_string) { 670 if (!key_system_string || !session_id_string || !default_url_string) {
668 decryptor_client_->KeyError("", "", media::Decryptor::kUnknownError, 0); 671 key_error_cb_.Run("", "", media::Decryptor::kUnknownError, 0);
669 return; 672 return;
670 } 673 }
671 674
672 decryptor_client_->KeyMessage(key_system_string->value(), 675 key_message_cb_.Run(key_system_string->value(),
673 session_id_string->value(), 676 session_id_string->value(),
674 message, 677 message,
675 default_url_string->value()); 678 default_url_string->value());
676 } 679 }
677 680
678 void ContentDecryptorDelegate::KeyError(PP_Var key_system_var, 681 void ContentDecryptorDelegate::KeyError(PP_Var key_system_var,
679 PP_Var session_id_var, 682 PP_Var session_id_var,
680 int32_t media_error, 683 int32_t media_error,
681 int32_t system_code) { 684 int32_t system_code) {
682 if (!decryptor_client_) 685 if (key_error_cb_.is_null())
683 return; 686 return;
684 687
685 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); 688 StringVar* key_system_string = StringVar::FromPPVar(key_system_var);
686 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); 689 StringVar* session_id_string = StringVar::FromPPVar(session_id_var);
687 if (!key_system_string || !session_id_string) { 690 if (!key_system_string || !session_id_string) {
688 decryptor_client_->KeyError("", "", media::Decryptor::kUnknownError, 0); 691 key_error_cb_.Run("", "", media::Decryptor::kUnknownError, 0);
689 return; 692 return;
690 } 693 }
691 694
692 decryptor_client_->KeyError( 695 key_error_cb_.Run(
693 key_system_string->value(), 696 key_system_string->value(),
694 session_id_string->value(), 697 session_id_string->value(),
695 static_cast<media::Decryptor::KeyError>(media_error), 698 static_cast<media::Decryptor::KeyError>(media_error),
696 system_code); 699 system_code);
697 } 700 }
698 701
699 void ContentDecryptorDelegate::DecoderInitializeDone( 702 void ContentDecryptorDelegate::DecoderInitializeDone(
700 PP_DecryptorStreamType decoder_type, 703 PP_DecryptorStreamType decoder_type,
701 uint32_t request_id, 704 uint32_t request_id,
702 PP_Bool success) { 705 PP_Bool success) {
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 1026
1024 if (free_buffers_.empty()) 1027 if (free_buffers_.empty())
1025 return; 1028 return;
1026 1029
1027 tracking_info->buffer_id = free_buffers_.front(); 1030 tracking_info->buffer_id = free_buffers_.front();
1028 free_buffers_.pop(); 1031 free_buffers_.pop();
1029 } 1032 }
1030 1033
1031 } // namespace ppapi 1034 } // namespace ppapi
1032 } // namespace webkit 1035 } // namespace webkit
OLDNEW
« webkit/media/crypto/proxy_decryptor.h ('K') | « webkit/plugins/ppapi/content_decryptor_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698