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

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

Issue 15979027: start/stop the source of the capturer when 1st audiotrack/last audiotrack is added/removed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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_CAPTURER_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_ 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <string> 9 #include <string>
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 // Creates and configures the default audio capturing source using the 46 // Creates and configures the default audio capturing source using the
47 // provided audio parameters. |render_view_id| specifies the render view 47 // provided audio parameters. |render_view_id| specifies the render view
48 // consuming audio for capture. |session_id| is passed to the browser to 48 // consuming audio for capture. |session_id| is passed to the browser to
49 // decide which device to use. Called on the main render thread. 49 // decide which device to use. Called on the main render thread.
50 bool Initialize(int render_view_id, 50 bool Initialize(int render_view_id,
51 media::ChannelLayout channel_layout, 51 media::ChannelLayout channel_layout,
52 int sample_rate, 52 int sample_rate,
53 int session_id); 53 int session_id);
54 54
55 // Called by the WebRtcAudioDeviceImpl to add the ADM as the default sink to
henrika (OOO until Aug 14) 2013/06/05 09:09:20 Please add some comments about the effects are by
no longer working on chromium 2013/06/05 16:29:45 Not the existing unittests, but I have already add
56 // the capturer. This function is needed since WebRTC supports only one ADM
57 // but multiple audio tracks, so the ADM can't be the sink of certain audio
58 // track now.
59 // TODO(xians): Remove this function after WebRtc supports multiple ADMs.
60 void SetDefaultSink(WebRtcAudioCapturerSink* sink);
61
55 // Add a audio track to the sinks of the capturer. 62 // Add a audio track to the sinks of the capturer.
56 // WebRtcAudioDeviceImpl calls this method on the main render thread but 63 // WebRtcAudioDeviceImpl calls this method on the main render thread but
57 // other clients may call it from other threads. The current implementation 64 // other clients may call it from other threads. The current implementation
58 // does not support multi-thread calling. 65 // does not support multi-thread calling.
59 // Called on the main render thread. 66 // Called on the main render thread or libjingle working thread.
60 void AddSink(WebRtcAudioCapturerSink* track); 67 void AddSink(WebRtcAudioCapturerSink* track);
61 68
62 // Remove a audio track from the sinks of the capturer. 69 // Remove a audio track from the sinks of the capturer.
63 // Called on the main render thread. 70 // Called on the main render thread or libjingle working thread.
64 void RemoveSink(WebRtcAudioCapturerSink* track); 71 void RemoveSink(WebRtcAudioCapturerSink* track);
65 72
66 // SetCapturerSource() is called if the client on the source side desires to 73 // SetCapturerSource() is called if the client on the source side desires to
67 // provide their own captured audio data. Client is responsible for calling 74 // provide their own captured audio data. Client is responsible for calling
68 // Start() on its own source to have the ball rolling. 75 // Start() on its own source to have the ball rolling.
69 // Called on the main render thread. 76 // Called on the main render thread.
70 void SetCapturerSource( 77 void SetCapturerSource(
71 const scoped_refptr<media::AudioCapturerSource>& source, 78 const scoped_refptr<media::AudioCapturerSource>& source,
72 media::ChannelLayout channel_layout, 79 media::ChannelLayout channel_layout,
73 float sample_rate); 80 float sample_rate);
74 81
75 // Starts recording audio.
76 // Called on the main render thread or a Libjingle working thread.
77 void Start();
78
79 // Stops recording audio.
80 // Called on the main render thread or a Libjingle working thread.
81 void Stop();
82
83 // Sets the microphone volume. 82 // Sets the microphone volume.
84 // Called on the AudioInputDevice audio thread. 83 // Called on the AudioInputDevice audio thread.
85 void SetVolume(double volume); 84 void SetVolume(double volume);
86 85
87 // Enables or disables the WebRtc AGC control. 86 // Enables or disables the WebRtc AGC control.
88 // Called from a Libjingle working thread. 87 // Called from a Libjingle working thread.
89 void SetAutomaticGainControl(bool enable); 88 void SetAutomaticGainControl(bool enable);
90 89
91 bool is_recording() const { return running_; } 90 bool is_recording() const { return running_; }
92 91
(...skipping 17 matching lines...) Expand all
110 // Called on the AudioInputDevice audio thread. 109 // Called on the AudioInputDevice audio thread.
111 virtual void Capture(media::AudioBus* audio_source, 110 virtual void Capture(media::AudioBus* audio_source,
112 int audio_delay_milliseconds, 111 int audio_delay_milliseconds,
113 double volume) OVERRIDE; 112 double volume) OVERRIDE;
114 virtual void OnCaptureError() OVERRIDE; 113 virtual void OnCaptureError() OVERRIDE;
115 114
116 // Reconfigures the capturer with a new buffer size and capture parameters. 115 // Reconfigures the capturer with a new buffer size and capture parameters.
117 // Must be called without holding the lock. Returns true on success. 116 // Must be called without holding the lock. Returns true on success.
118 bool Reconfigure(int sample_rate, media::ChannelLayout channel_layout); 117 bool Reconfigure(int sample_rate, media::ChannelLayout channel_layout);
119 118
119 // Starts recording audio.
120 // Triggered by AddSink() on the main render thread or a Libjingle working
121 // thread. It should NOT be called under |lock_|.
122 void Start();
123
124 // Stops recording audio.
125 // Triggered by RemoveSink() on the main render thread or a Libjingle working
126 // thread. It should NOT be called under |lock_|.
127 void Stop();
128
129
120 // Used to DCHECK that we are called on the correct thread. 130 // Used to DCHECK that we are called on the correct thread.
121 base::ThreadChecker thread_checker_; 131 base::ThreadChecker thread_checker_;
122 132
123 // Protects |source_|, |audio_tracks_|, |running_|, |loopback_fifo_|, 133 // Protects |source_|, |audio_tracks_|, |running_|, |loopback_fifo_|,
124 // |params_|, |buffering_| and |agc_is_enabled_|. 134 // |params_|, |buffering_| and |agc_is_enabled_|.
125 mutable base::Lock lock_; 135 mutable base::Lock lock_;
126 136
127 // A list of audio tracks that the audio data is fed to. 137 // A list of audio tracks that the audio data is fed to.
128 TrackList tracks_; 138 TrackList tracks_;
129 139
140 WebRtcAudioCapturerSink* default_sink_;
henrika (OOO until Aug 14) 2013/06/05 09:09:20 Add comment.
no longer working on chromium 2013/06/05 16:29:45 Done.
141
130 // The audio data source from the browser process. 142 // The audio data source from the browser process.
131 scoped_refptr<media::AudioCapturerSource> source_; 143 scoped_refptr<media::AudioCapturerSource> source_;
132 144
133 // Buffers used for temporary storage during capture callbacks. 145 // Buffers used for temporary storage during capture callbacks.
134 // Allocated during initialization. 146 // Allocated during initialization.
135 class ConfiguredBuffer; 147 class ConfiguredBuffer;
136 scoped_refptr<ConfiguredBuffer> buffer_; 148 scoped_refptr<ConfiguredBuffer> buffer_;
137 bool running_; 149 bool running_;
138 150
139 // True when automatic gain control is enabled, false otherwise. 151 // True when automatic gain control is enabled, false otherwise.
140 bool agc_is_enabled_; 152 bool agc_is_enabled_;
141 153
142 // The media session ID used to identify which input device to be started. 154 // The media session ID used to identify which input device to be started.
143 int session_id_; 155 int session_id_;
144 156
145 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioCapturer); 157 DISALLOW_COPY_AND_ASSIGN(WebRtcAudioCapturer);
146 }; 158 };
147 159
148 } // namespace content 160 } // namespace content
149 161
150 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_ 162 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_AUDIO_CAPTURER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698