Skip to content

Commit 9a6281c

Browse files
committed
Don't start the webrtc_operator binary
This is no longer supported since this version of run_cvd runs in hosts that have the signaling server.
1 parent 60f9a28 commit 9a6281c

File tree

15 files changed

+26
-257
lines changed

15 files changed

+26
-257
lines changed

base/cvd/cuttlefish/host/commands/assemble_cvd/assemble_cvd_flags.cpp

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -205,28 +205,11 @@ DEFINE_vec(start_webrtc, fmt::format("{}", CF_DEFAULTS_START_WEBRTC),
205205
"Whether to start the webrtc process.");
206206

207207
DEFINE_vec(webrtc_assets_dir, CF_DEFAULTS_WEBRTC_ASSETS_DIR,
208-
"[Experimental] Path to WebRTC webpage assets.");
209-
210-
DEFINE_string(webrtc_certs_dir, CF_DEFAULTS_WEBRTC_CERTS_DIR,
211-
"[Experimental] Path to WebRTC certificates directory.");
212-
213-
DEFINE_bool(
214-
// The actual default for this flag is set with SetCommandLineOption() in
215-
// GetGuestConfigsAndSetDefaults() at the end of this file.
216-
start_webrtc_sig_server, CF_DEFAULTS_START_WEBRTC_SIG_SERVER,
217-
"Whether to start the webrtc signaling server. This option only applies to "
218-
"the first instance, if multiple instances are launched they'll share the "
219-
"same signaling server, which is owned by the first one.");
208+
"Path to WebRTC webpage assets.");
220209

221210
DEFINE_string(webrtc_sig_server_addr, CF_DEFAULTS_WEBRTC_SIG_SERVER_ADDR,
222211
"The address of the webrtc signaling server.");
223212

