OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "webkit/media/crypto/ppapi_decryptor.h" | 5 #include "webkit/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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 110 } |
111 | 111 |
112 void PpapiDecryptor::CancelDecrypt(StreamType stream_type) { | 112 void PpapiDecryptor::CancelDecrypt(StreamType stream_type) { |
113 DVLOG(1) << "CancelDecrypt() - stream_type: " << stream_type; | 113 DVLOG(1) << "CancelDecrypt() - stream_type: " << stream_type; |
114 // TODO(xhwang): Implement CancelDecrypt() in PluginInstance and call it here. | 114 // TODO(xhwang): Implement CancelDecrypt() in PluginInstance and call it here. |
115 } | 115 } |
116 | 116 |
117 void PpapiDecryptor::InitializeAudioDecoder( | 117 void PpapiDecryptor::InitializeAudioDecoder( |
118 scoped_ptr<media::AudioDecoderConfig> config, | 118 scoped_ptr<media::AudioDecoderConfig> config, |
119 const DecoderInitCB& init_cb, | 119 const DecoderInitCB& init_cb, |
120 const KeyAddedCB& key_added_cb) { | 120 const OnKeyAddedCB& key_added_cb) { |
121 if (!render_loop_proxy_->BelongsToCurrentThread()) { | 121 if (!render_loop_proxy_->BelongsToCurrentThread()) { |
122 render_loop_proxy_->PostTask(FROM_HERE, base::Bind( | 122 render_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
123 &PpapiDecryptor::InitializeAudioDecoder, weak_this_, | 123 &PpapiDecryptor::InitializeAudioDecoder, weak_this_, |
124 base::Passed(&config), init_cb, key_added_cb)); | 124 base::Passed(&config), init_cb, key_added_cb)); |
125 return; | 125 return; |
126 } | 126 } |
127 | 127 |
128 DVLOG(2) << "InitializeAudioDecoder()"; | 128 DVLOG(2) << "InitializeAudioDecoder()"; |
129 DCHECK(config->is_encrypted()); | 129 DCHECK(config->is_encrypted()); |
130 DCHECK(config->IsValidConfig()); | 130 DCHECK(config->IsValidConfig()); |
(...skipping 10 matching lines...) Expand all Loading... |
141 base::ResetAndReturn(&audio_decoder_init_cb_).Run(false); | 141 base::ResetAndReturn(&audio_decoder_init_cb_).Run(false); |
142 #if 0 | 142 #if 0 |
143 return; | 143 return; |
144 } | 144 } |
145 #endif | 145 #endif |
146 } | 146 } |
147 | 147 |
148 void PpapiDecryptor::InitializeVideoDecoder( | 148 void PpapiDecryptor::InitializeVideoDecoder( |
149 scoped_ptr<media::VideoDecoderConfig> config, | 149 scoped_ptr<media::VideoDecoderConfig> config, |
150 const DecoderInitCB& init_cb, | 150 const DecoderInitCB& init_cb, |
151 const KeyAddedCB& key_added_cb) { | 151 const OnKeyAddedCB& key_added_cb) { |
152 if (!render_loop_proxy_->BelongsToCurrentThread()) { | 152 if (!render_loop_proxy_->BelongsToCurrentThread()) { |
153 render_loop_proxy_->PostTask(FROM_HERE, base::Bind( | 153 render_loop_proxy_->PostTask(FROM_HERE, base::Bind( |
154 &PpapiDecryptor::InitializeVideoDecoder, weak_this_, | 154 &PpapiDecryptor::InitializeVideoDecoder, weak_this_, |
155 base::Passed(&config), init_cb, key_added_cb)); | 155 base::Passed(&config), init_cb, key_added_cb)); |
156 return; | 156 return; |
157 } | 157 } |
158 | 158 |
159 DVLOG(2) << "InitializeVideoDecoder()"; | 159 DVLOG(2) << "InitializeVideoDecoder()"; |
160 DCHECK(config->is_encrypted()); | 160 DCHECK(config->is_encrypted()); |
161 DCHECK(config->IsValidConfig()); | 161 DCHECK(config->IsValidConfig()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 cdm_plugin_->DeinitializeDecoder(); | 226 cdm_plugin_->DeinitializeDecoder(); |
227 } | 227 } |
228 | 228 |
229 void PpapiDecryptor::ReportFailureToCallPlugin(const std::string& key_system, | 229 void PpapiDecryptor::ReportFailureToCallPlugin(const std::string& key_system, |
230 const std::string& session_id) { | 230 const std::string& session_id) { |
231 DVLOG(1) << "Failed to call plugin."; | 231 DVLOG(1) << "Failed to call plugin."; |
232 client_->KeyError(key_system, session_id, kUnknownError, 0); | 232 client_->KeyError(key_system, session_id, kUnknownError, 0); |
233 } | 233 } |
234 | 234 |
235 void PpapiDecryptor::OnDecoderInitialized(StreamType stream_type, | 235 void PpapiDecryptor::OnDecoderInitialized(StreamType stream_type, |
236 const KeyAddedCB& key_added_cb, | 236 const OnKeyAddedCB& key_added_cb, |
237 bool success) { | 237 bool success) { |
238 DCHECK(!key_added_cb.is_null()); | 238 DCHECK(!key_added_cb.is_null()); |
239 | 239 |
240 switch (stream_type) { | 240 switch (stream_type) { |
241 case kAudio: | 241 case kAudio: |
242 DCHECK(audio_key_added_cb_.is_null()); | 242 DCHECK(audio_key_added_cb_.is_null()); |
243 DCHECK(!audio_decoder_init_cb_.is_null()); | 243 DCHECK(!audio_decoder_init_cb_.is_null()); |
244 if (success) | 244 if (success) |
245 audio_key_added_cb_ = key_added_cb; | 245 audio_key_added_cb_ = key_added_cb; |
246 base::ResetAndReturn(&audio_decoder_init_cb_).Run(success); | 246 base::ResetAndReturn(&audio_decoder_init_cb_).Run(success); |
247 break; | 247 break; |
248 | 248 |
249 case kVideo: | 249 case kVideo: |
250 DCHECK(video_key_added_cb_.is_null()); | 250 DCHECK(video_key_added_cb_.is_null()); |
251 DCHECK(!video_decoder_init_cb_.is_null()); | 251 DCHECK(!video_decoder_init_cb_.is_null()); |
252 if (success) | 252 if (success) |
253 video_key_added_cb_ = key_added_cb; | 253 video_key_added_cb_ = key_added_cb; |
254 base::ResetAndReturn(&video_decoder_init_cb_).Run(success); | 254 base::ResetAndReturn(&video_decoder_init_cb_).Run(success); |
255 break; | 255 break; |
256 | 256 |
257 default: | 257 default: |
258 NOTREACHED(); | 258 NOTREACHED(); |
259 } | 259 } |
260 } | 260 } |
261 | 261 |
262 } // namespace webkit_media | 262 } // namespace webkit_media |
OLD | NEW |