| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // after the decode callback is fired - see DecryptAndDecodeBuffer() and | 109 // after the decode callback is fired - see DecryptAndDecodeBuffer() and |
| 110 // DeliverFrame(). | 110 // DeliverFrame(). |
| 111 if (state_ == kPendingDecode) { | 111 if (state_ == kPendingDecode) { |
| 112 DCHECK(!decode_cb_.is_null()); | 112 DCHECK(!decode_cb_.is_null()); |
| 113 return; | 113 return; |
| 114 } | 114 } |
| 115 | 115 |
| 116 if (state_ == kWaitingForKey) { | 116 if (state_ == kWaitingForKey) { |
| 117 DCHECK(!decode_cb_.is_null()); | 117 DCHECK(!decode_cb_.is_null()); |
| 118 pending_buffer_to_decode_ = NULL; | 118 pending_buffer_to_decode_ = NULL; |
| 119 base::ResetAndReturn(&decode_cb_).Run(kOk, NULL); | 119 base::ResetAndReturn(&decode_cb_).Run(kAborted, NULL); |
| 120 } | 120 } |
| 121 | 121 |
| 122 DCHECK(decode_cb_.is_null()); | 122 DCHECK(decode_cb_.is_null()); |
| 123 DoReset(); | 123 DoReset(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void DecryptingVideoDecoder::Stop(const base::Closure& closure) { | 126 void DecryptingVideoDecoder::Stop(const base::Closure& closure) { |
| 127 DCHECK(task_runner_->BelongsToCurrentThread()); | 127 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 128 DVLOG(2) << "Stop() - state: " << state_; | 128 DVLOG(2) << "Stop() - state: " << state_; |
| 129 | 129 |
| 130 // At this point the render thread is likely paused (in WebMediaPlayerImpl's | 130 // At this point the render thread is likely paused (in WebMediaPlayerImpl's |
| 131 // Destroy()), so running |closure| can't wait for anything that requires the | 131 // Destroy()), so running |closure| can't wait for anything that requires the |
| 132 // render thread to be processing messages to complete (such as PPAPI | 132 // render thread to be processing messages to complete (such as PPAPI |
| 133 // callbacks). | 133 // callbacks). |
| 134 if (decryptor_) { | 134 if (decryptor_) { |
| 135 decryptor_->RegisterNewKeyCB(Decryptor::kVideo, Decryptor::NewKeyCB()); | 135 decryptor_->RegisterNewKeyCB(Decryptor::kVideo, Decryptor::NewKeyCB()); |
| 136 decryptor_->DeinitializeDecoder(Decryptor::kVideo); | 136 decryptor_->DeinitializeDecoder(Decryptor::kVideo); |
| 137 decryptor_ = NULL; | 137 decryptor_ = NULL; |
| 138 } | 138 } |
| 139 if (!set_decryptor_ready_cb_.is_null()) | 139 if (!set_decryptor_ready_cb_.is_null()) |
| 140 base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB()); | 140 base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB()); |
| 141 pending_buffer_to_decode_ = NULL; | 141 pending_buffer_to_decode_ = NULL; |
| 142 if (!init_cb_.is_null()) | 142 if (!init_cb_.is_null()) |
| 143 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); | 143 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); |
| 144 if (!decode_cb_.is_null()) | 144 if (!decode_cb_.is_null()) |
| 145 base::ResetAndReturn(&decode_cb_).Run(kOk, NULL); | 145 base::ResetAndReturn(&decode_cb_).Run(kAborted, NULL); |
| 146 if (!reset_cb_.is_null()) | 146 if (!reset_cb_.is_null()) |
| 147 base::ResetAndReturn(&reset_cb_).Run(); | 147 base::ResetAndReturn(&reset_cb_).Run(); |
| 148 state_ = kStopped; | 148 state_ = kStopped; |
| 149 BindToCurrentLoop(closure).Run(); | 149 BindToCurrentLoop(closure).Run(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 DecryptingVideoDecoder::~DecryptingVideoDecoder() { | 152 DecryptingVideoDecoder::~DecryptingVideoDecoder() { |
| 153 DCHECK(state_ == kUninitialized || state_ == kStopped) << state_; | 153 DCHECK(state_ == kUninitialized || state_ == kStopped) << state_; |
| 154 } | 154 } |
| 155 | 155 |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 DCHECK(pending_buffer_to_decode_.get()); | 240 DCHECK(pending_buffer_to_decode_.get()); |
| 241 | 241 |
| 242 bool need_to_try_again_if_nokey_is_returned = key_added_while_decode_pending_; | 242 bool need_to_try_again_if_nokey_is_returned = key_added_while_decode_pending_; |
| 243 key_added_while_decode_pending_ = false; | 243 key_added_while_decode_pending_ = false; |
| 244 | 244 |
| 245 scoped_refptr<DecoderBuffer> scoped_pending_buffer_to_decode = | 245 scoped_refptr<DecoderBuffer> scoped_pending_buffer_to_decode = |
| 246 pending_buffer_to_decode_; | 246 pending_buffer_to_decode_; |
| 247 pending_buffer_to_decode_ = NULL; | 247 pending_buffer_to_decode_ = NULL; |
| 248 | 248 |
| 249 if (!reset_cb_.is_null()) { | 249 if (!reset_cb_.is_null()) { |
| 250 base::ResetAndReturn(&decode_cb_).Run(kOk, NULL); | 250 base::ResetAndReturn(&decode_cb_).Run(kAborted, NULL); |
| 251 DoReset(); | 251 DoReset(); |
| 252 return; | 252 return; |
| 253 } | 253 } |
| 254 | 254 |
| 255 DCHECK_EQ(status == Decryptor::kSuccess, frame.get() != NULL); | 255 DCHECK_EQ(status == Decryptor::kSuccess, frame.get() != NULL); |
| 256 | 256 |
| 257 if (status == Decryptor::kError) { | 257 if (status == Decryptor::kError) { |
| 258 DVLOG(2) << "DeliverFrame() - kError"; | 258 DVLOG(2) << "DeliverFrame() - kError"; |
| 259 state_ = kError; | 259 state_ = kError; |
| 260 base::ResetAndReturn(&decode_cb_).Run(kDecodeError, NULL); | 260 base::ResetAndReturn(&decode_cb_).Run(kDecodeError, NULL); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 } | 314 } |
| 315 | 315 |
| 316 void DecryptingVideoDecoder::DoReset() { | 316 void DecryptingVideoDecoder::DoReset() { |
| 317 DCHECK(init_cb_.is_null()); | 317 DCHECK(init_cb_.is_null()); |
| 318 DCHECK(decode_cb_.is_null()); | 318 DCHECK(decode_cb_.is_null()); |
| 319 state_ = kIdle; | 319 state_ = kIdle; |
| 320 base::ResetAndReturn(&reset_cb_).Run(); | 320 base::ResetAndReturn(&reset_cb_).Run(); |
| 321 } | 321 } |
| 322 | 322 |
| 323 } // namespace media | 323 } // namespace media |
| OLD | NEW |