Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: media/filters/opus_audio_decoder.h

Issue 141243003: Add AudioBufferStream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@decoderstream_rebased
Patch Set: even more cleanup! Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 14 matching lines...) Expand all
25 class DecoderBuffer; 25 class DecoderBuffer;
26 struct QueuedAudioBuffer; 26 struct QueuedAudioBuffer;
27 27
28 class MEDIA_EXPORT OpusAudioDecoder : public AudioDecoder { 28 class MEDIA_EXPORT OpusAudioDecoder : public AudioDecoder {
29 public: 29 public:
30 explicit OpusAudioDecoder( 30 explicit OpusAudioDecoder(
31 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); 31 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
32 virtual ~OpusAudioDecoder(); 32 virtual ~OpusAudioDecoder();
33 33
34 // AudioDecoder implementation. 34 // AudioDecoder implementation.
35 virtual void Initialize(DemuxerStream* stream, 35 //virtual void Initialize(DemuxerStream* stream,
36 const PipelineStatusCB& status_cb, 36 // const PipelineStatusCB& status_cb,
37 const StatisticsCB& statistics_cb) OVERRIDE; 37 // const StatisticsCB& statistics_cb) OVERRIDE;
38 virtual void Read(const ReadCB& read_cb) OVERRIDE; 38 virtual void Initialize(const AudioDecoderConfig& config,
39 const PipelineStatusCB& status_cb) OVERRIDE;
40 //virtual void Read(const ReadCB& read_cb) OVERRIDE;
41 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer,
42 const DecodeCB& decode_cb) OVERRIDE;
39 virtual int bits_per_channel() OVERRIDE; 43 virtual int bits_per_channel() OVERRIDE;
40 virtual ChannelLayout channel_layout() OVERRIDE; 44 virtual ChannelLayout channel_layout() OVERRIDE;
41 virtual int samples_per_second() OVERRIDE; 45 virtual int samples_per_second() OVERRIDE;
42 virtual void Reset(const base::Closure& closure) OVERRIDE; 46 virtual void Reset(const base::Closure& closure) OVERRIDE;
43 virtual void Stop(const base::Closure& closure) OVERRIDE; 47 virtual void Stop(const base::Closure& closure) OVERRIDE;
44 48
45 private: 49 private:
46 void DoReset(); 50 void DoReset();
47 void DoStop(); 51 void DoStop();
48 52
49 // Reads from the demuxer stream with corresponding callback method. 53 // Reads from the demuxer stream with corresponding callback method.
50 void ReadFromDemuxerStream(); 54 void ReadFromDemuxerStream();
51 void BufferReady(DemuxerStream::Status status, 55 void DecodeBuffer(const scoped_refptr<DecoderBuffer>& input);
52 const scoped_refptr<DecoderBuffer>& input);
53 56
54 bool ConfigureDecoder(); 57 bool ConfigureDecoder();
55 void CloseDecoder(); 58 void CloseDecoder();
56 void ResetTimestampState(); 59 void ResetTimestampState();
57 bool Decode(const scoped_refptr<DecoderBuffer>& input, 60 bool Decode(const scoped_refptr<DecoderBuffer>& input,
58 scoped_refptr<AudioBuffer>* output_buffer); 61 scoped_refptr<AudioBuffer>* output_buffer);
59 62
60 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 63 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
61 base::WeakPtrFactory<OpusAudioDecoder> weak_factory_; 64 base::WeakPtrFactory<OpusAudioDecoder> weak_factory_;
62 base::WeakPtr<OpusAudioDecoder> weak_this_; 65 base::WeakPtr<OpusAudioDecoder> weak_this_;
63 66
64 DemuxerStream* demuxer_stream_; 67 //DemuxerStream* demuxer_stream_;
65 StatisticsCB statistics_cb_; 68 AudioDecoderConfig config_;
66 OpusMSDecoder* opus_decoder_; 69 OpusMSDecoder* opus_decoder_;
67 70
68 // Decoded audio format. 71 // Decoded audio format.
69 ChannelLayout channel_layout_; 72 ChannelLayout channel_layout_;
70 int samples_per_second_; 73 int samples_per_second_;
71 const SampleFormat sample_format_; 74 const SampleFormat sample_format_;
72 const int bits_per_channel_; 75 const int bits_per_channel_;
73 76
74 // Used for computing output timestamps. 77 // Used for computing output timestamps.
75 scoped_ptr<AudioTimestampHelper> output_timestamp_helper_; 78 scoped_ptr<AudioTimestampHelper> output_timestamp_helper_;
76 base::TimeDelta last_input_timestamp_; 79 base::TimeDelta last_input_timestamp_;
77 80
78 ReadCB read_cb_; 81 //ReadCB read_cb_;
82 DecodeCB decode_cb_;
79 base::Closure reset_cb_; 83 base::Closure reset_cb_;
80 base::Closure stop_cb_; 84 base::Closure stop_cb_;
81 85
82 // Number of frames to be discarded from the start of the packet. This value 86 // Number of frames to be discarded from the start of the packet. This value
83 // is respected for all packets except for the first one in the stream. For 87 // is respected for all packets except for the first one in the stream. For
84 // the first packet in the stream, |frame_delay_at_start_| is used. This is 88 // the first packet in the stream, |frame_delay_at_start_| is used. This is
85 // usually set to the SeekPreRoll value from the container whenever a seek 89 // usually set to the SeekPreRoll value from the container whenever a seek
86 // happens. 90 // happens.
87 int frames_to_discard_; 91 int frames_to_discard_;
88 92
89 // Number of frames to be discarded at the start of the stream. This value 93 // Number of frames to be discarded at the start of the stream. This value
90 // is typically the CodecDelay value from the container. This value should 94 // is typically the CodecDelay value from the container. This value should
91 // only be applied when input timestamp is |start_input_timestamp_|. 95 // only be applied when input timestamp is |start_input_timestamp_|.
92 int frame_delay_at_start_; 96 int frame_delay_at_start_;
93 base::TimeDelta start_input_timestamp_; 97 base::TimeDelta start_input_timestamp_;
94 98
95 // Timestamp to be subtracted from all the frames. This is typically computed 99 // Timestamp to be subtracted from all the frames. This is typically computed
96 // from the CodecDelay value in the container. 100 // from the CodecDelay value in the container.
97 base::TimeDelta timestamp_offset_; 101 base::TimeDelta timestamp_offset_;
98 102
99 DISALLOW_IMPLICIT_CONSTRUCTORS(OpusAudioDecoder); 103 DISALLOW_IMPLICIT_CONSTRUCTORS(OpusAudioDecoder);
100 }; 104 };
101 105
102 } // namespace media 106 } // namespace media
103 107
104 #endif // MEDIA_FILTERS_OPUS_AUDIO_DECODER_H_ 108 #endif // MEDIA_FILTERS_OPUS_AUDIO_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698