From 5104133f4fa829dc43be5c27be6148f0330a283f Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Fri, 28 Apr 2017 16:39:37 -0400 Subject: [PATCH] Add support for WebRTC screen sharing (issue #1065) --- libcef/browser/browser_host_impl.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/libcef/browser/browser_host_impl.cc b/libcef/browser/browser_host_impl.cc index bbae0f3ec..43104d6f8 100644 --- a/libcef/browser/browser_host_impl.cc +++ b/libcef/browser/browser_host_impl.cc @@ -47,6 +47,7 @@ #include "content/browser/renderer_host/render_view_host_impl.h" #include "content/browser/gpu/compositor_util.h" #include "content/common/view_messages.h" +#include "content/public/browser/desktop_media_id.h" #include "content/public/browser/download_manager.h" #include "content/public/browser/download_url_parameters.h" #include "content/public/browser/host_zoom_map.h" @@ -2364,7 +2365,9 @@ void CefBrowserHostImpl::RequestMediaAccessPermission( (request.audio_type == content::MEDIA_DEVICE_AUDIO_CAPTURE); bool webcam_requested = (request.video_type == content::MEDIA_DEVICE_VIDEO_CAPTURE); - if (microphone_requested || webcam_requested) { + bool screen_requested = + (request.video_type == content::MEDIA_DESKTOP_VIDEO_CAPTURE); + if (microphone_requested || webcam_requested || screen_requested) { // Pick the desired device or fall back to the first available of the // given type. if (microphone_requested) { @@ -2381,6 +2384,19 @@ void CefBrowserHostImpl::RequestMediaAccessPermission( true, &devices); } + if (screen_requested) { + content::DesktopMediaID media_id; + if (request.requested_video_device_id.empty()) { + media_id = content::DesktopMediaID( + content::DesktopMediaID::TYPE_SCREEN, + -1 /* webrtc::kFullDesktopScreenId */); + } else { + media_id = + content::DesktopMediaID::Parse(request.requested_video_device_id); + } + devices.push_back(content::MediaStreamDevice( + content::MEDIA_DESKTOP_VIDEO_CAPTURE, media_id.ToString(), "Screen")); + } } callback.Run(devices, content::MEDIA_DEVICE_OK,