224-
DEFINE_int32(
225-
webrtc_sig_server_port, CF_DEFAULTS_WEBRTC_SIG_SERVER_PORT,
226-
"The port of the signaling server if started outside of this launch. If "
227-
"-start_webrtc_sig_server is given it will choose 8443+instance_num1-1 and "
228-
"this parameter is ignored.");
229-
230213
// TODO (jemoreira): We need a much bigger range to reliably support several
231214
// simultaneous connections.
232215
DEFINE_vec(tcp_port_range, CF_DEFAULTS_TCP_PORT_RANGE,
@@ -237,20 +220,6 @@ DEFINE_vec(udp_port_range, CF_DEFAULTS_UDP_PORT_RANGE,
237220
"The minimum and maximum UDP port numbers to allocate for ICE "
238221
"candidates as 'min:max'. To use any port just specify '0:0'");
239222

240-
DEFINE_string(webrtc_sig_server_path, CF_DEFAULTS_WEBRTC_SIG_SERVER_PATH,
241-
"The path section of the URL where the device should be "
242-
"registered with the signaling server.");
243-
244-
DEFINE_bool(
245-
webrtc_sig_server_secure, CF_DEFAULTS_WEBRTC_SIG_SERVER_SECURE,
246-
"Whether the WebRTC signaling server uses secure protocols (WSS vs WS).");
247-
248-
DEFINE_bool(verify_sig_server_certificate,
249-
CF_DEFAULTS_VERIFY_SIG_SERVER_CERTIFICATE,
250-
"Whether to verify the signaling server's certificate with a "
251-
"trusted signing authority (Disallow self signed certificates). "
252-
"This is ignored if an insecure server is configured.");
253-
254223
DEFINE_vec(
255224
webrtc_device_id, CF_DEFAULTS_WEBRTC_DEVICE_ID,
256225
"The for the device to register with the signaling server. Every "

base/cvd/cuttlefish/host/commands/assemble_cvd/assemble_cvd_flags.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,14 @@ DECLARE_vec(start_webrtc);
9797

9898
DECLARE_vec(webrtc_assets_dir);
9999

100-
DECLARE_string(webrtc_certs_dir);
101-
102100
DECLARE_bool(start_webrtc_sig_server);
103101

104102
DECLARE_string(webrtc_sig_server_addr);
105103

106-
DECLARE_int32(webrtc_sig_server_port);
107-
108104
DECLARE_vec(tcp_port_range);
109105

110106
DECLARE_vec(udp_port_range);
111107

112-
DECLARE_string(webrtc_sig_server_path);
113-
114-
DECLARE_bool(webrtc_sig_server_secure);
115-
116-
DECLARE_bool(verify_sig_server_certificate);
117-
118108
DECLARE_vec(webrtc_device_id);
119109

120110
DECLARE_vec(uuid);

base/cvd/cuttlefish/host/commands/assemble_cvd/flags.cc

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ using vm_manager::GetVmManager;
8484

8585
namespace {
8686

87-
constexpr auto HOST_OPERATOR_SOCKET_PATH = "/run/cuttlefish/operator";
88-
8987
std::pair<uint16_t, uint16_t> ParsePortRange(const std::string& flag) {
9088
static const std::regex rgx("[0-9]+:[0-9]+");
9189
CHECK(std::regex_match(flag, rgx))
@@ -444,14 +442,7 @@ Result<CuttlefishConfig> InitializeCuttlefishConfiguration(
444442

445443
tmp_config_obj.set_gem5_debug_flags(FLAGS_gem5_debug_flags);
446444

447-
// streaming, webrtc setup
448-
tmp_config_obj.set_webrtc_certs_dir(FLAGS_webrtc_certs_dir);
449-
tmp_config_obj.set_sig_server_secure(FLAGS_webrtc_sig_server_secure);
450-
// Note: This will be overridden if the sig server is started by us
451-
tmp_config_obj.set_sig_server_port(FLAGS_webrtc_sig_server_port);
452445
tmp_config_obj.set_sig_server_address(FLAGS_webrtc_sig_server_addr);
453-
tmp_config_obj.set_sig_server_path(FLAGS_webrtc_sig_server_path);
454-
tmp_config_obj.set_sig_server_strict(FLAGS_verify_sig_server_certificate);
455446

456447
tmp_config_obj.set_enable_metrics(FLAGS_report_anonymous_usage_stats);
457448
// TODO(moelsherif): Handle this flag (set_metrics_binary) in the future
@@ -1212,28 +1203,13 @@ Result<CuttlefishConfig> InitializeCuttlefishConfiguration(
12121203

12131204
// end of streaming, webrtc setup
12141205

1215-
instance.set_start_webrtc_signaling_server(false);
1216-
12171206
CF_EXPECT(Contains(num_to_webrtc_device_id_flag_map, num),
12181207
"Error in looking up num to webrtc_device_id_flag_map");
12191208
instance.set_webrtc_device_id(num_to_webrtc_device_id_flag_map[num]);
12201209

1221-
if (!is_first_instance || !start_webrtc_vec[instance_index]) {
1222-
// Only the first instance starts the signaling server or proxy
1223-
instance.set_start_webrtc_signaling_server(false);
1224-
instance.set_start_webrtc_sig_server_proxy(false);
1225-
} else {
1226-
auto port = 8443 + num - 1;
1227-
// Change the signaling server port for all instances
1228-
tmp_config_obj.set_sig_server_port(port);
1229-
// Either the signaling server or the proxy is started, never both
1230-
instance.set_start_webrtc_signaling_server(FLAGS_start_webrtc_sig_server);
1231-
// The proxy is only started if the host operator is available
1232-
instance.set_start_webrtc_sig_server_proxy(
1233-
cuttlefish::FileIsSocket(HOST_OPERATOR_SOCKET_PATH) &&
1234-
!FLAGS_start_webrtc_sig_server);
1235-
}
1236-
1210+
auto port = 8443 + num - 1;
1211+
// Change the signaling server port for all instances
1212+
tmp_config_obj.set_sig_server_proxy_port(port);
12371213
instance.set_start_netsim(is_first_instance && is_any_netsim);
12381214

12391215
instance.set_start_rootcanal(is_first_instance && !is_bt_netsim &&
@@ -1570,10 +1546,6 @@ Result<void> SetFlagDefaultsForVmm(
15701546
const std::vector<GuestConfig>& guest_configs,
15711547
const SystemImageDirFlag& system_image_dir,
15721548
const VmManagerFlag& vm_manager_flag) {
1573-
auto instance_nums =
1574-
CF_EXPECT(InstanceNumsCalculator().FromGlobalGflags().Calculate());
1575-
int32_t instances_size = instance_nums.size();
1576-
15771549
// get flag default values and store into map
15781550
auto name_to_default_value = CurrentFlagsToDefaultValue();
15791551

@@ -1594,30 +1566,6 @@ Result<void> SetFlagDefaultsForVmm(
15941566
case VmmMode::kUnknown:
15951567
return CF_ERR("Unknown VM manager");
15961568
}
1597-
if (vm_manager_flag.Mode() != VmmMode::kGem5) {
1598-
// After SetCommandLineOptionWithMode in SetDefaultFlagsForCrosvm/Qemu,
1599-
// default flag values changed, need recalculate name_to_default_value
1600-
name_to_default_value = CurrentFlagsToDefaultValue();
1601-
std::vector<bool> start_webrtc_vec = CF_EXPECT(GET_FLAG_BOOL_VALUE(
1602-
start_webrtc));
1603-
bool start_webrtc = false;
1604-
for(bool value : start_webrtc_vec) {
1605-
start_webrtc |= value;
1606-
}
1607-
1608-
auto host_operator_present =
1609-
cuttlefish::FileIsSocket(HOST_OPERATOR_SOCKET_PATH);
1610-
// The default for starting signaling server depends on whether or not webrtc
1611-
// is to be started and the presence of the host orchestrator.
1612-
SetCommandLineOptionWithMode(
1613-
"start_webrtc_sig_server",
1614-
start_webrtc && !host_operator_present ? "true" : "false",
1615-
google::FlagSettingMode::SET_FLAGS_DEFAULT);
1616-
SetCommandLineOptionWithMode(
1617-
"webrtc_sig_server_addr",
1618-
host_operator_present ? HOST_OPERATOR_SOCKET_PATH : "0.0.0.0",
1619-
google::FlagSettingMode::SET_FLAGS_DEFAULT);
1620-
}
16211569

16221570
SetDefaultFlagsForOpenwrt(guest_configs[0].target_arch);
16231571

base/cvd/cuttlefish/host/commands/assemble_cvd/flags_defaults.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,11 @@
220220

221221
// Streaming default parameters
222222
#define CF_DEFAULTS_START_WEBRTC false
223-
#define CF_DEFAULTS_START_WEBRTC_SIG_SERVER true
224223
#define CF_DEFAULTS_WEBRTC_DEVICE_ID "cvd-{num}"
225-
#define CF_DEFAULTS_VERIFY_SIG_SERVER_CERTIFICATE false
226224
#define CF_DEFAULTS_WEBRTC_ASSETS_DIR \
227225
cuttlefish::DefaultHostArtifactsPath("usr/share/webrtc/assets")
228-
#define CF_DEFAULTS_WEBRTC_CERTS_DIR \
229-
cuttlefish::DefaultHostArtifactsPath("usr/share/webrtc/certs")
230-
#define CF_DEFAULTS_WEBRTC_SIG_SERVER_ADDR CF_DEFAULTS_DYNAMIC_STRING
226+
#define CF_DEFAULTS_WEBRTC_SIG_SERVER_ADDR "/run/cuttlefish/operator"
231227
#define CF_DEFAULTS_WEBRTC_SIG_SERVER_PATH "/register_device"
232-
#define CF_DEFAULTS_WEBRTC_SIG_SERVER_PORT 443
233-
#define CF_DEFAULTS_WEBRTC_SIG_SERVER_SECURE true
234228
#define CF_DEFAULTS_TCP_PORT_RANGE "15550:15599"
235229
#define CF_DEFAULTS_UDP_PORT_RANGE "15550:15599"
236230

base/cvd/cuttlefish/host/commands/cvd/cli/parser/doc/streaming.dot

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ streaming--verify_sig_server_certificate
66
streaming--assets_dir
77
streaming--certs_dir
88
streaming--sig_server_addr
9-
streaming--sig_server_path
10-
streaming--sig_server_port
119
streaming--sig_server_secure
1210
streaming--tcp_port_range
1311
streaming--udp_port_range

base/cvd/cuttlefish/host/commands/run_cvd/launch/streamer.cpp

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -219,40 +219,24 @@ class WebRtcServer : public virtual CommandSource,
219219
sensors_socket_pair_(sensors_socket_pair) {}
220220
// DiagnosticInformation
221221
std::vector<std::string> Diagnostics() const override {
222-
if (!Enabled() ||
223-
!(config_.ForDefaultInstance().start_webrtc_sig_server() ||
224-
config_.ForDefaultInstance().start_webrtc_sig_server_proxy())) {
225-
// When WebRTC is enabled but an operator other than the one launched by
226-
// run_cvd is used there is no way to know the url to which to point the
227-
// browser to.
222+
if (!Enabled()) {
228223
return {};
229224
}
230225
std::ostringstream out;
231226
out << "Point your browser to https://localhost:"
232-
<< config_.sig_server_port() << " to interact with the device.";
227+
<< config_.sig_server_proxy_port() << " to interact with the device.";
233228
return {out.str()};
234229
}
235230

236231
// CommandSource
237232
Result<std::vector<MonitorCommand>> Commands() override {
238233
std::vector<MonitorCommand> commands;
239-
if (instance_.start_webrtc_sig_server()) {
240-
Command sig_server(WebRtcSigServerBinary());
241-
sig_server.AddParameter("-assets_dir=", instance_.webrtc_assets_dir());
242-
sig_server.AddParameter("-use_secure_http=",
243-
config_.sig_server_secure() ? "true" : "false");
244-
if (!config_.webrtc_certs_dir().empty()) {
245-
sig_server.AddParameter("-certs_dir=", config_.webrtc_certs_dir());
246-
}
247-
sig_server.AddParameter("-http_server_port=", config_.sig_server_port());
248-
commands.emplace_back(std::move(sig_server));
249-
}
250234

251-
if (instance_.start_webrtc_sig_server_proxy()) {
252-
Command sig_proxy(WebRtcSigServerProxyBinary());
253-
sig_proxy.AddParameter("-server_port=", config_.sig_server_port());
254-
commands.emplace_back(std::move(sig_proxy));
255-
}
235+
// Start a TCP proxy to make the host signaling server available on the
236+
// legacy port.
237+
Command sig_proxy(WebRtcSigServerProxyBinary());
238+
sig_proxy.AddParameter("-server_port=", config_.sig_server_proxy_port());
239+
commands.emplace_back(std::move(sig_proxy));
256240

257241
auto stopper = [webrtc_controller = webrtc_controller_]() mutable {
258242
(void)webrtc_controller.SendStopRecordingCommand();
@@ -263,13 +247,6 @@ class WebRtcServer : public virtual CommandSource,
263247

264248
webrtc.UnsetFromEnvironment("http_proxy");
265249
sockets_.AppendCommandArguments(webrtc);
266-
// Currently there is no way to ensure the signaling server will already
267-
// have bound the socket to the port by the time the webrtc process runs
268-
// (the common technique of doing it from the launcher is not possible here
269-
// as the server library being used creates its own sockets). However, this
270-
// issue is mitigated slightly by doing some retrying and backoff in the
271-
// webrtc process when connecting to the websocket, so it shouldn't be an
272-
// issue most of the time.
273250
webrtc.AddParameter("--command_fd=", webrtc_controller_.GetClientSocket());
274251
webrtc.AddParameter("-kernel_log_events_fd=", kernel_log_events_pipe_);
275252
webrtc.AddParameter("-client_dir=",

base/cvd/cuttlefish/host/commands/status/main.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ std::string CalcWebAccessUrl(const WebAccessUrlParam& web_access_url_param) {
7979
if (!FileIsSocket(web_access_url_param.sig_server_addr)) {
8080
return "";
8181
}
82+
// 1443 is the port of the global webrtc "operator" service
8283
return std::string("https://") + "localhost" + ":" + "1443" + "/devices/" +
8384
web_access_url_param.webrtc_device_id + "/files" + "/client.html";
8485
}
@@ -94,12 +95,10 @@ Json::Value PopulateDevicesInfoFromInstance(
9495
device_info["assembly_dir"] = config.assembly_dir();
9596
device_info["webrtc_device_id"] = webrtc_device_id;
9697
device_info["instance_dir"] = instance_config.instance_dir();
97-
// 1443 is the port of the global webrtc "operator" service
9898
device_info["web_access"] =
9999
CalcWebAccessUrl({.sig_server_addr = config.sig_server_address(),
100100
.webrtc_device_id = webrtc_device_id});
101101
device_info["adb_serial"] = instance_config.adb_ip_and_port();
102-
device_info["webrtc_port"] = std::to_string(config.sig_server_port());
103102
for (int i = 0; i < instance_config.display_configs().size(); i++) {
104103
device_info["displays"][i] =
105104
std::to_string(instance_config.display_configs()[i].width) + " x " +

base/cvd/cuttlefish/host/frontend/webrtc/libdevice/server_connection.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <atomic>
1919
#include <mutex>
20+
#include <string>
2021
#include <thread>
2122

2223
#include <android-base/logging.h>
@@ -54,10 +55,10 @@ class UnixServerConnection : public ServerConnection {
5455
};
5556

5657
std::unique_ptr<ServerConnection> ServerConnection::Connect(
57-
const ServerConfig& conf,
58+
const std::string& operator_path,
5859
std::weak_ptr<ServerConnectionObserver> observer) {
5960
std::unique_ptr<ServerConnection> ret(
60-
new UnixServerConnection(conf.addr, observer));
61+
new UnixServerConnection(operator_path, observer));
6162
ret->Connect();
6263
return ret;
6364
}

base/cvd/cuttlefish/host/frontend/webrtc/libdevice/server_connection.h

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,6 @@
2525
namespace cuttlefish {
2626
namespace webrtc_streaming {
2727

28-
struct ServerConfig {
29-
enum class Security {
30-
kInsecure,
31-
kAllowSelfSigned,
32-
kStrict,
33-
};
34-
35-
// The ip address or domain name of the operator server.
36-
std::string addr;
37-
int port;
38-
// The path component of the operator server's register url.
39-
std::string path;
40-
// The security level to use when connecting to the operator server.
41-
Security security;
42-
};
43-
4428
class ServerConnectionObserver {
4529
public:
4630
virtual ~ServerConnectionObserver() = default;
@@ -62,7 +46,7 @@ class ServerConnectionObserver {
6246
class ServerConnection {
6347
public:
6448
static std::unique_ptr<ServerConnection> Connect(
65-
const ServerConfig& conf,
49+
const std::string& operator_path,
6650
std::weak_ptr<ServerConnectionObserver> observer);
6751

6852
// Destroying the connection will disconnect from the signaling server and

base/cvd/cuttlefish/host/frontend/webrtc/libdevice/streamer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "cuttlefish/host/frontend/webrtc/libdevice/audio_track_source_impl.h"
3939
#include "cuttlefish/host/frontend/webrtc/libdevice/camera_streamer.h"
4040
#include "cuttlefish/host/frontend/webrtc/libdevice/client_handler.h"
41+
#include "cuttlefish/host/frontend/webrtc/libdevice/server_connection.h"
4142
#include "cuttlefish/host/frontend/webrtc/libdevice/video_track_source_impl.h"
4243
#include "cuttlefish/host/frontend/webrtc_operator/constants/signaling_constants.h"
4344

@@ -388,7 +389,7 @@ void Streamer::Impl::Register(std::weak_ptr<OperatorObserver> observer) {
388389
// the registration will take place
389390
if (!server_connection_) {
390391
server_connection_ =
391-
ServerConnection::Connect(config_.operator_server, weak_from_this());
392+
ServerConnection::Connect(config_.operator_path, weak_from_this());
392393
} else {
393394
// in case connection attempt is retried, just call Reconnect().
394395
// Recreating server_connection_ object will destroy existing WSConnection

0 commit comments

Comments
 (0)