+#ifdef HAVE_BACKEND_RDP
+static void
+weston_rdp_backend_config_init(struct weston_rdp_backend_config *config)
+{
+ config->base.struct_version = WESTON_RDP_BACKEND_CONFIG_VERSION;
+ config->base.struct_size = sizeof(struct weston_rdp_backend_config);
+
+ config->bind_address = NULL;
+ config->port = 3389;
+ config->rdp_key = NULL;
+ config->server_cert = NULL;
+ config->server_key = NULL;
+ config->env_socket = 0;
+ config->no_clients_resize = 1;
+ config->force_no_compression = 0;
+}
+
+static int
+rdp_backend_output_configure(struct weston_output *output)
+{
+ struct ivi_compositor *ivi = to_ivi_compositor(output->compositor);
+ struct ivi_output_config *parsed_options = ivi->parsed_options;
+ const struct weston_rdp_output_api *api =
+ weston_rdp_output_get_api(output->compositor);
+ int width = 640;
+ int height = 480;
+
+ assert(parsed_options);
+
+ if (!api) {
+ weston_log("Cannot use weston_rdp_output_api.\n");
+ return -1;
+ }
+
+ if (parsed_options->width)
+ width = parsed_options->width;
+
+ if (parsed_options->height)
+ height = parsed_options->height;
+
+ weston_output_set_scale(output, 1);
+ weston_output_set_transform(output, WL_OUTPUT_TRANSFORM_NORMAL);
+
+ if (api->output_set_size(output, width, height) < 0) {
+ weston_log("Cannot configure output \"%s\" using weston_rdp_output_api.\n",
+ output->name);
+ return -1;
+ }
+
+ return 0;
+}
+
+static int
+load_rdp_backend(struct ivi_compositor *ivi, int *argc, char **argv)
+{
+ struct weston_rdp_backend_config config = {};
+ int ret = 0;
+
+ struct ivi_output_config *parsed_options = ivi_init_parsed_options(ivi->compositor);
+ if (!parsed_options)
+ return -1;
+
+ weston_rdp_backend_config_init(&config);
+
+ const struct weston_option rdp_options[] = {
+ { WESTON_OPTION_BOOLEAN, "env-socket", 0, &config.env_socket },
+ { WESTON_OPTION_INTEGER, "width", 0, &parsed_options->width },
+ { WESTON_OPTION_INTEGER, "height", 0, &parsed_options->height },
+ { WESTON_OPTION_STRING, "address", 0, &config.bind_address },
+ { WESTON_OPTION_INTEGER, "port", 0, &config.port },
+ { WESTON_OPTION_BOOLEAN, "no-clients-resize", 0, &config.no_clients_resize },
+ { WESTON_OPTION_STRING, "rdp4-key", 0, &config.rdp_key },
+ { WESTON_OPTION_STRING, "rdp-tls-cert", 0, &config.server_cert },
+ { WESTON_OPTION_STRING, "rdp-tls-key", 0, &config.server_key },
+ { WESTON_OPTION_BOOLEAN, "force-no-compression", 0, &config.force_no_compression },
+ };
+
+ parse_options(rdp_options, ARRAY_LENGTH(rdp_options), argc, argv);
+
+ ivi->simple_output_configure = rdp_backend_output_configure;
+ ret = weston_compositor_load_backend(ivi->compositor, WESTON_BACKEND_RDP, &config.base);
+
+ free(config.bind_address);
+ free(config.rdp_key);
+ free(config.server_cert);
+ free(config.server_key);
+
+ return ret;
+}
+#else
+static int
+load_rdp_backend(struct ivi_compositor *ivi, int *argc, char **argv)
+{
+ return -1;
+}
+#endif
+
+