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

Side by Side Diff: content/renderer/pepper/content_decryptor_delegate.cc

Issue 105383002: Rename EME WD call parameters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tweak Created 7 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 "content/renderer/pepper/content_decryptor_delegate.h" 5 #include "content/renderer/pepper/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 "base/safe_numerics.h" 10 #include "base/safe_numerics.h"
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 const media::SessionReadyCB& session_ready_cb, 278 const media::SessionReadyCB& session_ready_cb,
279 const media::SessionClosedCB& session_closed_cb, 279 const media::SessionClosedCB& session_closed_cb,
280 const media::SessionErrorCB& session_error_cb) { 280 const media::SessionErrorCB& session_error_cb) {
281 session_created_cb_ = session_created_cb; 281 session_created_cb_ = session_created_cb;
282 session_message_cb_ = session_message_cb; 282 session_message_cb_ = session_message_cb;
283 session_ready_cb_ = session_ready_cb; 283 session_ready_cb_ = session_ready_cb;
284 session_closed_cb_ = session_closed_cb; 284 session_closed_cb_ = session_closed_cb;
285 session_error_cb_ = session_error_cb; 285 session_error_cb_ = session_error_cb;
286 } 286 }
287 287
288 bool ContentDecryptorDelegate::CreateSession(uint32 reference_id, 288 bool ContentDecryptorDelegate::CreateSession(uint32 session_id,
289 const std::string& type, 289 const std::string& type,
290 const uint8* init_data, 290 const uint8* init_data,
291 int init_data_length) { 291 int init_data_length) {
292 PP_Var init_data_array = 292 PP_Var init_data_array =
293 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( 293 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(
294 init_data_length, init_data); 294 init_data_length, init_data);
295 295
296 plugin_decryption_interface_->CreateSession( 296 plugin_decryption_interface_->CreateSession(pp_instance_,
297 pp_instance_, 297 session_id,
298 reference_id, 298 StringVar::StringToPPVar(type),
299 StringVar::StringToPPVar(type), 299 init_data_array);
300 init_data_array);
301 return true; 300 return true;
302 } 301 }
303 302
304 bool ContentDecryptorDelegate::UpdateSession(uint32 reference_id, 303 bool ContentDecryptorDelegate::UpdateSession(uint32 session_id,
305 const uint8* response, 304 const uint8* response,
306 int response_length) { 305 int response_length) {
307 PP_Var response_array = 306 PP_Var response_array =
308 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( 307 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(
309 response_length, response); 308 response_length, response);
310 plugin_decryption_interface_->UpdateSession( 309 plugin_decryption_interface_->UpdateSession(
311 pp_instance_, reference_id, response_array); 310 pp_instance_, session_id, response_array);
312 return true; 311 return true;
313 } 312 }
314 313
315 bool ContentDecryptorDelegate::ReleaseSession(uint32 reference_id) { 314 bool ContentDecryptorDelegate::ReleaseSession(uint32 session_id) {
316 plugin_decryption_interface_->ReleaseSession(pp_instance_, reference_id); 315 plugin_decryption_interface_->ReleaseSession(pp_instance_, session_id);
317 return true; 316 return true;
318 } 317 }
319 318
320 // TODO(xhwang): Remove duplication of code in Decrypt(), 319 // TODO(xhwang): Remove duplication of code in Decrypt(),
321 // DecryptAndDecodeAudio() and DecryptAndDecodeVideo(). 320 // DecryptAndDecodeAudio() and DecryptAndDecodeVideo().
322 bool ContentDecryptorDelegate::Decrypt( 321 bool ContentDecryptorDelegate::Decrypt(
323 media::Decryptor::StreamType stream_type, 322 media::Decryptor::StreamType stream_type,
324 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, 323 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer,
325 const media::Decryptor::DecryptCB& decrypt_cb) { 324 const media::Decryptor::DecryptCB& decrypt_cb) {
326 DVLOG(3) << "Decrypt() - stream_type: " << stream_type; 325 DVLOG(3) << "Decrypt() - stream_type: " << stream_type;
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 582
584 // TODO(tomfinegan): Need to get stream type from media stack. 583 // TODO(tomfinegan): Need to get stream type from media stack.
585 ScopedPPResource pp_resource(encrypted_resource.get()); 584 ScopedPPResource pp_resource(encrypted_resource.get());
586 plugin_decryption_interface_->DecryptAndDecode(pp_instance_, 585 plugin_decryption_interface_->DecryptAndDecode(pp_instance_,
587 PP_DECRYPTORSTREAMTYPE_VIDEO, 586 PP_DECRYPTORSTREAMTYPE_VIDEO,
588 pp_resource, 587 pp_resource,
589 &block_info); 588 &block_info);
590 return true; 589 return true;
591 } 590 }
592 591
593 void ContentDecryptorDelegate::OnSessionCreated(uint32 reference_id, 592 void ContentDecryptorDelegate::OnSessionCreated(uint32 session_id,
594 PP_Var session_id_var) { 593 PP_Var web_session_id_var) {
595 if (session_created_cb_.is_null()) 594 if (session_created_cb_.is_null())
596 return; 595 return;
597 596
598 StringVar* session_id_string = StringVar::FromPPVar(session_id_var); 597 StringVar* session_id_string = StringVar::FromPPVar(web_session_id_var);
599 598
600 if (!session_id_string) { 599 if (!session_id_string) {
601 OnSessionError(reference_id, media::MediaKeys::kUnknownError, 0); 600 OnSessionError(session_id, media::MediaKeys::kUnknownError, 0);
602 return; 601 return;
603 } 602 }
604 603
605 session_created_cb_.Run(reference_id, session_id_string->value()); 604 session_created_cb_.Run(session_id, session_id_string->value());
606 } 605 }
607 606
608 void ContentDecryptorDelegate::OnSessionMessage(uint32 reference_id, 607 void ContentDecryptorDelegate::OnSessionMessage(uint32 session_id,
609 PP_Var message_var, 608 PP_Var message_var,
610 PP_Var default_url_var) { 609 PP_Var default_url_var) {
611 if (session_message_cb_.is_null()) 610 if (session_message_cb_.is_null())
612 return; 611 return;
613 612
614 ArrayBufferVar* message_array_buffer = ArrayBufferVar::FromPPVar(message_var); 613 ArrayBufferVar* message_array_buffer = ArrayBufferVar::FromPPVar(message_var);
615 614
616 std::vector<uint8> message; 615 std::vector<uint8> message;
617 if (message_array_buffer) { 616 if (message_array_buffer) {
618 const uint8* data = static_cast<const uint8*>(message_array_buffer->Map()); 617 const uint8* data = static_cast<const uint8*>(message_array_buffer->Map());
619 message.assign(data, data + message_array_buffer->ByteLength()); 618 message.assign(data, data + message_array_buffer->ByteLength());
620 } 619 }
621 620
622 StringVar* default_url_string = StringVar::FromPPVar(default_url_var); 621 StringVar* default_url_string = StringVar::FromPPVar(default_url_var);
623 622
624 if (!default_url_string) { 623 if (!default_url_string) {
625 OnSessionError(reference_id, media::MediaKeys::kUnknownError, 0); 624 OnSessionError(session_id, media::MediaKeys::kUnknownError, 0);
626 return; 625 return;
627 } 626 }
628 627
629 session_message_cb_.Run(reference_id, message, default_url_string->value()); 628 session_message_cb_.Run(session_id, message, default_url_string->value());
630 } 629 }
631 630
632 void ContentDecryptorDelegate::OnSessionReady(uint32 reference_id) { 631 void ContentDecryptorDelegate::OnSessionReady(uint32 session_id) {
633 if (session_ready_cb_.is_null()) 632 if (session_ready_cb_.is_null())
634 return; 633 return;
635 634
636 session_ready_cb_.Run(reference_id); 635 session_ready_cb_.Run(session_id);
637 } 636 }
638 637
639 void ContentDecryptorDelegate::OnSessionClosed(uint32 reference_id) { 638 void ContentDecryptorDelegate::OnSessionClosed(uint32 session_id) {
640 if (session_closed_cb_.is_null()) 639 if (session_closed_cb_.is_null())
641 return; 640 return;
642 641
643 session_closed_cb_.Run(reference_id); 642 session_closed_cb_.Run(session_id);
644 } 643 }
645 644
646 void ContentDecryptorDelegate::OnSessionError(uint32 reference_id, 645 void ContentDecryptorDelegate::OnSessionError(uint32 session_id,
647 int32_t media_error, 646 int32_t media_error,
648 int32_t system_code) { 647 int32_t system_code) {
649 if (session_error_cb_.is_null()) 648 if (session_error_cb_.is_null())
650 return; 649 return;
651 650
652 session_error_cb_.Run(reference_id, 651 session_error_cb_.Run(session_id,
653 static_cast<media::MediaKeys::KeyError>(media_error), 652 static_cast<media::MediaKeys::KeyError>(media_error),
654 system_code); 653 system_code);
655 } 654 }
656 655
657 void ContentDecryptorDelegate::DecoderInitializeDone( 656 void ContentDecryptorDelegate::DecoderInitializeDone(
658 PP_DecryptorStreamType decoder_type, 657 PP_DecryptorStreamType decoder_type,
659 uint32_t request_id, 658 uint32_t request_id,
660 PP_Bool success) { 659 PP_Bool success) {
661 if (decoder_type == PP_DECRYPTORSTREAMTYPE_AUDIO) { 660 if (decoder_type == PP_DECRYPTORSTREAMTYPE_AUDIO) {
662 // If the request ID is not valid or does not match what's saved, do 661 // If the request ID is not valid or does not match what's saved, do
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 frames->push_back(frame); 1068 frames->push_back(frame);
1070 1069
1071 cur += frame_size; 1070 cur += frame_size;
1072 bytes_left -= frame_size; 1071 bytes_left -= frame_size;
1073 } while (bytes_left > 0); 1072 } while (bytes_left > 0);
1074 1073
1075 return true; 1074 return true;
1076 } 1075 }
1077 1076
1078 } // namespace content 1077 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698