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

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

Issue 555223004: Update MediaKeys interface for EME (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reorder Created 6 years, 3 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 } 213 }
214 214
215 const char* GetCdmVersion() { 215 const char* GetCdmVersion() {
216 return kClearKeyCdmVersion; 216 return kClearKeyCdmVersion;
217 } 217 }
218 218
219 namespace media { 219 namespace media {
220 220
221 ClearKeyCdm::ClearKeyCdm(ClearKeyCdmHost* host, const std::string& key_system) 221 ClearKeyCdm::ClearKeyCdm(ClearKeyCdmHost* host, const std::string& key_system)
222 : decryptor_( 222 : decryptor_(
223 base::Bind(&ClearKeyCdm::OnSessionMessage, base::Unretained(this)), 223 base::Bind(&ClearKeyCdm::OnSessionMessage, base::Unretained(this)),
224 base::Bind(&ClearKeyCdm::OnSessionClosed, base::Unretained(this))), 224 base::Bind(&ClearKeyCdm::OnSessionClosed, base::Unretained(this)),
225 base::Bind(&ClearKeyCdm::OnSessionKeysChange,
226 base::Unretained(this))),
225 host_(host), 227 host_(host),
226 key_system_(key_system), 228 key_system_(key_system),
227 timer_delay_ms_(kInitialTimerDelayMs), 229 timer_delay_ms_(kInitialTimerDelayMs),
228 heartbeat_timer_set_(false) { 230 heartbeat_timer_set_(false) {
229 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER) 231 #if defined(CLEAR_KEY_CDM_USE_FAKE_AUDIO_DECODER)
230 channel_count_ = 0; 232 channel_count_ = 0;
231 bits_per_channel_ = 0; 233 bits_per_channel_ = 0;
232 samples_per_second_ = 0; 234 samples_per_second_ = 0;
233 output_timestamp_base_in_microseconds_ = kNoTimestamp; 235 output_timestamp_base_in_microseconds_ = kNoTimestamp;
234 total_samples_generated_ = 0; 236 total_samples_generated_ = 0;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 322 }
321 } 323 }
322 324
323 void ClearKeyCdm::CloseSession(uint32 promise_id, 325 void ClearKeyCdm::CloseSession(uint32 promise_id,
324 const char* web_session_id, 326 const char* web_session_id,
325 uint32_t web_session_id_length) { 327 uint32_t web_session_id_length) {
326 DVLOG(1) << __FUNCTION__; 328 DVLOG(1) << __FUNCTION__;
327 std::string web_session_str(web_session_id, web_session_id_length); 329 std::string web_session_str(web_session_id, web_session_id_length);
328 330
329 scoped_ptr<media::SimpleCdmPromise> promise(new media::SimpleCdmPromise( 331 scoped_ptr<media::SimpleCdmPromise> promise(new media::SimpleCdmPromise(
330 base::Bind(&ClearKeyCdm::OnSessionReleased, 332 base::Bind(
331 base::Unretained(this), 333 &ClearKeyCdm::OnPromiseResolved, base::Unretained(this), promise_id),
332 promise_id,
333 web_session_str),
334 base::Bind( 334 base::Bind(
335 &ClearKeyCdm::OnPromiseFailed, base::Unretained(this), promise_id))); 335 &ClearKeyCdm::OnPromiseFailed, base::Unretained(this), promise_id)));
336 decryptor_.ReleaseSession(web_session_str, promise.Pass()); 336 decryptor_.CloseSession(web_session_str, promise.Pass());
337 } 337 }
338 338
339 void ClearKeyCdm::RemoveSession(uint32 promise_id, 339 void ClearKeyCdm::RemoveSession(uint32 promise_id,
340 const char* web_session_id, 340 const char* web_session_id,
341 uint32_t web_session_id_length) { 341 uint32_t web_session_id_length) {
342 DVLOG(1) << __FUNCTION__; 342 DVLOG(1) << __FUNCTION__;
343 // RemoveSession only allowed for persistent sessions. 343 // RemoveSession only allowed for persistent sessions.
344 bool is_persistent_session = 344 bool is_persistent_session =
345 std::string(kLoadableWebSessionId) == 345 std::string(kLoadableWebSessionId) ==
346 std::string(web_session_id, web_session_id_length); 346 std::string(web_session_id, web_session_id_length);
347 if (is_persistent_session) { 347 if (is_persistent_session) {
348 host_->OnResolvePromise(promise_id); 348 std::string web_session_str(web_session_id, web_session_id_length);
349
350 scoped_ptr<media::SimpleCdmPromise> promise(
351 new media::SimpleCdmPromise(base::Bind(&ClearKeyCdm::OnPromiseResolved,
352 base::Unretained(this),
353 promise_id),
354 base::Bind(&ClearKeyCdm::OnPromiseFailed,
355 base::Unretained(this),
356 promise_id)));
357 decryptor_.RemoveSession(web_session_str, promise.Pass());
ddorwin 2014/09/12 21:46:31 We're implementing persistent session support on a
jrummell 2014/09/15 18:22:41 The problem with calling close() is that it will r
349 } else { 358 } else {
350 std::string message("Not supported for non-persistent sessions."); 359 std::string message("Not supported for non-persistent sessions.");
351 host_->OnRejectPromise(promise_id, 360 host_->OnRejectPromise(promise_id,
ddorwin 2014/09/12 21:46:31 This should be a DCHECK once session type is moved
jrummell 2014/09/15 18:22:41 Done.
352 cdm::kInvalidAccessError, 361 cdm::kInvalidAccessError,
353 0, 362 0,
354 message.data(), 363 message.data(),
355 message.length()); 364 message.length());
356 } 365 }
357 } 366 }
358 367
359 void ClearKeyCdm::SetServerCertificate(uint32 promise_id, 368 void ClearKeyCdm::SetServerCertificate(uint32 promise_id,
360 const uint8_t* server_certificate_data, 369 const uint8_t* server_certificate_data,
361 uint32_t server_certificate_data_size) { 370 uint32_t server_certificate_data_size) {
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
676 // involved (OnSessionCreated() called to resolve the CreateSession() 685 // involved (OnSessionCreated() called to resolve the CreateSession()
677 // promise). 686 // promise).
678 host_->OnSessionMessage(web_session_id.data(), 687 host_->OnSessionMessage(web_session_id.data(),
679 web_session_id.length(), 688 web_session_id.length(),
680 reinterpret_cast<const char*>(message.data()), 689 reinterpret_cast<const char*>(message.data()),
681 message.size(), 690 message.size(),
682 destination_url.spec().data(), 691 destination_url.spec().data(),
683 destination_url.spec().size()); 692 destination_url.spec().size());
684 } 693 }
685 694
695 void ClearKeyCdm::OnSessionKeysChange(const std::string& web_session_id,
696 bool has_additional_usable_key) {
697 host_->OnSessionUsableKeysChange(web_session_id.data(),
698 web_session_id.length(),
699 has_additional_usable_key);
700 }
701
686 void ClearKeyCdm::OnSessionClosed(const std::string& web_session_id) { 702 void ClearKeyCdm::OnSessionClosed(const std::string& web_session_id) {
687 host_->OnSessionClosed(web_session_id.data(), web_session_id.length()); 703 host_->OnSessionClosed(web_session_id.data(), web_session_id.length());
688 } 704 }
689 705
690 void ClearKeyCdm::OnSessionCreated(uint32 promise_id, 706 void ClearKeyCdm::OnSessionCreated(uint32 promise_id,
691 const std::string& web_session_id) { 707 const std::string& web_session_id) {
692 // Save the latest session ID for heartbeat and file IO test messages. 708 // Save the latest session ID for heartbeat and file IO test messages.
693 last_session_id_ = web_session_id; 709 last_session_id_ = web_session_id;
694 710
695 host_->OnResolveNewSessionPromise( 711 host_->OnResolveNewSessionPromise(
(...skipping 30 matching lines...) Expand all
726 session_id_for_emulated_loadsession_ = std::string(); 742 session_id_for_emulated_loadsession_ = std::string();
727 // |promise_id| is the LoadSession() promise, so resolve appropriately. 743 // |promise_id| is the LoadSession() promise, so resolve appropriately.
728 host_->OnResolveNewSessionPromise( 744 host_->OnResolveNewSessionPromise(
729 promise_id, kLoadableWebSessionId, strlen(kLoadableWebSessionId)); 745 promise_id, kLoadableWebSessionId, strlen(kLoadableWebSessionId));
730 return; 746 return;
731 } 747 }
732 748
733 host_->OnResolvePromise(promise_id); 749 host_->OnResolvePromise(promise_id);
734 } 750 }
735 751
736 void ClearKeyCdm::OnSessionReleased(uint32 promise_id,
737 const std::string& web_session_id) {
738 host_->OnResolvePromise(promise_id);
739 }
740
741 void ClearKeyCdm::OnUsableKeyIdsObtained(uint32 promise_id, 752 void ClearKeyCdm::OnUsableKeyIdsObtained(uint32 promise_id,
742 const KeyIdsVector& key_ids) { 753 const KeyIdsVector& key_ids) {
743 scoped_ptr<cdm::BinaryData[]> result(new cdm::BinaryData[key_ids.size()]); 754 scoped_ptr<cdm::BinaryData[]> result(new cdm::BinaryData[key_ids.size()]);
744 for (uint32 i = 0; i < key_ids.size(); ++i) { 755 for (uint32 i = 0; i < key_ids.size(); ++i) {
745 result[i].data = key_ids[i].data(); 756 result[i].data = key_ids[i].data();
746 result[i].length = key_ids[i].size(); 757 result[i].length = key_ids[i].size();
747 } 758 }
748 host_->OnResolveKeyIdsPromise(promise_id, result.get(), key_ids.size()); 759 host_->OnResolveKeyIdsPromise(promise_id, result.get(), key_ids.size());
749 } 760 }
750 761
762 void ClearKeyCdm::OnPromiseResolved(uint32 promise_id) {
763 host_->OnResolvePromise(promise_id);
764 }
765
751 void ClearKeyCdm::OnPromiseFailed(uint32 promise_id, 766 void ClearKeyCdm::OnPromiseFailed(uint32 promise_id,
752 MediaKeys::Exception exception_code, 767 MediaKeys::Exception exception_code,
753 uint32 system_code, 768 uint32 system_code,
754 const std::string& error_message) { 769 const std::string& error_message) {
755 host_->OnRejectPromise(promise_id, 770 host_->OnRejectPromise(promise_id,
756 ConvertException(exception_code), 771 ConvertException(exception_code),
757 system_code, 772 system_code,
758 error_message.data(), 773 error_message.data(),
759 error_message.length()); 774 error_message.length());
760 } 775 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 host_->OnSessionMessage(last_session_id_.data(), 846 host_->OnSessionMessage(last_session_id_.data(),
832 last_session_id_.length(), 847 last_session_id_.length(),
833 message.data(), 848 message.data(),
834 message.length(), 849 message.length(),
835 NULL, 850 NULL,
836 0); 851 0);
837 file_io_test_runner_.reset(); 852 file_io_test_runner_.reset();
838 } 853 }
839 854
840 } // namespace media 855 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698