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 #ifndef MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ | 5 #ifndef MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ |
6 #define MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ | 6 #define MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/message_loop.h" | |
12 #include "media/base/audio_decoder.h" | 11 #include "media/base/audio_decoder.h" |
13 #include "media/base/demuxer_stream.h" | 12 #include "media/base/demuxer_stream.h" |
14 | 13 |
15 struct AVCodecContext; | 14 struct AVCodecContext; |
16 struct AVFrame; | 15 struct AVFrame; |
17 | 16 |
| 17 namespace base { |
| 18 class MessageLoopProxy; |
| 19 } |
| 20 |
18 namespace media { | 21 namespace media { |
19 | 22 |
20 class DataBuffer; | 23 class DataBuffer; |
21 class DecoderBuffer; | 24 class DecoderBuffer; |
22 | 25 |
23 class MEDIA_EXPORT FFmpegAudioDecoder : public AudioDecoder { | 26 class MEDIA_EXPORT FFmpegAudioDecoder : public AudioDecoder { |
24 public: | 27 public: |
25 FFmpegAudioDecoder(const base::Callback<MessageLoop*()>& message_loop_cb); | 28 typedef base::Callback< |
| 29 scoped_refptr<base::MessageLoopProxy>()> MessageLoopFactoryCB; |
| 30 explicit FFmpegAudioDecoder( |
| 31 const MessageLoopFactoryCB& message_loop_factory_cb); |
26 | 32 |
27 // AudioDecoder implementation. | 33 // AudioDecoder implementation. |
28 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, | 34 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, |
29 const PipelineStatusCB& status_cb, | 35 const PipelineStatusCB& status_cb, |
30 const StatisticsCB& statistics_cb) OVERRIDE; | 36 const StatisticsCB& statistics_cb) OVERRIDE; |
31 virtual void Read(const ReadCB& read_cb) OVERRIDE; | 37 virtual void Read(const ReadCB& read_cb) OVERRIDE; |
32 virtual int bits_per_channel() OVERRIDE; | 38 virtual int bits_per_channel() OVERRIDE; |
33 virtual ChannelLayout channel_layout() OVERRIDE; | 39 virtual ChannelLayout channel_layout() OVERRIDE; |
34 virtual int samples_per_second() OVERRIDE; | 40 virtual int samples_per_second() OVERRIDE; |
35 virtual void Reset(const base::Closure& closure) OVERRIDE; | 41 virtual void Reset(const base::Closure& closure) OVERRIDE; |
(...skipping 15 matching lines...) Expand all Loading... |
51 void ReadFromDemuxerStream(); | 57 void ReadFromDemuxerStream(); |
52 void DecodeBuffer(DemuxerStream::Status status, | 58 void DecodeBuffer(DemuxerStream::Status status, |
53 const scoped_refptr<DecoderBuffer>& buffer); | 59 const scoped_refptr<DecoderBuffer>& buffer); |
54 | 60 |
55 // Returns the timestamp that should be used for the next buffer returned | 61 // Returns the timestamp that should be used for the next buffer returned |
56 // via |read_cb_|. It is calculated from |output_timestamp_base_| and | 62 // via |read_cb_|. It is calculated from |output_timestamp_base_| and |
57 // |total_frames_decoded_|. | 63 // |total_frames_decoded_|. |
58 base::TimeDelta GetNextOutputTimestamp() const; | 64 base::TimeDelta GetNextOutputTimestamp() const; |
59 | 65 |
60 // This is !is_null() iff Initialize() hasn't been called. | 66 // This is !is_null() iff Initialize() hasn't been called. |
61 base::Callback<MessageLoop*()> message_loop_factory_cb_; | 67 MessageLoopFactoryCB message_loop_factory_cb_; |
62 MessageLoop* message_loop_; | 68 |
| 69 scoped_refptr<base::MessageLoopProxy> message_loop_; |
63 | 70 |
64 scoped_refptr<DemuxerStream> demuxer_stream_; | 71 scoped_refptr<DemuxerStream> demuxer_stream_; |
65 StatisticsCB statistics_cb_; | 72 StatisticsCB statistics_cb_; |
66 AVCodecContext* codec_context_; | 73 AVCodecContext* codec_context_; |
67 | 74 |
68 // Decoded audio format. | 75 // Decoded audio format. |
69 int bits_per_channel_; | 76 int bits_per_channel_; |
70 ChannelLayout channel_layout_; | 77 ChannelLayout channel_layout_; |
71 int samples_per_second_; | 78 int samples_per_second_; |
72 | 79 |
(...skipping 11 matching lines...) Expand all Loading... |
84 AVFrame* av_frame_; | 91 AVFrame* av_frame_; |
85 | 92 |
86 ReadCB read_cb_; | 93 ReadCB read_cb_; |
87 | 94 |
88 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); | 95 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); |
89 }; | 96 }; |
90 | 97 |
91 } // namespace media | 98 } // namespace media |
92 | 99 |
93 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ | 100 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ |
OLD | NEW |