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

Side by Side Diff: media/cdm/ppapi/external_clear_key/clear_key_cdm.cc

Issue 448893002: Update ClearKey to support CDM_6 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cdm6
Patch Set: rebase now that CDM_6 in Created 6 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "media/cdm/ppapi/external_clear_key/clear_key_cdm.h" 5 #include "media/cdm/ppapi/external_clear_key/clear_key_cdm.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 #include <sstream> 9 #include <sstream>
10 #include <string> 10 #include <string>
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 const int64 kMaxTimerDelayMs = 1 * kSecondsPerMinute * kMsPerSecond; 88 const int64 kMaxTimerDelayMs = 1 * kSecondsPerMinute * kMsPerSecond;
89 // Heart beat message header. If a key message starts with |kHeartBeatHeader|, 89 // Heart beat message header. If a key message starts with |kHeartBeatHeader|,
90 // it's a heart beat message. Otherwise, it's a key request. 90 // it's a heart beat message. Otherwise, it's a key request.
91 const char kHeartBeatHeader[] = "HEARTBEAT"; 91 const char kHeartBeatHeader[] = "HEARTBEAT";
92 // CDM file IO test result header. 92 // CDM file IO test result header.
93 const char kFileIOTestResultHeader[] = "FILEIOTESTRESULT"; 93 const char kFileIOTestResultHeader[] = "FILEIOTESTRESULT";
94 94
95 // Copies |input_buffer| into a media::DecoderBuffer. If the |input_buffer| is 95 // Copies |input_buffer| into a media::DecoderBuffer. If the |input_buffer| is
96 // empty, an empty (end-of-stream) media::DecoderBuffer is returned. 96 // empty, an empty (end-of-stream) media::DecoderBuffer is returned.
97 static scoped_refptr<media::DecoderBuffer> CopyDecoderBufferFrom( 97 static scoped_refptr<media::DecoderBuffer> CopyDecoderBufferFrom(
98 const cdm::InputBuffer_1& input_buffer) { 98 const cdm::InputBuffer& input_buffer) {
99 if (!input_buffer.data) { 99 if (!input_buffer.data) {
100 DCHECK(!input_buffer.data_size); 100 DCHECK(!input_buffer.data_size);
101 return media::DecoderBuffer::CreateEOSBuffer(); 101 return media::DecoderBuffer::CreateEOSBuffer();
102 } 102 }
103 103
104 // TODO(xhwang): Get rid of this copy. 104 // TODO(xhwang): Get rid of this copy.
105 scoped_refptr<media::DecoderBuffer> output_buffer = 105 scoped_refptr<media::DecoderBuffer> output_buffer =
106 media::DecoderBuffer::CopyFrom(input_buffer.data, input_buffer.data_size); 106 media::DecoderBuffer::CopyFrom(input_buffer.data, input_buffer.data_size);
107 107
108 std::vector<media::SubsampleEntry> subsamples; 108 std::vector<media::SubsampleEntry> subsamples;
109 for (uint32_t i = 0; i < input_buffer.num_subsamples; ++i) { 109 for (uint32_t i = 0; i < input_buffer.num_subsamples; ++i) {
110 media::SubsampleEntry subsample; 110 media::SubsampleEntry subsample;
111 subsample.clear_bytes = input_buffer.subsamples[i].clear_bytes; 111 subsample.clear_bytes = input_buffer.subsamples[i].clear_bytes;
112 subsample.cypher_bytes = input_buffer.subsamples[i].cipher_bytes; 112 subsample.cypher_bytes = input_buffer.subsamples[i].cipher_bytes;
113 subsamples.push_back(subsample); 113 subsamples.push_back(subsample);
114 } 114 }
115 115
116 DCHECK_EQ(input_buffer.data_offset, 0u);
117 scoped_ptr<media::DecryptConfig> decrypt_config(new media::DecryptConfig( 116 scoped_ptr<media::DecryptConfig> decrypt_config(new media::DecryptConfig(
118 std::string(reinterpret_cast<const char*>(input_buffer.key_id), 117 std::string(reinterpret_cast<const char*>(input_buffer.key_id),
119 input_buffer.key_id_size), 118 input_buffer.key_id_size),
120 std::string(reinterpret_cast<const char*>(input_buffer.iv), 119 std::string(reinterpret_cast<const char*>(input_buffer.iv),
121 input_buffer.iv_size), 120 input_buffer.iv_size),
122 subsamples)); 121 subsamples));
123 122
124 output_buffer->set_decrypt_config(decrypt_config.Pass()); 123 output_buffer->set_decrypt_config(decrypt_config.Pass());
125 output_buffer->set_timestamp( 124 output_buffer->set_timestamp(
126 base::TimeDelta::FromMicroseconds(input_buffer.timestamp)); 125 base::TimeDelta::FromMicroseconds(input_buffer.timestamp));
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 // (containing a |kLoadableSessionKey| for |kLoadableSessionKeyId|) is 266 // (containing a |kLoadableSessionKey| for |kLoadableSessionKeyId|) is
268 // supported. 267 // supported.
269 void ClearKeyCdm::LoadSession(uint32 promise_id, 268 void ClearKeyCdm::LoadSession(uint32 promise_id,
270 const char* web_session_id, 269 const char* web_session_id,
271 uint32_t web_session_id_length) { 270 uint32_t web_session_id_length) {
272 DVLOG(1) << __FUNCTION__; 271 DVLOG(1) << __FUNCTION__;
273 272
274 if (std::string(kLoadableWebSessionId) != 273 if (std::string(kLoadableWebSessionId) !=
275 std::string(web_session_id, web_session_id_length)) { 274 std::string(web_session_id, web_session_id_length)) {
276 std::string message("Incorrect session id specified for LoadSession()."); 275 std::string message("Incorrect session id specified for LoadSession().");
277 host_->OnRejectPromise(promise_id, 276 host_->OnRejectPromise(promise_id,
ddorwin 2014/08/08 23:36:25 Separate CL: This should be resolved with undefine
jrummell 2014/08/11 18:59:04 Added TODO.
278 cdm::kInvalidAccessError, 277 cdm::kInvalidAccessError,
279 0, 278 0,
280 message.data(), 279 message.data(),
281 message.length()); 280 message.length());
282 return; 281 return;
283 } 282 }
284 283
285 scoped_ptr<media::NewSessionCdmPromise> promise( 284 scoped_ptr<media::NewSessionCdmPromise> promise(
286 new media::NewSessionCdmPromise(base::Bind(&ClearKeyCdm::OnSessionLoaded, 285 new media::NewSessionCdmPromise(base::Bind(&ClearKeyCdm::OnSessionLoaded,
287 base::Unretained(this), 286 base::Unretained(this),
288 promise_id), 287 promise_id),
289 base::Bind(&ClearKeyCdm::OnPromiseFailed, 288 base::Bind(&ClearKeyCdm::OnPromiseFailed,
290 base::Unretained(this), 289 base::Unretained(this),
291 promise_id))); 290 promise_id)));
292 decryptor_.CreateSession(std::string(kLoadableSessionContentType), 291 decryptor_.CreateSession(std::string(kLoadableSessionContentType),
293 NULL, 292 NULL,
294 0, 293 0,
295 MediaKeys::TEMPORARY_SESSION, 294 MediaKeys::TEMPORARY_SESSION,
296 promise.Pass()); 295 promise.Pass());
297 } 296 }
298 297
299 void ClearKeyCdm::UpdateSession(uint32 promise_id, 298 void ClearKeyCdm::UpdateSession(uint32 promise_id,
300 const char* web_session_id, 299 const char* web_session_id,
301 uint32_t web_session_id_size, 300 uint32_t web_session_id_length,
302 const uint8* response, 301 const uint8* response,
303 uint32 response_size) { 302 uint32 response_size) {
304 DVLOG(1) << __FUNCTION__; 303 DVLOG(1) << __FUNCTION__;
305 std::string web_session_str(web_session_id, web_session_id_size); 304 std::string web_session_str(web_session_id, web_session_id_length);
306 305
307 scoped_ptr<media::SimpleCdmPromise> promise(new media::SimpleCdmPromise( 306 scoped_ptr<media::SimpleCdmPromise> promise(new media::SimpleCdmPromise(
308 base::Bind(&ClearKeyCdm::OnSessionUpdated, 307 base::Bind(&ClearKeyCdm::OnSessionUpdated,
309 base::Unretained(this), 308 base::Unretained(this),
310 promise_id, 309 promise_id,
311 web_session_str), 310 web_session_str),
312 base::Bind( 311 base::Bind(
313 &ClearKeyCdm::OnPromiseFailed, base::Unretained(this), promise_id))); 312 &ClearKeyCdm::OnPromiseFailed, base::Unretained(this), promise_id)));
314 decryptor_.UpdateSession( 313 decryptor_.UpdateSession(
315 web_session_str, response, response_size, promise.Pass()); 314 web_session_str, response, response_size, promise.Pass());
316 315
317 if (!heartbeat_timer_set_) { 316 if (!heartbeat_timer_set_) {
318 ScheduleNextHeartBeat(); 317 ScheduleNextHeartBeat();
319 heartbeat_timer_set_ = true; 318 heartbeat_timer_set_ = true;
320 } 319 }
321 } 320 }
322 321
323 void ClearKeyCdm::ReleaseSession(uint32 promise_id, 322 void ClearKeyCdm::CloseSession(uint32 promise_id,
324 const char* web_session_id, 323 const char* web_session_id,
325 uint32_t web_session_id_size) { 324 uint32_t web_session_id_length) {
326 DVLOG(1) << __FUNCTION__; 325 DVLOG(1) << __FUNCTION__;
327 std::string web_session_str(web_session_id, web_session_id_size); 326 std::string web_session_str(web_session_id, web_session_id_length);
328 327
329 scoped_ptr<media::SimpleCdmPromise> promise(new media::SimpleCdmPromise( 328 scoped_ptr<media::SimpleCdmPromise> promise(new media::SimpleCdmPromise(
330 base::Bind(&ClearKeyCdm::OnSessionReleased, 329 base::Bind(&ClearKeyCdm::OnSessionReleased,
331 base::Unretained(this), 330 base::Unretained(this),
332 promise_id, 331 promise_id,
333 web_session_str), 332 web_session_str),
334 base::Bind( 333 base::Bind(
335 &ClearKeyCdm::OnPromiseFailed, base::Unretained(this), promise_id))); 334 &ClearKeyCdm::OnPromiseFailed, base::Unretained(this), promise_id)));
336 decryptor_.ReleaseSession(web_session_str, promise.Pass()); 335 decryptor_.ReleaseSession(web_session_str, promise.Pass());
337 } 336 }
338 337
338 void ClearKeyCdm::RemoveSession(uint32 promise_id,
339 const char* web_session_id,
340 uint32_t web_session_id_length) {
341 DVLOG(1) << __FUNCTION__;
342 // RemoveSession only allowed for the simulated loadable session.
ddorwin 2014/08/08 23:36:25 Really, the session must be persistent. How about
jrummell 2014/08/11 18:59:04 Done.
343 if (std::string(kLoadableWebSessionId) ==
344 std::string(web_session_id, web_session_id_length)) {
345 host_->OnResolvePromise(promise_id);
346 } else {
347 std::string message("Incorrect session id specified for RemoveSession().");
ddorwin 2014/08/08 23:36:25 "Not supported for non-persistent sessions."
jrummell 2014/08/11 18:59:04 Done.
348 host_->OnRejectPromise(promise_id,
349 cdm::kInvalidAccessError,
350 0,
351 message.data(),
352 message.length());
353 }
354 }
355
339 void ClearKeyCdm::SetServerCertificate(uint32 promise_id, 356 void ClearKeyCdm::SetServerCertificate(uint32 promise_id,
340 const uint8_t* server_certificate_data, 357 const uint8_t* server_certificate_data,
341 uint32_t server_certificate_data_size) { 358 uint32_t server_certificate_data_size) {
342 // ClearKey doesn't use a server certificate. 359 // ClearKey doesn't use a server certificate.
343 host_->OnResolvePromise(promise_id); 360 host_->OnResolvePromise(promise_id);
344 } 361 }
345 362
363 void ClearKeyCdm::GetUsableKeyIds(uint32_t promise_id,
364 const char* web_session_id,
365 uint32_t web_session_id_length) {
366 std::string web_session_str(web_session_id, web_session_id_length);
367 scoped_ptr<media::KeyIdsPromise> promise(new media::KeyIdsPromise(
368 base::Bind(&ClearKeyCdm::OnUsableKeyIdsObtained,
369 base::Unretained(this),
370 promise_id),
371 base::Bind(
372 &ClearKeyCdm::OnPromiseFailed, base::Unretained(this), promise_id)));
373 decryptor_.GetUsableKeyIds(web_session_str, promise.Pass());
374 }
375
346 void ClearKeyCdm::TimerExpired(void* context) { 376 void ClearKeyCdm::TimerExpired(void* context) {
347 if (context == &session_id_for_emulated_loadsession_) { 377 if (context == &session_id_for_emulated_loadsession_) {
348 LoadLoadableSession(); 378 LoadLoadableSession();
349 return; 379 return;
350 } 380 }
351 381
352 DCHECK(heartbeat_timer_set_); 382 DCHECK(heartbeat_timer_set_);
353 std::string heartbeat_message; 383 std::string heartbeat_message;
354 if (!next_heartbeat_message_.empty() && 384 if (!next_heartbeat_message_.empty() &&
355 context == &next_heartbeat_message_[0]) { 385 context == &next_heartbeat_message_[0]) {
(...skipping 18 matching lines...) Expand all
374 404
375 static void CopyDecryptResults( 405 static void CopyDecryptResults(
376 media::Decryptor::Status* status_copy, 406 media::Decryptor::Status* status_copy,
377 scoped_refptr<media::DecoderBuffer>* buffer_copy, 407 scoped_refptr<media::DecoderBuffer>* buffer_copy,
378 media::Decryptor::Status status, 408 media::Decryptor::Status status,
379 const scoped_refptr<media::DecoderBuffer>& buffer) { 409 const scoped_refptr<media::DecoderBuffer>& buffer) {
380 *status_copy = status; 410 *status_copy = status;
381 *buffer_copy = buffer; 411 *buffer_copy = buffer;
382 } 412 }
383 413
384 cdm::Status ClearKeyCdm::Decrypt(const cdm::InputBuffer_1& encrypted_buffer, 414 cdm::Status ClearKeyCdm::Decrypt(const cdm::InputBuffer& encrypted_buffer,
385 cdm::DecryptedBlock* decrypted_block) { 415 cdm::DecryptedBlock* decrypted_block) {
386 DVLOG(1) << "Decrypt()"; 416 DVLOG(1) << "Decrypt()";
387 DCHECK(encrypted_buffer.data); 417 DCHECK(encrypted_buffer.data);
388 418
389 scoped_refptr<media::DecoderBuffer> buffer; 419 scoped_refptr<media::DecoderBuffer> buffer;
390 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer); 420 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer);
391 421
392 if (status != cdm::kSuccess) 422 if (status != cdm::kSuccess)
393 return status; 423 return status;
394 424
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 output_timestamp_base_in_microseconds_ = kNoTimestamp; 510 output_timestamp_base_in_microseconds_ = kNoTimestamp;
481 total_samples_generated_ = 0; 511 total_samples_generated_ = 0;
482 #endif 512 #endif
483 break; 513 break;
484 default: 514 default:
485 NOTREACHED() << "DeinitializeDecoder(): invalid cdm::StreamType"; 515 NOTREACHED() << "DeinitializeDecoder(): invalid cdm::StreamType";
486 } 516 }
487 } 517 }
488 518
489 cdm::Status ClearKeyCdm::DecryptAndDecodeFrame( 519 cdm::Status ClearKeyCdm::DecryptAndDecodeFrame(
490 const cdm::InputBuffer_1& encrypted_buffer, 520 const cdm::InputBuffer& encrypted_buffer,
491 cdm::VideoFrame* decoded_frame) { 521 cdm::VideoFrame* decoded_frame) {
492 DVLOG(1) << "DecryptAndDecodeFrame()"; 522 DVLOG(1) << "DecryptAndDecodeFrame()";
493 TRACE_EVENT0("media", "ClearKeyCdm::DecryptAndDecodeFrame"); 523 TRACE_EVENT0("media", "ClearKeyCdm::DecryptAndDecodeFrame");
494 524
495 scoped_refptr<media::DecoderBuffer> buffer; 525 scoped_refptr<media::DecoderBuffer> buffer;
496 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer); 526 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer);
497 527
498 if (status != cdm::kSuccess) 528 if (status != cdm::kSuccess)
499 return status; 529 return status;
500 530
501 const uint8_t* data = NULL; 531 const uint8_t* data = NULL;
502 int32_t size = 0; 532 int32_t size = 0;
503 int64_t timestamp = 0; 533 int64_t timestamp = 0;
504 if (!buffer->end_of_stream()) { 534 if (!buffer->end_of_stream()) {
505 data = buffer->data(); 535 data = buffer->data();
506 size = buffer->data_size(); 536 size = buffer->data_size();
507 timestamp = encrypted_buffer.timestamp; 537 timestamp = encrypted_buffer.timestamp;
508 } 538 }
509 539
510 return video_decoder_->DecodeFrame(data, size, timestamp, decoded_frame); 540 return video_decoder_->DecodeFrame(data, size, timestamp, decoded_frame);
511 } 541 }
512 542
513 cdm::Status ClearKeyCdm::DecryptAndDecodeSamples( 543 cdm::Status ClearKeyCdm::DecryptAndDecodeSamples(
514 const cdm::InputBuffer_1& encrypted_buffer, 544 const cdm::InputBuffer& encrypted_buffer,
515 cdm::AudioFrames* audio_frames) { 545 cdm::AudioFrames* audio_frames) {
516 DVLOG(1) << "DecryptAndDecodeSamples()"; 546 DVLOG(1) << "DecryptAndDecodeSamples()";
517 547
518 // Trigger a crash on purpose for testing purpose. 548 // Trigger a crash on purpose for testing purpose.
519 if (key_system_ == kExternalClearKeyCrashKeySystem) 549 if (key_system_ == kExternalClearKeyCrashKeySystem)
520 CHECK(false); 550 CHECK(false);
521 551
522 scoped_refptr<media::DecoderBuffer> buffer; 552 scoped_refptr<media::DecoderBuffer> buffer;
523 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer); 553 cdm::Status status = DecryptToMediaDecoderBuffer(encrypted_buffer, &buffer);
524 554
(...skipping 25 matching lines...) Expand all
550 580
551 void ClearKeyCdm::Destroy() { 581 void ClearKeyCdm::Destroy() {
552 DVLOG(1) << "Destroy()"; 582 DVLOG(1) << "Destroy()";
553 delete this; 583 delete this;
554 } 584 }
555 585
556 void ClearKeyCdm::ScheduleNextHeartBeat() { 586 void ClearKeyCdm::ScheduleNextHeartBeat() {
557 // Prepare the next heartbeat message and set timer. 587 // Prepare the next heartbeat message and set timer.
558 std::ostringstream msg_stream; 588 std::ostringstream msg_stream;
559 msg_stream << kHeartBeatHeader << " from ClearKey CDM set at time " 589 msg_stream << kHeartBeatHeader << " from ClearKey CDM set at time "
560 << host_->GetCurrentTime() << "."; 590 << host_->GetCurrentWallTime() << ".";
561 next_heartbeat_message_ = msg_stream.str(); 591 next_heartbeat_message_ = msg_stream.str();
562 592
563 host_->SetTimer(timer_delay_ms_, &next_heartbeat_message_[0]); 593 host_->SetTimer(timer_delay_ms_, &next_heartbeat_message_[0]);
564 594
565 // Use a smaller timer delay at start-up to facilitate testing. Increase the 595 // Use a smaller timer delay at start-up to facilitate testing. Increase the
566 // timer delay up to a limit to avoid message spam. 596 // timer delay up to a limit to avoid message spam.
567 if (timer_delay_ms_ < kMaxTimerDelayMs) 597 if (timer_delay_ms_ < kMaxTimerDelayMs)
568 timer_delay_ms_ = std::min(2 * timer_delay_ms_, kMaxTimerDelayMs); 598 timer_delay_ms_ = std::min(2 * timer_delay_ms_, kMaxTimerDelayMs);
569 } 599 }
570 600
571 cdm::Status ClearKeyCdm::DecryptToMediaDecoderBuffer( 601 cdm::Status ClearKeyCdm::DecryptToMediaDecoderBuffer(
572 const cdm::InputBuffer_1& encrypted_buffer, 602 const cdm::InputBuffer& encrypted_buffer,
573 scoped_refptr<media::DecoderBuffer>* decrypted_buffer) { 603 scoped_refptr<media::DecoderBuffer>* decrypted_buffer) {
574 DCHECK(decrypted_buffer); 604 DCHECK(decrypted_buffer);
575 scoped_refptr<media::DecoderBuffer> buffer = 605 scoped_refptr<media::DecoderBuffer> buffer =
576 CopyDecoderBufferFrom(encrypted_buffer); 606 CopyDecoderBufferFrom(encrypted_buffer);
577 607
578 if (buffer->end_of_stream()) { 608 if (buffer->end_of_stream()) {
579 *decrypted_buffer = buffer; 609 *decrypted_buffer = buffer;
580 return cdm::kSuccess; 610 return cdm::kSuccess;
581 } 611 }
582 612
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 // Defer resolving the promise until the session is loaded. 710 // Defer resolving the promise until the session is loaded.
681 promise_id_for_emulated_loadsession_ = promise_id; 711 promise_id_for_emulated_loadsession_ = promise_id;
682 712
683 // Use the address of |session_id_for_emulated_loadsession_| as the timer 713 // Use the address of |session_id_for_emulated_loadsession_| as the timer
684 // context so that we can call LoadLoadableSession() when the timer expires. 714 // context so that we can call LoadLoadableSession() when the timer expires.
685 host_->SetTimer(kDelayToLoadSessionMs, &session_id_for_emulated_loadsession_); 715 host_->SetTimer(kDelayToLoadSessionMs, &session_id_for_emulated_loadsession_);
686 } 716 }
687 717
688 void ClearKeyCdm::OnSessionUpdated(uint32 promise_id, 718 void ClearKeyCdm::OnSessionUpdated(uint32 promise_id,
689 const std::string& web_session_id) { 719 const std::string& web_session_id) {
690 // OnSessionReady() only called as success for UpdateSession(). However, 720 // UpdateSession() may be called to finish loading sessions, so handle
ddorwin 2014/08/08 23:36:25 I wonder what this means. Is itan artifact of the
jrummell 2014/08/11 18:59:04 It's part of simulating LoadSession().
691 // UpdateSession() also called to finish loading sessions, so handle
692 // appropriately. 721 // appropriately.
693 if (web_session_id == session_id_for_emulated_loadsession_) { 722 if (web_session_id == session_id_for_emulated_loadsession_) {
694 session_id_for_emulated_loadsession_ = std::string(); 723 session_id_for_emulated_loadsession_ = std::string();
ddorwin 2014/08/08 23:36:25 Separate CL: Do we need session_id_for_emulated_lo
jrummell 2014/08/11 18:59:03 I think this is needed by the simulated LoadSessio
695 // |promise_id| is the LoadSession() promise, so resolve appropriately. 724 // |promise_id| is the LoadSession() promise, so resolve appropriately.
696 host_->OnResolveNewSessionPromise( 725 host_->OnResolveNewSessionPromise(
697 promise_id, kLoadableWebSessionId, strlen(kLoadableWebSessionId)); 726 promise_id, kLoadableWebSessionId, strlen(kLoadableWebSessionId));
698 host_->OnSessionReady(kLoadableWebSessionId, strlen(kLoadableWebSessionId));
699 return; 727 return;
700 } 728 }
701 729
702 host_->OnResolvePromise(promise_id); 730 host_->OnResolvePromise(promise_id);
703 } 731 }
704 732
705 void ClearKeyCdm::OnSessionReleased(uint32 promise_id, 733 void ClearKeyCdm::OnSessionReleased(uint32 promise_id,
706 const std::string& web_session_id) { 734 const std::string& web_session_id) {
707 host_->OnResolvePromise(promise_id); 735 host_->OnResolvePromise(promise_id);
708 } 736 }
709 737
738 void ClearKeyCdm::OnUsableKeyIdsObtained(uint32 promise_id,
739 const KeyIdsVector& key_ids) {
740 scoped_ptr<cdm::BinaryData[]> result(new cdm::BinaryData[key_ids.size()]);
741 for (uint32 i = 0; i < key_ids.size(); ++i) {
742 result[i].data = key_ids[i].data();
743 result[i].length = key_ids[i].size();
744 }
745 host_->OnResolveKeyIdsPromise(promise_id, result.get(), key_ids.size());
ddorwin 2014/08/08 23:36:25 result.size()
jrummell 2014/08/11 18:59:03 Not done. No operators on scoped_ptr<T[]> return t
746 }
747
710 void ClearKeyCdm::OnPromiseFailed(uint32 promise_id, 748 void ClearKeyCdm::OnPromiseFailed(uint32 promise_id,
711 MediaKeys::Exception exception_code, 749 MediaKeys::Exception exception_code,
712 uint32 system_code, 750 uint32 system_code,
713 const std::string& error_message) { 751 const std::string& error_message) {
714 host_->OnRejectPromise(promise_id, 752 host_->OnRejectPromise(promise_id,
715 ConvertException(exception_code), 753 ConvertException(exception_code),
716 system_code, 754 system_code,
717 error_message.data(), 755 error_message.data(),
718 error_message.length()); 756 error_message.length());
719 } 757 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 host_->OnSessionMessage(last_session_id_.data(), 828 host_->OnSessionMessage(last_session_id_.data(),
791 last_session_id_.length(), 829 last_session_id_.length(),
792 message.data(), 830 message.data(),
793 message.length(), 831 message.length(),
794 NULL, 832 NULL,
795 0); 833 0);
796 file_io_test_runner_.reset(); 834 file_io_test_runner_.reset();
797 } 835 }
798 836
799 } // namespace media 837 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698