Report errors from ChromiumEnv::GetChildren in Posix.
[chromium-blink-merge.git] / media / filters / opus_audio_decoder.h
blob50ba0690eb37ecde901cfe7245d4b5f6a4c6e388
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
3 // found in the LICENSE file.
5 #ifndef MEDIA_FILTERS_OPUS_AUDIO_DECODER_H_
6 #define MEDIA_FILTERS_OPUS_AUDIO_DECODER_H_
8 #include "base/callback.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/time/time.h"
11 #include "media/base/audio_decoder.h"
12 #include "media/base/demuxer_stream.h"
14 struct OpusMSDecoder;
16 namespace base {
17 class MessageLoopProxy;
20 namespace media {
22 class AudioBuffer;
23 class AudioTimestampHelper;
24 class DecoderBuffer;
25 struct QueuedAudioBuffer;
27 class MEDIA_EXPORT OpusAudioDecoder : public AudioDecoder {
28 public:
29 explicit OpusAudioDecoder(
30 const scoped_refptr<base::MessageLoopProxy>& message_loop);
31 virtual ~OpusAudioDecoder();
33 // AudioDecoder implementation.
34 virtual void Initialize(DemuxerStream* stream,
35 const PipelineStatusCB& status_cb,
36 const StatisticsCB& statistics_cb) OVERRIDE;
37 virtual void Read(const ReadCB& read_cb) OVERRIDE;
38 virtual int bits_per_channel() OVERRIDE;
39 virtual ChannelLayout channel_layout() OVERRIDE;
40 virtual int samples_per_second() OVERRIDE;
41 virtual void Reset(const base::Closure& closure) OVERRIDE;
43 private:
44 // Reads from the demuxer stream with corresponding callback method.
45 void ReadFromDemuxerStream();
46 void BufferReady(DemuxerStream::Status status,
47 const scoped_refptr<DecoderBuffer>& input);
50 bool ConfigureDecoder();
51 void CloseDecoder();
52 void ResetTimestampState();
53 bool Decode(const scoped_refptr<DecoderBuffer>& input,
54 scoped_refptr<AudioBuffer>* output_buffer);
56 scoped_refptr<base::MessageLoopProxy> message_loop_;
57 base::WeakPtrFactory<OpusAudioDecoder> weak_factory_;
58 base::WeakPtr<OpusAudioDecoder> weak_this_;
60 DemuxerStream* demuxer_stream_;
61 StatisticsCB statistics_cb_;
62 OpusMSDecoder* opus_decoder_;
64 // Decoded audio format.
65 int bits_per_channel_;
66 ChannelLayout channel_layout_;
67 int samples_per_second_;
69 // Used for computing output timestamps.
70 scoped_ptr<AudioTimestampHelper> output_timestamp_helper_;
71 base::TimeDelta last_input_timestamp_;
73 ReadCB read_cb_;
75 // Number of frames to be discarded from the start of the packet. This value
76 // is respected for all packets except for the first one in the stream. For
77 // the first packet in the stream, |frame_delay_at_start_| is used. This is
78 // usually set to the SeekPreRoll value from the container whenever a seek
79 // happens.
80 int frames_to_discard_;
82 // Number of frames to be discarded at the start of the stream. This value
83 // is typically the CodecDelay value from the container.
84 int frame_delay_at_start_;
86 // Timestamp to be subtracted from all the frames. This is typically computed
87 // from the CodecDelay value in the container.
88 base::TimeDelta timestamp_offset_;
90 // Buffer for output from libopus.
91 scoped_ptr<int16[]> output_buffer_;
93 DISALLOW_IMPLICIT_CONSTRUCTORS(OpusAudioDecoder);
96 } // namespace media
98 #endif // MEDIA_FILTERS_OPUS_AUDIO_DECODER_H_