| 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_audio_decoder.h" | 5 #include "media/filters/decrypting_audio_decoder.h" |
| 6 | 6 |
| 7 #include <cstdlib> | 7 #include <cstdlib> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 state_ = kIdle; | 303 state_ = kIdle; |
| 304 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL); | 304 base::ResetAndReturn(&read_cb_).Run(kAborted, NULL); |
| 305 return; | 305 return; |
| 306 } | 306 } |
| 307 | 307 |
| 308 DCHECK_EQ(status, DemuxerStream::kOk); | 308 DCHECK_EQ(status, DemuxerStream::kOk); |
| 309 | 309 |
| 310 // Initialize the |next_output_timestamp_| to be the timestamp of the first | 310 // Initialize the |next_output_timestamp_| to be the timestamp of the first |
| 311 // non-EOS buffer. | 311 // non-EOS buffer. |
| 312 if (timestamp_helper_->base_timestamp() == kNoTimestamp() && | 312 if (timestamp_helper_->base_timestamp() == kNoTimestamp() && |
| 313 !buffer->IsEndOfStream()) { | 313 !buffer->end_of_stream()) { |
| 314 timestamp_helper_->SetBaseTimestamp(buffer->GetTimestamp()); | 314 timestamp_helper_->SetBaseTimestamp(buffer->timestamp()); |
| 315 } | 315 } |
| 316 | 316 |
| 317 pending_buffer_to_decode_ = buffer; | 317 pending_buffer_to_decode_ = buffer; |
| 318 state_ = kPendingDecode; | 318 state_ = kPendingDecode; |
| 319 DecodePendingBuffer(); | 319 DecodePendingBuffer(); |
| 320 } | 320 } |
| 321 | 321 |
| 322 void DecryptingAudioDecoder::DecodePendingBuffer() { | 322 void DecryptingAudioDecoder::DecodePendingBuffer() { |
| 323 DCHECK(message_loop_->BelongsToCurrentThread()); | 323 DCHECK(message_loop_->BelongsToCurrentThread()); |
| 324 DCHECK_EQ(state_, kPendingDecode) << state_; | 324 DCHECK_EQ(state_, kPendingDecode) << state_; |
| 325 | 325 |
| 326 int buffer_size = 0; | 326 int buffer_size = 0; |
| 327 if (!pending_buffer_to_decode_->IsEndOfStream()) { | 327 if (!pending_buffer_to_decode_->end_of_stream()) { |
| 328 buffer_size = pending_buffer_to_decode_->GetDataSize(); | 328 buffer_size = pending_buffer_to_decode_->data_size(); |
| 329 } | 329 } |
| 330 | 330 |
| 331 decryptor_->DecryptAndDecodeAudio( | 331 decryptor_->DecryptAndDecodeAudio( |
| 332 pending_buffer_to_decode_, | 332 pending_buffer_to_decode_, |
| 333 BindToCurrentLoop(base::Bind( | 333 BindToCurrentLoop(base::Bind( |
| 334 &DecryptingAudioDecoder::DeliverFrame, weak_this_, buffer_size))); | 334 &DecryptingAudioDecoder::DeliverFrame, weak_this_, buffer_size))); |
| 335 } | 335 } |
| 336 | 336 |
| 337 void DecryptingAudioDecoder::DeliverFrame( | 337 void DecryptingAudioDecoder::DeliverFrame( |
| 338 int buffer_size, | 338 int buffer_size, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 | 385 |
| 386 // The buffer has been accepted by the decoder, let's report statistics. | 386 // The buffer has been accepted by the decoder, let's report statistics. |
| 387 if (buffer_size) { | 387 if (buffer_size) { |
| 388 PipelineStatistics statistics; | 388 PipelineStatistics statistics; |
| 389 statistics.audio_bytes_decoded = buffer_size; | 389 statistics.audio_bytes_decoded = buffer_size; |
| 390 statistics_cb_.Run(statistics); | 390 statistics_cb_.Run(statistics); |
| 391 } | 391 } |
| 392 | 392 |
| 393 if (status == Decryptor::kNeedMoreData) { | 393 if (status == Decryptor::kNeedMoreData) { |
| 394 DVLOG(2) << "DeliverFrame() - kNeedMoreData"; | 394 DVLOG(2) << "DeliverFrame() - kNeedMoreData"; |
| 395 if (scoped_pending_buffer_to_decode->IsEndOfStream()) { | 395 if (scoped_pending_buffer_to_decode->end_of_stream()) { |
| 396 state_ = kDecodeFinished; | 396 state_ = kDecodeFinished; |
| 397 base::ResetAndReturn(&read_cb_).Run(kOk, AudioBuffer::CreateEOSBuffer()); | 397 base::ResetAndReturn(&read_cb_).Run(kOk, AudioBuffer::CreateEOSBuffer()); |
| 398 return; | 398 return; |
| 399 } | 399 } |
| 400 | 400 |
| 401 state_ = kPendingDemuxerRead; | 401 state_ = kPendingDemuxerRead; |
| 402 ReadFromDemuxerStream(); | 402 ReadFromDemuxerStream(); |
| 403 return; | 403 return; |
| 404 } | 404 } |
| 405 | 405 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 } | 463 } |
| 464 | 464 |
| 465 frame->set_timestamp(current_time); | 465 frame->set_timestamp(current_time); |
| 466 frame->set_duration( | 466 frame->set_duration( |
| 467 timestamp_helper_->GetFrameDuration(frame->frame_count())); | 467 timestamp_helper_->GetFrameDuration(frame->frame_count())); |
| 468 timestamp_helper_->AddFrames(frame->frame_count()); | 468 timestamp_helper_->AddFrames(frame->frame_count()); |
| 469 } | 469 } |
| 470 } | 470 } |
| 471 | 471 |
| 472 } // namespace media | 472 } // namespace media |
| OLD | NEW |