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

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

Issue 1897953003: Unmute Tab Audio For Desktop Share (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix trybot error Created 4 years, 7 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) 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 <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // successful audio capture. 79 // successful audio capture.
80 void UnmuteWebContentsAudio(); 80 void UnmuteWebContentsAudio();
81 81
82 // AudioMirroringManager::MirroringDestination implementation 82 // AudioMirroringManager::MirroringDestination implementation
83 void QueryForMatches(const std::set<SourceFrameRef>& candidates, 83 void QueryForMatches(const std::set<SourceFrameRef>& candidates,
84 const MatchesCallback& results_callback) override; 84 const MatchesCallback& results_callback) override;
85 void QueryForMatchesOnUIThread(const std::set<SourceFrameRef>& candidates, 85 void QueryForMatchesOnUIThread(const std::set<SourceFrameRef>& candidates,
86 const MatchesCallback& results_callback); 86 const MatchesCallback& results_callback);
87 media::AudioOutputStream* AddInput( 87 media::AudioOutputStream* AddInput(
88 const media::AudioParameters& params) override; 88 const media::AudioParameters& params) override;
89 media::AudioPushSink* AddPushInput(
90 const media::AudioParameters& params) override;
89 91
90 // Callback which is run when |stream| is closed. Deletes |stream|. 92 // Callback which is run when |stream| is closed. Deletes |stream|.
91 void ReleaseInput(media::VirtualAudioOutputStream* stream); 93 void ReleaseInput(media::VirtualAudioOutputStream* stream);
94 void ReleasePushInput(media::VirtualAudioSink* sink);
92 95
93 // Called by WebContentsTracker when the target of the audio mirroring has 96 // Called by WebContentsTracker when the target of the audio mirroring has
94 // changed. 97 // changed.
95 void OnTargetChanged(bool had_target); 98 void OnTargetChanged(bool had_target);
96 99
97 // Injected dependencies. 100 // Injected dependencies.
98 const int initial_render_process_id_; 101 const int initial_render_process_id_;
99 const int initial_main_render_frame_id_; 102 const int initial_main_render_frame_id_;
100 AudioMirroringManager* const mirroring_manager_; 103 AudioMirroringManager* const mirroring_manager_;
101 const scoped_refptr<WebContentsTracker> tracker_; 104 const scoped_refptr<WebContentsTracker> tracker_;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 for (std::set<SourceFrameRef>::const_iterator i = candidates.begin(); 279 for (std::set<SourceFrameRef>::const_iterator i = candidates.begin();
277 i != candidates.end(); ++i) { 280 i != candidates.end(); ++i) {
278 WebContents* const contents_containing_frame = 281 WebContents* const contents_containing_frame =
279 WebContents::FromRenderFrameHost( 282 WebContents::FromRenderFrameHost(
280 RenderFrameHost::FromID(i->first, i->second)); 283 RenderFrameHost::FromID(i->first, i->second));
281 if (contents_containing_frame == contents) 284 if (contents_containing_frame == contents)
282 matches.insert(*i); 285 matches.insert(*i);
283 } 286 }
284 } 287 }
285 288
286 results_callback.Run(matches); 289 // TODO(qiangchen): Plug in true for the case of Tab Typed Desktop Share.
290 results_callback.Run(matches, true);
miu 2016/05/02 20:06:13 The 2nd argument here should be false, to maintain
qiangchen 2016/05/03 16:58:23 Done. Ha, that's my testing code. Forgot to chang
287 } 291 }
288 292
289 media::AudioOutputStream* WebContentsAudioInputStream::Impl::AddInput( 293 media::AudioOutputStream* WebContentsAudioInputStream::Impl::AddInput(
290 const media::AudioParameters& params) { 294 const media::AudioParameters& params) {
291 // Note: The closure created here holds a reference to "this," which will 295 // Note: The closure created here holds a reference to "this," which will
292 // guarantee the VirtualAudioInputStream (mixer_stream_) outlives the 296 // guarantee the VirtualAudioInputStream (mixer_stream_) outlives the
293 // VirtualAudioOutputStream. 297 // VirtualAudioOutputStream.
294 return new media::VirtualAudioOutputStream( 298 return new media::VirtualAudioOutputStream(
295 params, 299 params,
296 mixer_stream_.get(), 300 mixer_stream_.get(),
297 base::Bind(&Impl::ReleaseInput, this)); 301 base::Bind(&Impl::ReleaseInput, this));
298 } 302 }
299 303
300 void WebContentsAudioInputStream::Impl::ReleaseInput( 304 void WebContentsAudioInputStream::Impl::ReleaseInput(
301 media::VirtualAudioOutputStream* stream) { 305 media::VirtualAudioOutputStream* stream) {
302 delete stream; 306 delete stream;
303 } 307 }
304 308
309 media::AudioPushSink* WebContentsAudioInputStream::Impl::AddPushInput(
310 const media::AudioParameters& params) {
311 // Note: The closure created here holds a reference to "this," which will
312 // guarantee the VirtualAudioInputStream (mixer_stream_) outlives the
313 // VirtualAudioSink.
314 return new media::VirtualAudioSink(params, mixer_stream_.get(),
315 base::Bind(&Impl::ReleasePushInput, this));
316 }
317
318 void WebContentsAudioInputStream::Impl::ReleasePushInput(
319 media::VirtualAudioSink* stream) {
320 delete stream;
321 }
322
305 void WebContentsAudioInputStream::Impl::OnTargetChanged(bool had_target) { 323 void WebContentsAudioInputStream::Impl::OnTargetChanged(bool had_target) {
306 DCHECK(thread_checker_.CalledOnValidThread()); 324 DCHECK(thread_checker_.CalledOnValidThread());
307 325
308 is_target_lost_ = !had_target; 326 is_target_lost_ = !had_target;
309 327
310 if (state_ == MIRRORING) { 328 if (state_ == MIRRORING) {
311 if (is_target_lost_) { 329 if (is_target_lost_) {
312 ReportError(); 330 ReportError();
313 Stop(); 331 Stop();
314 } else { 332 } else {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 402
385 bool WebContentsAudioInputStream::GetAutomaticGainControl() { 403 bool WebContentsAudioInputStream::GetAutomaticGainControl() {
386 return impl_->mixer_stream()->GetAutomaticGainControl(); 404 return impl_->mixer_stream()->GetAutomaticGainControl();
387 } 405 }
388 406
389 bool WebContentsAudioInputStream::IsMuted() { 407 bool WebContentsAudioInputStream::IsMuted() {
390 return false; 408 return false;
391 } 409 }
392 410
393 } // namespace content 411 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698