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

Side by Side Diff: media/mojo/services/mojo_cdm_service.cc

Issue 833963003: Pass key_information on SessionKeysChange message (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes Created 5 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/mojo/services/mojo_cdm_service.h" 5 #include "media/mojo/services/mojo_cdm_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "media/base/cdm_key_information.h"
8 #include "media/base/key_systems.h" 9 #include "media/base/key_systems.h"
9 #include "media/cdm/aes_decryptor.h" 10 #include "media/cdm/aes_decryptor.h"
11 #include "media/mojo/services/media_type_converters.h"
10 #include "media/mojo/services/mojo_cdm_promise.h" 12 #include "media/mojo/services/mojo_cdm_promise.h"
11 #include "mojo/common/common_type_converters.h" 13 #include "mojo/common/common_type_converters.h"
12 14
13 namespace media { 15 namespace media {
14 16
15 typedef MojoCdmPromise<> SimpleMojoCdmPromise; 17 typedef MojoCdmPromise<> SimpleMojoCdmPromise;
16 typedef MojoCdmPromise<std::string> NewSessionMojoCdmPromise; 18 typedef MojoCdmPromise<std::string> NewSessionMojoCdmPromise;
17 typedef MojoCdmPromise<std::vector<std::vector<uint8_t>>> KeyIdsMojoCdmPromise;
18 19
19 MojoCdmService::MojoCdmService(const mojo::String& key_system) 20 MojoCdmService::MojoCdmService(const mojo::String& key_system)
20 : weak_factory_(this) { 21 : weak_factory_(this) {
21 base::WeakPtr<MojoCdmService> weak_this = weak_factory_.GetWeakPtr(); 22 base::WeakPtr<MojoCdmService> weak_this = weak_factory_.GetWeakPtr();
22 if (CanUseAesDecryptor(key_system)) { 23 if (CanUseAesDecryptor(key_system)) {
23 cdm_.reset(new AesDecryptor( 24 cdm_.reset(new AesDecryptor(
24 base::Bind(&MojoCdmService::OnSessionMessage, weak_this), 25 base::Bind(&MojoCdmService::OnSessionMessage, weak_this),
25 base::Bind(&MojoCdmService::OnSessionClosed, weak_this), 26 base::Bind(&MojoCdmService::OnSessionClosed, weak_this),
26 base::Bind(&MojoCdmService::OnSessionKeysChange, weak_this))); 27 base::Bind(&MojoCdmService::OnSessionKeysChange, weak_this)));
27 } 28 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 } 105 }
105 106
106 void MojoCdmService::OnSessionMessage(const std::string& session_id, 107 void MojoCdmService::OnSessionMessage(const std::string& session_id,
107 const std::vector<uint8_t>& message, 108 const std::vector<uint8_t>& message,
108 const GURL& destination_url) { 109 const GURL& destination_url) {
109 client()->OnSessionMessage(session_id, mojo::Array<uint8_t>::From(message), 110 client()->OnSessionMessage(session_id, mojo::Array<uint8_t>::From(message),
110 mojo::String::From(destination_url)); 111 mojo::String::From(destination_url));
111 } 112 }
112 113
113 void MojoCdmService::OnSessionKeysChange(const std::string& session_id, 114 void MojoCdmService::OnSessionKeysChange(const std::string& session_id,
114 bool has_additional_usable_key) { 115 bool has_additional_usable_key,
115 client()->OnSessionKeysChange(session_id, has_additional_usable_key); 116 CdmKeysInfo keys_info) {
117 mojo::Array<mojo::CdmKeyInformationPtr> keys_data;
118 for (media::CdmKeyInformation* key : keys_info)
xhwang 2015/01/06 02:46:21 Will it work if you do: for (const auto& key : ke
jrummell 2015/01/06 17:37:04 It does, but I thought using *key on the next line
119 keys_data.push_back(mojo::CdmKeyInformation::From(*key));
120 client()->OnSessionKeysChange(session_id, has_additional_usable_key,
121 keys_data.Pass());
116 } 122 }
117 123
118 void MojoCdmService::OnSessionExpirationUpdate( 124 void MojoCdmService::OnSessionExpirationUpdate(
119 const std::string& session_id, 125 const std::string& session_id,
120 const base::Time& new_expiry_time) { 126 const base::Time& new_expiry_time) {
121 client()->OnSessionExpirationUpdate(session_id, 127 client()->OnSessionExpirationUpdate(session_id,
122 new_expiry_time.ToInternalValue()); 128 new_expiry_time.ToInternalValue());
123 } 129 }
124 130
125 void MojoCdmService::OnSessionClosed(const std::string& session_id) { 131 void MojoCdmService::OnSessionClosed(const std::string& session_id) {
126 client()->OnSessionClosed(session_id); 132 client()->OnSessionClosed(session_id);
127 } 133 }
128 134
129 void MojoCdmService::OnSessionError(const std::string& session_id, 135 void MojoCdmService::OnSessionError(const std::string& session_id,
130 MediaKeys::Exception exception, 136 MediaKeys::Exception exception,
131 uint32_t system_code, 137 uint32_t system_code,
132 const std::string& error_message) { 138 const std::string& error_message) {
133 client()->OnSessionError(session_id, 139 client()->OnSessionError(session_id,
134 static_cast<mojo::CdmException>(exception), 140 static_cast<mojo::CdmException>(exception),
135 system_code, error_message); 141 system_code, error_message);
136 } 142 }
137 143
138 } // namespace media 144 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698