Index: content/browser/media/capture/web_contents_audio_input_stream.cc |
diff --git a/content/browser/media/capture/web_contents_audio_input_stream.cc b/content/browser/media/capture/web_contents_audio_input_stream.cc |
index ce8f7f46419f158a31a0540eb0b9583e997d0848..a345a37dc7bcaecb4685ed97f8b0f3d80684f76a 100644 |
--- a/content/browser/media/capture/web_contents_audio_input_stream.cc |
+++ b/content/browser/media/capture/web_contents_audio_input_stream.cc |
@@ -29,10 +29,12 @@ class WebContentsAudioInputStream::Impl |
public AudioMirroringManager::MirroringDestination { |
public: |
// Takes ownership of |mixer_stream|. The rest outlive this instance. |
- Impl(int render_process_id, int main_render_frame_id, |
+ Impl(int render_process_id, |
+ int main_render_frame_id, |
AudioMirroringManager* mirroring_manager, |
const scoped_refptr<WebContentsTracker>& tracker, |
- media::VirtualAudioInputStream* mixer_stream); |
+ media::VirtualAudioInputStream* mixer_stream, |
+ bool is_duplication); |
// Open underlying VirtualAudioInputStream and start tracker. |
bool Open(); |
@@ -86,9 +88,12 @@ class WebContentsAudioInputStream::Impl |
const MatchesCallback& results_callback); |
media::AudioOutputStream* AddInput( |
const media::AudioParameters& params) override; |
+ media::AudioPushSink* AddPushInput( |
+ const media::AudioParameters& params) override; |
// Callback which is run when |stream| is closed. Deletes |stream|. |
void ReleaseInput(media::VirtualAudioOutputStream* stream); |
+ void ReleasePushInput(media::VirtualAudioSink* sink); |
// Called by WebContentsTracker when the target of the audio mirroring has |
// changed. |
@@ -112,16 +117,22 @@ class WebContentsAudioInputStream::Impl |
// Current callback used to consume the resulting mixed audio data. |
AudioInputCallback* callback_; |
+ // If true, this WebContentsAudioInputStream will request a duplication of |
+ // audio data. |
miu
2016/05/06 22:29:49
nit: Append to the end of the sentence: "instead o
qiangchen
2016/05/10 22:36:52
Done.
|
+ bool is_duplication_; |
+ |
base::ThreadChecker thread_checker_; |
DISALLOW_COPY_AND_ASSIGN(Impl); |
}; |
WebContentsAudioInputStream::Impl::Impl( |
- int render_process_id, int main_render_frame_id, |
+ int render_process_id, |
+ int main_render_frame_id, |
AudioMirroringManager* mirroring_manager, |
const scoped_refptr<WebContentsTracker>& tracker, |
- media::VirtualAudioInputStream* mixer_stream) |
+ media::VirtualAudioInputStream* mixer_stream, |
+ bool is_duplication) |
: initial_render_process_id_(render_process_id), |
initial_main_render_frame_id_(main_render_frame_id), |
mirroring_manager_(mirroring_manager), |
@@ -129,7 +140,8 @@ WebContentsAudioInputStream::Impl::Impl( |
mixer_stream_(mixer_stream), |
state_(CONSTRUCTED), |
is_target_lost_(false), |
- callback_(NULL) { |
+ callback_(NULL), |
+ is_duplication_(is_duplication) { |
DCHECK(mirroring_manager_); |
DCHECK(tracker_); |
DCHECK(mixer_stream_); |
@@ -283,7 +295,7 @@ void WebContentsAudioInputStream::Impl::QueryForMatchesOnUIThread( |
} |
} |
- results_callback.Run(matches); |
+ results_callback.Run(matches, is_duplication_); |
} |
media::AudioOutputStream* WebContentsAudioInputStream::Impl::AddInput( |
@@ -302,6 +314,20 @@ void WebContentsAudioInputStream::Impl::ReleaseInput( |
delete stream; |
} |
+media::AudioPushSink* WebContentsAudioInputStream::Impl::AddPushInput( |
+ const media::AudioParameters& params) { |
+ // Note: The closure created here holds a reference to "this," which will |
+ // guarantee the VirtualAudioInputStream (mixer_stream_) outlives the |
+ // VirtualAudioSink. |
+ return new media::VirtualAudioSink(params, mixer_stream_.get(), |
+ base::Bind(&Impl::ReleasePushInput, this)); |
+} |
+ |
+void WebContentsAudioInputStream::Impl::ReleasePushInput( |
+ media::VirtualAudioSink* stream) { |
+ delete stream; |
+} |
+ |
void WebContentsAudioInputStream::Impl::OnTargetChanged(bool had_target) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
@@ -330,22 +356,29 @@ WebContentsAudioInputStream* WebContentsAudioInputStream::Create( |
return NULL; |
} |
+ // TODO(qiangchen): Plug in true for the case of Tab Typed Desktop Share. |
miu
2016/05/06 22:29:49
Note: The JavaScript API to start tab capture shou
qiangchen
2016/05/10 22:36:52
For the current use case: Cast uses chrome.tabCapt
|
return new WebContentsAudioInputStream( |
- render_process_id, main_render_frame_id, |
- audio_mirroring_manager, |
+ render_process_id, main_render_frame_id, audio_mirroring_manager, |
new WebContentsTracker(false), |
new media::VirtualAudioInputStream( |
params, worker_task_runner, |
- media::VirtualAudioInputStream::AfterCloseCallback())); |
+ media::VirtualAudioInputStream::AfterCloseCallback()), |
+ false); |
} |
WebContentsAudioInputStream::WebContentsAudioInputStream( |
- int render_process_id, int main_render_frame_id, |
+ int render_process_id, |
+ int main_render_frame_id, |
AudioMirroringManager* mirroring_manager, |
const scoped_refptr<WebContentsTracker>& tracker, |
- media::VirtualAudioInputStream* mixer_stream) |
- : impl_(new Impl(render_process_id, main_render_frame_id, |
- mirroring_manager, tracker, mixer_stream)) {} |
+ media::VirtualAudioInputStream* mixer_stream, |
+ bool is_duplication) |
+ : impl_(new Impl(render_process_id, |
+ main_render_frame_id, |
+ mirroring_manager, |
+ tracker, |
+ mixer_stream, |
+ is_duplication)) {} |
WebContentsAudioInputStream::~WebContentsAudioInputStream() {} |