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" | 11 #include "base/message_loop.h" |
12 #include "media/base/audio_decoder.h" | 12 #include "media/base/audio_decoder.h" |
| 13 #include "media/base/demuxer_stream.h" |
13 | 14 |
14 struct AVCodecContext; | 15 struct AVCodecContext; |
15 struct AVFrame; | 16 struct AVFrame; |
16 | 17 |
17 namespace media { | 18 namespace media { |
18 | 19 |
19 class DataBuffer; | 20 class DataBuffer; |
20 class DecoderBuffer; | 21 class DecoderBuffer; |
21 | 22 |
22 class MEDIA_EXPORT FFmpegAudioDecoder : public AudioDecoder { | 23 class MEDIA_EXPORT FFmpegAudioDecoder : public AudioDecoder { |
(...skipping 13 matching lines...) Expand all Loading... |
36 protected: | 37 protected: |
37 virtual ~FFmpegAudioDecoder(); | 38 virtual ~FFmpegAudioDecoder(); |
38 | 39 |
39 private: | 40 private: |
40 // Methods running on decoder thread. | 41 // Methods running on decoder thread. |
41 void DoInitialize(const scoped_refptr<DemuxerStream>& stream, | 42 void DoInitialize(const scoped_refptr<DemuxerStream>& stream, |
42 const PipelineStatusCB& status_cb, | 43 const PipelineStatusCB& status_cb, |
43 const StatisticsCB& statistics_cb); | 44 const StatisticsCB& statistics_cb); |
44 void DoReset(const base::Closure& closure); | 45 void DoReset(const base::Closure& closure); |
45 void DoRead(const ReadCB& read_cb); | 46 void DoRead(const ReadCB& read_cb); |
46 void DoDecodeBuffer(const scoped_refptr<DecoderBuffer>& input); | 47 void DoDecodeBuffer(DemuxerStream::Status status, |
| 48 const scoped_refptr<DecoderBuffer>& input); |
47 | 49 |
48 // Reads from the demuxer stream with corresponding callback method. | 50 // Reads from the demuxer stream with corresponding callback method. |
49 void ReadFromDemuxerStream(); | 51 void ReadFromDemuxerStream(); |
50 void DecodeBuffer(const scoped_refptr<DecoderBuffer>& buffer); | 52 void DecodeBuffer(DemuxerStream::Status status, |
| 53 const scoped_refptr<DecoderBuffer>& buffer); |
51 | 54 |
52 // Updates the output buffer's duration and timestamp based on the input | 55 // Updates the output buffer's duration and timestamp based on the input |
53 // buffer. Will fall back to an estimated timestamp if the input lacks a | 56 // buffer. Will fall back to an estimated timestamp if the input lacks a |
54 // valid timestamp. | 57 // valid timestamp. |
55 void UpdateDurationAndTimestamp(const Buffer* input, DataBuffer* output); | 58 void UpdateDurationAndTimestamp(const Buffer* input, DataBuffer* output); |
56 | 59 |
57 // Calculates duration based on size of decoded audio bytes. | 60 // Calculates duration based on size of decoded audio bytes. |
58 base::TimeDelta CalculateDuration(int size); | 61 base::TimeDelta CalculateDuration(int size); |
59 | 62 |
60 // Delivers decoded samples to |read_cb_| and resets the callback. | |
61 void DeliverSamples(const scoped_refptr<Buffer>& samples); | |
62 | |
63 // This is !is_null() iff Initialize() hasn't been called. | 63 // This is !is_null() iff Initialize() hasn't been called. |
64 base::Callback<MessageLoop*()> message_loop_factory_cb_; | 64 base::Callback<MessageLoop*()> message_loop_factory_cb_; |
65 MessageLoop* message_loop_; | 65 MessageLoop* message_loop_; |
66 | 66 |
67 scoped_refptr<DemuxerStream> demuxer_stream_; | 67 scoped_refptr<DemuxerStream> demuxer_stream_; |
68 StatisticsCB statistics_cb_; | 68 StatisticsCB statistics_cb_; |
69 AVCodecContext* codec_context_; | 69 AVCodecContext* codec_context_; |
70 | 70 |
71 // Decoded audio format. | 71 // Decoded audio format. |
72 int bits_per_channel_; | 72 int bits_per_channel_; |
73 ChannelLayout channel_layout_; | 73 ChannelLayout channel_layout_; |
74 int samples_per_second_; | 74 int samples_per_second_; |
75 | 75 |
76 base::TimeDelta estimated_next_timestamp_; | 76 base::TimeDelta estimated_next_timestamp_; |
77 | 77 |
78 // Holds decoded audio. | 78 // Holds decoded audio. |
79 AVFrame* av_frame_; | 79 AVFrame* av_frame_; |
80 | 80 |
81 ReadCB read_cb_; | 81 ReadCB read_cb_; |
82 | 82 |
83 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); | 83 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); |
84 }; | 84 }; |
85 | 85 |
86 } // namespace media | 86 } // namespace media |
87 | 87 |
88 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ | 88 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ |
OLD | NEW |