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_OPUS_AUDIO_DECODER_H_ | 5 #ifndef MEDIA_FILTERS_OPUS_AUDIO_DECODER_H_ |
6 #define MEDIA_FILTERS_OPUS_AUDIO_DECODER_H_ | 6 #define MEDIA_FILTERS_OPUS_AUDIO_DECODER_H_ |
7 | 7 |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
11 #include "media/base/audio_decoder.h" | 11 #include "media/base/audio_decoder.h" |
12 #include "media/base/demuxer_stream.h" | 12 #include "media/base/demuxer_stream.h" |
13 | 13 |
14 struct OpusMSDecoder; | 14 struct OpusMSDecoder; |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 class MessageLoopProxy; | 17 class SingleThreadTaskRunner; |
18 } | 18 } |
19 | 19 |
20 namespace media { | 20 namespace media { |
21 | 21 |
22 class AudioBuffer; | 22 class AudioBuffer; |
23 class AudioTimestampHelper; | 23 class AudioTimestampHelper; |
24 class DecoderBuffer; | 24 class DecoderBuffer; |
25 struct QueuedAudioBuffer; | 25 struct QueuedAudioBuffer; |
26 | 26 |
27 class MEDIA_EXPORT OpusAudioDecoder : public AudioDecoder { | 27 class MEDIA_EXPORT OpusAudioDecoder : public AudioDecoder { |
28 public: | 28 public: |
29 explicit OpusAudioDecoder( | 29 explicit OpusAudioDecoder( |
30 const scoped_refptr<base::MessageLoopProxy>& message_loop); | 30 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
31 virtual ~OpusAudioDecoder(); | 31 virtual ~OpusAudioDecoder(); |
32 | 32 |
33 // AudioDecoder implementation. | 33 // AudioDecoder implementation. |
34 virtual void Initialize(DemuxerStream* stream, | 34 virtual void Initialize(DemuxerStream* stream, |
35 const PipelineStatusCB& status_cb, | 35 const PipelineStatusCB& status_cb, |
36 const StatisticsCB& statistics_cb) OVERRIDE; | 36 const StatisticsCB& statistics_cb) OVERRIDE; |
37 virtual void Read(const ReadCB& read_cb) OVERRIDE; | 37 virtual void Read(const ReadCB& read_cb) OVERRIDE; |
38 virtual int bits_per_channel() OVERRIDE; | 38 virtual int bits_per_channel() OVERRIDE; |
39 virtual ChannelLayout channel_layout() OVERRIDE; | 39 virtual ChannelLayout channel_layout() OVERRIDE; |
40 virtual int samples_per_second() OVERRIDE; | 40 virtual int samples_per_second() OVERRIDE; |
41 virtual void Reset(const base::Closure& closure) OVERRIDE; | 41 virtual void Reset(const base::Closure& closure) OVERRIDE; |
42 | 42 |
43 private: | 43 private: |
44 // Reads from the demuxer stream with corresponding callback method. | 44 // Reads from the demuxer stream with corresponding callback method. |
45 void ReadFromDemuxerStream(); | 45 void ReadFromDemuxerStream(); |
46 void BufferReady(DemuxerStream::Status status, | 46 void BufferReady(DemuxerStream::Status status, |
47 const scoped_refptr<DecoderBuffer>& input); | 47 const scoped_refptr<DecoderBuffer>& input); |
48 | 48 |
49 | 49 |
50 bool ConfigureDecoder(); | 50 bool ConfigureDecoder(); |
51 void CloseDecoder(); | 51 void CloseDecoder(); |
52 void ResetTimestampState(); | 52 void ResetTimestampState(); |
53 bool Decode(const scoped_refptr<DecoderBuffer>& input, | 53 bool Decode(const scoped_refptr<DecoderBuffer>& input, |
54 scoped_refptr<AudioBuffer>* output_buffer); | 54 scoped_refptr<AudioBuffer>* output_buffer); |
55 | 55 |
56 scoped_refptr<base::MessageLoopProxy> message_loop_; | 56 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
57 base::WeakPtrFactory<OpusAudioDecoder> weak_factory_; | 57 base::WeakPtrFactory<OpusAudioDecoder> weak_factory_; |
58 base::WeakPtr<OpusAudioDecoder> weak_this_; | 58 base::WeakPtr<OpusAudioDecoder> weak_this_; |
59 | 59 |
60 DemuxerStream* demuxer_stream_; | 60 DemuxerStream* demuxer_stream_; |
61 StatisticsCB statistics_cb_; | 61 StatisticsCB statistics_cb_; |
62 OpusMSDecoder* opus_decoder_; | 62 OpusMSDecoder* opus_decoder_; |
63 | 63 |
64 // Decoded audio format. | 64 // Decoded audio format. |
65 int bits_per_channel_; | 65 int bits_per_channel_; |
66 ChannelLayout channel_layout_; | 66 ChannelLayout channel_layout_; |
(...skipping 22 matching lines...) Expand all Loading... |
89 | 89 |
90 // Buffer for output from libopus. | 90 // Buffer for output from libopus. |
91 scoped_ptr<int16[]> output_buffer_; | 91 scoped_ptr<int16[]> output_buffer_; |
92 | 92 |
93 DISALLOW_IMPLICIT_CONSTRUCTORS(OpusAudioDecoder); | 93 DISALLOW_IMPLICIT_CONSTRUCTORS(OpusAudioDecoder); |
94 }; | 94 }; |
95 | 95 |
96 } // namespace media | 96 } // namespace media |
97 | 97 |
98 #endif // MEDIA_FILTERS_OPUS_AUDIO_DECODER_H_ | 98 #endif // MEDIA_FILTERS_OPUS_AUDIO_DECODER_H_ |
OLD | NEW |