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

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: prototype cl of new approach 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/var.h" 18 #include "ppapi/shared_impl/var.h"
20 #include "ppapi/shared_impl/var_tracker.h" 19 #include "ppapi/shared_impl/var_tracker.h"
21 #include "ppapi/thunk/enter.h" 20 #include "ppapi/thunk/enter.h"
22 #include "ppapi/thunk/ppb_buffer_api.h" 21 #include "ppapi/thunk/ppb_buffer_api.h"
23 #include "ui/gfx/rect.h" 22 #include "ui/gfx/rect.h"
24 #include "webkit/plugins/ppapi/ppb_buffer_impl.h" 23 #include "webkit/plugins/ppapi/ppb_buffer_impl.h"
25 24
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 } 267 }
269 } 268 }
270 269
271 } // namespace 270 } // namespace
272 271
273 ContentDecryptorDelegate::ContentDecryptorDelegate( 272 ContentDecryptorDelegate::ContentDecryptorDelegate(
274 PP_Instance pp_instance, 273 PP_Instance pp_instance,
275 const PPP_ContentDecryptor_Private* plugin_decryption_interface) 274 const PPP_ContentDecryptor_Private* plugin_decryption_interface)
276 : pp_instance_(pp_instance), 275 : pp_instance_(pp_instance),
277 plugin_decryption_interface_(plugin_decryption_interface), 276 plugin_decryption_interface_(plugin_decryption_interface),
278 decryptor_client_(NULL),
279 next_decryption_request_id_(1), 277 next_decryption_request_id_(1),
280 pending_audio_decrypt_request_id_(0), 278 pending_audio_decrypt_request_id_(0),
281 pending_video_decrypt_request_id_(0), 279 pending_video_decrypt_request_id_(0),
282 pending_audio_decoder_init_request_id_(0), 280 pending_audio_decoder_init_request_id_(0),
283 pending_video_decoder_init_request_id_(0), 281 pending_video_decoder_init_request_id_(0),
284 pending_audio_decode_request_id_(0), 282 pending_audio_decode_request_id_(0),
285 pending_video_decode_request_id_(0), 283 pending_video_decode_request_id_(0),
286 audio_input_resource_size_(0), 284 audio_input_resource_size_(0),
287 video_input_resource_size_(0), 285 video_input_resource_size_(0),
288 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)), 286 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)),
289 weak_this_(weak_ptr_factory_.GetWeakPtr()) { 287 weak_this_(weak_ptr_factory_.GetWeakPtr()) {
290 } 288 }
291 289
292 void ContentDecryptorDelegate::set_decrypt_client( 290 void ContentDecryptorDelegate::SetKeyEventCallbacks(
293 media::DecryptorClient* decryptor_client) { 291 const media::KeyAddedCB& key_added_cb,
294 decryptor_client_ = decryptor_client; 292 const media::KeyErrorCB& key_error_cb,
293 const media::KeyMessageCB& key_message_cb,
294 const media::NeedKeyCB& need_key_cb) {
295 key_added_cb_ = key_added_cb;
296 key_error_cb_ = key_error_cb;
297 key_message_cb_ = key_message_cb;
298 need_key_cb_ = need_key_cb;
295 } 299 }
296 300
297 bool ContentDecryptorDelegate::GenerateKeyRequest(const std::string& key_system, 301 bool ContentDecryptorDelegate::GenerateKeyRequest(const std::string& key_system,
298 const std::string& type, 302 const std::string& type,
299 const uint8* init_data, 303 const uint8* init_data,
300 int init_data_length) { 304 int init_data_length) {
301 if (key_system.empty()) 305 if (key_system.empty())
302 return false; 306 return false;
303 307
304 PP_Var init_data_array = 308 PP_Var init_data_array =
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 } 623 }
620 624
621 void ContentDecryptorDelegate::NeedKey(PP_Var key_system_var, 625 void ContentDecryptorDelegate::NeedKey(PP_Var key_system_var,
622 PP_Var session_id_var, 626 PP_Var session_id_var,
623 PP_Var init_data_var) { 627 PP_Var init_data_var) {
624 // TODO(tomfinegan): send the data to media stack. 628 // TODO(tomfinegan): send the data to media stack.
625 } 629 }
626 630
627 void ContentDecryptorDelegate::KeyAdded(PP_Var key_system_var, 631 void ContentDecryptorDelegate::KeyAdded(PP_Var key_system_var,
628 PP_Var session_id_var) { 632 PP_Var session_id_var) {
629 if (!decryptor_client_) 633 if (key_added_cb_.is_null())
630 return; 634 return;
631 635
632 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); 636 StringVar* key_system_string = StringVar::FromPPVar(key_system_var);
633 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); 637 StringVar* session_id_string = StringVar::FromPPVar(session_id_var);
634 if (!key_system_string || !session_id_string) { 638 if (!key_system_string || !session_id_string) {
635 decryptor_client_->KeyError("", "", media::Decryptor::kUnknownError, 0); 639 key_error_cb_.Run("", "", media::Decryptor::kUnknownError, 0);
636 return; 640 return;
637 } 641 }
638 642
639 decryptor_client_->KeyAdded(key_system_string->value(), 643 key_added_cb_.Run(key_system_string->value(), session_id_string->value());
640 session_id_string->value());
641 } 644 }
642 645
643 void ContentDecryptorDelegate::KeyMessage(PP_Var key_system_var, 646 void ContentDecryptorDelegate::KeyMessage(PP_Var key_system_var,
644 PP_Var session_id_var, 647 PP_Var session_id_var,
645 PP_Var message_var, 648 PP_Var message_var,
646 PP_Var default_url_var) { 649 PP_Var default_url_var) {
647 if (!decryptor_client_) 650 if (key_message_cb_.is_null())
648 return; 651 return;
649 652
650 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); 653 StringVar* key_system_string = StringVar::FromPPVar(key_system_var);
651 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); 654 StringVar* session_id_string = StringVar::FromPPVar(session_id_var);
652 655
653 ArrayBufferVar* message_array_buffer = 656 ArrayBufferVar* message_array_buffer =
654 ArrayBufferVar::FromPPVar(message_var); 657 ArrayBufferVar::FromPPVar(message_var);
655 658
656 std::string message; 659 std::string message;
657 if (message_array_buffer) { 660 if (message_array_buffer) {
658 const char* data = static_cast<const char*>(message_array_buffer->Map()); 661 const char* data = static_cast<const char*>(message_array_buffer->Map());
659 message.assign(data, message_array_buffer->ByteLength()); 662 message.assign(data, message_array_buffer->ByteLength());
660 } 663 }
661 664
662 StringVar* default_url_string = StringVar::FromPPVar(default_url_var); 665 StringVar* default_url_string = StringVar::FromPPVar(default_url_var);
663 666
664 if (!key_system_string || !session_id_string || !default_url_string) { 667 if (!key_system_string || !session_id_string || !default_url_string) {
665 decryptor_client_->KeyError("", "", media::Decryptor::kUnknownError, 0); 668 key_error_cb_.Run("", "", media::Decryptor::kUnknownError, 0);
666 return; 669 return;
667 } 670 }
668 671
669 decryptor_client_->KeyMessage(key_system_string->value(), 672 key_message_cb_.Run(key_system_string->value(),
670 session_id_string->value(), 673 session_id_string->value(),
671 message, 674 message,
672 default_url_string->value()); 675 default_url_string->value());
673 } 676 }
674 677
675 void ContentDecryptorDelegate::KeyError(PP_Var key_system_var, 678 void ContentDecryptorDelegate::KeyError(PP_Var key_system_var,
676 PP_Var session_id_var, 679 PP_Var session_id_var,
677 int32_t media_error, 680 int32_t media_error,
678 int32_t system_code) { 681 int32_t system_code) {
679 if (!decryptor_client_) 682 if (key_error_cb_.is_null())
680 return; 683 return;
681 684
682 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); 685 StringVar* key_system_string = StringVar::FromPPVar(key_system_var);
683 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); 686 StringVar* session_id_string = StringVar::FromPPVar(session_id_var);
684 if (!key_system_string || !session_id_string) { 687 if (!key_system_string || !session_id_string) {
685 decryptor_client_->KeyError("", "", media::Decryptor::kUnknownError, 0); 688 key_error_cb_.Run("", "", media::Decryptor::kUnknownError, 0);
686 return; 689 return;
687 } 690 }
688 691
689 decryptor_client_->KeyError( 692 key_error_cb_.Run(
690 key_system_string->value(), 693 key_system_string->value(),
691 session_id_string->value(), 694 session_id_string->value(),
692 static_cast<media::Decryptor::KeyError>(media_error), 695 static_cast<media::Decryptor::KeyError>(media_error),
693 system_code); 696 system_code);
694 } 697 }
695 698
696 void ContentDecryptorDelegate::DecoderInitializeDone( 699 void ContentDecryptorDelegate::DecoderInitializeDone(
697 PP_DecryptorStreamType decoder_type, 700 PP_DecryptorStreamType decoder_type,
698 uint32_t request_id, 701 uint32_t request_id,
699 PP_Bool success) { 702 PP_Bool success) {
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 1036
1034 if (free_buffers_.empty()) 1037 if (free_buffers_.empty())
1035 return; 1038 return;
1036 1039
1037 tracking_info->buffer_id = free_buffers_.front(); 1040 tracking_info->buffer_id = free_buffers_.front();
1038 free_buffers_.pop(); 1041 free_buffers_.pop();
1039 } 1042 }
1040 1043
1041 } // namespace ppapi 1044 } // namespace ppapi
1042 } // namespace webkit 1045 } // namespace webkit
OLDNEW
« media/base/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