| 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 "media/base/audio_decoder_config.h" | 8 #include "media/base/audio_decoder_config.h" |
| 9 #include "media/base/data_buffer.h" | 9 #include "media/base/data_buffer.h" |
| 10 #include "media/base/decoder_buffer.h" | 10 #include "media/base/decoder_buffer.h" |
| 11 #include "media/base/demuxer.h" | 11 #include "media/base/demuxer.h" |
| 12 #include "media/base/pipeline.h" | 12 #include "media/base/pipeline.h" |
| 13 #include "media/ffmpeg/ffmpeg_common.h" | 13 #include "media/ffmpeg/ffmpeg_common.h" |
| 14 #include "media/filters/ffmpeg_glue.h" |
| 14 | 15 |
| 15 namespace media { | 16 namespace media { |
| 16 | 17 |
| 17 // Returns true if the decode result was a timestamp packet and not actual audio | 18 // Returns true if the decode result was a timestamp packet and not actual audio |
| 18 // data. | 19 // data. |
| 19 static inline bool IsTimestampMarkerPacket(int result, Buffer* input) { | 20 static inline bool IsTimestampMarkerPacket(int result, Buffer* input) { |
| 20 // We can get a positive result but no decoded data. This is ok because this | 21 // We can get a positive result but no decoded data. This is ok because this |
| 21 // this can be a marker packet that only contains timestamp. | 22 // this can be a marker packet that only contains timestamp. |
| 22 return result > 0 && !input->IsEndOfStream() && | 23 return result > 0 && !input->IsEndOfStream() && |
| 23 input->GetTimestamp() != kNoTimestamp() && | 24 input->GetTimestamp() != kNoTimestamp() && |
| (...skipping 18 matching lines...) Expand all Loading... |
| 42 bits_per_channel_(0), | 43 bits_per_channel_(0), |
| 43 channel_layout_(CHANNEL_LAYOUT_NONE), | 44 channel_layout_(CHANNEL_LAYOUT_NONE), |
| 44 samples_per_second_(0), | 45 samples_per_second_(0), |
| 45 av_frame_(NULL) { | 46 av_frame_(NULL) { |
| 46 } | 47 } |
| 47 | 48 |
| 48 void FFmpegAudioDecoder::Initialize( | 49 void FFmpegAudioDecoder::Initialize( |
| 49 const scoped_refptr<DemuxerStream>& stream, | 50 const scoped_refptr<DemuxerStream>& stream, |
| 50 const PipelineStatusCB& status_cb, | 51 const PipelineStatusCB& status_cb, |
| 51 const StatisticsCB& statistics_cb) { | 52 const StatisticsCB& statistics_cb) { |
| 53 // Ensure FFmpeg has been initialized |
| 54 FFmpegGlue::GetInstance(); |
| 55 |
| 52 if (!message_loop_) { | 56 if (!message_loop_) { |
| 53 message_loop_ = message_loop_factory_cb_.Run(); | 57 message_loop_ = message_loop_factory_cb_.Run(); |
| 54 message_loop_factory_cb_.Reset(); | 58 message_loop_factory_cb_.Reset(); |
| 55 } else { | 59 } else { |
| 56 // TODO(scherkus): initialization currently happens more than once in | 60 // TODO(scherkus): initialization currently happens more than once in |
| 57 // PipelineIntegrationTest.BasicPlayback. | 61 // PipelineIntegrationTest.BasicPlayback. |
| 58 LOG(ERROR) << "Initialize has already been called."; | 62 LOG(ERROR) << "Initialize has already been called."; |
| 59 } | 63 } |
| 60 message_loop_->PostTask( | 64 message_loop_->PostTask( |
| 61 FROM_HERE, | 65 FROM_HERE, |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 } | 296 } |
| 293 | 297 |
| 294 void FFmpegAudioDecoder::DeliverSamples(const scoped_refptr<Buffer>& samples) { | 298 void FFmpegAudioDecoder::DeliverSamples(const scoped_refptr<Buffer>& samples) { |
| 295 // Reset the callback before running to protect against reentrancy. | 299 // Reset the callback before running to protect against reentrancy. |
| 296 ReadCB read_cb = read_cb_; | 300 ReadCB read_cb = read_cb_; |
| 297 read_cb_.Reset(); | 301 read_cb_.Reset(); |
| 298 read_cb.Run(samples); | 302 read_cb.Run(samples); |
| 299 } | 303 } |
| 300 | 304 |
| 301 } // namespace media | 305 } // namespace media |
| OLD | NEW |