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" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 void DoReset(const base::Closure& closure); | 45 void DoReset(const base::Closure& closure); |
46 void DoRead(const ReadCB& read_cb); | 46 void DoRead(const ReadCB& read_cb); |
47 void DoDecodeBuffer(DemuxerStream::Status status, | 47 void DoDecodeBuffer(DemuxerStream::Status status, |
48 const scoped_refptr<DecoderBuffer>& input); | 48 const scoped_refptr<DecoderBuffer>& input); |
49 | 49 |
50 // Reads from the demuxer stream with corresponding callback method. | 50 // Reads from the demuxer stream with corresponding callback method. |
51 void ReadFromDemuxerStream(); | 51 void ReadFromDemuxerStream(); |
52 void DecodeBuffer(DemuxerStream::Status status, | 52 void DecodeBuffer(DemuxerStream::Status status, |
53 const scoped_refptr<DecoderBuffer>& buffer); | 53 const scoped_refptr<DecoderBuffer>& buffer); |
54 | 54 |
55 // Updates the output buffer's duration and timestamp based on the input | 55 // Returns the timestamp that should be used for the next buffer returned |
56 // buffer. Will fall back to an estimated timestamp if the input lacks a | 56 // via |read_cb_|. It is calculated from |output_timestamp_base_| and |
57 // valid timestamp. | 57 // |total_frames_decoded_|. |
58 void UpdateDurationAndTimestamp(const Buffer* input, DataBuffer* output); | 58 base::TimeDelta GetNextOutputTimestamp() const; |
59 | |
60 // Calculates duration based on size of decoded audio bytes. | |
61 base::TimeDelta CalculateDuration(int size); | |
62 | 59 |
63 // This is !is_null() iff Initialize() hasn't been called. | 60 // This is !is_null() iff Initialize() hasn't been called. |
64 base::Callback<MessageLoop*()> message_loop_factory_cb_; | 61 base::Callback<MessageLoop*()> message_loop_factory_cb_; |
65 MessageLoop* message_loop_; | 62 MessageLoop* message_loop_; |
66 | 63 |
67 scoped_refptr<DemuxerStream> demuxer_stream_; | 64 scoped_refptr<DemuxerStream> demuxer_stream_; |
68 StatisticsCB statistics_cb_; | 65 StatisticsCB statistics_cb_; |
69 AVCodecContext* codec_context_; | 66 AVCodecContext* codec_context_; |
70 | 67 |
71 // Decoded audio format. | 68 // Decoded audio format. |
72 int bits_per_channel_; | 69 int bits_per_channel_; |
73 ChannelLayout channel_layout_; | 70 ChannelLayout channel_layout_; |
74 int samples_per_second_; | 71 int samples_per_second_; |
75 | 72 |
76 base::TimeDelta estimated_next_timestamp_; | 73 // Used for computing output timestamps. |
| 74 int bytes_per_frame_; |
| 75 base::TimeDelta output_timestamp_base_; |
| 76 double total_frames_decoded_; |
| 77 base::TimeDelta last_input_timestamp_; |
| 78 |
| 79 // Number of output sample bytes to drop before generating |
| 80 // output buffers. |
| 81 int output_bytes_to_drop_; |
77 | 82 |
78 // Holds decoded audio. | 83 // Holds decoded audio. |
79 AVFrame* av_frame_; | 84 AVFrame* av_frame_; |
80 | 85 |
81 ReadCB read_cb_; | 86 ReadCB read_cb_; |
82 | 87 |
83 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); | 88 DISALLOW_IMPLICIT_CONSTRUCTORS(FFmpegAudioDecoder); |
84 }; | 89 }; |
85 | 90 |
86 } // namespace media | 91 } // namespace media |
87 | 92 |
88 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ | 93 #endif // MEDIA_FILTERS_FFMPEG_AUDIO_DECODER_H_ |
OLD | NEW |