| 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_demuxer_stream.h" | 5 #include "media/filters/decrypting_demuxer_stream.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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB()); | 153 base::ResetAndReturn(&set_decryptor_ready_cb_).Run(DecryptorReadyCB()); |
| 154 if (!init_cb_.is_null()) | 154 if (!init_cb_.is_null()) |
| 155 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT); | 155 base::ResetAndReturn(&init_cb_).Run(PIPELINE_ERROR_ABORT); |
| 156 if (!read_cb_.is_null()) | 156 if (!read_cb_.is_null()) |
| 157 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL); | 157 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL); |
| 158 if (!reset_cb_.is_null()) | 158 if (!reset_cb_.is_null()) |
| 159 base::ResetAndReturn(&reset_cb_).Run(); | 159 base::ResetAndReturn(&reset_cb_).Run(); |
| 160 pending_buffer_to_decrypt_ = NULL; | 160 pending_buffer_to_decrypt_ = NULL; |
| 161 } | 161 } |
| 162 | 162 |
| 163 void DecryptingDemuxerStream::SetDecryptor(Decryptor* decryptor) { | 163 void DecryptingDemuxerStream::SetDecryptor( |
| 164 Decryptor* decryptor, |
| 165 const DecryptorAttachedCB& decryptor_attached_cb) { |
| 164 DVLOG(2) << __FUNCTION__; | 166 DVLOG(2) << __FUNCTION__; |
| 165 DCHECK(task_runner_->BelongsToCurrentThread()); | 167 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 166 DCHECK_EQ(state_, kDecryptorRequested) << state_; | 168 DCHECK_EQ(state_, kDecryptorRequested) << state_; |
| 167 DCHECK(!init_cb_.is_null()); | 169 DCHECK(!init_cb_.is_null()); |
| 168 DCHECK(!set_decryptor_ready_cb_.is_null()); | 170 DCHECK(!set_decryptor_ready_cb_.is_null()); |
| 169 | 171 |
| 170 set_decryptor_ready_cb_.Reset(); | 172 set_decryptor_ready_cb_.Reset(); |
| 171 | 173 |
| 172 if (!decryptor) { | 174 if (!decryptor) { |
| 173 state_ = kUninitialized; | 175 state_ = kUninitialized; |
| 174 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); | 176 base::ResetAndReturn(&init_cb_).Run(DECODER_ERROR_NOT_SUPPORTED); |
| 177 decryptor_attached_cb.Run(false); |
| 175 return; | 178 return; |
| 176 } | 179 } |
| 177 | 180 |
| 178 decryptor_ = decryptor; | 181 decryptor_ = decryptor; |
| 179 | 182 |
| 180 decryptor_->RegisterNewKeyCB( | 183 decryptor_->RegisterNewKeyCB( |
| 181 GetDecryptorStreamType(), | 184 GetDecryptorStreamType(), |
| 182 BindToCurrentLoop( | 185 BindToCurrentLoop( |
| 183 base::Bind(&DecryptingDemuxerStream::OnKeyAdded, weak_this_))); | 186 base::Bind(&DecryptingDemuxerStream::OnKeyAdded, weak_this_))); |
| 184 | 187 |
| 185 state_ = kIdle; | 188 state_ = kIdle; |
| 186 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); | 189 base::ResetAndReturn(&init_cb_).Run(PIPELINE_OK); |
| 190 decryptor_attached_cb.Run(true); |
| 187 } | 191 } |
| 188 | 192 |
| 189 void DecryptingDemuxerStream::DecryptBuffer( | 193 void DecryptingDemuxerStream::DecryptBuffer( |
| 190 DemuxerStream::Status status, | 194 DemuxerStream::Status status, |
| 191 const scoped_refptr<DecoderBuffer>& buffer) { | 195 const scoped_refptr<DecoderBuffer>& buffer) { |
| 192 DVLOG(3) << __FUNCTION__; | 196 DVLOG(3) << __FUNCTION__; |
| 193 DCHECK(task_runner_->BelongsToCurrentThread()); | 197 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 194 DCHECK_EQ(state_, kPendingDemuxerRead) << state_; | 198 DCHECK_EQ(state_, kPendingDemuxerRead) << state_; |
| 195 DCHECK(!read_cb_.is_null()); | 199 DCHECK(!read_cb_.is_null()); |
| 196 DCHECK_EQ(buffer.get() != NULL, status == kOk) << status; | 200 DCHECK_EQ(buffer.get() != NULL, status == kOk) << status; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 break; | 385 break; |
| 382 } | 386 } |
| 383 | 387 |
| 384 default: | 388 default: |
| 385 NOTREACHED(); | 389 NOTREACHED(); |
| 386 return; | 390 return; |
| 387 } | 391 } |
| 388 } | 392 } |
| 389 | 393 |
| 390 } // namespace media | 394 } // namespace media |
| OLD | NEW |