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

Unified Diff: content/browser/renderer_host/media/media_stream_manager.cc

Issue 2291893002: Let Contraints Controll Mute/Unmute Audio Local Playback For Desktop Sharing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/media/media_stream_manager.cc
diff --git a/content/browser/renderer_host/media/media_stream_manager.cc b/content/browser/renderer_host/media/media_stream_manager.cc
index 0b44e5f79f8b1a3c32b377b22302fea877600a3b..28fd3dfd9da939c95de268b7bff8135763cc41dd 100644
--- a/content/browser/renderer_host/media/media_stream_manager.cc
+++ b/content/browser/renderer_host/media/media_stream_manager.cc
@@ -305,7 +305,7 @@ class MediaStreamManager::DeviceRequest {
requesting_process_id, requesting_frame_id, page_request_id,
security_origin.GetURL(), user_gesture, request_type,
requested_audio_device_id, requested_video_device_id, audio_type_,
- video_type_));
+ video_type_, controls.disable_local_echo));
}
// Creates a tab capture specific MediaStreamRequest object that is used by
@@ -318,7 +318,7 @@ class MediaStreamManager::DeviceRequest {
ui_request_.reset(new MediaStreamRequest(
target_render_process_id, target_render_frame_id, page_request_id,
security_origin.GetURL(), user_gesture, request_type, "", "",
- audio_type_, video_type_));
+ audio_type_, video_type_, controls.disable_local_echo));
}
bool HasUIRequest() const { return ui_request_.get() != nullptr; }
@@ -535,6 +535,18 @@ void MediaStreamManager::GenerateStream(MediaStreamRequester* requester,
const std::string& label = AddRequest(request);
+ if (!generate_stream_test_callback_.is_null()) {
+ // The test callback is responsible to verify whether the |controls| is
+ // as expected. Then we need to finish getUserMedia and let Javascript
+ // access the result.
+ if (generate_stream_test_callback_.Run(controls)) {
+ FinalizeGenerateStream(label, request);
+ } else {
+ FinalizeRequestFailed(label, request, MEDIA_DEVICE_INVALID_STATE);
+ }
+ return;
+ }
+
// Post a task and handle the request asynchronously. The reason is that the
// requester won't have a label for the request until this function returns
// and thus can not handle a response. Using base::Unretained is safe since
@@ -1179,11 +1191,9 @@ bool MediaStreamManager::SetupTabCaptureRequest(DeviceRequest* request) {
}
// Customize controls for a WebContents based capture.
- int target_render_process_id = 0;
- int target_render_frame_id = 0;
-
- bool has_valid_device_id = WebContentsMediaCaptureId::ExtractTabCaptureTarget(
- capture_device_id, &target_render_process_id, &target_render_frame_id);
+ content::WebContentsMediaCaptureId web_id;
+ bool has_valid_device_id =
+ WebContentsMediaCaptureId::Parse(capture_device_id, &web_id);
if (!has_valid_device_id ||
(request->audio_type() != MEDIA_TAB_AUDIO_CAPTURE &&
request->audio_type() != MEDIA_NO_SERVICE) ||
@@ -1191,16 +1201,19 @@ bool MediaStreamManager::SetupTabCaptureRequest(DeviceRequest* request) {
request->video_type() != MEDIA_NO_SERVICE)) {
return false;
}
- request->tab_capture_device_id = capture_device_id;
+ web_id.disable_local_echo = request->controls.disable_local_echo;
+
+ request->tab_capture_device_id = web_id.ToString();
- request->CreateTabCaptureUIRequest(target_render_process_id,
- target_render_frame_id);
+ request->CreateTabCaptureUIRequest(web_id.render_process_id,
+ web_id.main_render_frame_id);
DVLOG(3) << "SetupTabCaptureRequest "
- << ", {capture_device_id = " << capture_device_id << "}"
- << ", {target_render_process_id = " << target_render_process_id
+ << ", {capture_device_id = " << capture_device_id << "}"
+ << ", {target_render_process_id = " << web_id.render_process_id
<< "}"
- << ", {target_render_frame_id = " << target_render_frame_id << "}";
+ << ", {target_render_frame_id = " << web_id.main_render_frame_id
+ << "}";
return true;
}
@@ -2031,4 +2044,9 @@ void MediaStreamManager::ProcessOpenEnumerationRequests(
}
}
+void MediaStreamManager::SetGenerateStreamCallbackForTesting(
+ GenerateStreamTestCallback test_callback) {
+ generate_stream_test_callback_ = test_callback;
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698