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

Side by Side Diff: content/renderer/media/webrtc_audio_renderer.h

Issue 139303016: Feed the render data to MediaStreamAudioProcessor and used AudioBus in render callback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased and added check the thread check on the destructor 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 | Annotate | Revision Log
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 CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "base/threading/non_thread_safe.h" 10 #include "base/threading/non_thread_safe.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 // etc and similarly maintains the same state for Stop(). 89 // etc and similarly maintains the same state for Stop().
90 // When Stop() is called or when the proxy goes out of scope, the proxy 90 // When Stop() is called or when the proxy goes out of scope, the proxy
91 // will ensure that Pause() is called followed by a call to Stop(), which 91 // will ensure that Pause() is called followed by a call to Stop(), which
92 // is the usage pattern that WebRtcAudioRenderer requires. 92 // is the usage pattern that WebRtcAudioRenderer requires.
93 scoped_refptr<MediaStreamAudioRenderer> CreateSharedAudioRendererProxy( 93 scoped_refptr<MediaStreamAudioRenderer> CreateSharedAudioRendererProxy(
94 const scoped_refptr<webrtc::MediaStreamInterface>& media_stream); 94 const scoped_refptr<webrtc::MediaStreamInterface>& media_stream);
95 95
96 // Used to DCHECK on the expected state. 96 // Used to DCHECK on the expected state.
97 bool IsStarted() const; 97 bool IsStarted() const;
98 98
99 // Accessors to the sink audio parameters.
100 int channels() const { return number_of_channels_; }
101 int sample_rate() const { return sample_rate_; }
102
99 private: 103 private:
100 // MediaStreamAudioRenderer implementation. This is private since we want 104 // MediaStreamAudioRenderer implementation. This is private since we want
101 // callers to use proxy objects. 105 // callers to use proxy objects.
102 // TODO(tommi): Make the MediaStreamAudioRenderer implementation a pimpl? 106 // TODO(tommi): Make the MediaStreamAudioRenderer implementation a pimpl?
103 virtual void Start() OVERRIDE; 107 virtual void Start() OVERRIDE;
104 virtual void Play() OVERRIDE; 108 virtual void Play() OVERRIDE;
105 virtual void Pause() OVERRIDE; 109 virtual void Pause() OVERRIDE;
106 virtual void Stop() OVERRIDE; 110 virtual void Stop() OVERRIDE;
107 virtual void SetVolume(float volume) OVERRIDE; 111 virtual void SetVolume(float volume) OVERRIDE;
108 virtual base::TimeDelta GetCurrentRenderTime() const OVERRIDE; 112 virtual base::TimeDelta GetCurrentRenderTime() const OVERRIDE;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 187
184 // The sink (destination) for rendered audio. 188 // The sink (destination) for rendered audio.
185 scoped_refptr<media::AudioOutputDevice> sink_; 189 scoped_refptr<media::AudioOutputDevice> sink_;
186 190
187 // The media stream that holds the audio tracks that this renderer renders. 191 // The media stream that holds the audio tracks that this renderer renders.
188 const scoped_refptr<webrtc::MediaStreamInterface> media_stream_; 192 const scoped_refptr<webrtc::MediaStreamInterface> media_stream_;
189 193
190 // Audio data source from the browser process. 194 // Audio data source from the browser process.
191 WebRtcAudioRendererSource* source_; 195 WebRtcAudioRendererSource* source_;
192 196
193 // Buffers used for temporary storage during render callbacks.
194 // Allocated during initialization.
195 scoped_ptr<int16[]> buffer_;
196
197 // Protects access to |state_|, |source_| and |sink_|. 197 // Protects access to |state_|, |source_| and |sink_|.
198 base::Lock lock_; 198 base::Lock lock_;
199 199
200 // Ref count for the MediaPlayers which are playing audio. 200 // Ref count for the MediaPlayers which are playing audio.
201 int play_ref_count_; 201 int play_ref_count_;
202 202
203 // Ref count for the MediaPlayers which have called Start() but not Stop(). 203 // Ref count for the MediaPlayers which have called Start() but not Stop().
204 int start_ref_count_; 204 int start_ref_count_;
205 205
206 // Used to buffer data between the client and the output device in cases where 206 // Used to buffer data between the client and the output device in cases where
207 // the client buffer size is not the same as the output device buffer size. 207 // the client buffer size is not the same as the output device buffer size.
208 scoped_ptr<media::AudioPullFifo> audio_fifo_; 208 scoped_ptr<media::AudioPullFifo> audio_fifo_;
209 209
210 // Contains the accumulated delay estimate which is provided to the WebRTC 210 // Contains the accumulated delay estimate which is provided to the WebRTC
211 // AEC. 211 // AEC.
212 int audio_delay_milliseconds_; 212 int audio_delay_milliseconds_;
213 213
214 // Delay due to the FIFO in milliseconds. 214 // Delay due to the FIFO in milliseconds.
215 int fifo_delay_milliseconds_; 215 int fifo_delay_milliseconds_;
216 216
217 // Saved volume and playing state of the root renderer. 217 // Saved volume and playing state of the root renderer.
218 PlayingState playing_state_; 218 PlayingState playing_state_;
219 219
220 // The preferred sample rate and buffer sizes provided via the ctor. 220 // The sample rate, number of channels and buffer sizes used by the sink of
tommi (sloooow) - chröme 2014/02/17 15:03:44 should we just store a |const AudioParameters| her
no longer working on chromium 2014/02/17 17:15:32 This can't be a const since it will be modified in
tommi (sloooow) - chröme 2014/02/18 12:54:12 yeah since we're already storing the same paramete
no longer working on chromium 2014/02/18 17:37:53 Done.
221 const int sample_rate_; 221 // the renderer.
222 const int frames_per_buffer_; 222 // Only modified in the Initialize() on the main render thread.
223 int sample_rate_;
224 int number_of_channels_;
225 int frames_per_buffer_;
223 226
224 // Maps audio sources to a list of active audio renderers. 227 // Maps audio sources to a list of active audio renderers.
225 // Pointers to PlayingState objects are only kept in this map while the 228 // Pointers to PlayingState objects are only kept in this map while the
226 // associated renderer is actually playing the stream. Ownership of the 229 // associated renderer is actually playing the stream. Ownership of the
227 // state objects lies with the renderers and they must leave the playing state 230 // state objects lies with the renderers and they must leave the playing state
228 // before being destructed (PlayingState object goes out of scope). 231 // before being destructed (PlayingState object goes out of scope).
229 SourcePlayingStates source_playing_states_; 232 SourcePlayingStates source_playing_states_;
230 233
231 DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioRenderer); 234 DISALLOW_IMPLICIT_CONSTRUCTORS(WebRtcAudioRenderer);
232 }; 235 };
233 236
234 } // namespace content 237 } // namespace content
235 238
236 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_ 239 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_RENDERER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698