File: desktop_environment_options.cc

package info (click to toggle)
chromium 139.0.7258.127-2
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 6,122,156 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (160 lines) | stat: -rw-r--r-- 5,044 bytes parent folder | download | duplicates (5)
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