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

Side by Side Diff: content/renderer/media/crypto/ppapi_decryptor.cc

Issue 105383002: Rename EME WD call parameters (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix nit Created 7 years 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 "content/renderer/media/crypto/ppapi_decryptor.h" 5 #include "content/renderer/media/crypto/ppapi_decryptor.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 base::Bind(&PpapiDecryptor::OnSessionClosed, weak_this_), 86 base::Bind(&PpapiDecryptor::OnSessionClosed, weak_this_),
87 base::Bind(&PpapiDecryptor::OnSessionError, weak_this_)); 87 base::Bind(&PpapiDecryptor::OnSessionError, weak_this_));
88 } 88 }
89 89
90 PpapiDecryptor::~PpapiDecryptor() { 90 PpapiDecryptor::~PpapiDecryptor() {
91 plugin_cdm_delegate_ = NULL; 91 plugin_cdm_delegate_ = NULL;
92 plugin_instance_ = NULL; 92 plugin_instance_ = NULL;
93 destroy_plugin_cb_.Run(); 93 destroy_plugin_cb_.Run();
94 } 94 }
95 95
96 bool PpapiDecryptor::CreateSession(uint32 reference_id, 96 bool PpapiDecryptor::CreateSession(uint32 session_id,
97 const std::string& type, 97 const std::string& type,
98 const uint8* init_data, 98 const uint8* init_data,
99 int init_data_length) { 99 int init_data_length) {
100 DVLOG(2) << __FUNCTION__; 100 DVLOG(2) << __FUNCTION__;
101 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); 101 DCHECK(render_loop_proxy_->BelongsToCurrentThread());
102 DCHECK(plugin_cdm_delegate_); 102 DCHECK(plugin_cdm_delegate_);
103 103
104 if (!plugin_cdm_delegate_->CreateSession( 104 if (!plugin_cdm_delegate_->CreateSession(
105 reference_id, type, init_data, init_data_length)) { 105 session_id, type, init_data, init_data_length)) {
106 ReportFailureToCallPlugin(reference_id); 106 ReportFailureToCallPlugin(session_id);
107 return false; 107 return false;
108 } 108 }
109 109
110 return true; 110 return true;
111 } 111 }
112 112
113 void PpapiDecryptor::UpdateSession(uint32 reference_id, 113 void PpapiDecryptor::UpdateSession(uint32 session_id,
114 const uint8* response, 114 const uint8* response,
115 int response_length) { 115 int response_length) {
116 DVLOG(2) << __FUNCTION__; 116 DVLOG(2) << __FUNCTION__;
117 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); 117 DCHECK(render_loop_proxy_->BelongsToCurrentThread());
118 118
119 if (!plugin_cdm_delegate_->UpdateSession( 119 if (!plugin_cdm_delegate_->UpdateSession(
120 reference_id, response, response_length)) 120 session_id, response, response_length))
121 ReportFailureToCallPlugin(reference_id); 121 ReportFailureToCallPlugin(session_id);
122 122
123 if (!new_audio_key_cb_.is_null()) 123 if (!new_audio_key_cb_.is_null())
124 new_audio_key_cb_.Run(); 124 new_audio_key_cb_.Run();
125 125
126 if (!new_video_key_cb_.is_null()) 126 if (!new_video_key_cb_.is_null())
127 new_video_key_cb_.Run(); 127 new_video_key_cb_.Run();
128 } 128 }
129 129
130 void PpapiDecryptor::ReleaseSession(uint32 reference_id) { 130 void PpapiDecryptor::ReleaseSession(uint32 session_id) {
131 DVLOG(2) << __FUNCTION__; 131 DVLOG(2) << __FUNCTION__;
132 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); 132 DCHECK(render_loop_proxy_->BelongsToCurrentThread());
133 133
134 if (!plugin_cdm_delegate_->ReleaseSession(reference_id)) 134 if (!plugin_cdm_delegate_->ReleaseSession(session_id))
135 ReportFailureToCallPlugin(reference_id); 135 ReportFailureToCallPlugin(session_id);
136 } 136 }
137 137
138 media::Decryptor* PpapiDecryptor::GetDecryptor() { 138 media::Decryptor* PpapiDecryptor::GetDecryptor() {
139 #if defined(GOOGLE_TV) 139 #if defined(GOOGLE_TV)
140 // Google TV only uses PpapiDecrytor as a MediaKeys and does not need the 140 // Google TV only uses PpapiDecrytor as a MediaKeys and does not need the
141 // Decryptor interface of the PpapiDecryptor. 141 // Decryptor interface of the PpapiDecryptor.
142 // Details: If we don't do this GTV will be broken. The reason is that during 142 // Details: If we don't do this GTV will be broken. The reason is that during
143 // initialization, MediaSourceDelegate tries to use DecryptingDemuxerStream 143 // initialization, MediaSourceDelegate tries to use DecryptingDemuxerStream
144 // to decrypt the stream in the renderer process (for ClearKey support). 144 // to decrypt the stream in the renderer process (for ClearKey support).
145 // However, for GTV, PpapiDecryptor cannot do decryption at all. By returning 145 // However, for GTV, PpapiDecryptor cannot do decryption at all. By returning
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 if (!render_loop_proxy_->BelongsToCurrentThread()) { 286 if (!render_loop_proxy_->BelongsToCurrentThread()) {
287 render_loop_proxy_->PostTask(FROM_HERE, base::Bind( 287 render_loop_proxy_->PostTask(FROM_HERE, base::Bind(
288 &PpapiDecryptor::DeinitializeDecoder, weak_this_, stream_type)); 288 &PpapiDecryptor::DeinitializeDecoder, weak_this_, stream_type));
289 return; 289 return;
290 } 290 }
291 291
292 DVLOG(2) << __FUNCTION__ << " - stream_type: " << stream_type; 292 DVLOG(2) << __FUNCTION__ << " - stream_type: " << stream_type;
293 plugin_cdm_delegate_->DeinitializeDecoder(stream_type); 293 plugin_cdm_delegate_->DeinitializeDecoder(stream_type);
294 } 294 }
295 295
296 void PpapiDecryptor::ReportFailureToCallPlugin(uint32 reference_id) { 296 void PpapiDecryptor::ReportFailureToCallPlugin(uint32 session_id) {
297 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); 297 DCHECK(render_loop_proxy_->BelongsToCurrentThread());
298 DVLOG(1) << "Failed to call plugin."; 298 DVLOG(1) << "Failed to call plugin.";
299 session_error_cb_.Run(reference_id, kUnknownError, 0); 299 session_error_cb_.Run(session_id, kUnknownError, 0);
300 } 300 }
301 301
302 void PpapiDecryptor::OnDecoderInitialized(StreamType stream_type, 302 void PpapiDecryptor::OnDecoderInitialized(StreamType stream_type,
303 bool success) { 303 bool success) {
304 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); 304 DCHECK(render_loop_proxy_->BelongsToCurrentThread());
305 switch (stream_type) { 305 switch (stream_type) {
306 case kAudio: 306 case kAudio:
307 DCHECK(!audio_decoder_init_cb_.is_null()); 307 DCHECK(!audio_decoder_init_cb_.is_null());
308 base::ResetAndReturn(&audio_decoder_init_cb_).Run(success); 308 base::ResetAndReturn(&audio_decoder_init_cb_).Run(success);
309 break; 309 break;
310 case kVideo: 310 case kVideo:
311 DCHECK(!video_decoder_init_cb_.is_null()); 311 DCHECK(!video_decoder_init_cb_.is_null());
312 base::ResetAndReturn(&video_decoder_init_cb_).Run(success); 312 base::ResetAndReturn(&video_decoder_init_cb_).Run(success);
313 break; 313 break;
314 default: 314 default:
315 NOTREACHED(); 315 NOTREACHED();
316 } 316 }
317 } 317 }
318 318
319 void PpapiDecryptor::OnSessionCreated(uint32 reference_id, 319 void PpapiDecryptor::OnSessionCreated(uint32 session_id,
320 const std::string& session_id) { 320 const std::string& web_session_id) {
321 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); 321 DCHECK(render_loop_proxy_->BelongsToCurrentThread());
322 session_created_cb_.Run(reference_id, session_id); 322 session_created_cb_.Run(session_id, web_session_id);
323 } 323 }
324 324
325 void PpapiDecryptor::OnSessionMessage(uint32 reference_id, 325 void PpapiDecryptor::OnSessionMessage(uint32 session_id,
326 const std::vector<uint8>& message, 326 const std::vector<uint8>& message,
327 const std::string& destination_url) { 327 const std::string& destination_url) {
328 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); 328 DCHECK(render_loop_proxy_->BelongsToCurrentThread());
329 session_message_cb_.Run(reference_id, message, destination_url); 329 session_message_cb_.Run(session_id, message, destination_url);
330 } 330 }
331 331
332 void PpapiDecryptor::OnSessionReady(uint32 reference_id) { 332 void PpapiDecryptor::OnSessionReady(uint32 session_id) {
333 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); 333 DCHECK(render_loop_proxy_->BelongsToCurrentThread());
334 session_ready_cb_.Run(reference_id); 334 session_ready_cb_.Run(session_id);
335 } 335 }
336 336
337 void PpapiDecryptor::OnSessionClosed(uint32 reference_id) { 337 void PpapiDecryptor::OnSessionClosed(uint32 session_id) {
338 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); 338 DCHECK(render_loop_proxy_->BelongsToCurrentThread());
339 session_closed_cb_.Run(reference_id); 339 session_closed_cb_.Run(session_id);
340 } 340 }
341 341
342 void PpapiDecryptor::OnSessionError(uint32 reference_id, 342 void PpapiDecryptor::OnSessionError(uint32 session_id,
343 media::MediaKeys::KeyError error_code, 343 media::MediaKeys::KeyError error_code,
344 int system_code) { 344 int system_code) {
345 DCHECK(render_loop_proxy_->BelongsToCurrentThread()); 345 DCHECK(render_loop_proxy_->BelongsToCurrentThread());
346 session_error_cb_.Run(reference_id, error_code, system_code); 346 session_error_cb_.Run(session_id, error_code, system_code);
347 } 347 }
348 348
349 } // namespace content 349 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/crypto/ppapi_decryptor.h ('k') | content/renderer/media/crypto/proxy_decryptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698