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

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

Issue 265993002: Add Promises for EME (Chromium side) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: latest CDM_5 Created 6 years, 7 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 "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
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::MediaKeysException PpExceptionTypeToMediaException(
263 PP_ExceptionCodeType exception_code) {
264 switch (exception_code) {
265 case PP_EXCEPTIONCODETYPE_NOMODIFICATIONALLOWEDERROR:
266 return media::MediaKeys::
267 MEDIA_KEYS_EXCEPTION_NO_MODIFICATION_ALLOWED_ERROR;
268 case PP_EXCEPTIONCODETYPE_NOTFOUNDERROR:
269 return media::MediaKeys::MEDIA_KEYS_EXCEPTION_NOT_FOUND_ERROR;
270 case PP_EXCEPTIONCODETYPE_NOTSUPPORTEDERROR:
271 return media::MediaKeys::MEDIA_KEYS_EXCEPTION_NOT_SUPPORTED_ERROR;
272 case PP_EXCEPTIONCODETYPE_INVALIDSTATEERROR:
273 return media::MediaKeys::MEDIA_KEYS_EXCEPTION_INVALID_STATE_ERROR;
274 case PP_EXCEPTIONCODETYPE_SYNTAXERROR:
275 return media::MediaKeys::MEDIA_KEYS_EXCEPTION_SYNTAX_ERROR;
276 case PP_EXCEPTIONCODETYPE_INVALIDMODIFICATIONERROR:
277 return media::MediaKeys::MEDIA_KEYS_EXCEPTION_INVALID_MODIFICATION_ERROR;
278 case PP_EXCEPTIONCODETYPE_INVALIDACCESSERROR:
279 return media::MediaKeys::MEDIA_KEYS_EXCEPTION_INVALID_ACCESS_ERROR;
280 case PP_EXCEPTIONCODETYPE_SECURITYERROR:
281 return media::MediaKeys::MEDIA_KEYS_EXCEPTION_SECURITY_ERROR;
282 case PP_EXCEPTIONCODETYPE_ABORTERROR:
283 return media::MediaKeys::MEDIA_KEYS_EXCEPTION_ABORT_ERROR;
284 case PP_EXCEPTIONCODETYPE_QUOTAEXCEEDEDERROR:
285 return media::MediaKeys::MEDIA_KEYS_EXCEPTION_QUOTA_EXCEEDED_ERROR;
286 case PP_EXCEPTIONCODETYPE_TIMEOUTERROR:
287 return media::MediaKeys::MEDIA_KEYS_EXCEPTION_TIMEOUT_ERROR;
288 case PP_EXCEPTIONCODETYPE_UNKNOWNERROR:
289 return media::MediaKeys::MEDIA_KEYS_EXCEPTION_UNKNOWN_ERROR;
290 case PP_EXCEPTIONCODETYPE_DATAERROR:
291 return media::MediaKeys::MEDIA_KEYS_EXCEPTION_DATA_ERROR;
292 case PP_EXCEPTIONCODETYPE_VERSIONERROR:
293 return media::MediaKeys::MEDIA_KEYS_EXCEPTION_VERSION_ERROR;
294 case PP_EXCEPTIONCODETYPE_NOTREADABLEERROR:
295 return media::MediaKeys::MEDIA_KEYS_EXCEPTION_NOT_READABLE_ERROR;
296 case PP_EXCEPTIONCODETYPE_OPERATIONERROR:
297 return media::MediaKeys::MEDIA_KEYS_EXCEPTION_OPERATION_ERROR;
298 case PP_EXCEPTIONCODETYPE_CLIENTERROR:
299 return media::MediaKeys::MEDIA_KEYS_EXCEPTION_CLIENT_ERROR;
300 case PP_EXCEPTIONCODETYPE_OUTPUTERROR:
301 return media::MediaKeys::MEDIA_KEYS_EXCEPTION_OUTPUT_ERROR;
302 default:
303 NOTREACHED();
304 return media::MediaKeys::MEDIA_KEYS_EXCEPTION_UNKNOWN_ERROR;
305 }
306 }
307
248 } // namespace 308 } // namespace
249 309
250 ContentDecryptorDelegate::ContentDecryptorDelegate( 310 ContentDecryptorDelegate::ContentDecryptorDelegate(
251 PP_Instance pp_instance, 311 PP_Instance pp_instance,
252 const PPP_ContentDecryptor_Private* plugin_decryption_interface) 312 const PPP_ContentDecryptor_Private* plugin_decryption_interface)
253 : pp_instance_(pp_instance), 313 : pp_instance_(pp_instance),
254 plugin_decryption_interface_(plugin_decryption_interface), 314 plugin_decryption_interface_(plugin_decryption_interface),
255 next_decryption_request_id_(1), 315 next_decryption_request_id_(1),
256 audio_samples_per_second_(0), 316 audio_samples_per_second_(0),
257 audio_channel_count_(0), 317 audio_channel_count_(0),
258 audio_channel_layout_(media::CHANNEL_LAYOUT_NONE), 318 audio_channel_layout_(media::CHANNEL_LAYOUT_NONE),
319 next_promise_id_(0),
259 weak_ptr_factory_(this) { 320 weak_ptr_factory_(this) {
260 weak_this_ = weak_ptr_factory_.GetWeakPtr(); 321 weak_this_ = weak_ptr_factory_.GetWeakPtr();
261 } 322 }
262 323
263 ContentDecryptorDelegate::~ContentDecryptorDelegate() { 324 ContentDecryptorDelegate::~ContentDecryptorDelegate() {
264 SatisfyAllPendingCallbacksOnError(); 325 SatisfyAllPendingCallbacksOnError();
265 } 326 }
266 327
267 void ContentDecryptorDelegate::Initialize( 328 void ContentDecryptorDelegate::Initialize(
268 const std::string& key_system, 329 const std::string& key_system,
269 const media::SessionCreatedCB& session_created_cb,
270 const media::SessionMessageCB& session_message_cb, 330 const media::SessionMessageCB& session_message_cb,
271 const media::SessionReadyCB& session_ready_cb, 331 const media::SessionReadyCB& session_ready_cb,
272 const media::SessionClosedCB& session_closed_cb, 332 const media::SessionClosedCB& session_closed_cb,
273 const media::SessionErrorCB& session_error_cb, 333 const media::SessionErrorCB& session_error_cb,
274 const base::Closure& fatal_plugin_error_cb) { 334 const base::Closure& fatal_plugin_error_cb) {
275 DCHECK(!key_system.empty()); 335 DCHECK(!key_system.empty());
276 DCHECK(key_system_.empty()); 336 DCHECK(key_system_.empty());
277 key_system_ = key_system; 337 key_system_ = key_system;
278 338
279 session_created_cb_ = session_created_cb;
280 session_message_cb_ = session_message_cb; 339 session_message_cb_ = session_message_cb;
281 session_ready_cb_ = session_ready_cb; 340 session_ready_cb_ = session_ready_cb;
282 session_closed_cb_ = session_closed_cb; 341 session_closed_cb_ = session_closed_cb;
283 session_error_cb_ = session_error_cb; 342 session_error_cb_ = session_error_cb;
284 fatal_plugin_error_cb_ = fatal_plugin_error_cb; 343 fatal_plugin_error_cb_ = fatal_plugin_error_cb;
285 344
286 plugin_decryption_interface_->Initialize( 345 plugin_decryption_interface_->Initialize(
287 pp_instance_, StringVar::StringToPPVar(key_system_)); 346 pp_instance_, StringVar::StringToPPVar(key_system_));
288 } 347 }
289 348
290 void ContentDecryptorDelegate::InstanceCrashed() { 349 void ContentDecryptorDelegate::InstanceCrashed() {
291 fatal_plugin_error_cb_.Run(); 350 fatal_plugin_error_cb_.Run();
292 SatisfyAllPendingCallbacksOnError(); 351 SatisfyAllPendingCallbacksOnError();
293 } 352 }
294 353
295 bool ContentDecryptorDelegate::CreateSession(uint32 session_id, 354 void ContentDecryptorDelegate::CreateSession(
296 const std::string& content_type, 355 const std::string& init_data_type,
297 const uint8* init_data, 356 const uint8* init_data,
298 int init_data_length) { 357 int init_data_length,
358 media::MediaKeys::SessionType session_type,
359 scoped_ptr<media::CdmNewSessionPromise> promise) {
360 uint32_t promise_id = SaveSessionPromise(promise.Pass());
299 PP_Var init_data_array = 361 PP_Var init_data_array =
300 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( 362 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(
301 init_data_length, init_data); 363 init_data_length, init_data);
302
303 plugin_decryption_interface_->CreateSession( 364 plugin_decryption_interface_->CreateSession(
304 pp_instance_, 365 pp_instance_,
305 session_id, 366 promise_id,
306 StringVar::StringToPPVar(content_type), 367 StringVar::StringToPPVar(init_data_type),
307 init_data_array); 368 init_data_array,
308 return true; 369 MediaSessionTypeToPpSessionType(session_type));
309 } 370 }
310 371
311 void ContentDecryptorDelegate::LoadSession(uint32 session_id, 372 void ContentDecryptorDelegate::LoadSession(
312 const std::string& web_session_id) { 373 const std::string& web_session_id,
374 scoped_ptr<media::CdmNewSessionPromise> promise) {
375 uint32_t promise_id = SaveSessionPromise(promise.Pass());
313 plugin_decryption_interface_->LoadSession( 376 plugin_decryption_interface_->LoadSession(
314 pp_instance_, session_id, StringVar::StringToPPVar(web_session_id)); 377 pp_instance_, promise_id, StringVar::StringToPPVar(web_session_id));
315 } 378 }
316 379
317 bool ContentDecryptorDelegate::UpdateSession(uint32 session_id, 380 void ContentDecryptorDelegate::UpdateSession(
318 const uint8* response, 381 const std::string& web_session_id,
319 int response_length) { 382 const uint8* response,
383 int response_length,
384 scoped_ptr<media::CdmChangeSessionPromise> promise) {
385 uint32_t promise_id = SaveVoidPromise(promise.Pass());
320 PP_Var response_array = 386 PP_Var response_array =
321 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar( 387 PpapiGlobals::Get()->GetVarTracker()->MakeArrayBufferPPVar(
322 response_length, response); 388 response_length, response);
323 plugin_decryption_interface_->UpdateSession( 389 plugin_decryption_interface_->UpdateSession(
324 pp_instance_, session_id, response_array); 390 pp_instance_,
325 return true; 391 promise_id,
392 StringVar::StringToPPVar(web_session_id),
393 response_array);
326 } 394 }
327 395
328 bool ContentDecryptorDelegate::ReleaseSession(uint32 session_id) { 396 void ContentDecryptorDelegate::ReleaseSession(
329 plugin_decryption_interface_->ReleaseSession(pp_instance_, session_id); 397 const std::string& web_session_id,
330 return true; 398 scoped_ptr<media::CdmChangeSessionPromise> promise) {
399 uint32_t promise_id = SaveVoidPromise(promise.Pass());
400 plugin_decryption_interface_->ReleaseSession(
401 pp_instance_, promise_id, StringVar::StringToPPVar(web_session_id));
331 } 402 }
332 403
333 // TODO(xhwang): Remove duplication of code in Decrypt(), 404 // TODO(xhwang): Remove duplication of code in Decrypt(),
334 // DecryptAndDecodeAudio() and DecryptAndDecodeVideo(). 405 // DecryptAndDecodeAudio() and DecryptAndDecodeVideo().
335 bool ContentDecryptorDelegate::Decrypt( 406 bool ContentDecryptorDelegate::Decrypt(
336 Decryptor::StreamType stream_type, 407 Decryptor::StreamType stream_type,
337 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer, 408 const scoped_refptr<media::DecoderBuffer>& encrypted_buffer,
338 const Decryptor::DecryptCB& decrypt_cb) { 409 const Decryptor::DecryptCB& decrypt_cb) {
339 DVLOG(3) << "Decrypt() - stream_type: " << stream_type; 410 DVLOG(3) << "Decrypt() - stream_type: " << stream_type;
340 411
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 // buffer. 637 // buffer.
567 video_decode_cb_.Set(request_id, video_decode_cb); 638 video_decode_cb_.Set(request_id, video_decode_cb);
568 639
569 // TODO(tomfinegan): Need to get stream type from media stack. 640 // TODO(tomfinegan): Need to get stream type from media stack.
570 ScopedPPResource pp_resource(encrypted_resource.get()); 641 ScopedPPResource pp_resource(encrypted_resource.get());
571 plugin_decryption_interface_->DecryptAndDecode( 642 plugin_decryption_interface_->DecryptAndDecode(
572 pp_instance_, PP_DECRYPTORSTREAMTYPE_VIDEO, pp_resource, &block_info); 643 pp_instance_, PP_DECRYPTORSTREAMTYPE_VIDEO, pp_resource, &block_info);
573 return true; 644 return true;
574 } 645 }
575 646
576 void ContentDecryptorDelegate::OnSessionCreated(uint32 session_id, 647 void ContentDecryptorDelegate::OnPromiseResolved(uint32 promise_id) {
577 PP_Var web_session_id_var) { 648 scoped_ptr<media::CdmChangeSessionPromise> promise =
578 if (session_created_cb_.is_null()) 649 RetrieveVoidPromise(promise_id);
579 return; 650 promise->resolve();
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 } 651 }
590 652
591 void ContentDecryptorDelegate::OnSessionMessage(uint32 session_id, 653 void ContentDecryptorDelegate::OnPromiseResolvedWithSession(
654 uint32 promise_id,
655 PP_Var web_session_id_var) {
656 scoped_ptr<media::CdmNewSessionPromise> promise =
657 RetrieveSessionPromise(promise_id);
658
659 StringVar* web_session_id = StringVar::FromPPVar(web_session_id_var);
660 DCHECK(web_session_id);
661
662 promise->resolve(web_session_id->value());
663 }
664
665 void ContentDecryptorDelegate::OnPromiseRejected(
666 uint32 promise_id,
667 PP_ExceptionCodeType exception_code,
668 uint32 system_code,
669 PP_Var error_description_var) {
670 StringVar* error_description = StringVar::FromPPVar(error_description_var);
671 DCHECK(error_description);
672
673 scoped_ptr<media::CdmNewSessionPromise> promise =
674 RetrieveSessionPromise(promise_id);
675 if (promise) {
676 promise->reject(PpExceptionTypeToMediaException(exception_code),
677 system_code,
678 error_description->value());
679 } else {
680 scoped_ptr<media::CdmChangeSessionPromise> promise =
681 RetrieveVoidPromise(promise_id);
682 promise->reject(PpExceptionTypeToMediaException(exception_code),
683 system_code,
684 error_description->value());
685 }
686 }
687
688 void ContentDecryptorDelegate::OnSessionMessage(PP_Var web_session_id_var,
592 PP_Var message_var, 689 PP_Var message_var,
593 PP_Var default_url_var) { 690 PP_Var destination_url_var) {
594 if (session_message_cb_.is_null()) 691 if (session_message_cb_.is_null())
595 return; 692 return;
596 693
694 StringVar* web_session_id = StringVar::FromPPVar(web_session_id_var);
695 DCHECK(web_session_id);
696
597 ArrayBufferVar* message_array_buffer = ArrayBufferVar::FromPPVar(message_var); 697 ArrayBufferVar* message_array_buffer = ArrayBufferVar::FromPPVar(message_var);
598
599 std::vector<uint8> message; 698 std::vector<uint8> message;
600 if (message_array_buffer) { 699 if (message_array_buffer) {
601 const uint8* data = static_cast<const uint8*>(message_array_buffer->Map()); 700 const uint8* data = static_cast<const uint8*>(message_array_buffer->Map());
602 message.assign(data, data + message_array_buffer->ByteLength()); 701 message.assign(data, data + message_array_buffer->ByteLength());
603 } 702 }
604 703
605 StringVar* default_url_string = StringVar::FromPPVar(default_url_var); 704 StringVar* destination_url_string = StringVar::FromPPVar(destination_url_var);
705 DCHECK(destination_url_string);
606 706
607 if (!default_url_string) { 707 session_message_cb_.Run(
608 OnSessionError(session_id, media::MediaKeys::kUnknownError, 0); 708 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 } 709 }
614 710
615 void ContentDecryptorDelegate::OnSessionReady(uint32 session_id) { 711 void ContentDecryptorDelegate::OnSessionReady(PP_Var web_session_id_var) {
616 if (session_ready_cb_.is_null()) 712 if (session_ready_cb_.is_null())
617 return; 713 return;
618 714
619 session_ready_cb_.Run(session_id); 715 StringVar* web_session_id = StringVar::FromPPVar(web_session_id_var);
716 DCHECK(web_session_id);
717
718 session_ready_cb_.Run(web_session_id->value());
620 } 719 }
621 720
622 void ContentDecryptorDelegate::OnSessionClosed(uint32 session_id) { 721 void ContentDecryptorDelegate::OnSessionClosed(PP_Var web_session_id_var) {
623 if (session_closed_cb_.is_null()) 722 if (session_closed_cb_.is_null())
624 return; 723 return;
625 724
626 session_closed_cb_.Run(session_id); 725 StringVar* web_session_id = StringVar::FromPPVar(web_session_id_var);
726 DCHECK(web_session_id);
727
728 session_closed_cb_.Run(web_session_id->value());
627 } 729 }
628 730
629 void ContentDecryptorDelegate::OnSessionError(uint32 session_id, 731 void ContentDecryptorDelegate::OnSessionError(
630 int32_t media_error, 732 PP_Var web_session_id_var,
631 uint32_t system_code) { 733 PP_ExceptionCodeType exception_code,
734 uint32 system_code,
735 PP_Var error_description_var) {
632 if (session_error_cb_.is_null()) 736 if (session_error_cb_.is_null())
633 return; 737 return;
634 738
635 session_error_cb_.Run(session_id, 739 StringVar* web_session_id = StringVar::FromPPVar(web_session_id_var);
636 static_cast<media::MediaKeys::KeyError>(media_error), 740 DCHECK(web_session_id);
637 system_code); 741
742 StringVar* error_description = StringVar::FromPPVar(error_description_var);
743 DCHECK(error_description);
744
745 session_error_cb_.Run(web_session_id->value(),
746 PpExceptionTypeToMediaException(exception_code),
747 system_code,
748 error_description->value());
638 } 749 }
639 750
640 void ContentDecryptorDelegate::DecoderInitializeDone( 751 void ContentDecryptorDelegate::DecoderInitializeDone(
641 PP_DecryptorStreamType decoder_type, 752 PP_DecryptorStreamType decoder_type,
642 uint32_t request_id, 753 uint32_t request_id,
643 PP_Bool success) { 754 PP_Bool success) {
644 if (decoder_type == PP_DECRYPTORSTREAMTYPE_AUDIO) { 755 if (decoder_type == PP_DECRYPTORSTREAMTYPE_AUDIO) {
645 // If the request ID is not valid or does not match what's saved, do 756 // If the request ID is not valid or does not match what's saved, do
646 // nothing. 757 // nothing.
647 if (request_id == 0 || !audio_decoder_init_cb_.Matches(request_id)) 758 if (request_id == 0 || !audio_decoder_init_cb_.Matches(request_id))
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 video_decrypt_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); 1164 video_decrypt_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL);
1054 1165
1055 if (!audio_decode_cb_.is_null()) { 1166 if (!audio_decode_cb_.is_null()) {
1056 const media::Decryptor::AudioBuffers empty_frames; 1167 const media::Decryptor::AudioBuffers empty_frames;
1057 audio_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, 1168 audio_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError,
1058 empty_frames); 1169 empty_frames);
1059 } 1170 }
1060 1171
1061 if (!video_decode_cb_.is_null()) 1172 if (!video_decode_cb_.is_null())
1062 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL); 1173 video_decode_cb_.ResetAndReturn().Run(media::Decryptor::kError, NULL);
1174
1175 // TODO(jrummell): Reject all outstanding promises. Currently some tests
1176 // (ECKEncryptedMediaTest.CDMExpectedCrash and CDMCrashDuringDecode)
1177 // trigger a crash in the CDM, and don't handle the response to the pending
1178 // request. Once blink:: uses promises, this will be required.
1179 }
1180
1181 uint32_t ContentDecryptorDelegate::SaveVoidPromise(
1182 scoped_ptr<media::CdmChangeSessionPromise> promise) {
1183 uint32_t promise_id = ++next_promise_id_;
1184 void_promises_.insert(std::make_pair(promise_id, promise.release()));
1185 return promise_id;
1186 }
1187
1188 scoped_ptr<media::CdmChangeSessionPromise>
1189 ContentDecryptorDelegate::RetrieveVoidPromise(uint32_t promise_id) {
1190 std::map<uint32_t, media::CdmChangeSessionPromise*>::iterator it =
1191 void_promises_.find(promise_id);
1192 if (it == void_promises_.end())
1193 return scoped_ptr<media::CdmChangeSessionPromise>();
1194 scoped_ptr<media::CdmChangeSessionPromise> result(it->second);
1195 void_promises_.erase(it);
1196 return result.Pass();
1197 }
1198
1199 uint32_t ContentDecryptorDelegate::SaveSessionPromise(
1200 scoped_ptr<media::CdmNewSessionPromise> promise) {
1201 uint32_t promise_id = ++next_promise_id_;
1202 session_promises_.insert(std::make_pair(promise_id, promise.release()));
1203 return promise_id;
1204 }
1205
1206 scoped_ptr<media::CdmNewSessionPromise>
1207 ContentDecryptorDelegate::RetrieveSessionPromise(uint32_t promise_id) {
1208 std::map<uint32_t, media::CdmNewSessionPromise*>::iterator it =
1209 session_promises_.find(promise_id);
1210 if (it == session_promises_.end())
1211 return scoped_ptr<media::CdmNewSessionPromise>();
1212 scoped_ptr<media::CdmNewSessionPromise> result(it->second);
1213 session_promises_.erase(it);
1214 return result.Pass();
1063 } 1215 }
1064 1216
1065 } // namespace content 1217 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698