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/ffmpeg_audio_decoder.h" | 5 #include "media/filters/ffmpeg_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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 codec_context_->refcounted_frames = 1; | 365 codec_context_->refcounted_frames = 1; |
366 | 366 |
367 AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); | 367 AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); |
368 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { | 368 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { |
369 DLOG(ERROR) << "Could not initialize audio decoder: " | 369 DLOG(ERROR) << "Could not initialize audio decoder: " |
370 << codec_context_->codec_id; | 370 << codec_context_->codec_id; |
371 return false; | 371 return false; |
372 } | 372 } |
373 | 373 |
374 // Success! | 374 // Success! |
375 av_frame_.reset(avcodec_alloc_frame()); | 375 av_frame_.reset(av_frame_alloc()); |
376 channel_layout_ = config.channel_layout(); | 376 channel_layout_ = config.channel_layout(); |
377 samples_per_second_ = config.samples_per_second(); | 377 samples_per_second_ = config.samples_per_second(); |
378 output_timestamp_helper_.reset( | 378 output_timestamp_helper_.reset( |
379 new AudioTimestampHelper(config.samples_per_second())); | 379 new AudioTimestampHelper(config.samples_per_second())); |
380 | 380 |
381 // Store initial values to guard against midstream configuration changes. | 381 // Store initial values to guard against midstream configuration changes. |
382 channels_ = codec_context_->channels; | 382 channels_ = codec_context_->channels; |
383 if (channels_ != ChannelLayoutToChannelCount(channel_layout_)) { | 383 if (channels_ != ChannelLayoutToChannelCount(channel_layout_)) { |
384 DLOG(ERROR) << "Audio configuration specified " | 384 DLOG(ERROR) << "Audio configuration specified " |
385 << ChannelLayoutToChannelCount(channel_layout_) | 385 << ChannelLayoutToChannelCount(channel_layout_) |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 // Decoding finished successfully, update statistics. | 532 // Decoding finished successfully, update statistics. |
533 if (result > 0) { | 533 if (result > 0) { |
534 PipelineStatistics statistics; | 534 PipelineStatistics statistics; |
535 statistics.audio_bytes_decoded = result; | 535 statistics.audio_bytes_decoded = result; |
536 statistics_cb_.Run(statistics); | 536 statistics_cb_.Run(statistics); |
537 } | 537 } |
538 } while (packet.size > 0); | 538 } while (packet.size > 0); |
539 } | 539 } |
540 | 540 |
541 } // namespace media | 541 } // namespace media |
OLD | NEW |