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

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

Issue 2425663003: media: Use native CDM enum types in media mojo interfaces (Closed)
Patch Set: comments addressed Created 4 years, 2 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
« no previous file with comments | « media/mojo/services/mojo_cdm_service.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 120
121 void MojoCdmService::SetServerCertificate( 121 void MojoCdmService::SetServerCertificate(
122 const std::vector<uint8_t>& certificate_data, 122 const std::vector<uint8_t>& certificate_data,
123 const SetServerCertificateCallback& callback) { 123 const SetServerCertificateCallback& callback) {
124 DVLOG(2) << __FUNCTION__; 124 DVLOG(2) << __FUNCTION__;
125 cdm_->SetServerCertificate(certificate_data, 125 cdm_->SetServerCertificate(certificate_data,
126 base::MakeUnique<SimpleMojoCdmPromise>(callback)); 126 base::MakeUnique<SimpleMojoCdmPromise>(callback));
127 } 127 }
128 128
129 void MojoCdmService::CreateSessionAndGenerateRequest( 129 void MojoCdmService::CreateSessionAndGenerateRequest(
130 mojom::ContentDecryptionModule::SessionType session_type, 130 SessionType session_type,
131 mojom::ContentDecryptionModule::InitDataType init_data_type, 131 EmeInitDataType init_data_type,
132 const std::vector<uint8_t>& init_data, 132 const std::vector<uint8_t>& init_data,
133 const CreateSessionAndGenerateRequestCallback& callback) { 133 const CreateSessionAndGenerateRequestCallback& callback) {
134 DVLOG(2) << __FUNCTION__; 134 DVLOG(2) << __FUNCTION__;
135 cdm_->CreateSessionAndGenerateRequest( 135 cdm_->CreateSessionAndGenerateRequest(
136 static_cast<MediaKeys::SessionType>(session_type), 136 session_type, init_data_type, init_data,
137 static_cast<EmeInitDataType>(init_data_type), init_data,
138 base::MakeUnique<NewSessionMojoCdmPromise>(callback)); 137 base::MakeUnique<NewSessionMojoCdmPromise>(callback));
139 } 138 }
140 139
141 void MojoCdmService::LoadSession( 140 void MojoCdmService::LoadSession(SessionType session_type,
142 mojom::ContentDecryptionModule::SessionType session_type, 141 const std::string& session_id,
143 const std::string& session_id, 142 const LoadSessionCallback& callback) {
144 const LoadSessionCallback& callback) {
145 DVLOG(2) << __FUNCTION__; 143 DVLOG(2) << __FUNCTION__;
146 cdm_->LoadSession(static_cast<MediaKeys::SessionType>(session_type), 144 cdm_->LoadSession(session_type, session_id,
147 session_id,
148 base::MakeUnique<NewSessionMojoCdmPromise>(callback)); 145 base::MakeUnique<NewSessionMojoCdmPromise>(callback));
149 } 146 }
150 147
151 void MojoCdmService::UpdateSession(const std::string& session_id, 148 void MojoCdmService::UpdateSession(const std::string& session_id,
152 const std::vector<uint8_t>& response, 149 const std::vector<uint8_t>& response,
153 const UpdateSessionCallback& callback) { 150 const UpdateSessionCallback& callback) {
154 DVLOG(2) << __FUNCTION__; 151 DVLOG(2) << __FUNCTION__;
155 cdm_->UpdateSession( 152 cdm_->UpdateSession(
156 session_id, response, 153 session_id, response,
157 std::unique_ptr<SimpleCdmPromise>(new SimpleMojoCdmPromise(callback))); 154 std::unique_ptr<SimpleCdmPromise>(new SimpleMojoCdmPromise(callback)));
(...skipping 19 matching lines...) Expand all
177 174
178 void MojoCdmService::OnCdmCreated(const InitializeCallback& callback, 175 void MojoCdmService::OnCdmCreated(const InitializeCallback& callback,
179 const scoped_refptr<MediaKeys>& cdm, 176 const scoped_refptr<MediaKeys>& cdm,
180 const std::string& error_message) { 177 const std::string& error_message) {
181 mojom::CdmPromiseResultPtr cdm_promise_result(mojom::CdmPromiseResult::New()); 178 mojom::CdmPromiseResultPtr cdm_promise_result(mojom::CdmPromiseResult::New());
182 179
183 // TODO(xhwang): This should not happen when KeySystemInfo is properly 180 // TODO(xhwang): This should not happen when KeySystemInfo is properly
184 // populated. See http://crbug.com/469366 181 // populated. See http://crbug.com/469366
185 if (!cdm || !context_) { 182 if (!cdm || !context_) {
186 cdm_promise_result->success = false; 183 cdm_promise_result->success = false;
187 cdm_promise_result->exception = mojom::CdmException::NOT_SUPPORTED_ERROR; 184 cdm_promise_result->exception = MediaKeys::Exception::NOT_SUPPORTED_ERROR;
188 cdm_promise_result->system_code = 0; 185 cdm_promise_result->system_code = 0;
189 cdm_promise_result->error_message = error_message; 186 cdm_promise_result->error_message = error_message;
190 callback.Run(std::move(cdm_promise_result), 0, nullptr); 187 callback.Run(std::move(cdm_promise_result), 0, nullptr);
191 return; 188 return;
192 } 189 }
193 190
194 cdm_ = cdm; 191 cdm_ = cdm;
195 cdm_id_ = next_cdm_id_++; 192 cdm_id_ = next_cdm_id_++;
196 193
197 context_->RegisterCdm(cdm_id_, this); 194 context_->RegisterCdm(cdm_id_, this);
(...skipping 14 matching lines...) Expand all
212 DVLOG(1) << __FUNCTION__ << ": CDM successfully created with ID " << cdm_id_; 209 DVLOG(1) << __FUNCTION__ << ": CDM successfully created with ID " << cdm_id_;
213 cdm_promise_result->success = true; 210 cdm_promise_result->success = true;
214 callback.Run(std::move(cdm_promise_result), cdm_id_, 211 callback.Run(std::move(cdm_promise_result), cdm_id_,
215 std::move(decryptor_service)); 212 std::move(decryptor_service));
216 } 213 }
217 214
218 void MojoCdmService::OnSessionMessage(const std::string& session_id, 215 void MojoCdmService::OnSessionMessage(const std::string& session_id,
219 MediaKeys::MessageType message_type, 216 MediaKeys::MessageType message_type,
220 const std::vector<uint8_t>& message) { 217 const std::vector<uint8_t>& message) {
221 DVLOG(2) << __FUNCTION__ << "(" << message_type << ")"; 218 DVLOG(2) << __FUNCTION__ << "(" << message_type << ")";
222 client_->OnSessionMessage( 219 client_->OnSessionMessage(session_id, message_type, message);
223 session_id, static_cast<mojom::CdmMessageType>(message_type), message);
224 } 220 }
225 221
226 void MojoCdmService::OnSessionKeysChange(const std::string& session_id, 222 void MojoCdmService::OnSessionKeysChange(const std::string& session_id,
227 bool has_additional_usable_key, 223 bool has_additional_usable_key,
228 CdmKeysInfo keys_info) { 224 CdmKeysInfo keys_info) {
229 DVLOG(2) << __FUNCTION__ 225 DVLOG(2) << __FUNCTION__
230 << " has_additional_usable_key=" << has_additional_usable_key; 226 << " has_additional_usable_key=" << has_additional_usable_key;
231 227
232 std::vector<mojom::CdmKeyInformationPtr> keys_data; 228 std::vector<mojom::CdmKeyInformationPtr> keys_data;
233 for (auto* key : keys_info) 229 for (auto* key : keys_info)
(...skipping 17 matching lines...) Expand all
251 247
252 void MojoCdmService::OnDecryptorConnectionError() { 248 void MojoCdmService::OnDecryptorConnectionError() {
253 DVLOG(2) << __FUNCTION__; 249 DVLOG(2) << __FUNCTION__;
254 250
255 // MojoDecryptorService has lost connectivity to it's client, so it can be 251 // MojoDecryptorService has lost connectivity to it's client, so it can be
256 // freed. 252 // freed.
257 decryptor_.reset(); 253 decryptor_.reset();
258 } 254 }
259 255
260 } // namespace media 256 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_cdm_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698