| 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 "media/filters/decrypting_video_decoder.h" | 5 #include "media/filters/decrypting_video_decoder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 129 |
| 130 // Invalidate all weak pointers so that pending callbacks won't be fired into | 130 // Invalidate all weak pointers so that pending callbacks won't be fired into |
| 131 // this object. | 131 // this object. |
| 132 weak_factory_.InvalidateWeakPtrs(); | 132 weak_factory_.InvalidateWeakPtrs(); |
| 133 | 133 |
| 134 // At this point the render thread is likely paused (in WebMediaPlayerImpl's | 134 // At this point the render thread is likely paused (in WebMediaPlayerImpl's |
| 135 // Destroy()), so running |closure| can't wait for anything that requires the | 135 // Destroy()), so running |closure| can't wait for anything that requires the |
| 136 // render thread to be processing messages to complete (such as PPAPI | 136 // render thread to be processing messages to complete (such as PPAPI |
| 137 // callbacks). | 137 // callbacks). |
| 138 if (decryptor_) { | 138 if (decryptor_) { |
| 139 decryptor_->RegisterNewKeyCB(Decryptor::kVideo, Decryptor::NewKeyCB()); | |
| 140 decryptor_->DeinitializeDecoder(Decryptor::kVideo); | 139 decryptor_->DeinitializeDecoder(Decryptor::kVideo); |
| 141 decryptor_ = NULL; | 140 decryptor_ = NULL; |
| 142 } | 141 } |
| 143 if (!set_decryptor_ready_cb_.is_null()) | 142 if (!set_decryptor_ready_cb_.is_null()) |
| 144 base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB()); | 143 base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB()); |
| 145 pending_buffer_to_decode_ = NULL; | 144 pending_buffer_to_decode_ = NULL; |
| 146 if (!init_cb_.is_null()) | 145 if (!init_cb_.is_null()) |
| 147 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); | 146 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); |
| 148 if (!decode_cb_.is_null()) | 147 if (!decode_cb_.is_null()) |
| 149 base::ResetAndReturn(&decode_cb_).Run(kAborted, NULL); | 148 base::ResetAndReturn(&decode_cb_).Run(kAborted, NULL); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 DCHECK(!init_cb_.is_null()); | 187 DCHECK(!init_cb_.is_null()); |
| 189 DCHECK(reset_cb_.is_null()); // No Reset() before initialization finished. | 188 DCHECK(reset_cb_.is_null()); // No Reset() before initialization finished. |
| 190 DCHECK(decode_cb_.is_null()); // No Decode() before initialization finished. | 189 DCHECK(decode_cb_.is_null()); // No Decode() before initialization finished. |
| 191 | 190 |
| 192 if (!success) { | 191 if (!success) { |
| 193 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); | 192 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); |
| 194 state_ = kStopped; | 193 state_ = kStopped; |
| 195 return; | 194 return; |
| 196 } | 195 } |
| 197 | 196 |
| 198 decryptor_->RegisterNewKeyCB(Decryptor::kVideo, BindToCurrentLoop( | 197 decryptor_->RegisterNewKeyCB( |
| 199 base::Bind(&DecryptingVideoDecoder::OnKeyAdded, weak_this_))); | 198 Decryptor::kVideo, |
| 199 BindToCurrentLoop( |
| 200 base::Bind(&DecryptingVideoDecoder::OnKeyAdded, weak_this_))); |
| 200 | 201 |
| 201 // Success! | 202 // Success! |
| 202 state_ = kIdle; | 203 state_ = kIdle; |
| 203 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); | 204 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); |
| 204 } | 205 } |
| 205 | 206 |
| 206 | 207 |
| 207 void DecryptingVideoDecoder::DecodePendingBuffer() { | 208 void DecryptingVideoDecoder::DecodePendingBuffer() { |
| 208 DCHECK(task_runner_->BelongsToCurrentThread()); | 209 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 209 DCHECK_EQ(state_, kPendingDecode) << state_; | 210 DCHECK_EQ(state_, kPendingDecode) << state_; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 } | 309 } |
| 309 | 310 |
| 310 void DecryptingVideoDecoder::DoReset() { | 311 void DecryptingVideoDecoder::DoReset() { |
| 311 DCHECK(init_cb_.is_null()); | 312 DCHECK(init_cb_.is_null()); |
| 312 DCHECK(decode_cb_.is_null()); | 313 DCHECK(decode_cb_.is_null()); |
| 313 state_ = kIdle; | 314 state_ = kIdle; |
| 314 base::ResetAndReturn(&reset_cb_).Run(); | 315 base::ResetAndReturn(&reset_cb_).Run(); |
| 315 } | 316 } |
| 316 | 317 |
| 317 } // namespace media | 318 } // namespace media |
| OLD | NEW |