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/opus_audio_decoder.h" | 5 #include "media/filters/opus_audio_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/message_loop_proxy.h" | 10 #include "base/message_loop/message_loop_proxy.h" |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 ReadFromDemuxerStream(); | 350 ReadFromDemuxerStream(); |
351 return; | 351 return; |
352 } | 352 } |
353 | 353 |
354 DCHECK_EQ(status, DemuxerStream::kOk); | 354 DCHECK_EQ(status, DemuxerStream::kOk); |
355 DCHECK(input.get()); | 355 DCHECK(input.get()); |
356 | 356 |
357 // Libopus does not buffer output. Decoding is complete when an end of stream | 357 // Libopus does not buffer output. Decoding is complete when an end of stream |
358 // input buffer is received. | 358 // input buffer is received. |
359 if (input->IsEndOfStream()) { | 359 if (input->IsEndOfStream()) { |
360 base::ResetAndReturn(&read_cb_).Run(kOk, DataBuffer::CreateEOSBuffer()); | 360 base::ResetAndReturn(&read_cb_).Run(kOk, DataBuffer::create_eos_buffer()); |
361 return; | 361 return; |
362 } | 362 } |
363 | 363 |
364 // Make sure we are notified if http://crbug.com/49709 returns. Issue also | 364 // Make sure we are notified if http://crbug.com/49709 returns. Issue also |
365 // occurs with some damaged files. | 365 // occurs with some damaged files. |
366 if (input->GetTimestamp() == kNoTimestamp() && | 366 if (input->GetTimestamp() == kNoTimestamp() && |
367 output_timestamp_helper_->base_timestamp() == kNoTimestamp()) { | 367 output_timestamp_helper_->base_timestamp() == kNoTimestamp()) { |
368 DVLOG(1) << "Received a buffer without timestamps!"; | 368 DVLOG(1) << "Received a buffer without timestamps!"; |
369 base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL); | 369 base::ResetAndReturn(&read_cb_).Run(kDecodeError, NULL); |
370 return; | 370 return; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 if (decoded_audio_size > 0 && output_bytes_to_drop_ > 0) { | 542 if (decoded_audio_size > 0 && output_bytes_to_drop_ > 0) { |
543 int dropped_size = std::min(decoded_audio_size, output_bytes_to_drop_); | 543 int dropped_size = std::min(decoded_audio_size, output_bytes_to_drop_); |
544 DCHECK_EQ(dropped_size % kBytesPerChannel, 0); | 544 DCHECK_EQ(dropped_size % kBytesPerChannel, 0); |
545 decoded_audio_data += dropped_size; | 545 decoded_audio_data += dropped_size; |
546 decoded_audio_size -= dropped_size; | 546 decoded_audio_size -= dropped_size; |
547 output_bytes_to_drop_ -= dropped_size; | 547 output_bytes_to_drop_ -= dropped_size; |
548 } | 548 } |
549 | 549 |
550 if (decoded_audio_size > 0) { | 550 if (decoded_audio_size > 0) { |
551 // Copy the audio samples into an output buffer. | 551 // Copy the audio samples into an output buffer. |
552 *output_buffer = DataBuffer::CopyFrom( | 552 *output_buffer = DataBuffer::copy_from( |
553 decoded_audio_data, decoded_audio_size); | 553 decoded_audio_data, decoded_audio_size); |
554 (*output_buffer)->SetTimestamp(output_timestamp_helper_->GetTimestamp()); | 554 (*output_buffer)->set_timestamp(output_timestamp_helper_->GetTimestamp()); |
555 (*output_buffer)->SetDuration( | 555 (*output_buffer)->set_duration( |
556 output_timestamp_helper_->GetDuration(decoded_audio_size)); | 556 output_timestamp_helper_->GetDuration(decoded_audio_size)); |
557 output_timestamp_helper_->AddBytes(decoded_audio_size); | 557 output_timestamp_helper_->AddBytes(decoded_audio_size); |
558 } | 558 } |
559 | 559 |
560 // Decoding finished successfully, update statistics. | 560 // Decoding finished successfully, update statistics. |
561 PipelineStatistics statistics; | 561 PipelineStatistics statistics; |
562 statistics.audio_bytes_decoded = decoded_audio_size; | 562 statistics.audio_bytes_decoded = decoded_audio_size; |
563 statistics_cb_.Run(statistics); | 563 statistics_cb_.Run(statistics); |
564 | 564 |
565 return true; | 565 return true; |
566 } | 566 } |
567 | 567 |
568 } // namespace media | 568 } // namespace media |
OLD | NEW |