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

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

Issue 757033005: Make tab audible and muted states and cause available for an extension API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: MutedToggleCause --> muted_toggle_cause Created 6 years 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) 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"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/threading/thread_checker.h" 13 #include "base/threading/thread_checker.h"
14 #include "content/browser/media/capture/audio_mirroring_manager.h" 14 #include "content/browser/media/capture/audio_mirroring_manager.h"
15 #include "content/browser/media/capture/web_contents_capture_util.h" 15 #include "content/browser/media/capture/web_contents_capture_util.h"
16 #include "content/browser/media/capture/web_contents_tracker.h" 16 #include "content/browser/media/capture/web_contents_tracker.h"
17 #include "content/public/browser/browser_thread.h" 17 #include "content/public/browser/browser_thread.h"
18 #include "content/public/browser/render_frame_host.h" 18 #include "content/public/browser/render_frame_host.h"
19 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
20 #include "media/audio/virtual_audio_input_stream.h" 20 #include "media/audio/virtual_audio_input_stream.h"
21 #include "media/audio/virtual_audio_output_stream.h" 21 #include "media/audio/virtual_audio_output_stream.h"
22 #include "media/base/bind_to_current_loop.h" 22 #include "media/base/bind_to_current_loop.h"
23 23
24 namespace content { 24 namespace content {
25 25
26 // String to indicate that muted state change was caused by capture
27 // (instead of initial, user or an extension id).
28 static const char kMutedToggleCauseCapture[] = "auto-forced for capture";
29
26 class WebContentsAudioInputStream::Impl 30 class WebContentsAudioInputStream::Impl
27 : public base::RefCountedThreadSafe<WebContentsAudioInputStream::Impl>, 31 : public base::RefCountedThreadSafe<WebContentsAudioInputStream::Impl>,
28 public AudioMirroringManager::MirroringDestination { 32 public AudioMirroringManager::MirroringDestination {
29 public: 33 public:
30 // Takes ownership of |mixer_stream|. The rest outlive this instance. 34 // Takes ownership of |mixer_stream|. The rest outlive this instance.
31 Impl(int render_process_id, int main_render_frame_id, 35 Impl(int render_process_id, int main_render_frame_id,
32 AudioMirroringManager* mirroring_manager, 36 AudioMirroringManager* mirroring_manager,
33 const scoped_refptr<WebContentsTracker>& tracker, 37 const scoped_refptr<WebContentsTracker>& tracker,
34 media::VirtualAudioInputStream* mixer_stream); 38 media::VirtualAudioInputStream* mixer_stream);
35 39
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 base::Bind(&AudioMirroringManager::StopMirroring, 248 base::Bind(&AudioMirroringManager::StopMirroring,
245 base::Unretained(mirroring_manager_), 249 base::Unretained(mirroring_manager_),
246 make_scoped_refptr(this))); 250 make_scoped_refptr(this)));
247 } 251 }
248 252
249 void WebContentsAudioInputStream::Impl::UnmuteWebContentsAudio() { 253 void WebContentsAudioInputStream::Impl::UnmuteWebContentsAudio() {
250 DCHECK_CURRENTLY_ON(BrowserThread::UI); 254 DCHECK_CURRENTLY_ON(BrowserThread::UI);
251 255
252 WebContents* const contents = tracker_->web_contents(); 256 WebContents* const contents = tracker_->web_contents();
253 if (contents) 257 if (contents)
254 contents->SetAudioMuted(false); 258 contents->SetAudioMuted(false, kMutedToggleCauseCapture);
255 } 259 }
256 260
257 void WebContentsAudioInputStream::Impl::QueryForMatches( 261 void WebContentsAudioInputStream::Impl::QueryForMatches(
258 const std::set<SourceFrameRef>& candidates, 262 const std::set<SourceFrameRef>& candidates,
259 const MatchesCallback& results_callback) { 263 const MatchesCallback& results_callback) {
260 BrowserThread::PostTask( 264 BrowserThread::PostTask(
261 BrowserThread::UI, 265 BrowserThread::UI,
262 FROM_HERE, 266 FROM_HERE,
263 base::Bind(&Impl::QueryForMatchesOnUIThread, 267 base::Bind(&Impl::QueryForMatchesOnUIThread,
264 this, 268 this,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 392
389 bool WebContentsAudioInputStream::GetAutomaticGainControl() { 393 bool WebContentsAudioInputStream::GetAutomaticGainControl() {
390 return impl_->mixer_stream()->GetAutomaticGainControl(); 394 return impl_->mixer_stream()->GetAutomaticGainControl();
391 } 395 }
392 396
393 bool WebContentsAudioInputStream::IsMuted() { 397 bool WebContentsAudioInputStream::IsMuted() {
394 return false; 398 return false;
395 } 399 }
396 400
397 } // namespace content 401 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698