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

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

Issue 17289006: Separate CDM initialization from GenerateKeyRequest & remove key_system parameters. (Closed) Base URL: master
Patch Set: remove from proxy calls Created 7 years, 6 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
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/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "media/base/audio_decoder_config.h" 10 #include "media/base/audio_decoder_config.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 pending_audio_decrypt_request_id_(0), 278 pending_audio_decrypt_request_id_(0),
279 pending_video_decrypt_request_id_(0), 279 pending_video_decrypt_request_id_(0),
280 pending_audio_decoder_init_request_id_(0), 280 pending_audio_decoder_init_request_id_(0),
281 pending_video_decoder_init_request_id_(0), 281 pending_video_decoder_init_request_id_(0),
282 pending_audio_decode_request_id_(0), 282 pending_audio_decode_request_id_(0),
283 pending_video_decode_request_id_(0), 283 pending_video_decode_request_id_(0),
284 weak_ptr_factory_(this), 284 weak_ptr_factory_(this),
285 weak_this_(weak_ptr_factory_.GetWeakPtr()) { 285 weak_this_(weak_ptr_factory_.GetWeakPtr()) {
286 } 286 }
287 287
288 void ContentDecryptorDelegate::Initialize(const std::string& key_system) {
289 // TODO(ddorwin): Add an Initialize method to PPP_ContentDecryptor_Private.
290 DCHECK(!key_system.empty());
291 key_system_ = key_system;
292 }
293
288 void ContentDecryptorDelegate::SetKeyEventCallbacks( 294 void ContentDecryptorDelegate::SetKeyEventCallbacks(
289 const media::KeyAddedCB& key_added_cb, 295 const media::KeyAddedCB& key_added_cb,
290 const media::KeyErrorCB& key_error_cb, 296 const media::KeyErrorCB& key_error_cb,
291 const media::KeyMessageCB& key_message_cb, 297 const media::KeyMessageCB& key_message_cb,
292 const media::NeedKeyCB& need_key_cb) { 298 const media::NeedKeyCB& need_key_cb) {
293 key_added_cb_ = key_added_cb; 299 key_added_cb_ = key_added_cb;
294 key_error_cb_ = key_error_cb; 300 key_error_cb_ = key_error_cb;
295 key_message_cb_ = key_message_cb; 301 key_message_cb_ = key_message_cb;
296 need_key_cb_ = need_key_cb; 302 need_key_cb_ = need_key_cb;
297 } 303 }
298 304
299 bool ContentDecryptorDelegate::GenerateKeyRequest(const std::string& key_system, 305 bool ContentDecryptorDelegate::GenerateKeyRequest(const std::string& type,
300 const std::string& type,
301 const uint8* init_data, 306 const uint8* init_data,
302 int init_data_length) { 307 int init_data_length) {
303 if (key_system.empty())
304 return false;
305
306 PP_Var init_data_array = 308 PP_Var init_data_array =
307 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( 309 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(
308 init_data_length, init_data); 310 init_data_length, init_data);
309 311
310 plugin_decryption_interface_->GenerateKeyRequest( 312 plugin_decryption_interface_->GenerateKeyRequest(
311 pp_instance_, 313 pp_instance_,
312 StringVar::StringToPPVar(key_system), 314 StringVar::StringToPPVar(key_system_), // TODO(ddorwin): Remove.
313 StringVar::StringToPPVar(type), 315 StringVar::StringToPPVar(type),
314 init_data_array); 316 init_data_array);
315 return true; 317 return true;
316 } 318 }
317 319
318 bool ContentDecryptorDelegate::AddKey(const std::string& session_id, 320 bool ContentDecryptorDelegate::AddKey(const std::string& session_id,
319 const uint8* key, 321 const uint8* key,
320 int key_length, 322 int key_length,
321 const uint8* init_data, 323 const uint8* init_data,
322 int init_data_length) { 324 int init_data_length) {
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 plugin_decryption_interface_->DecryptAndDecode(pp_instance_, 610 plugin_decryption_interface_->DecryptAndDecode(pp_instance_,
609 PP_DECRYPTORSTREAMTYPE_VIDEO, 611 PP_DECRYPTORSTREAMTYPE_VIDEO,
610 pp_resource, 612 pp_resource,
611 &block_info); 613 &block_info);
612 return true; 614 return true;
613 } 615 }
614 616
615 void ContentDecryptorDelegate::NeedKey(PP_Var key_system_var, 617 void ContentDecryptorDelegate::NeedKey(PP_Var key_system_var,
616 PP_Var session_id_var, 618 PP_Var session_id_var,
617 PP_Var init_data_var) { 619 PP_Var init_data_var) {
618 // TODO(tomfinegan): send the data to media stack. 620 // TODO(ddorwin): Remove from PPB_ContentDecryptor_Private.
621 NOTREACHED();
619 } 622 }
620 623
621 void ContentDecryptorDelegate::KeyAdded(PP_Var key_system_var, 624 void ContentDecryptorDelegate::KeyAdded(PP_Var key_system_var,
622 PP_Var session_id_var) { 625 PP_Var session_id_var) {
623 if (key_added_cb_.is_null()) 626 if (key_added_cb_.is_null())
624 return; 627 return;
625 628
626 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); 629 // Verify the key_system values are the same until the param is removed.
630 DCHECK(StringVar::FromPPVar(key_system_var)->value() == key_system_);
627 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); 631 StringVar* session_id_string = StringVar::FromPPVar(session_id_var);
628 if (!key_system_string || !session_id_string) { 632 if (!session_id_string) {
629 key_error_cb_.Run( 633 key_error_cb_.Run(std::string(), media::MediaKeys::kUnknownError, 0);
630 std::string(), std::string(), media::MediaKeys::kUnknownError, 0);
631 return; 634 return;
632 } 635 }
633 636
634 key_added_cb_.Run(key_system_string->value(), session_id_string->value()); 637 key_added_cb_.Run(session_id_string->value());
635 } 638 }
636 639
637 void ContentDecryptorDelegate::KeyMessage(PP_Var key_system_var, 640 void ContentDecryptorDelegate::KeyMessage(PP_Var key_system_var,
638 PP_Var session_id_var, 641 PP_Var session_id_var,
639 PP_Var message_var, 642 PP_Var message_var,
640 PP_Var default_url_var) { 643 PP_Var default_url_var) {
641 if (key_message_cb_.is_null()) 644 if (key_message_cb_.is_null())
642 return; 645 return;
643 646
644 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); 647 DCHECK(StringVar::FromPPVar(key_system_var)->value() == key_system_);
dmichael (off chromium) 2013/06/18 21:45:31 I think it would be better to explicitly make sure
ddorwin 2013/06/19 00:29:27 I just removed these checks since they aren't that
645 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); 648 StringVar* session_id_string = StringVar::FromPPVar(session_id_var);
646 649
647 ArrayBufferVar* message_array_buffer = 650 ArrayBufferVar* message_array_buffer =
648 ArrayBufferVar::FromPPVar(message_var); 651 ArrayBufferVar::FromPPVar(message_var);
649 652
650 std::string message; 653 std::string message;
651 if (message_array_buffer) { 654 if (message_array_buffer) {
652 const char* data = static_cast<const char*>(message_array_buffer->Map()); 655 const char* data = static_cast<const char*>(message_array_buffer->Map());
653 message.assign(data, message_array_buffer->ByteLength()); 656 message.assign(data, message_array_buffer->ByteLength());
654 } 657 }
655 658
656 StringVar* default_url_string = StringVar::FromPPVar(default_url_var); 659 StringVar* default_url_string = StringVar::FromPPVar(default_url_var);
657 660
658 if (!key_system_string || !session_id_string || !default_url_string) { 661 if (!session_id_string || !default_url_string) {
659 key_error_cb_.Run( 662 key_error_cb_.Run(std::string(), media::MediaKeys::kUnknownError, 0);
660 std::string(), std::string(), media::MediaKeys::kUnknownError, 0);
661 return; 663 return;
662 } 664 }
663 665
664 key_message_cb_.Run(key_system_string->value(), 666 key_message_cb_.Run(session_id_string->value(),
665 session_id_string->value(),
666 message, 667 message,
667 default_url_string->value()); 668 default_url_string->value());
668 } 669 }
669 670
670 void ContentDecryptorDelegate::KeyError(PP_Var key_system_var, 671 void ContentDecryptorDelegate::KeyError(PP_Var key_system_var,
671 PP_Var session_id_var, 672 PP_Var session_id_var,
672 int32_t media_error, 673 int32_t media_error,
673 int32_t system_code) { 674 int32_t system_code) {
674 if (key_error_cb_.is_null()) 675 if (key_error_cb_.is_null())
675 return; 676 return;
676 677
677 StringVar* key_system_string = StringVar::FromPPVar(key_system_var); 678 DCHECK(StringVar::FromPPVar(key_system_var)->value() == key_system_);
dmichael (off chromium) 2013/06/18 21:45:31 ditto
ddorwin 2013/06/19 00:29:27 Done.
678 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); 679 StringVar* session_id_string = StringVar::FromPPVar(session_id_var);
679 if (!key_system_string || !session_id_string) { 680 if (!session_id_string) {
680 key_error_cb_.Run( 681 key_error_cb_.Run(std::string(), media::MediaKeys::kUnknownError, 0);
681 std::string(), std::string(), media::MediaKeys::kUnknownError, 0);
682 return; 682 return;
683 } 683 }
684 684
685 key_error_cb_.Run( 685 key_error_cb_.Run(session_id_string->value(),
686 key_system_string->value(), 686 static_cast<media::MediaKeys::KeyError>(media_error),
687 session_id_string->value(), 687 system_code);
688 static_cast<media::MediaKeys::KeyError>(media_error),
689 system_code);
690 } 688 }
691 689
692 void ContentDecryptorDelegate::DecoderInitializeDone( 690 void ContentDecryptorDelegate::DecoderInitializeDone(
693 PP_DecryptorStreamType decoder_type, 691 PP_DecryptorStreamType decoder_type,
694 uint32_t request_id, 692 uint32_t request_id,
695 PP_Bool success) { 693 PP_Bool success) {
696 if (decoder_type == PP_DECRYPTORSTREAMTYPE_AUDIO) { 694 if (decoder_type == PP_DECRYPTORSTREAMTYPE_AUDIO) {
697 // If the request ID is not valid or does not match what's saved, do 695 // If the request ID is not valid or does not match what's saved, do
698 // nothing. 696 // nothing.
699 if (request_id == 0 || 697 if (request_id == 0 ||
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 1022
1025 if (free_buffers_.empty()) 1023 if (free_buffers_.empty())
1026 return; 1024 return;
1027 1025
1028 tracking_info->buffer_id = free_buffers_.front(); 1026 tracking_info->buffer_id = free_buffers_.front();
1029 free_buffers_.pop(); 1027 free_buffers_.pop();
1030 } 1028 }
1031 1029
1032 } // namespace ppapi 1030 } // namespace ppapi
1033 } // namespace webkit 1031 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698