OLD | NEW |
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 Loading... |
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); |
| 95 |
| 96 bool IsDuplication() override; |
92 | 97 |
93 // Called by WebContentsTracker when the target of the audio mirroring has | 98 // Called by WebContentsTracker when the target of the audio mirroring has |
94 // changed. | 99 // changed. |
95 void OnTargetChanged(bool had_target); | 100 void OnTargetChanged(bool had_target); |
96 | 101 |
97 // Injected dependencies. | 102 // Injected dependencies. |
98 const int initial_render_process_id_; | 103 const int initial_render_process_id_; |
99 const int initial_main_render_frame_id_; | 104 const int initial_main_render_frame_id_; |
100 AudioMirroringManager* const mirroring_manager_; | 105 AudioMirroringManager* const mirroring_manager_; |
101 const scoped_refptr<WebContentsTracker> tracker_; | 106 const scoped_refptr<WebContentsTracker> tracker_; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 params, | 300 params, |
296 mixer_stream_.get(), | 301 mixer_stream_.get(), |
297 base::Bind(&Impl::ReleaseInput, this)); | 302 base::Bind(&Impl::ReleaseInput, this)); |
298 } | 303 } |
299 | 304 |
300 void WebContentsAudioInputStream::Impl::ReleaseInput( | 305 void WebContentsAudioInputStream::Impl::ReleaseInput( |
301 media::VirtualAudioOutputStream* stream) { | 306 media::VirtualAudioOutputStream* stream) { |
302 delete stream; | 307 delete stream; |
303 } | 308 } |
304 | 309 |
| 310 media::AudioPushSink* WebContentsAudioInputStream::Impl::AddPushInput( |
| 311 const media::AudioParameters& params) { |
| 312 // Note: The closure created here holds a reference to "this," which will |
| 313 // guarantee the VirtualAudioInputStream (mixer_stream_) outlives the |
| 314 // VirtualAudioSink. |
| 315 return new media::VirtualAudioSink(params, mixer_stream_.get(), |
| 316 base::Bind(&Impl::ReleasePushInput, this)); |
| 317 } |
| 318 |
| 319 void WebContentsAudioInputStream::Impl::ReleasePushInput( |
| 320 media::VirtualAudioSink* stream) { |
| 321 delete stream; |
| 322 } |
| 323 |
| 324 bool WebContentsAudioInputStream::Impl::IsDuplication() { |
| 325 // TODO(qiangchen): Return true for the case of Tab Typed Desktop Share. |
| 326 return false; |
| 327 } |
| 328 |
305 void WebContentsAudioInputStream::Impl::OnTargetChanged(bool had_target) { | 329 void WebContentsAudioInputStream::Impl::OnTargetChanged(bool had_target) { |
306 DCHECK(thread_checker_.CalledOnValidThread()); | 330 DCHECK(thread_checker_.CalledOnValidThread()); |
307 | 331 |
308 is_target_lost_ = !had_target; | 332 is_target_lost_ = !had_target; |
309 | 333 |
310 if (state_ == MIRRORING) { | 334 if (state_ == MIRRORING) { |
311 if (is_target_lost_) { | 335 if (is_target_lost_) { |
312 ReportError(); | 336 ReportError(); |
313 Stop(); | 337 Stop(); |
314 } else { | 338 } else { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 408 |
385 bool WebContentsAudioInputStream::GetAutomaticGainControl() { | 409 bool WebContentsAudioInputStream::GetAutomaticGainControl() { |
386 return impl_->mixer_stream()->GetAutomaticGainControl(); | 410 return impl_->mixer_stream()->GetAutomaticGainControl(); |
387 } | 411 } |
388 | 412 |
389 bool WebContentsAudioInputStream::IsMuted() { | 413 bool WebContentsAudioInputStream::IsMuted() { |
390 return false; | 414 return false; |
391 } | 415 } |
392 | 416 |
393 } // namespace content | 417 } // namespace content |
OLD | NEW |