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

Side by Side Diff: content/browser/media/capture/web_contents_audio_input_stream.cc

Issue 586303004: WebContentsAudioMuter: Mute all audio output from a WebContentsImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Dale's comments. Created 6 years, 2 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
« no previous file with comments | « no previous file | content/browser/media/capture/web_contents_audio_muter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #include "content/browser/media/capture/web_contents_audio_input_stream.h" 5 #include "content/browser/media/capture/web_contents_audio_input_stream.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 virtual ~Impl(); 67 virtual ~Impl();
68 68
69 // Notifies the consumer callback that the stream is now dead. 69 // Notifies the consumer callback that the stream is now dead.
70 void ReportError(); 70 void ReportError();
71 71
72 // (Re-)Start/Stop mirroring by posting a call to AudioMirroringManager on the 72 // (Re-)Start/Stop mirroring by posting a call to AudioMirroringManager on the
73 // IO BrowserThread. 73 // IO BrowserThread.
74 void StartMirroring(); 74 void StartMirroring();
75 void StopMirroring(); 75 void StopMirroring();
76 76
77 // Invoked on the UI thread to make sure WebContents muting is turned off for
78 // successful audio capture.
79 void UnmuteWebContentsAudio();
80
77 // AudioMirroringManager::MirroringDestination implementation 81 // AudioMirroringManager::MirroringDestination implementation
78 virtual void QueryForMatches( 82 virtual void QueryForMatches(
79 const std::set<SourceFrameRef>& candidates, 83 const std::set<SourceFrameRef>& candidates,
80 const MatchesCallback& results_callback) OVERRIDE; 84 const MatchesCallback& results_callback) OVERRIDE;
81 void QueryForMatchesOnUIThread(const std::set<SourceFrameRef>& candidates, 85 void QueryForMatchesOnUIThread(const std::set<SourceFrameRef>& candidates,
82 const MatchesCallback& results_callback); 86 const MatchesCallback& results_callback);
83 virtual media::AudioOutputStream* AddInput( 87 virtual media::AudioOutputStream* AddInput(
84 const media::AudioParameters& params) OVERRIDE; 88 const media::AudioParameters& params) OVERRIDE;
85 89
86 // Callback which is run when |stream| is closed. Deletes |stream|. 90 // Callback which is run when |stream| is closed. Deletes |stream|.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 if (is_target_lost_) { 171 if (is_target_lost_) {
168 ReportError(); 172 ReportError();
169 callback_ = NULL; 173 callback_ = NULL;
170 return; 174 return;
171 } 175 }
172 176
173 state_ = MIRRORING; 177 state_ = MIRRORING;
174 mixer_stream_->Start(callback); 178 mixer_stream_->Start(callback);
175 179
176 StartMirroring(); 180 StartMirroring();
181
182 // WebContents audio muting is implemented as audio capture to nowhere.
183 // Unmuting will stop that audio capture, allowing AudioMirroringManager to
184 // divert audio capture to here.
185 BrowserThread::PostTask(
186 BrowserThread::UI,
187 FROM_HERE,
188 base::Bind(&Impl::UnmuteWebContentsAudio, this));
177 } 189 }
178 190
179 void WebContentsAudioInputStream::Impl::Stop() { 191 void WebContentsAudioInputStream::Impl::Stop() {
180 DCHECK(thread_checker_.CalledOnValidThread()); 192 DCHECK(thread_checker_.CalledOnValidThread());
181 193
182 if (state_ != MIRRORING) 194 if (state_ != MIRRORING)
183 return; 195 return;
184 196
185 state_ = OPENED; 197 state_ = OPENED;
186 198
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 DCHECK(thread_checker_.CalledOnValidThread()); 240 DCHECK(thread_checker_.CalledOnValidThread());
229 241
230 BrowserThread::PostTask( 242 BrowserThread::PostTask(
231 BrowserThread::IO, 243 BrowserThread::IO,
232 FROM_HERE, 244 FROM_HERE,
233 base::Bind(&AudioMirroringManager::StopMirroring, 245 base::Bind(&AudioMirroringManager::StopMirroring,
234 base::Unretained(mirroring_manager_), 246 base::Unretained(mirroring_manager_),
235 make_scoped_refptr(this))); 247 make_scoped_refptr(this)));
236 } 248 }
237 249
250 void WebContentsAudioInputStream::Impl::UnmuteWebContentsAudio() {
251 DCHECK_CURRENTLY_ON(BrowserThread::UI);
252
253 WebContents* const contents = tracker_->web_contents();
254 if (contents)
255 contents->SetAudioMuted(false);
256 }
257
238 void WebContentsAudioInputStream::Impl::QueryForMatches( 258 void WebContentsAudioInputStream::Impl::QueryForMatches(
239 const std::set<SourceFrameRef>& candidates, 259 const std::set<SourceFrameRef>& candidates,
240 const MatchesCallback& results_callback) { 260 const MatchesCallback& results_callback) {
241 BrowserThread::PostTask( 261 BrowserThread::PostTask(
242 BrowserThread::UI, 262 BrowserThread::UI,
243 FROM_HERE, 263 FROM_HERE,
244 base::Bind(&Impl::QueryForMatchesOnUIThread, 264 base::Bind(&Impl::QueryForMatchesOnUIThread,
245 this, 265 this,
246 candidates, 266 candidates,
247 media::BindToCurrentLoop(results_callback))); 267 media::BindToCurrentLoop(results_callback)));
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 385
366 void WebContentsAudioInputStream::SetAutomaticGainControl(bool enabled) { 386 void WebContentsAudioInputStream::SetAutomaticGainControl(bool enabled) {
367 impl_->mixer_stream()->SetAutomaticGainControl(enabled); 387 impl_->mixer_stream()->SetAutomaticGainControl(enabled);
368 } 388 }
369 389
370 bool WebContentsAudioInputStream::GetAutomaticGainControl() { 390 bool WebContentsAudioInputStream::GetAutomaticGainControl() {
371 return impl_->mixer_stream()->GetAutomaticGainControl(); 391 return impl_->mixer_stream()->GetAutomaticGainControl();
372 } 392 }
373 393
374 } // namespace content 394 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/media/capture/web_contents_audio_muter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698