| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 state_ = kIdle; | 234 state_ = kIdle; |
| 235 base::ResetAndReturn(&read_cb_).Run(status, buffer); | 235 base::ResetAndReturn(&read_cb_).Run(status, buffer); |
| 236 return; | 236 return; |
| 237 } | 237 } |
| 238 | 238 |
| 239 DCHECK(buffer->decrypt_config()); | 239 DCHECK(buffer->decrypt_config()); |
| 240 // An empty iv string signals that the frame is unencrypted. | 240 // An empty iv string signals that the frame is unencrypted. |
| 241 if (buffer->decrypt_config()->iv().empty()) { | 241 if (buffer->decrypt_config()->iv().empty()) { |
| 242 DVLOG(2) << "DoDecryptBuffer() - clear buffer."; | 242 DVLOG(2) << "DoDecryptBuffer() - clear buffer."; |
| 243 scoped_refptr<DecoderBuffer> decrypted = DecoderBuffer::CopyFrom( | 243 scoped_refptr<DecoderBuffer> decrypted = DecoderBuffer::CopyFrom( |
| 244 buffer->data(), buffer->data_size()); | 244 buffer->data(), buffer->data_size(), buffer->is_keyframe()); |
| 245 decrypted->set_timestamp(buffer->timestamp()); | 245 decrypted->set_timestamp(buffer->timestamp()); |
| 246 decrypted->set_duration(buffer->duration()); | 246 decrypted->set_duration(buffer->duration()); |
| 247 state_ = kIdle; | 247 state_ = kIdle; |
| 248 base::ResetAndReturn(&read_cb_).Run(kOk, decrypted); | 248 base::ResetAndReturn(&read_cb_).Run(kOk, decrypted); |
| 249 return; | 249 return; |
| 250 } | 250 } |
| 251 | 251 |
| 252 pending_buffer_to_decrypt_ = buffer; | 252 pending_buffer_to_decrypt_ = buffer; |
| 253 state_ = kPendingDecrypt; | 253 state_ = kPendingDecrypt; |
| 254 DecryptPendingBuffer(); | 254 DecryptPendingBuffer(); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 // The |state_| is still kPendingDecrypt. | 300 // The |state_| is still kPendingDecrypt. |
| 301 DecryptPendingBuffer(); | 301 DecryptPendingBuffer(); |
| 302 return; | 302 return; |
| 303 } | 303 } |
| 304 | 304 |
| 305 state_ = kWaitingForKey; | 305 state_ = kWaitingForKey; |
| 306 return; | 306 return; |
| 307 } | 307 } |
| 308 | 308 |
| 309 DCHECK_EQ(status, Decryptor::kSuccess); | 309 DCHECK_EQ(status, Decryptor::kSuccess); |
| 310 |
| 311 // Copy the keyframe flag from the encrypted to decrypted buffer, assuming |
| 312 // that the decryptor initialized the flag to false. |
| 313 if (pending_buffer_to_decrypt_->is_keyframe()) |
| 314 decrypted_buffer->set_is_keyframe(true); |
| 315 |
| 310 pending_buffer_to_decrypt_ = NULL; | 316 pending_buffer_to_decrypt_ = NULL; |
| 311 state_ = kIdle; | 317 state_ = kIdle; |
| 318 |
| 312 base::ResetAndReturn(&read_cb_).Run(kOk, decrypted_buffer); | 319 base::ResetAndReturn(&read_cb_).Run(kOk, decrypted_buffer); |
| 313 } | 320 } |
| 314 | 321 |
| 315 void DecryptingDemuxerStream::OnKeyAdded() { | 322 void DecryptingDemuxerStream::OnKeyAdded() { |
| 316 DCHECK(task_runner_->BelongsToCurrentThread()); | 323 DCHECK(task_runner_->BelongsToCurrentThread()); |
| 317 | 324 |
| 318 if (state_ == kPendingDecrypt) { | 325 if (state_ == kPendingDecrypt) { |
| 319 key_added_while_decrypt_pending_ = true; | 326 key_added_while_decrypt_pending_ = true; |
| 320 return; | 327 return; |
| 321 } | 328 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 break; | 392 break; |
| 386 } | 393 } |
| 387 | 394 |
| 388 default: | 395 default: |
| 389 NOTREACHED(); | 396 NOTREACHED(); |
| 390 return; | 397 return; |
| 391 } | 398 } |
| 392 } | 399 } |
| 393 | 400 |
| 394 } // namespace media | 401 } // namespace media |
| OLD | NEW |