| 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/location.h" | 9 #include "base/location.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 DCHECK(state_ == kIdle || | 60 DCHECK(state_ == kIdle || |
| 61 state_ == kPendingDemuxerRead || | 61 state_ == kPendingDemuxerRead || |
| 62 state_ == kPendingDecode || | 62 state_ == kPendingDecode || |
| 63 state_ == kWaitingForKey || | 63 state_ == kWaitingForKey || |
| 64 state_ == kDecodeFinished) << state_; | 64 state_ == kDecodeFinished) << state_; |
| 65 DCHECK(init_cb_.is_null()); // No Reset() during pending initialization. | 65 DCHECK(init_cb_.is_null()); // No Reset() during pending initialization. |
| 66 DCHECK(reset_cb_.is_null()); | 66 DCHECK(reset_cb_.is_null()); |
| 67 | 67 |
| 68 reset_cb_ = closure; | 68 reset_cb_ = closure; |
| 69 | 69 |
| 70 decryptor_->CancelDecryptAndDecodeVideo(); | 70 decryptor_->ResetDecoder(Decryptor::kVideo); |
| 71 | 71 |
| 72 // Reset() cannot complete if the read callback is still pending. | 72 // Reset() cannot complete if the read callback is still pending. |
| 73 // Defer the resetting process in this case. The |reset_cb_| will be fired | 73 // Defer the resetting process in this case. The |reset_cb_| will be fired |
| 74 // after the read callback is fired - see DoDecryptAndDecodeBuffer() and | 74 // after the read callback is fired - see DoDecryptAndDecodeBuffer() and |
| 75 // DoDeliverFrame(). | 75 // DoDeliverFrame(). |
| 76 if (state_ == kPendingDemuxerRead || state_ == kPendingDecode) { | 76 if (state_ == kPendingDemuxerRead || state_ == kPendingDecode) { |
| 77 DCHECK(!read_cb_.is_null()); | 77 DCHECK(!read_cb_.is_null()); |
| 78 return; | 78 return; |
| 79 } | 79 } |
| 80 | 80 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 95 return; | 95 return; |
| 96 } | 96 } |
| 97 | 97 |
| 98 DVLOG(2) << "Stop() - state: " << state_; | 98 DVLOG(2) << "Stop() - state: " << state_; |
| 99 | 99 |
| 100 // At this point the render thread is likely paused (in WebMediaPlayerImpl's | 100 // At this point the render thread is likely paused (in WebMediaPlayerImpl's |
| 101 // Destroy()), so running |closure| can't wait for anything that requires the | 101 // Destroy()), so running |closure| can't wait for anything that requires the |
| 102 // render thread to be processing messages to complete (such as PPAPI | 102 // render thread to be processing messages to complete (such as PPAPI |
| 103 // callbacks). | 103 // callbacks). |
| 104 if (decryptor_) | 104 if (decryptor_) |
| 105 decryptor_->StopVideoDecoder(); | 105 decryptor_->DeinitializeDecoder(Decryptor::kVideo); |
| 106 if (!request_decryptor_notification_cb_.is_null()) { | 106 if (!request_decryptor_notification_cb_.is_null()) { |
| 107 base::ResetAndReturn(&request_decryptor_notification_cb_).Run( | 107 base::ResetAndReturn(&request_decryptor_notification_cb_).Run( |
| 108 DecryptorNotificationCB()); | 108 DecryptorNotificationCB()); |
| 109 } | 109 } |
| 110 pending_buffer_to_decode_ = NULL; | 110 pending_buffer_to_decode_ = NULL; |
| 111 if (!init_cb_.is_null()) | 111 if (!init_cb_.is_null()) |
| 112 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); | 112 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); |
| 113 if (!read_cb_.is_null()) | 113 if (!read_cb_.is_null()) |
| 114 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); | 114 base::ResetAndReturn(&read_cb_).Run(kOk, NULL); |
| 115 if (!reset_cb_.is_null()) | 115 if (!reset_cb_.is_null()) |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 } | 384 } |
| 385 | 385 |
| 386 void DecryptingVideoDecoder::DoReset() { | 386 void DecryptingVideoDecoder::DoReset() { |
| 387 DCHECK(init_cb_.is_null()); | 387 DCHECK(init_cb_.is_null()); |
| 388 DCHECK(read_cb_.is_null()); | 388 DCHECK(read_cb_.is_null()); |
| 389 state_ = kIdle; | 389 state_ = kIdle; |
| 390 base::ResetAndReturn(&reset_cb_).Run(); | 390 base::ResetAndReturn(&reset_cb_).Run(); |
| 391 } | 391 } |
| 392 | 392 |
| 393 } // namespace media | 393 } // namespace media |
| OLD | NEW |