1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
|
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "remoting/host/base/desktop_environment_options.h"
#include <optional>
#include <string>
#include <utility>
#include "base/time/time.h"
#include "build/build_config.h"
namespace remoting {
using DesktopCaptureOptions = webrtc::DesktopCaptureOptions;
// static
DesktopEnvironmentOptions DesktopEnvironmentOptions::CreateDefault() {
DesktopEnvironmentOptions options;
options.desktop_capture_options_ = DesktopCaptureOptions::CreateDefault();
options.Initialize();
return options;
}
DesktopEnvironmentOptions::DesktopEnvironmentOptions() {
Initialize();
}
DesktopEnvironmentOptions::DesktopEnvironmentOptions(
DesktopEnvironmentOptions&& other) = default;
DesktopEnvironmentOptions::DesktopEnvironmentOptions(
const DesktopEnvironmentOptions& other) = default;
DesktopEnvironmentOptions::~DesktopEnvironmentOptions() = default;
DesktopEnvironmentOptions& DesktopEnvironmentOptions::operator=(
DesktopEnvironmentOptions&& other) = default;
DesktopEnvironmentOptions& DesktopEnvironmentOptions::operator=(
const DesktopEnvironmentOptions& other) = default;
void DesktopEnvironmentOptions::Initialize() {
desktop_capture_options_.set_detect_updated_region(true);
// Enable iosurface in the Mac capturer to work around a recent change to
// the Mac screen-capturer - see http://crbug.com/1523038.
#if BUILDFLAG(IS_MAC)
desktop_capture_options_.set_allow_iosurface(true);
#endif
}
const DesktopCaptureOptions*
DesktopEnvironmentOptions::desktop_capture_options() const {
return &desktop_capture_options_;
}
DesktopCaptureOptions* DesktopEnvironmentOptions::desktop_capture_options() {
return &desktop_capture_options_;
}
bool DesktopEnvironmentOptions::enable_curtaining() const {
return enable_curtaining_;
}
void DesktopEnvironmentOptions::set_enable_curtaining(bool enabled) {
enable_curtaining_ = enabled;
}
bool DesktopEnvironmentOptions::enable_user_interface() const {
return enable_user_interface_;
}
void DesktopEnvironmentOptions::set_enable_user_interface(bool enabled) {
enable_user_interface_ = enabled;
}
bool DesktopEnvironmentOptions::enable_notifications() const {
return enable_notifications_;
}
void DesktopEnvironmentOptions::set_enable_notifications(bool enabled) {
enable_notifications_ = enabled;
}
bool DesktopEnvironmentOptions::terminate_upon_input() const {
return terminate_upon_input_;
}
void DesktopEnvironmentOptions::set_terminate_upon_input(bool enabled) {
terminate_upon_input_ = enabled;
}
bool DesktopEnvironmentOptions::enable_remote_webauthn() const {
return enable_remote_webauthn_;
}
void DesktopEnvironmentOptions::set_enable_remote_webauthn(bool enabled) {
enable_remote_webauthn_ = enabled;
}
base::TimeDelta DesktopEnvironmentOptions::maximum_session_duration() const {
return maximum_session_duration_;
}
void DesktopEnvironmentOptions::set_maximum_session_duration(
base::TimeDelta duration) {
maximum_session_duration_ = duration;
}
bool DesktopEnvironmentOptions::capture_video_on_dedicated_thread() const {
// TODO(joedow): Determine whether we can migrate additional platforms to
// using the DesktopCaptureWrapper instead of the DesktopCaptureProxy. Then
// clean up DesktopCapturerProxy::Core::CreateCapturer().
#if BUILDFLAG(IS_LINUX)
return capture_video_on_dedicated_thread_;
#else
return false;
#endif
}
void DesktopEnvironmentOptions::set_capture_video_on_dedicated_thread(
bool use_dedicated_thread) {
capture_video_on_dedicated_thread_ = use_dedicated_thread;
}
void DesktopEnvironmentOptions::ApplySessionOptions(
const SessionOptions& options) {
// This field is for test purpose. Usually it should not be set to false.
std::optional<bool> detect_updated_region =
options.GetBool("Detect-Updated-Region");
if (detect_updated_region.has_value()) {
desktop_capture_options_.set_detect_updated_region(*detect_updated_region);
}
std::optional<bool> capture_video_on_dedicated_thread =
options.GetBool("Capture-Video-On-Dedicated-Thread");
if (capture_video_on_dedicated_thread.has_value()) {
set_capture_video_on_dedicated_thread(*capture_video_on_dedicated_thread);
}
#if BUILDFLAG(IS_MAC)
std::optional<bool> enable_sck_capturer =
options.GetBool("Enable-Sck-Capturer");
if (enable_sck_capturer.has_value()) {
desktop_capture_options_.set_allow_sck_capturer(*enable_sck_capturer);
}
#endif // IS_MAC
#if BUILDFLAG(IS_WIN)
std::optional<bool> allow_dxgi_capturer =
options.GetBool("Allow-Dxgi-Capturer");
if (allow_dxgi_capturer.has_value()) {
desktop_capture_options_.set_allow_directx_capturer(*allow_dxgi_capturer);
}
#endif // IS_WIN
#if defined(WEBRTC_USE_PIPEWIRE)
desktop_capture_options_.set_allow_pipewire(true);
desktop_capture_options_.set_pipewire_use_damage_region(true);
#endif // defined(WEBRTC_USE_PIPEWIRE)
}
} // namespace remoting
|