OLD | NEW |
---|---|
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/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
11 #include "content/renderer/pepper/ppb_buffer_impl.h" | 11 #include "content/renderer/pepper/ppb_buffer_impl.h" |
12 #include "media/base/audio_buffer.h" | 12 #include "media/base/audio_buffer.h" |
13 #include "media/base/audio_decoder_config.h" | 13 #include "media/base/audio_decoder_config.h" |
14 #include "media/base/bind_to_current_loop.h" | 14 #include "media/base/bind_to_current_loop.h" |
15 #include "media/base/cdm_promise.h" | |
15 #include "media/base/channel_layout.h" | 16 #include "media/base/channel_layout.h" |
16 #include "media/base/data_buffer.h" | 17 #include "media/base/data_buffer.h" |
17 #include "media/base/decoder_buffer.h" | 18 #include "media/base/decoder_buffer.h" |
18 #include "media/base/decrypt_config.h" | 19 #include "media/base/decrypt_config.h" |
19 #include "media/base/video_decoder_config.h" | 20 #include "media/base/video_decoder_config.h" |
20 #include "media/base/video_frame.h" | 21 #include "media/base/video_frame.h" |
21 #include "media/base/video_util.h" | 22 #include "media/base/video_util.h" |
22 #include "ppapi/shared_impl/scoped_pp_resource.h" | 23 #include "ppapi/shared_impl/scoped_pp_resource.h" |
23 #include "ppapi/shared_impl/var.h" | 24 #include "ppapi/shared_impl/var.h" |
24 #include "ppapi/shared_impl/var_tracker.h" | 25 #include "ppapi/shared_impl/var_tracker.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 case PP_DECRYPTEDSAMPLEFORMAT_PLANAR_S16: | 239 case PP_DECRYPTEDSAMPLEFORMAT_PLANAR_S16: |
239 return media::kSampleFormatPlanarS16; | 240 return media::kSampleFormatPlanarS16; |
240 case PP_DECRYPTEDSAMPLEFORMAT_PLANAR_F32: | 241 case PP_DECRYPTEDSAMPLEFORMAT_PLANAR_F32: |
241 return media::kSampleFormatPlanarF32; | 242 return media::kSampleFormatPlanarF32; |
242 default: | 243 default: |
243 NOTREACHED(); | 244 NOTREACHED(); |
244 return media::kUnknownSampleFormat; | 245 return media::kUnknownSampleFormat; |
245 } | 246 } |
246 } | 247 } |
247 | 248 |
249 PP_SessionType MediaSessionTypeToPpSessionType( | |
250 media::MediaKeys::SessionType session_type) { | |
251 switch (session_type) { | |
252 case media::MediaKeys::SESSION_TYPE_TEMPORARY: | |
253 return PP_SESSIONTYPE_TEMPORARY; | |
254 case media::MediaKeys::SESSION_TYPE_PERSISTENT: | |
255 return PP_SESSIONTYPE_PERSISTENT; | |
256 default: | |
257 NOTREACHED(); | |
258 return PP_SESSIONTYPE_TEMPORARY; | |
259 } | |
260 } | |
261 | |
262 media::MediaKeys::Exception PpExceptionTypeToMediaException( | |
263 PP_ExceptionCode exception_code) { | |
264 switch (exception_code) { | |
265 case PP_EXCEPTIONCODE_NOMODIFICATIONALLOWEDERROR: | |
266 return media::MediaKeys::EXCEPTION_NO_MODIFICATION_ALLOWED_ERROR; | |
267 case PP_EXCEPTIONCODE_NOTFOUNDERROR: | |
268 return media::MediaKeys::EXCEPTION_NOT_FOUND_ERROR; | |
269 case PP_EXCEPTIONCODE_NOTSUPPORTEDERROR: | |
270 return media::MediaKeys::EXCEPTION_NOT_SUPPORTED_ERROR; | |
271 case PP_EXCEPTIONCODE_INVALIDSTATEERROR: | |
272 return media::MediaKeys::EXCEPTION_INVALID_STATE_ERROR; | |
273 case PP_EXCEPTIONCODE_SYNTAXERROR: | |
ddorwin
2014/05/15 23:15:32
Let's not support this in Pepper (and remove from
jrummell
2014/05/16 00:49:53
Done.
| |
274 return media::MediaKeys::EXCEPTION_SYNTAX_ERROR; | |
275 case PP_EXCEPTIONCODE_INVALIDMODIFICATIONERROR: | |
276 return media::MediaKeys::EXCEPTION_INVALID_MODIFICATION_ERROR; | |
277 case PP_EXCEPTIONCODE_INVALIDACCESSERROR: | |
278 return media::MediaKeys::EXCEPTION_INVALID_ACCESS_ERROR; | |
279 case PP_EXCEPTIONCODE_SECURITYERROR: | |
280 return media::MediaKeys::EXCEPTION_SECURITY_ERROR; | |
281 case PP_EXCEPTIONCODE_ABORTERROR: | |
282 return media::MediaKeys::EXCEPTION_ABORT_ERROR; | |
283 case PP_EXCEPTIONCODE_QUOTAEXCEEDEDERROR: | |
284 return media::MediaKeys::EXCEPTION_QUOTA_EXCEEDED_ERROR; | |
285 case PP_EXCEPTIONCODE_TIMEOUTERROR: | |
286 return media::MediaKeys::EXCEPTION_TIMEOUT_ERROR; | |
287 case PP_EXCEPTIONCODE_UNKNOWNERROR: | |
288 return media::MediaKeys::EXCEPTION_UNKNOWN_ERROR; | |
289 case PP_EXCEPTIONCODE_DATAERROR: | |
290 return media::MediaKeys::EXCEPTION_DATA_ERROR; | |
291 case PP_EXCEPTIONCODE_VERSIONERROR: | |
292 return media::MediaKeys::EXCEPTION_VERSION_ERROR; | |
293 case PP_EXCEPTIONCODE_NOTREADABLEERROR: | |
294 return media::MediaKeys::EXCEPTION_NOT_READABLE_ERROR; | |
295 case PP_EXCEPTIONCODE_OPERATIONERROR: | |
296 return media::MediaKeys::EXCEPTION_OPERATION_ERROR; | |
297 case PP_EXCEPTIONCODE_CLIENTERROR: | |
298 return media::MediaKeys::EXCEPTION_CLIENT_ERROR; | |
299 case PP_EXCEPTIONCODE_OUTPUTERROR: | |
300 return media::MediaKeys::EXCEPTION_OUTPUT_ERROR; | |
301 default: | |
302 NOTREACHED(); | |
303 return media::MediaKeys::EXCEPTION_UNKNOWN_ERROR; | |
304 } | |
305 } | |
306 | |
248 } // namespace | 307 } // namespace |
249 | 308 |
250 ContentDecryptorDelegate::ContentDecryptorDelegate( | 309 ContentDecryptorDelegate::ContentDecryptorDelegate( |
251 PP_Instance pp_instance, | 310 PP_Instance pp_instance, |
252 const PPP_ContentDecryptor_Private* plugin_decryption_interface) | 311 const PPP_ContentDecryptor_Private* plugin_decryption_interface) |
253 : pp_instance_(pp_instance), | 312 : pp_instance_(pp_instance), |
254 plugin_decryption_interface_(plugin_decryption_interface), | 313 plugin_decryption_interface_(plugin_decryption_interface), |
255 next_decryption_request_id_(1), | 314 next_decryption_request_id_(1), |
256 audio_samples_per_second_(0), | 315 audio_samples_per_second_(0), |
257 audio_channel_count_(0), | 316 audio_channel_count_(0), |
258 audio_channel_layout_(media::CHANNEL_LAYOUT_NONE), | 317 audio_channel_layout_(media::CHANNEL_LAYOUT_NONE), |
318 next_promise_id_(0), | |
259 weak_ptr_factory_(this) { | 319 weak_ptr_factory_(this) { |
260 weak_this_ = weak_ptr_factory_.GetWeakPtr(); | 320 weak_this_ = weak_ptr_factory_.GetWeakPtr(); |
261 } | 321 } |
262 | 322 |
263 ContentDecryptorDelegate::~ContentDecryptorDelegate() { | 323 ContentDecryptorDelegate::~ContentDecryptorDelegate() { |
264 SatisfyAllPendingCallbacksOnError(); | 324 SatisfyAllPendingCallbacksOnError(); |
265 } | 325 } |
266 | 326 |
267 void ContentDecryptorDelegate::Initialize( | 327 void ContentDecryptorDelegate::Initialize( |
268 const std::string& key_system, | 328 const std::string& key_system, |
269 const media::SessionCreatedCB& session_created_cb, | |
270 const media::SessionMessageCB& session_message_cb, | 329 const media::SessionMessageCB& session_message_cb, |
271 const media::SessionReadyCB& session_ready_cb, | 330 const media::SessionReadyCB& session_ready_cb, |
272 const media::SessionClosedCB& session_closed_cb, | 331 const media::SessionClosedCB& session_closed_cb, |
273 const media::SessionErrorCB& session_error_cb, | 332 const media::SessionErrorCB& session_error_cb, |
274 const base::Closure& fatal_plugin_error_cb) { | 333 const base::Closure& fatal_plugin_error_cb) { |
275 DCHECK(!key_system.empty()); | 334 DCHECK(!key_system.empty()); |
276 DCHECK(key_system_.empty()); | 335 DCHECK(key_system_.empty()); |
277 key_system_ = key_system; | 336 key_system_ = key_system; |
278 | 337 |
279 session_created_cb_ = session_created_cb; | |
280 session_message_cb_ = session_message_cb; | 338 session_message_cb_ = session_message_cb; |
281 session_ready_cb_ = session_ready_cb; | 339 session_ready_cb_ = session_ready_cb; |
282 session_closed_cb_ = session_closed_cb; | 340 session_closed_cb_ = session_closed_cb; |
283 session_error_cb_ = session_error_cb; | 341 session_error_cb_ = session_error_cb; |
284 fatal_plugin_error_cb_ = fatal_plugin_error_cb; | 342 fatal_plugin_error_cb_ = fatal_plugin_error_cb; |
285 | 343 |
286 plugin_decryption_interface_->Initialize( | 344 plugin_decryption_interface_->Initialize( |
287 pp_instance_, StringVar::StringToPPVar(key_system_)); | 345 pp_instance_, StringVar::StringToPPVar(key_system_)); |
288 } | 346 } |
289 | 347 |
290 void ContentDecryptorDelegate::InstanceCrashed() { | 348 void ContentDecryptorDelegate::InstanceCrashed() { |
291 fatal_plugin_error_cb_.Run(); | 349 fatal_plugin_error_cb_.Run(); |
292 SatisfyAllPendingCallbacksOnError(); | 350 SatisfyAllPendingCallbacksOnError(); |
293 } | 351 } |
294 | 352 |
295 bool ContentDecryptorDelegate::CreateSession(uint32 session_id, | 353 void ContentDecryptorDelegate::CreateSession( |
296 const std::string& content_type, | 354 const std::string& init_data_type, |
297 const uint8* init_data, | 355 const uint8* init_data, |
298 int init_data_length) { | 356 int init_data_length, |
357 media::MediaKeys::SessionType session_type, | |
358 scoped_ptr<media::NewSessionCdmPromise> promise) { | |
359 uint32_t promise_id = SaveNewSessionPromise(promise.Pass()); | |
299 PP_Var init_data_array = | 360 PP_Var init_data_array = |
300 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( | 361 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
301 init_data_length, init_data); | 362 init_data_length, init_data); |
302 | |
303 plugin_decryption_interface_->CreateSession( | 363 plugin_decryption_interface_->CreateSession( |
304 pp_instance_, | 364 pp_instance_, |
305 session_id, | 365 promise_id, |
306 StringVar::StringToPPVar(content_type), | 366 StringVar::StringToPPVar(init_data_type), |
307 init_data_array); | 367 init_data_array, |
308 return true; | 368 MediaSessionTypeToPpSessionType(session_type)); |
309 } | 369 } |
310 | 370 |
311 void ContentDecryptorDelegate::LoadSession(uint32 session_id, | 371 void ContentDecryptorDelegate::LoadSession( |
312 const std::string& web_session_id) { | 372 const std::string& web_session_id, |
373 scoped_ptr<media::NewSessionCdmPromise> promise) { | |
374 uint32_t promise_id = SaveNewSessionPromise(promise.Pass()); | |
313 plugin_decryption_interface_->LoadSession( | 375 plugin_decryption_interface_->LoadSession( |
314 pp_instance_, session_id, StringVar::StringToPPVar(web_session_id)); | 376 pp_instance_, promise_id, StringVar::StringToPPVar(web_session_id)); |
315 } | 377 } |
316 | 378 |
317 bool ContentDecryptorDelegate::UpdateSession(uint32 session_id, | 379 void ContentDecryptorDelegate::UpdateSession( |
318 const uint8* response, | 380 const std::string& web_session_id, |
319 int response_length) { | 381 const uint8* response, |
382 int response_length, | |
383 scoped_ptr<media::SimpleCdmPromise> promise) { | |
384 uint32_t promise_id = SaveSimplePromise(promise.Pass()); | |
320 PP_Var response_array = | 385 PP_Var response_array = |
321 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( | 386 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( |
322 response_length, response); | 387 response_length, response); |
323 plugin_decryption_interface_->UpdateSession( | 388 plugin_decryption_interface_->UpdateSession( |
324 pp_instance_, session_id, response_array); | 389 pp_instance_, |
325 return true; | 390 promise_id, |
391 StringVar::StringToPPVar(web_session_id), | |
392 response_array); | |
326 } | 393 } |
327 | 394 |
328 bool ContentDecryptorDelegate::ReleaseSession(uint32 session_id) { | 395 void ContentDecryptorDelegate::ReleaseSession( |
329 plugin_decryption_interface_->ReleaseSession(pp_instance_, session_id); | 396 const std::string& web_session_id, |
330 return true; | 397 scoped_ptr<media::SimpleCdmPromise> promise) { |
398 uint32_t promise_id = SaveSimplePromise(promise.Pass()); | |
399 plugin_decryption_interface_->ReleaseSession( | |
400 pp_instance_, promise_id, StringVar::StringToPPVar(web_session_id)); | |
331 } | 401 } |
332 | 402 |
333 // TODO(xhwang): Remove duplication of code in Decrypt(), | 403 // TODO(xhwang): Remove duplication of code in Decrypt(), |
334 // DecryptAndDecodeAudio() and DecryptAndDecodeVideo(). | 404 // DecryptAndDecodeAudio() and DecryptAndDecodeVideo(). |
335 bool ContentDecryptorDelegate::Decrypt( | 405 bool ContentDecryptorDelegate::Decrypt( |
336 Decryptor::StreamType stream_type, | 406 Decryptor::StreamType stream_type, |
337 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, | 407 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, |
338 const Decryptor::DecryptCB& decrypt_cb) { | 408 const Decryptor::DecryptCB& decrypt_cb) { |
339 DVLOG(3) << "Decrypt() - stream_type: " << stream_type; | 409 DVLOG(3) << "Decrypt() - stream_type: " << stream_type; |
340 | 410 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
566 // buffer. | 636 // buffer. |
567 video_decode_cb_.Set(request_id, video_decode_cb); | 637 video_decode_cb_.Set(request_id, video_decode_cb); |
568 | 638 |
569 // TODO(tomfinegan): Need to get stream type from media stack. | 639 // TODO(tomfinegan): Need to get stream type from media stack. |
570 ScopedPPResource pp_resource(encrypted_resource.get()); | 640 ScopedPPResource pp_resource(encrypted_resource.get()); |
571 plugin_decryption_interface_->DecryptAndDecode( | 641 plugin_decryption_interface_->DecryptAndDecode( |
572 pp_instance_, PP_DECRYPTORSTREAMTYPE_VIDEO, pp_resource, &block_info); | 642 pp_instance_, PP_DECRYPTORSTREAMTYPE_VIDEO, pp_resource, &block_info); |
573 return true; | 643 return true; |
574 } | 644 } |
575 | 645 |
576 void ContentDecryptorDelegate::OnSessionCreated(uint32 session_id, | 646 void ContentDecryptorDelegate::OnPromiseResolved(uint32 promise_id) { |
577 PP_Var web_session_id_var) { | 647 scoped_ptr<media::SimpleCdmPromise> promise = TakeSimplePromise(promise_id); |
578 if (session_created_cb_.is_null()) | 648 promise->resolve(); |
579 return; | |
580 | |
581 StringVar* session_id_string = StringVar::FromPPVar(web_session_id_var); | |
582 | |
583 if (!session_id_string) { | |
584 OnSessionError(session_id, media::MediaKeys::kUnknownError, 0); | |
585 return; | |
586 } | |
587 | |
588 session_created_cb_.Run(session_id, session_id_string->value()); | |
589 } | 649 } |
590 | 650 |
591 void ContentDecryptorDelegate::OnSessionMessage(uint32 session_id, | 651 void ContentDecryptorDelegate::OnPromiseResolvedWithSession( |
652 uint32 promise_id, | |
653 PP_Var web_session_id_var) { | |
654 scoped_ptr<media::NewSessionCdmPromise> promise = | |
655 TakeNewSessionPromise(promise_id); | |
656 | |
657 StringVar* web_session_id = StringVar::FromPPVar(web_session_id_var); | |
658 DCHECK(web_session_id); | |
659 | |
660 promise->resolve(web_session_id->value()); | |
661 } | |
662 | |
663 void ContentDecryptorDelegate::OnPromiseRejected( | |
664 uint32 promise_id, | |
665 PP_ExceptionCode exception_code, | |
666 uint32 system_code, | |
667 PP_Var error_description_var) { | |
668 StringVar* error_description = StringVar::FromPPVar(error_description_var); | |
669 DCHECK(error_description); | |
670 | |
671 scoped_ptr<media::NewSessionCdmPromise> promise = | |
672 TakeNewSessionPromise(promise_id); | |
673 if (promise) { | |
674 promise->reject(PpExceptionTypeToMediaException(exception_code), | |
675 system_code, | |
676 error_description->value()); | |
677 } else { | |
678 scoped_ptr<media::SimpleCdmPromise> promise = TakeSimplePromise(promise_id); | |
679 promise->reject(PpExceptionTypeToMediaException(exception_code), | |
680 system_code, | |
681 error_description->value()); | |
682 } | |
683 } | |
684 | |
685 void ContentDecryptorDelegate::OnSessionMessage(PP_Var web_session_id_var, | |
592 PP_Var message_var, | 686 PP_Var message_var, |
593 PP_Var default_url_var) { | 687 PP_Var destination_url_var) { |
594 if (session_message_cb_.is_null()) | 688 if (session_message_cb_.is_null()) |
595 return; | 689 return; |
596 | 690 |
691 StringVar* web_session_id = StringVar::FromPPVar(web_session_id_var); | |
692 DCHECK(web_session_id); | |
693 | |
597 ArrayBufferVar* message_array_buffer = ArrayBufferVar::FromPPVar(message_var); | 694 ArrayBufferVar* message_array_buffer = ArrayBufferVar::FromPPVar(message_var); |
598 | |
599 std::vector<uint8> message; | 695 std::vector<uint8> message; |
600 if (message_array_buffer) { | 696 if (message_array_buffer) { |
601 const uint8* data = static_cast<const uint8*>(message_array_buffer->Map()); | 697 const uint8* data = static_cast<const uint8*>(message_array_buffer->Map()); |
602 message.assign(data, data + message_array_buffer->ByteLength()); | 698 message.assign(data, data + message_array_buffer->ByteLength()); |
603 } | 699 } |
604 | 700 |
605 StringVar* default_url_string = StringVar::FromPPVar(default_url_var); | 701 StringVar* destination_url_string = StringVar::FromPPVar(destination_url_var); |
702 DCHECK(destination_url_string); | |
606 | 703 |
607 if (!default_url_string) { | 704 session_message_cb_.Run( |
608 OnSessionError(session_id, media::MediaKeys::kUnknownError, 0); | 705 web_session_id->value(), message, destination_url_string->value()); |
609 return; | |
610 } | |
611 | |
612 session_message_cb_.Run(session_id, message, default_url_string->value()); | |
613 } | 706 } |
614 | 707 |
615 void ContentDecryptorDelegate::OnSessionReady(uint32 session_id) { | 708 void ContentDecryptorDelegate::OnSessionReady(PP_Var web_session_id_var) { |
616 if (session_ready_cb_.is_null()) | 709 if (session_ready_cb_.is_null()) |
617 return; | 710 return; |
618 | 711 |
619 session_ready_cb_.Run(session_id); | 712 StringVar* web_session_id = StringVar::FromPPVar(web_session_id_var); |
713 DCHECK(web_session_id); | |
714 | |
715 session_ready_cb_.Run(web_session_id->value()); | |
620 } | 716 } |
621 | 717 |
622 void ContentDecryptorDelegate::OnSessionClosed(uint32 session_id) { | 718 void ContentDecryptorDelegate::OnSessionClosed(PP_Var web_session_id_var) { |
623 if (session_closed_cb_.is_null()) | 719 if (session_closed_cb_.is_null()) |
624 return; | 720 return; |
625 | 721 |
626 session_closed_cb_.Run(session_id); | 722 StringVar* web_session_id = StringVar::FromPPVar(web_session_id_var); |
723 DCHECK(web_session_id); | |
724 | |
725 session_closed_cb_.Run(web_session_id->value()); | |
627 } | 726 } |
628 | 727 |
629 void ContentDecryptorDelegate::OnSessionError(uint32 session_id, | 728 void ContentDecryptorDelegate::OnSessionError(PP_Var web_session_id_var, |
630 int32_t media_error, | 729 PP_ExceptionCode exception_code, |
631 uint32_t system_code) { | 730 uint32 system_code, |
731 PP_Var error_description_var) { | |
632 if (session_error_cb_.is_null()) | 732 if (session_error_cb_.is_null()) |
633 return; | 733 return; |
634 | 734 |
635 session_error_cb_.Run(session_id, | 735 StringVar* web_session_id = StringVar::FromPPVar(web_session_id_var); |
636 static_cast<media::MediaKeys::KeyError>(media_error), | 736 DCHECK(web_session_id); |
637 system_code); | 737 |
738 StringVar* error_description = StringVar::FromPPVar(error_description_var); | |
739 DCHECK(error_description); | |
740 | |
741 session_error_cb_.Run(web_session_id->value(), | |
742 PpExceptionTypeToMediaException(exception_code), | |
743 system_code, | |
744 error_description->value()); | |
638 } | 745 } |
639 | 746 |
640 void ContentDecryptorDelegate::DecoderInitializeDone( | 747 void ContentDecryptorDelegate::DecoderInitializeDone( |
641 PP_DecryptorStreamType decoder_type, | 748 PP_DecryptorStreamType decoder_type, |
642 uint32_t request_id, | 749 uint32_t request_id, |
643 PP_Bool success) { | 750 PP_Bool success) { |
644 if (decoder_type == PP_DECRYPTORSTREAMTYPE_AUDIO) { | 751 if (decoder_type == PP_DECRYPTORSTREAMTYPE_AUDIO) { |
645 // If the request ID is not valid or does not match what's saved, do | 752 // If the request ID is not valid or does not match what's saved, do |
646 // nothing. | 753 // nothing. |
647 if (request_id == 0 || !audio_decoder_init_cb_.Matches(request_id)) | 754 if (request_id == 0 || !audio_decoder_init_cb_.Matches(request_id)) |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1053 video_decrypt_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); | 1160 video_decrypt_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); |
1054 | 1161 |
1055 if (!audio_decode_cb_.is_null()) { | 1162 if (!audio_decode_cb_.is_null()) { |
1056 const media::Decryptor::AudioBuffers empty_frames; | 1163 const media::Decryptor::AudioBuffers empty_frames; |
1057 audio_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, | 1164 audio_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, |
1058 empty_frames); | 1165 empty_frames); |
1059 } | 1166 } |
1060 | 1167 |
1061 if (!video_decode_cb_.is_null()) | 1168 if (!video_decode_cb_.is_null()) |
1062 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); | 1169 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); |
1170 | |
1171 // TODO(jrummell): Reject all outstanding promises. Currently some tests | |
1172 // (ECKEncryptedMediaTest.CDMExpectedCrash and CDMCrashDuringDecode) | |
1173 // trigger a crash in the CDM, and don't handle the response to the pending | |
1174 // request. Once blink:: uses promises, this will be required. | |
1175 } | |
1176 | |
1177 uint32_t ContentDecryptorDelegate::SaveSimplePromise( | |
1178 scoped_ptr<media::SimpleCdmPromise> promise) { | |
1179 uint32_t promise_id = ++next_promise_id_; | |
1180 void_promises_.insert(std::make_pair(promise_id, promise.release())); | |
1181 return promise_id; | |
1182 } | |
1183 | |
1184 scoped_ptr<media::SimpleCdmPromise> ContentDecryptorDelegate::TakeSimplePromise( | |
1185 uint32_t promise_id) { | |
1186 std::map<uint32_t, media::SimpleCdmPromise*>::iterator it = | |
1187 void_promises_.find(promise_id); | |
1188 if (it == void_promises_.end()) | |
1189 return scoped_ptr<media::SimpleCdmPromise>(); | |
1190 scoped_ptr<media::SimpleCdmPromise> result(it->second); | |
1191 void_promises_.erase(it); | |
1192 return result.Pass(); | |
1193 } | |
1194 | |
1195 uint32_t ContentDecryptorDelegate::SaveNewSessionPromise( | |
1196 scoped_ptr<media::NewSessionCdmPromise> promise) { | |
1197 uint32_t promise_id = ++next_promise_id_; | |
1198 session_promises_.insert(std::make_pair(promise_id, promise.release())); | |
1199 return promise_id; | |
1200 } | |
1201 | |
1202 scoped_ptr<media::NewSessionCdmPromise> | |
1203 ContentDecryptorDelegate::TakeNewSessionPromise(uint32_t promise_id) { | |
1204 std::map<uint32_t, media::NewSessionCdmPromise*>::iterator it = | |
1205 session_promises_.find(promise_id); | |
1206 if (it == session_promises_.end()) | |
1207 return scoped_ptr<media::NewSessionCdmPromise>(); | |
1208 scoped_ptr<media::NewSessionCdmPromise> result(it->second); | |
1209 session_promises_.erase(it); | |
1210 return result.Pass(); | |
1063 } | 1211 } |
1064 | 1212 |
1065 } // namespace content | 1213 } // namespace content |
OLD | NEW |