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 "media/base/audio_decoder.h" | 10 #include "media/base/audio_decoder.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 class DecoderBuffer; | 23 class DecoderBuffer; |
24 struct QueuedAudioBuffer; | 24 struct QueuedAudioBuffer; |
25 | 25 |
26 class MEDIA_EXPORT OpusAudioDecoder : public AudioDecoder { | 26 class MEDIA_EXPORT OpusAudioDecoder : public AudioDecoder { |
27 public: | 27 public: |
28 explicit OpusAudioDecoder( | 28 explicit OpusAudioDecoder( |
29 const scoped_refptr<base::MessageLoopProxy>& message_loop); | 29 const scoped_refptr<base::MessageLoopProxy>& message_loop); |
30 virtual ~OpusAudioDecoder(); | 30 virtual ~OpusAudioDecoder(); |
31 | 31 |
32 // AudioDecoder implementation. | 32 // AudioDecoder implementation. |
33 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, | 33 virtual void Initialize(DemuxerStream* stream, |
34 const PipelineStatusCB& status_cb, | 34 const PipelineStatusCB& status_cb, |
35 const StatisticsCB& statistics_cb) OVERRIDE; | 35 const StatisticsCB& statistics_cb) OVERRIDE; |
36 virtual void Read(const ReadCB& read_cb) OVERRIDE; | 36 virtual void Read(const ReadCB& read_cb) OVERRIDE; |
37 virtual int bits_per_channel() OVERRIDE; | 37 virtual int bits_per_channel() OVERRIDE; |
38 virtual ChannelLayout channel_layout() OVERRIDE; | 38 virtual ChannelLayout channel_layout() OVERRIDE; |
39 virtual int samples_per_second() OVERRIDE; | 39 virtual int samples_per_second() OVERRIDE; |
40 virtual void Reset(const base::Closure& closure) OVERRIDE; | 40 virtual void Reset(const base::Closure& closure) OVERRIDE; |
41 | 41 |
42 private: | 42 private: |
43 // Reads from the demuxer stream with corresponding callback method. | 43 // Reads from the demuxer stream with corresponding callback method. |
44 void ReadFromDemuxerStream(); | 44 void ReadFromDemuxerStream(); |
45 void BufferReady(DemuxerStream::Status status, | 45 void BufferReady(DemuxerStream::Status status, |
46 const scoped_refptr<DecoderBuffer>& input); | 46 const scoped_refptr<DecoderBuffer>& input); |
47 | 47 |
48 | 48 |
49 bool ConfigureDecoder(); | 49 bool ConfigureDecoder(); |
50 void CloseDecoder(); | 50 void CloseDecoder(); |
51 void ResetTimestampState(); | 51 void ResetTimestampState(); |
52 bool Decode(const scoped_refptr<DecoderBuffer>& input, | 52 bool Decode(const scoped_refptr<DecoderBuffer>& input, |
53 scoped_refptr<DataBuffer>* output_buffer); | 53 scoped_refptr<DataBuffer>* output_buffer); |
54 | 54 |
55 scoped_refptr<base::MessageLoopProxy> message_loop_; | 55 scoped_refptr<base::MessageLoopProxy> message_loop_; |
56 base::WeakPtrFactory<OpusAudioDecoder> weak_factory_; | 56 base::WeakPtrFactory<OpusAudioDecoder> weak_factory_; |
57 base::WeakPtr<OpusAudioDecoder> weak_this_; | 57 base::WeakPtr<OpusAudioDecoder> weak_this_; |
58 | 58 |
59 scoped_refptr<DemuxerStream> demuxer_stream_; | 59 DemuxerStream* demuxer_stream_; |
60 StatisticsCB statistics_cb_; | 60 StatisticsCB statistics_cb_; |
61 OpusMSDecoder* opus_decoder_; | 61 OpusMSDecoder* opus_decoder_; |
62 | 62 |
63 // Decoded audio format. | 63 // Decoded audio format. |
64 int bits_per_channel_; | 64 int bits_per_channel_; |
65 ChannelLayout channel_layout_; | 65 ChannelLayout channel_layout_; |
66 int samples_per_second_; | 66 int samples_per_second_; |
67 | 67 |
68 // Used for computing output timestamps. | 68 // Used for computing output timestamps. |
69 scoped_ptr<AudioTimestampHelper> output_timestamp_helper_; | 69 scoped_ptr<AudioTimestampHelper> output_timestamp_helper_; |
70 base::TimeDelta last_input_timestamp_; | 70 base::TimeDelta last_input_timestamp_; |
71 | 71 |
72 // Number of output sample bytes to drop before generating | 72 // Number of output sample bytes to drop before generating |
73 // output buffers. | 73 // output buffers. |
74 int output_bytes_to_drop_; | 74 int output_bytes_to_drop_; |
75 | 75 |
76 ReadCB read_cb_; | 76 ReadCB read_cb_; |
77 | 77 |
78 int skip_samples_; | 78 int skip_samples_; |
79 | 79 |
80 // Buffer for output from libopus. | 80 // Buffer for output from libopus. |
81 scoped_ptr<int16[]> output_buffer_; | 81 scoped_ptr<int16[]> output_buffer_; |
82 | 82 |
83 DISALLOW_IMPLICIT_CONSTRUCTORS(OpusAudioDecoder); | 83 DISALLOW_IMPLICIT_CONSTRUCTORS(OpusAudioDecoder); |
84 }; | 84 }; |
85 | 85 |
86 } // namespace media | 86 } // namespace media |
87 | 87 |
88 #endif // MEDIA_FILTERS_OPUS_AUDIO_DECODER_H_ | 88 #endif // MEDIA_FILTERS_OPUS_AUDIO_DECODER_H_ |
OLD | NEW |