clang-format: Increase column limit from 80 to 120

This commit is contained in:
Ryan Foster
2024-10-04 18:19:27 -04:00
parent 109f64c446
commit a1fbf1015f
736 changed files with 22684 additions and 45435 deletions
+138 -277
View File
@@ -87,16 +87,13 @@ static void ensure_camera_portal_proxy(void)
{
g_autoptr(GError) error = NULL;
if (!camera_proxy) {
camera_proxy = g_dbus_proxy_new_sync(
portal_get_dbus_connection(), G_DBUS_PROXY_FLAGS_NONE,
NULL, "org.freedesktop.portal.Desktop",
"/org/freedesktop/portal/desktop",
"org.freedesktop.portal.Camera", NULL, &error);
camera_proxy = g_dbus_proxy_new_sync(portal_get_dbus_connection(), G_DBUS_PROXY_FLAGS_NONE, NULL,
"org.freedesktop.portal.Desktop",
"/org/freedesktop/portal/desktop", "org.freedesktop.portal.Camera",
NULL, &error);
if (error) {
blog(LOG_WARNING,
"[portals] Error retrieving D-Bus proxy: %s",
error->message);
blog(LOG_WARNING, "[portals] Error retrieving D-Bus proxy: %s", error->message);
return;
}
}
@@ -150,8 +147,7 @@ static uint32_t clear_params(struct spa_list *param_list, uint32_t id)
return count;
}
static struct param *add_param(struct spa_list *params, int seq, uint32_t id,
const struct spa_pod *param)
static struct param *add_param(struct spa_list *params, int seq, uint32_t id, const struct spa_pod *param)
{
struct param *p;
@@ -181,9 +177,7 @@ static struct param *add_param(struct spa_list *params, int seq, uint32_t id,
return p;
}
static void object_update_params(struct spa_list *param_list,
struct spa_list *pending_list,
uint32_t n_params,
static void object_update_params(struct spa_list *param_list, struct spa_list *pending_list, uint32_t n_params,
struct spa_param_info *params)
{
struct param *p, *t;
@@ -192,8 +186,7 @@ static void object_update_params(struct spa_list *param_list,
for (i = 0; i < n_params; i++) {
spa_list_for_each_safe(p, t, pending_list, link)
{
if (p->id == params[i].id && p->seq != params[i].seq &&
p->param != NULL) {
if (p->id == params[i].id && p->seq != params[i].seq && p->param != NULL) {
spa_list_remove(&p->link);
free(p);
}
@@ -211,13 +204,11 @@ static void object_update_params(struct spa_list *param_list,
}
}
static struct camera_device *
camera_device_new(uint32_t id, const struct spa_dict *properties)
static struct camera_device *camera_device_new(uint32_t id, const struct spa_dict *properties)
{
struct camera_device *device = bzalloc(sizeof(struct camera_device));
device->id = id;
device->properties = properties ? pw_properties_new_dict(properties)
: NULL;
device->properties = properties ? pw_properties_new_dict(properties) : NULL;
spa_list_init(&device->pending_list);
spa_list_init(&device->param_list);
return device;
@@ -237,8 +228,7 @@ static void camera_device_free(struct camera_device *device)
/* ------------------------------------------------- */
static bool update_device_id(struct camera_portal_source *camera_source,
const char *new_device_id)
static bool update_device_id(struct camera_portal_source *camera_source, const char *new_device_id)
{
if (strcmp(camera_source->device_id, new_device_id) == 0)
return false;
@@ -256,17 +246,14 @@ static void stream_camera(struct camera_portal_source *camera_source)
const struct spa_fraction *framerate = NULL;
struct camera_device *device;
g_clear_pointer(&camera_source->obs_pw_stream,
obs_pipewire_stream_destroy);
g_clear_pointer(&camera_source->obs_pw_stream, obs_pipewire_stream_destroy);
device = g_hash_table_lookup(connection->devices,
camera_source->device_id);
device = g_hash_table_lookup(connection->devices, camera_source->device_id);
if (!device)
return;
blog(LOG_INFO, "[camera-portal] streaming camera '%s'",
camera_source->device_id);
blog(LOG_INFO, "[camera-portal] streaming camera '%s'", camera_source->device_id);
if (camera_source->resolution.set)
resolution = &camera_source->resolution.rect;
@@ -275,17 +262,15 @@ static void stream_camera(struct camera_portal_source *camera_source)
connect_info = (struct obs_pipwire_connect_stream_info){
.stream_name = "OBS PipeWire Camera",
.stream_properties = pw_properties_new(
PW_KEY_MEDIA_TYPE, "Video", PW_KEY_MEDIA_CATEGORY,
"Capture", PW_KEY_MEDIA_ROLE, "Camera", NULL),
.stream_properties = pw_properties_new(PW_KEY_MEDIA_TYPE, "Video", PW_KEY_MEDIA_CATEGORY, "Capture",
PW_KEY_MEDIA_ROLE, "Camera", NULL),
.video = {
.resolution = resolution,
.framerate = framerate,
}};
camera_source->obs_pw_stream = obs_pipewire_connect_stream(
connection->obs_pw, camera_source->source, device->id,
&connect_info);
camera_source->obs_pw_stream =
obs_pipewire_connect_stream(connection->obs_pw, camera_source->source, device->id, &connect_info);
}
static void camera_format_list(struct camera_device *dev, obs_property_t *prop)
@@ -308,17 +293,14 @@ static void camera_format_list(struct camera_device *dev, obs_property_t *prop)
if (media_type != SPA_MEDIA_TYPE_video)
continue;
if (media_subtype == SPA_MEDIA_SUBTYPE_raw) {
if (spa_pod_parse_object(p->param,
SPA_TYPE_OBJECT_Format, NULL,
SPA_FORMAT_VIDEO_format,
if (spa_pod_parse_object(p->param, SPA_TYPE_OBJECT_Format, NULL, SPA_FORMAT_VIDEO_format,
SPA_POD_Id(&format)) < 0)
continue;
} else {
format = SPA_VIDEO_FORMAT_ENCODED;
}
if (!obs_pw_video_format_from_spa_format(format,
&obs_pw_video_format))
if (!obs_pw_video_format_from_spa_format(format, &obs_pw_video_format))
continue;
if (obs_pw_video_format.video_format == last_format)
@@ -326,13 +308,11 @@ static void camera_format_list(struct camera_device *dev, obs_property_t *prop)
last_format = obs_pw_video_format.video_format;
obs_property_list_add_int(prop, obs_pw_video_format.pretty_name,
format);
obs_property_list_add_int(prop, obs_pw_video_format.pretty_name, format);
}
}
static bool control_changed(void *data, obs_properties_t *props,
obs_property_t *prop, obs_data_t *settings)
static bool control_changed(void *data, obs_properties_t *props, obs_property_t *prop, obs_data_t *settings)
{
UNUSED_PARAMETER(props);
@@ -354,8 +334,7 @@ static bool control_changed(void *data, obs_properties_t *props,
id = SPA_PTR_TO_UINT32(data);
spa_pod_builder_push_object(&b, &f[0], SPA_TYPE_OBJECT_Props,
SPA_PARAM_Props);
spa_pod_builder_push_object(&b, &f[0], SPA_TYPE_OBJECT_Props, SPA_PARAM_Props);
switch (obs_property_get_type(prop)) {
case OBS_PROPERTY_BOOL: {
@@ -364,8 +343,7 @@ static bool control_changed(void *data, obs_properties_t *props,
break;
}
case OBS_PROPERTY_FLOAT: {
float val =
obs_data_get_double(settings, obs_property_name(prop));
float val = obs_data_get_double(settings, obs_property_name(prop));
spa_pod_builder_add(&b, id, SPA_POD_Float(val), 0);
break;
}
@@ -376,21 +354,17 @@ static bool control_changed(void *data, obs_properties_t *props,
break;
}
default:
blog(LOG_ERROR, "unknown property type for %s",
obs_property_name(prop));
blog(LOG_ERROR, "unknown property type for %s", obs_property_name(prop));
return false;
}
param = spa_pod_builder_pop(&b, &f[0]);
pw_node_set_param((struct pw_node *)dev->proxy, SPA_PARAM_Props, 0,
param);
pw_node_set_param((struct pw_node *)dev->proxy, SPA_PARAM_Props, 0, param);
return true;
}
static inline void add_control_property(obs_properties_t *props,
obs_data_t *settings,
struct camera_device *dev,
static inline void add_control_property(obs_properties_t *props, obs_data_t *settings, struct camera_device *dev,
struct param *p)
{
UNUSED_PARAMETER(dev);
@@ -400,13 +374,10 @@ static inline void add_control_property(obs_properties_t *props,
obs_property_t *prop = NULL;
const char *name;
if (spa_pod_parse_object(
p->param, SPA_TYPE_OBJECT_PropInfo, NULL, SPA_PROP_INFO_id,
SPA_POD_Id(&id), SPA_PROP_INFO_description,
SPA_POD_OPT_String(&name), SPA_PROP_INFO_type,
SPA_POD_PodChoice(&type), SPA_PROP_INFO_container,
SPA_POD_OPT_Id(&container), SPA_PROP_INFO_labels,
SPA_POD_OPT_PodStruct(&labels)) < 0)
if (spa_pod_parse_object(p->param, SPA_TYPE_OBJECT_PropInfo, NULL, SPA_PROP_INFO_id, SPA_POD_Id(&id),
SPA_PROP_INFO_description, SPA_POD_OPT_String(&name), SPA_PROP_INFO_type,
SPA_POD_PodChoice(&type), SPA_PROP_INFO_container, SPA_POD_OPT_Id(&container),
SPA_PROP_INFO_labels, SPA_POD_OPT_PodStruct(&labels)) < 0)
return;
pod = spa_pod_get_values(type, &n_vals, &choice);
@@ -427,9 +398,7 @@ static inline void add_control_property(obs_properties_t *props,
if (labels == NULL)
return;
prop = obs_properties_add_list(props, (char *)name,
(char *)name,
OBS_COMBO_TYPE_LIST,
prop = obs_properties_add_list(props, (char *)name, (char *)name, OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_INT);
spa_pod_parser_pod(&prs, (struct spa_pod *)labels);
@@ -439,35 +408,27 @@ static inline void add_control_property(obs_properties_t *props,
while (1) {
int32_t id;
const char *desc;
if (spa_pod_parser_get_int(&prs, &id) < 0 ||
spa_pod_parser_get_string(&prs, &desc) < 0)
if (spa_pod_parser_get_int(&prs, &id) < 0 || spa_pod_parser_get_string(&prs, &desc) < 0)
break;
obs_property_list_add_int(prop, (char *)desc,
id);
obs_property_list_add_int(prop, (char *)desc, id);
}
} else {
min = n_vals > 1 ? vals[1] : def;
max = n_vals > 2 ? vals[2] : def;
step = n_vals > 3 ? vals[3] : (max - min) / 256.0f;
prop = obs_properties_add_int_slider(props,
(char *)name,
(char *)name, min,
max, step);
prop = obs_properties_add_int_slider(props, (char *)name, (char *)name, min, max, step);
}
obs_data_set_default_int(settings, (char *)name, def);
obs_property_set_modified_callback2(prop, control_changed,
SPA_UINT32_TO_PTR(id));
obs_property_set_modified_callback2(prop, control_changed, SPA_UINT32_TO_PTR(id));
break;
}
case SPA_TYPE_Bool: {
int32_t *vals = SPA_POD_BODY(pod);
if (n_vals < 1)
return;
prop = obs_properties_add_bool(props, (char *)name,
(char *)name);
prop = obs_properties_add_bool(props, (char *)name, (char *)name);
obs_data_set_default_bool(settings, (char *)name, vals[0]);
obs_property_set_modified_callback2(prop, control_changed,
SPA_UINT32_TO_PTR(id));
obs_property_set_modified_callback2(prop, control_changed, SPA_UINT32_TO_PTR(id));
break;
}
case SPA_TYPE_Float: {
@@ -479,11 +440,9 @@ static inline void add_control_property(obs_properties_t *props,
min = n_vals > 1 ? vals[1] : def;
max = n_vals > 2 ? vals[2] : def;
step = n_vals > 3 ? vals[3] : (max - min) / 256.0f;
prop = obs_properties_add_float_slider(
props, (char *)name, (char *)name, min, max, step);
prop = obs_properties_add_float_slider(props, (char *)name, (char *)name, min, max, step);
obs_data_set_default_double(settings, (char *)name, def);
obs_property_set_modified_callback2(prop, control_changed,
SPA_UINT32_TO_PTR(id));
obs_property_set_modified_callback2(prop, control_changed, SPA_UINT32_TO_PTR(id));
break;
}
default:
@@ -491,9 +450,7 @@ static inline void add_control_property(obs_properties_t *props,
}
}
static void camera_update_controls(struct camera_device *dev,
obs_properties_t *props,
obs_data_t *settings)
static void camera_update_controls(struct camera_device *dev, obs_properties_t *props, obs_data_t *settings)
{
struct param *p;
spa_list_for_each(p, &dev->param_list, link)
@@ -504,8 +461,7 @@ static void camera_update_controls(struct camera_device *dev,
}
}
static bool device_selected(void *data, obs_properties_t *props,
obs_property_t *property, obs_data_t *settings)
static bool device_selected(void *data, obs_properties_t *props, obs_property_t *property, obs_data_t *settings)
{
UNUSED_PARAMETER(props);
UNUSED_PARAMETER(property);
@@ -534,9 +490,8 @@ static bool device_selected(void *data, obs_properties_t *props,
camera_format_list(device, property);
camera_update_controls(device, new_control_properties, settings);
obs_properties_add_group(props, "controls",
obs_module_text("CameraControls"),
OBS_GROUP_NORMAL, new_control_properties);
obs_properties_add_group(props, "controls", obs_module_text("CameraControls"), OBS_GROUP_NORMAL,
new_control_properties);
obs_property_modified(property, settings);
@@ -553,8 +508,7 @@ static int sort_resolutions(gconstpointer a, gconstpointer b)
return area_a - area_b;
}
static void resolution_list(struct camera_device *dev, uint32_t pixelformat,
obs_property_t *prop)
static void resolution_list(struct camera_device *dev, uint32_t pixelformat, obs_property_t *prop)
{
struct spa_rectangle last_resolution = SPA_RECTANGLE(0, 0);
g_autoptr(GArray) resolutions = NULL;
@@ -577,30 +531,24 @@ static void resolution_list(struct camera_device *dev, uint32_t pixelformat,
if (media_type != SPA_MEDIA_TYPE_video)
continue;
if (media_subtype == SPA_MEDIA_SUBTYPE_raw) {
if (spa_pod_parse_object(p->param,
SPA_TYPE_OBJECT_Format, NULL,
SPA_FORMAT_VIDEO_format,
if (spa_pod_parse_object(p->param, SPA_TYPE_OBJECT_Format, NULL, SPA_FORMAT_VIDEO_format,
SPA_POD_Id(&format)) < 0)
continue;
} else {
format = SPA_VIDEO_FORMAT_ENCODED;
}
if (!obs_pw_video_format_from_spa_format(format,
&obs_pw_video_format))
if (!obs_pw_video_format_from_spa_format(format, &obs_pw_video_format))
continue;
if (obs_pw_video_format.video_format != pixelformat)
continue;
if (spa_pod_parse_object(p->param, SPA_TYPE_OBJECT_Format, NULL,
SPA_FORMAT_VIDEO_size,
SPA_POD_OPT_Rectangle(&resolution)) <
0)
if (spa_pod_parse_object(p->param, SPA_TYPE_OBJECT_Format, NULL, SPA_FORMAT_VIDEO_size,
SPA_POD_OPT_Rectangle(&resolution)) < 0)
continue;
if (resolution.width == last_resolution.width &&
resolution.height == last_resolution.height)
if (resolution.width == last_resolution.width && resolution.height == last_resolution.height)
continue;
last_resolution = resolution;
@@ -613,18 +561,15 @@ static void resolution_list(struct camera_device *dev, uint32_t pixelformat,
data = obs_data_create();
for (size_t i = 0; i < resolutions->len; i++) {
const struct spa_rectangle *resolution =
&g_array_index(resolutions, struct spa_rectangle, i);
const struct spa_rectangle *resolution = &g_array_index(resolutions, struct spa_rectangle, i);
struct dstr str = {};
dstr_printf(&str, "%ux%u", resolution->width,
resolution->height);
dstr_printf(&str, "%ux%u", resolution->width, resolution->height);
obs_data_set_int(data, "width", resolution->width);
obs_data_set_int(data, "height", resolution->height);
obs_property_list_add_string(prop, str.array,
obs_data_get_json(data));
obs_property_list_add_string(prop, str.array, obs_data_get_json(data));
dstr_free(&str);
}
@@ -634,8 +579,7 @@ static void resolution_list(struct camera_device *dev, uint32_t pixelformat,
/*
* Format selected callback
*/
static bool format_selected(void *data, obs_properties_t *properties,
obs_property_t *property, obs_data_t *settings)
static bool format_selected(void *data, obs_properties_t *properties, obs_property_t *property, obs_data_t *settings)
{
UNUSED_PARAMETER(property);
UNUSED_PARAMETER(settings);
@@ -644,17 +588,14 @@ static bool format_selected(void *data, obs_properties_t *properties,
struct camera_device *device;
obs_property_t *resolution;
blog(LOG_INFO, "[camera-portal] Selected format for '%s'",
camera_source->device_id);
blog(LOG_INFO, "[camera-portal] Selected format for '%s'", camera_source->device_id);
device = g_hash_table_lookup(connection->devices,
camera_source->device_id);
device = g_hash_table_lookup(connection->devices, camera_source->device_id);
if (device == NULL)
return false;
resolution = obs_properties_get(properties, "resolution");
resolution_list(device, obs_data_get_int(settings, "pixelformat"),
resolution);
resolution_list(device, obs_data_get_int(settings, "pixelformat"), resolution);
return true;
}
@@ -669,8 +610,7 @@ static int compare_framerates(gconstpointer a, gconstpointer b)
return da - db;
}
static void framerate_list(struct camera_device *dev, uint32_t pixelformat,
const struct spa_rectangle *resolution,
static void framerate_list(struct camera_device *dev, uint32_t pixelformat, const struct spa_rectangle *resolution,
obs_property_t *prop)
{
g_autoptr(GArray) framerates = NULL;
@@ -700,42 +640,33 @@ static void framerate_list(struct camera_device *dev, uint32_t pixelformat,
if (media_type != SPA_MEDIA_TYPE_video)
continue;
if (media_subtype == SPA_MEDIA_SUBTYPE_raw) {
if (spa_pod_parse_object(p->param,
SPA_TYPE_OBJECT_Format, NULL,
SPA_FORMAT_VIDEO_format,
if (spa_pod_parse_object(p->param, SPA_TYPE_OBJECT_Format, NULL, SPA_FORMAT_VIDEO_format,
SPA_POD_Id(&format)) < 0)
continue;
} else {
format = SPA_VIDEO_FORMAT_ENCODED;
}
if (!obs_pw_video_format_from_spa_format(format,
&obs_pw_video_format))
if (!obs_pw_video_format_from_spa_format(format, &obs_pw_video_format))
continue;
if (obs_pw_video_format.video_format != pixelformat)
continue;
if (spa_pod_parse_object(
p->param, SPA_TYPE_OBJECT_Format, NULL,
SPA_FORMAT_VIDEO_size,
SPA_POD_OPT_Rectangle(&this_resolution)) < 0)
if (spa_pod_parse_object(p->param, SPA_TYPE_OBJECT_Format, NULL, SPA_FORMAT_VIDEO_size,
SPA_POD_OPT_Rectangle(&this_resolution)) < 0)
continue;
if (this_resolution.width != resolution->width ||
this_resolution.height != resolution->height)
if (this_resolution.width != resolution->width || this_resolution.height != resolution->height)
continue;
prop = spa_pod_find_prop(p->param, NULL,
SPA_FORMAT_VIDEO_framerate);
prop = spa_pod_find_prop(p->param, NULL, SPA_FORMAT_VIDEO_framerate);
if (!prop)
continue;
framerate_pod = spa_pod_get_values(&prop->value, &n_framerates,
&choice);
framerate_pod = spa_pod_get_values(&prop->value, &n_framerates, &choice);
if (framerate_pod->type != SPA_TYPE_Fraction) {
blog(LOG_WARNING,
"Framerate is not a fraction - something is wrong");
blog(LOG_WARNING, "Framerate is not a fraction - something is wrong");
continue;
}
@@ -754,8 +685,7 @@ static void framerate_list(struct camera_device *dev, uint32_t pixelformat,
case SPA_CHOICE_Enum:
/* i=0 is the default framerate, skip it */
for (uint32_t i = 1; i < n_framerates; i++)
g_array_append_val(framerates,
framerate_values[i]);
g_array_append_val(framerates, framerate_values[i]);
break;
default:
break;
@@ -768,8 +698,7 @@ static void framerate_list(struct camera_device *dev, uint32_t pixelformat,
data = obs_data_create();
for (size_t i = 0; i < framerates->len; i++) {
const struct spa_fraction *framerate =
&g_array_index(framerates, struct spa_fraction, i);
const struct spa_fraction *framerate = &g_array_index(framerates, struct spa_fraction, i);
struct media_frames_per_second fps;
struct dstr str = {};
@@ -779,10 +708,8 @@ static void framerate_list(struct camera_device *dev, uint32_t pixelformat,
};
obs_data_set_frames_per_second(data, "framerate", fps, NULL);
dstr_printf(&str, "%.2f",
framerate->num / (double)framerate->denom);
obs_property_list_add_string(prop, str.array,
obs_data_get_json(data));
dstr_printf(&str, "%.2f", framerate->num / (double)framerate->denom);
obs_property_list_add_string(prop, str.array, obs_data_get_json(data));
dstr_free(&str);
}
@@ -809,8 +736,7 @@ static bool parse_framerate(struct spa_fraction *dest, const char *json)
return true;
}
static bool framerate_selected(void *data, obs_properties_t *properties,
obs_property_t *property, obs_data_t *settings)
static bool framerate_selected(void *data, obs_properties_t *properties, obs_property_t *property, obs_data_t *settings)
{
UNUSED_PARAMETER(properties);
UNUSED_PARAMETER(property);
@@ -819,18 +745,15 @@ static bool framerate_selected(void *data, obs_properties_t *properties,
struct camera_device *device;
struct spa_fraction framerate;
device = g_hash_table_lookup(connection->devices,
camera_source->device_id);
device = g_hash_table_lookup(connection->devices, camera_source->device_id);
if (device == NULL)
return false;
if (!parse_framerate(&framerate,
obs_data_get_string(settings, "framerate")))
if (!parse_framerate(&framerate, obs_data_get_string(settings, "framerate")))
return false;
if (camera_source->obs_pw_stream)
obs_pipewire_stream_set_framerate(camera_source->obs_pw_stream,
&framerate);
obs_pipewire_stream_set_framerate(camera_source->obs_pw_stream, &framerate);
return true;
}
@@ -852,8 +775,8 @@ static bool parse_resolution(struct spa_rectangle *dest, const char *json)
return true;
}
static bool resolution_selected(void *data, obs_properties_t *properties,
obs_property_t *property, obs_data_t *settings)
static bool resolution_selected(void *data, obs_properties_t *properties, obs_property_t *property,
obs_data_t *settings)
{
UNUSED_PARAMETER(properties);
UNUSED_PARAMETER(property);
@@ -863,31 +786,25 @@ static bool resolution_selected(void *data, obs_properties_t *properties,
struct spa_rectangle resolution;
struct camera_device *device;
blog(LOG_INFO, "[camera-portal] Selected resolution for '%s'",
camera_source->device_id);
blog(LOG_INFO, "[camera-portal] Selected resolution for '%s'", camera_source->device_id);
device = g_hash_table_lookup(connection->devices,
camera_source->device_id);
device = g_hash_table_lookup(connection->devices, camera_source->device_id);
if (device == NULL)
return false;
if (!parse_resolution(&resolution,
obs_data_get_string(settings, "resolution")))
if (!parse_resolution(&resolution, obs_data_get_string(settings, "resolution")))
return false;
if (camera_source->obs_pw_stream)
obs_pipewire_stream_set_resolution(camera_source->obs_pw_stream,
&resolution);
obs_pipewire_stream_set_resolution(camera_source->obs_pw_stream, &resolution);
property = obs_properties_get(properties, "framerate");
framerate_list(device, obs_data_get_int(settings, "pixelformat"),
&resolution, property);
framerate_list(device, obs_data_get_int(settings, "pixelformat"), &resolution, property);
return true;
}
static void populate_cameras_list(struct camera_portal_source *camera_source,
obs_property_t *device_list)
static void populate_cameras_list(struct camera_portal_source *camera_source, obs_property_t *device_list)
{
struct camera_device *device;
GHashTableIter iter;
@@ -901,25 +818,20 @@ static void populate_cameras_list(struct camera_portal_source *camera_source,
device_found = false;
g_hash_table_iter_init(&iter, connection->devices);
while (g_hash_table_iter_next(&iter, (gpointer *)&device_id,
(gpointer *)&device)) {
while (g_hash_table_iter_next(&iter, (gpointer *)&device_id, (gpointer *)&device)) {
const char *device_name;
device_name = pw_properties_get(device->properties,
PW_KEY_NODE_DESCRIPTION);
device_name = pw_properties_get(device->properties, PW_KEY_NODE_DESCRIPTION);
obs_property_list_add_string(device_list, device_name,
device_id);
obs_property_list_add_string(device_list, device_name, device_id);
device_found |= strcmp(device_id, camera_source->device_id) ==
0;
device_found |= strcmp(device_id, camera_source->device_id) == 0;
}
if (!device_found && camera_source->device_id) {
size_t device_index;
device_index = obs_property_list_add_string(
device_list, camera_source->device_id,
camera_source->device_id);
device_index =
obs_property_list_add_string(device_list, camera_source->device_id, camera_source->device_id);
obs_property_list_item_disable(device_list, device_index, true);
}
}
@@ -949,9 +861,8 @@ static void node_info(void *data, const struct pw_node_info *info)
if (!(info->params[i].flags & SPA_PARAM_INFO_READ))
continue;
res = pw_node_enum_params(
(struct pw_node *)device->proxy,
++info->params[i].seq, id, 0, -1, NULL);
res = pw_node_enum_params((struct pw_node *)device->proxy, ++info->params[i].seq, id, 0, -1,
NULL);
if (SPA_RESULT_IS_ASYNC(res))
info->params[i].seq = res;
}
@@ -959,13 +870,11 @@ static void node_info(void *data, const struct pw_node_info *info)
if (changed) {
device->changed += changed;
device->pending_sync =
pw_proxy_sync(device->proxy, device->pending_sync);
device->pending_sync = pw_proxy_sync(device->proxy, device->pending_sync);
}
}
static void node_param(void *data, int seq, uint32_t id, uint32_t index,
uint32_t next, const struct spa_pod *param)
static void node_param(void *data, int seq, uint32_t id, uint32_t index, uint32_t next, const struct spa_pod *param)
{
UNUSED_PARAMETER(index);
UNUSED_PARAMETER(next);
@@ -998,8 +907,7 @@ static void on_done_proxy_cb(void *data, int seq)
{
struct camera_device *device = data;
if (device->info != NULL && device->pending_sync == seq) {
object_update_params(&device->param_list, &device->pending_list,
device->info->n_params,
object_update_params(&device->param_list, &device->pending_list, device->info->n_params,
device->info->params);
}
}
@@ -1011,10 +919,8 @@ static const struct pw_proxy_events proxy_events = {
.done = on_done_proxy_cb,
};
static void on_registry_global_cb(void *user_data, uint32_t id,
uint32_t permissions, const char *type,
uint32_t version,
const struct spa_dict *props)
static void on_registry_global_cb(void *user_data, uint32_t id, uint32_t permissions, const char *type,
uint32_t version, const struct spa_dict *props)
{
UNUSED_PARAMETER(user_data);
UNUSED_PARAMETER(permissions);
@@ -1035,22 +941,18 @@ static void on_registry_global_cb(void *user_data, uint32_t id,
device = camera_device_new(id, props);
device->proxy = pw_registry_bind(registry, id, type, version, 0);
if (!device->proxy) {
blog(LOG_WARNING, "[camera-portal] Failed to bind device %s",
device_id);
blog(LOG_WARNING, "[camera-portal] Failed to bind device %s", device_id);
bfree(device);
return;
}
pw_proxy_add_listener(device->proxy, &device->proxy_listener,
&proxy_events, device);
pw_proxy_add_listener(device->proxy, &device->proxy_listener, &proxy_events, device);
device->node = (struct pw_node *)device->proxy;
pw_node_add_listener(device->node, &device->node_listener, &node_events,
device);
pw_node_add_listener(device->node, &device->node_listener, &node_events, device);
g_hash_table_insert(connection->devices, bstrdup(device_id), device);
for (size_t i = 0; i < connection->sources->len; i++) {
struct camera_portal_source *camera_source =
g_ptr_array_index(connection->sources, i);
struct camera_portal_source *camera_source = g_ptr_array_index(connection->sources, i);
obs_source_update_properties(camera_source->source);
if (strcmp(camera_source->device_id, device_id) == 0)
stream_camera(camera_source);
@@ -1066,17 +968,14 @@ static void on_registry_global_remove_cb(void *user_data, uint32_t id)
GHashTableIter iter;
g_hash_table_iter_init(&iter, connection->devices);
while (g_hash_table_iter_next(&iter, (gpointer *)&device_id,
(gpointer *)&device)) {
while (g_hash_table_iter_next(&iter, (gpointer *)&device_id, (gpointer *)&device)) {
if (device->id != id)
continue;
g_hash_table_iter_remove(&iter);
blog(LOG_INFO, "[pipewire-camera] Removed device %s",
device_id);
blog(LOG_INFO, "[pipewire-camera] Removed device %s", device_id);
}
for (size_t i = 0; i < connection->sources->len; i++) {
struct camera_portal_source *camera_source =
g_ptr_array_index(connection->sources, i);
struct camera_portal_source *camera_source = g_ptr_array_index(connection->sources, i);
obs_source_update_properties(camera_source->source);
}
}
@@ -1089,8 +988,7 @@ static const struct pw_registry_events registry_events = {
/* ------------------------------------------------- */
static void on_pipewire_remote_opened_cb(GObject *source, GAsyncResult *res,
void *user_data)
static void on_pipewire_remote_opened_cb(GObject *source, GAsyncResult *res, void *user_data)
{
UNUSED_PARAMETER(user_data);
@@ -1100,13 +998,10 @@ static void on_pipewire_remote_opened_cb(GObject *source, GAsyncResult *res,
int pipewire_fd;
int fd_index;
result = g_dbus_proxy_call_with_unix_fd_list_finish(
G_DBUS_PROXY(source), &fd_list, res, &error);
result = g_dbus_proxy_call_with_unix_fd_list_finish(G_DBUS_PROXY(source), &fd_list, res, &error);
if (error) {
if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
blog(LOG_ERROR,
"[camera-portal] Error retrieving PipeWire fd: %s",
error->message);
blog(LOG_ERROR, "[camera-portal] Error retrieving PipeWire fd: %s", error->message);
return;
}
@@ -1115,14 +1010,11 @@ static void on_pipewire_remote_opened_cb(GObject *source, GAsyncResult *res,
pipewire_fd = g_unix_fd_list_get(fd_list, fd_index, &error);
if (error) {
if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
blog(LOG_ERROR,
"[camera-portal] Error retrieving PipeWire fd: %s",
error->message);
blog(LOG_ERROR, "[camera-portal] Error retrieving PipeWire fd: %s", error->message);
return;
}
connection->obs_pw = obs_pipewire_connect_fd(
pipewire_fd, &registry_events, connection);
connection->obs_pw = obs_pipewire_connect_fd(pipewire_fd, &registry_events, connection);
obs_pipewire_roundtrip(connection->obs_pw);
}
@@ -1133,18 +1025,14 @@ static void open_pipewire_remote(void)
g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
g_dbus_proxy_call_with_unix_fd_list(get_camera_portal_proxy(),
"OpenPipeWireRemote",
g_variant_new("(a{sv})", &builder),
G_DBUS_CALL_FLAGS_NONE, -1, NULL,
connection->cancellable,
on_pipewire_remote_opened_cb, NULL);
g_dbus_proxy_call_with_unix_fd_list(get_camera_portal_proxy(), "OpenPipeWireRemote",
g_variant_new("(a{sv})", &builder), G_DBUS_CALL_FLAGS_NONE, -1, NULL,
connection->cancellable, on_pipewire_remote_opened_cb, NULL);
}
/* ------------------------------------------------- */
static void on_access_camera_response_received_cb(GVariant *parameters,
void *user_data)
static void on_access_camera_response_received_cb(GVariant *parameters, void *user_data)
{
UNUSED_PARAMETER(user_data);
@@ -1154,8 +1042,7 @@ static void on_access_camera_response_received_cb(GVariant *parameters,
g_variant_get(parameters, "(u@a{sv})", &response, &result);
if (response != 0) {
blog(LOG_WARNING,
"[camera-portal] Failed to create session, denied or cancelled by user");
blog(LOG_WARNING, "[camera-portal] Failed to create session, denied or cancelled by user");
return;
}
@@ -1164,8 +1051,7 @@ static void on_access_camera_response_received_cb(GVariant *parameters,
open_pipewire_remote();
}
static void on_access_camera_finished_cb(GObject *source, GAsyncResult *res,
void *user_data)
static void on_access_camera_finished_cb(GObject *source, GAsyncResult *res, void *user_data)
{
UNUSED_PARAMETER(user_data);
@@ -1175,9 +1061,7 @@ static void on_access_camera_finished_cb(GObject *source, GAsyncResult *res,
result = g_dbus_proxy_call_finish(G_DBUS_PROXY(source), res, &error);
if (error) {
if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
blog(LOG_ERROR,
"[camera-portal] Error accessing camera: %s",
error->message);
blog(LOG_ERROR, "[camera-portal] Error accessing camera: %s", error->message);
return;
}
}
@@ -1195,9 +1079,8 @@ static void access_camera(struct camera_portal_source *camera_source)
if (!connection) {
connection = bzalloc(sizeof(struct pw_portal_connection));
connection->devices = g_hash_table_new_full(
g_str_hash, g_str_equal, bfree,
(GDestroyNotify)camera_device_free);
connection->devices =
g_hash_table_new_full(g_str_hash, g_str_equal, bfree, (GDestroyNotify)camera_device_free);
connection->cancellable = g_cancellable_new();
connection->sources = g_ptr_array_new();
connection->initializing = false;
@@ -1210,17 +1093,13 @@ static void access_camera(struct camera_portal_source *camera_source)
portal_create_request_path(&request_path, &request_token);
portal_signal_subscribe(request_path, NULL,
on_access_camera_response_received_cb, NULL);
portal_signal_subscribe(request_path, NULL, on_access_camera_response_received_cb, NULL);
g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add(&builder, "{sv}", "handle_token",
g_variant_new_string(request_token));
g_variant_builder_add(&builder, "{sv}", "handle_token", g_variant_new_string(request_token));
g_dbus_proxy_call(get_camera_portal_proxy(), "AccessCamera",
g_variant_new("(a{sv})", &builder),
G_DBUS_CALL_FLAGS_NONE, -1, connection->cancellable,
on_access_camera_finished_cb, NULL);
g_dbus_proxy_call(get_camera_portal_proxy(), "AccessCamera", g_variant_new("(a{sv})", &builder),
G_DBUS_CALL_FLAGS_NONE, -1, connection->cancellable, on_access_camera_finished_cb, NULL);
connection->initializing = true;
@@ -1242,14 +1121,11 @@ static void *pipewire_camera_create(obs_data_t *settings, obs_source_t *source)
camera_source = bzalloc(sizeof(struct camera_portal_source));
camera_source->source = source;
camera_source->device_id =
bstrdup(obs_data_get_string(settings, "device_id"));
camera_source->device_id = bstrdup(obs_data_get_string(settings, "device_id"));
camera_source->framerate.set =
parse_framerate(&camera_source->framerate.fraction,
obs_data_get_string(settings, "framerate"));
parse_framerate(&camera_source->framerate.fraction, obs_data_get_string(settings, "framerate"));
camera_source->resolution.set =
parse_resolution(&camera_source->resolution.rect,
obs_data_get_string(settings, "resolution"));
parse_resolution(&camera_source->resolution.rect, obs_data_get_string(settings, "resolution"));
access_camera(camera_source);
@@ -1263,8 +1139,7 @@ static void pipewire_camera_destroy(void *data)
if (connection)
g_ptr_array_remove(connection->sources, camera_source);
g_clear_pointer(&camera_source->obs_pw_stream,
obs_pipewire_stream_destroy);
g_clear_pointer(&camera_source->obs_pw_stream, obs_pipewire_stream_destroy);
g_clear_pointer(&camera_source->device_id, bfree);
bfree(camera_source);
@@ -1287,41 +1162,29 @@ static obs_properties_t *pipewire_camera_get_properties(void *data)
props = obs_properties_create();
device_list = obs_properties_add_list(
props, "device_id", obs_module_text("PipeWireCameraDevice"),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
device_list = obs_properties_add_list(props, "device_id", obs_module_text("PipeWireCameraDevice"),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
format_list = obs_properties_add_list(props, "pixelformat",
obs_module_text("VideoFormat"),
OBS_COMBO_TYPE_LIST,
format_list = obs_properties_add_list(props, "pixelformat", obs_module_text("VideoFormat"), OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_INT);
resolution_list = obs_properties_add_list(props, "resolution",
obs_module_text("Resolution"),
OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_STRING);
resolution_list = obs_properties_add_list(props, "resolution", obs_module_text("Resolution"),
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
framerate_list = obs_properties_add_list(props, "framerate",
obs_module_text("FrameRate"),
OBS_COMBO_TYPE_LIST,
framerate_list = obs_properties_add_list(props, "framerate", obs_module_text("FrameRate"), OBS_COMBO_TYPE_LIST,
OBS_COMBO_FORMAT_STRING);
// a group to contain the camera control
controls_props = obs_properties_create();
obs_properties_add_group(props, "controls",
obs_module_text("CameraControls"),
OBS_GROUP_NORMAL, controls_props);
obs_properties_add_group(props, "controls", obs_module_text("CameraControls"), OBS_GROUP_NORMAL,
controls_props);
populate_cameras_list(camera_source, device_list);
obs_property_set_modified_callback2(device_list, device_selected,
camera_source);
obs_property_set_modified_callback2(format_list, format_selected,
camera_source);
obs_property_set_modified_callback2(resolution_list,
resolution_selected, camera_source);
obs_property_set_modified_callback2(framerate_list, framerate_selected,
camera_source);
obs_property_set_modified_callback2(device_list, device_selected, camera_source);
obs_property_set_modified_callback2(format_list, format_selected, camera_source);
obs_property_set_modified_callback2(resolution_list, resolution_selected, camera_source);
obs_property_set_modified_callback2(framerate_list, framerate_selected, camera_source);
return props;
}
@@ -1360,8 +1223,7 @@ static uint32_t pipewire_camera_get_width(void *data)
struct camera_portal_source *camera_source = data;
if (camera_source->obs_pw_stream)
return obs_pipewire_stream_get_width(
camera_source->obs_pw_stream);
return obs_pipewire_stream_get_width(camera_source->obs_pw_stream);
else
return 0;
}
@@ -1371,8 +1233,7 @@ static uint32_t pipewire_camera_get_height(void *data)
struct camera_portal_source *camera_source = data;
if (camera_source->obs_pw_stream)
return obs_pipewire_stream_get_height(
camera_source->obs_pw_stream);
return obs_pipewire_stream_get_height(camera_source->obs_pw_stream);
else
return 0;
}
+2 -4
View File
@@ -103,11 +103,9 @@ static const struct obs_pw_video_format supported_formats[] = {
#endif
};
#define N_SUPPORTED_FORMATS \
(sizeof(supported_formats) / sizeof(supported_formats[0]))
#define N_SUPPORTED_FORMATS (sizeof(supported_formats) / sizeof(supported_formats[0]))
bool obs_pw_video_format_from_spa_format(
uint32_t spa_format, struct obs_pw_video_format *out_video_format)
bool obs_pw_video_format_from_spa_format(uint32_t spa_format, struct obs_pw_video_format *out_video_format)
{
for (size_t i = 0; i < N_SUPPORTED_FORMATS; i++) {
if (supported_formats[i].spa_format != spa_format)
+1 -2
View File
@@ -35,5 +35,4 @@ struct obs_pw_video_format {
const char *pretty_name;
};
bool obs_pw_video_format_from_spa_format(
uint32_t spa_format, struct obs_pw_video_format *out_format_info);
bool obs_pw_video_format_from_spa_format(uint32_t spa_format, struct obs_pw_video_format *out_format_info);
File diff suppressed because it is too large Load Diff
+8 -15
View File
@@ -39,30 +39,23 @@ struct obs_pipwire_connect_stream_info {
} video;
};
obs_pipewire *
obs_pipewire_connect_fd(int pipewire_fd,
const struct pw_registry_events *registry_events,
void *user_data);
obs_pipewire *obs_pipewire_connect_fd(int pipewire_fd, const struct pw_registry_events *registry_events,
void *user_data);
struct pw_registry *obs_pipewire_get_registry(obs_pipewire *obs_pw);
void obs_pipewire_roundtrip(obs_pipewire *obs_pw);
void obs_pipewire_destroy(obs_pipewire *obs_pw);
obs_pipewire_stream *obs_pipewire_connect_stream(
obs_pipewire *obs_pw, obs_source_t *source, int pipewire_node,
const struct obs_pipwire_connect_stream_info *connect_info);
obs_pipewire_stream *obs_pipewire_connect_stream(obs_pipewire *obs_pw, obs_source_t *source, int pipewire_node,
const struct obs_pipwire_connect_stream_info *connect_info);
void obs_pipewire_stream_show(obs_pipewire_stream *obs_pw_stream);
void obs_pipewire_stream_hide(obs_pipewire_stream *obs_pw_stream);
uint32_t obs_pipewire_stream_get_width(obs_pipewire_stream *obs_pw_stream);
uint32_t obs_pipewire_stream_get_height(obs_pipewire_stream *obs_pw_stream);
void obs_pipewire_stream_video_render(obs_pipewire_stream *obs_pw_stream,
gs_effect_t *effect);
void obs_pipewire_stream_video_render(obs_pipewire_stream *obs_pw_stream, gs_effect_t *effect);
void obs_pipewire_stream_set_cursor_visible(obs_pipewire_stream *obs_pw_stream,
bool cursor_visible);
void obs_pipewire_stream_set_cursor_visible(obs_pipewire_stream *obs_pw_stream, bool cursor_visible);
void obs_pipewire_stream_destroy(obs_pipewire_stream *obs_pw_stream);
void obs_pipewire_stream_set_framerate(obs_pipewire_stream *obs_pw_stream,
const struct spa_fraction *framerate);
void obs_pipewire_stream_set_resolution(obs_pipewire_stream *obs_pw,
const struct spa_rectangle *resolution);
void obs_pipewire_stream_set_framerate(obs_pipewire_stream *obs_pw_stream, const struct spa_fraction *framerate);
void obs_pipewire_stream_set_resolution(obs_pipewire_stream *obs_pw, const struct spa_rectangle *resolution);
+18 -34
View File
@@ -44,9 +44,7 @@ static void ensure_connection(void)
connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
if (error) {
blog(LOG_WARNING,
"[portals] Error retrieving D-Bus connection: %s",
error->message);
blog(LOG_WARNING, "[portals] Error retrieving D-Bus connection: %s", error->message);
return;
}
}
@@ -59,8 +57,7 @@ char *get_sender_name(void)
ensure_connection();
sender_name =
bstrdup(g_dbus_connection_get_unique_name(connection) + 1);
sender_name = bstrdup(g_dbus_connection_get_unique_name(connection) + 1);
/* Replace dots by underscores */
while ((aux = strstr(sender_name, ".")) != NULL)
@@ -95,8 +92,7 @@ void portal_create_request_path(char **out_path, char **out_token)
sender_name = get_sender_name();
dstr_init(&str);
dstr_printf(&str, REQUEST_PATH, sender_name,
request_token_count);
dstr_printf(&str, REQUEST_PATH, sender_name, request_token_count);
*out_path = str.array;
bfree(sender_name);
@@ -123,8 +119,7 @@ void portal_create_session_path(char **out_path, char **out_token)
sender_name = get_sender_name();
dstr_init(&str);
dstr_printf(&str, SESSION_PATH, sender_name,
session_token_count);
dstr_printf(&str, SESSION_PATH, sender_name, session_token_count);
*out_path = str.array;
bfree(sender_name);
@@ -134,12 +129,10 @@ void portal_create_session_path(char **out_path, char **out_token)
static void portal_signal_call_free(struct portal_signal_call *call)
{
if (call->signal_id)
g_dbus_connection_signal_unsubscribe(
portal_get_dbus_connection(), call->signal_id);
g_dbus_connection_signal_unsubscribe(portal_get_dbus_connection(), call->signal_id);
if (call->cancelled_id > 0)
g_signal_handler_disconnect(call->cancellable,
call->cancelled_id);
g_signal_handler_disconnect(call->cancellable, call->cancelled_id);
g_clear_pointer(&call->request_path, bfree);
bfree(call);
@@ -153,20 +146,16 @@ static void on_cancelled_cb(GCancellable *cancellable, void *data)
blog(LOG_INFO, "[portals] Request cancelled");
g_dbus_connection_call(
portal_get_dbus_connection(), "org.freedesktop.portal.Desktop",
call->request_path, "org.freedesktop.portal.Request", "Close",
NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
g_dbus_connection_call(portal_get_dbus_connection(), "org.freedesktop.portal.Desktop", call->request_path,
"org.freedesktop.portal.Request", "Close", NULL, NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL,
NULL, NULL);
portal_signal_call_free(call);
}
static void on_response_received_cb(GDBusConnection *connection,
const char *sender_name,
const char *object_path,
const char *interface_name,
const char *signal_name,
GVariant *parameters, void *user_data)
static void on_response_received_cb(GDBusConnection *connection, const char *sender_name, const char *object_path,
const char *interface_name, const char *signal_name, GVariant *parameters,
void *user_data)
{
UNUSED_PARAMETER(connection);
UNUSED_PARAMETER(sender_name);
@@ -182,8 +171,7 @@ static void on_response_received_cb(GDBusConnection *connection,
portal_signal_call_free(call);
}
void portal_signal_subscribe(const char *path, GCancellable *cancellable,
portal_signal_callback callback,
void portal_signal_subscribe(const char *path, GCancellable *cancellable, portal_signal_callback callback,
gpointer user_data)
{
struct portal_signal_call *call;
@@ -193,14 +181,10 @@ void portal_signal_subscribe(const char *path, GCancellable *cancellable,
call->callback = callback;
call->user_data = user_data;
call->cancellable = cancellable ? g_object_ref(cancellable) : NULL;
call->cancelled_id =
cancellable
? g_signal_connect(cancellable, "cancelled",
G_CALLBACK(on_cancelled_cb), call)
: 0;
call->cancelled_id = cancellable ? g_signal_connect(cancellable, "cancelled", G_CALLBACK(on_cancelled_cb), call)
: 0;
call->signal_id = g_dbus_connection_signal_subscribe(
portal_get_dbus_connection(), "org.freedesktop.portal.Desktop",
"org.freedesktop.portal.Request", "Response",
call->request_path, NULL, G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE,
on_response_received_cb, call, NULL);
portal_get_dbus_connection(), "org.freedesktop.portal.Desktop", "org.freedesktop.portal.Request",
"Response", call->request_path, NULL, G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE, on_response_received_cb, call,
NULL);
}
+2 -2
View File
@@ -30,5 +30,5 @@ GDBusConnection *portal_get_dbus_connection(void);
void portal_create_request_path(char **out_path, char **out_token);
void portal_create_session_path(char **out_path, char **out_token);
void portal_signal_subscribe(const char *path, GCancellable *cancellable,
portal_signal_callback callback, void *user_data);
void portal_signal_subscribe(const char *path, GCancellable *cancellable, portal_signal_callback callback,
void *user_data);
+91 -183
View File
@@ -38,8 +38,7 @@ enum portal_cursor_mode {
enum obs_portal_capture_type {
OBS_PORTAL_CAPTURE_TYPE_MONITOR = PORTAL_CAPTURE_TYPE_MONITOR,
OBS_PORTAL_CAPTURE_TYPE_WINDOW = PORTAL_CAPTURE_TYPE_WINDOW,
OBS_PORTAL_CAPTURE_TYPE_UNIFIED = PORTAL_CAPTURE_TYPE_MONITOR |
PORTAL_CAPTURE_TYPE_WINDOW,
OBS_PORTAL_CAPTURE_TYPE_UNIFIED = PORTAL_CAPTURE_TYPE_MONITOR | PORTAL_CAPTURE_TYPE_WINDOW,
};
struct screencast_portal_capture {
@@ -68,16 +67,13 @@ static void ensure_screencast_portal_proxy(void)
{
g_autoptr(GError) error = NULL;
if (!screencast_proxy) {
screencast_proxy = g_dbus_proxy_new_sync(
portal_get_dbus_connection(), G_DBUS_PROXY_FLAGS_NONE,
NULL, "org.freedesktop.portal.Desktop",
"/org/freedesktop/portal/desktop",
"org.freedesktop.portal.ScreenCast", NULL, &error);
screencast_proxy = g_dbus_proxy_new_sync(portal_get_dbus_connection(), G_DBUS_PROXY_FLAGS_NONE, NULL,
"org.freedesktop.portal.Desktop",
"/org/freedesktop/portal/desktop",
"org.freedesktop.portal.ScreenCast", NULL, &error);
if (error) {
blog(LOG_WARNING,
"[portals] Error retrieving D-Bus proxy: %s",
error->message);
blog(LOG_WARNING, "[portals] Error retrieving D-Bus proxy: %s", error->message);
return;
}
}
@@ -99,11 +95,8 @@ static uint32_t get_available_capture_types(void)
if (!screencast_proxy)
return 0;
cached_source_types = g_dbus_proxy_get_cached_property(
screencast_proxy, "AvailableSourceTypes");
available_source_types =
cached_source_types ? g_variant_get_uint32(cached_source_types)
: 0;
cached_source_types = g_dbus_proxy_get_cached_property(screencast_proxy, "AvailableSourceTypes");
available_source_types = cached_source_types ? g_variant_get_uint32(cached_source_types) : 0;
return available_source_types;
}
@@ -118,11 +111,8 @@ static uint32_t get_available_cursor_modes(void)
if (!screencast_proxy)
return 0;
cached_cursor_modes = g_dbus_proxy_get_cached_property(
screencast_proxy, "AvailableCursorModes");
available_cursor_modes =
cached_cursor_modes ? g_variant_get_uint32(cached_cursor_modes)
: 0;
cached_cursor_modes = g_dbus_proxy_get_cached_property(screencast_proxy, "AvailableCursorModes");
available_cursor_modes = cached_cursor_modes ? g_variant_get_uint32(cached_cursor_modes) : 0;
return available_cursor_modes;
}
@@ -137,8 +127,7 @@ static uint32_t get_screencast_version(void)
if (!screencast_proxy)
return 0;
cached_version =
g_dbus_proxy_get_cached_property(screencast_proxy, "version");
cached_version = g_dbus_proxy_get_cached_property(screencast_proxy, "version");
version = cached_version ? g_variant_get_uint32(cached_version) : 0;
return version;
@@ -146,8 +135,7 @@ static uint32_t get_screencast_version(void)
/* ------------------------------------------------- */
static const char *
capture_type_to_string(enum obs_portal_capture_type capture_type)
static const char *capture_type_to_string(enum obs_portal_capture_type capture_type)
{
switch (capture_type) {
case OBS_PORTAL_CAPTURE_TYPE_MONITOR:
@@ -163,8 +151,7 @@ capture_type_to_string(enum obs_portal_capture_type capture_type)
/* ------------------------------------------------- */
static void on_pipewire_remote_opened_cb(GObject *source, GAsyncResult *res,
void *user_data)
static void on_pipewire_remote_opened_cb(GObject *source, GAsyncResult *res, void *user_data)
{
struct obs_pipwire_connect_stream_info connect_info;
struct screencast_portal_capture *capture;
@@ -175,13 +162,10 @@ static void on_pipewire_remote_opened_cb(GObject *source, GAsyncResult *res,
int fd_index;
capture = user_data;
result = g_dbus_proxy_call_with_unix_fd_list_finish(
G_DBUS_PROXY(source), &fd_list, res, &error);
result = g_dbus_proxy_call_with_unix_fd_list_finish(G_DBUS_PROXY(source), &fd_list, res, &error);
if (error) {
if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
blog(LOG_ERROR,
"[pipewire] Error retrieving pipewire fd: %s",
error->message);
blog(LOG_ERROR, "[pipewire] Error retrieving pipewire fd: %s", error->message);
return;
}
@@ -190,9 +174,7 @@ static void on_pipewire_remote_opened_cb(GObject *source, GAsyncResult *res,
pipewire_fd = g_unix_fd_list_get(fd_list, fd_index, &error);
if (error) {
if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
blog(LOG_ERROR,
"[pipewire] Error retrieving pipewire fd: %s",
error->message);
blog(LOG_ERROR, "[pipewire] Error retrieving pipewire fd: %s", error->message);
return;
}
@@ -203,18 +185,16 @@ static void on_pipewire_remote_opened_cb(GObject *source, GAsyncResult *res,
connect_info = (struct obs_pipwire_connect_stream_info){
.stream_name = "OBS Studio",
.stream_properties = pw_properties_new(
PW_KEY_MEDIA_TYPE, "Video", PW_KEY_MEDIA_CATEGORY,
"Capture", PW_KEY_MEDIA_ROLE, "Screen", NULL),
.stream_properties = pw_properties_new(PW_KEY_MEDIA_TYPE, "Video", PW_KEY_MEDIA_CATEGORY, "Capture",
PW_KEY_MEDIA_ROLE, "Screen", NULL),
.screencast =
{
.cursor_visible = capture->cursor_visible,
},
};
capture->obs_pw_stream = obs_pipewire_connect_stream(
capture->obs_pw, capture->source, capture->pipewire_node,
&connect_info);
capture->obs_pw_stream =
obs_pipewire_connect_stream(capture->obs_pw, capture->source, capture->pipewire_node, &connect_info);
}
static void open_pipewire_remote(struct screencast_portal_capture *capture)
@@ -223,11 +203,10 @@ static void open_pipewire_remote(struct screencast_portal_capture *capture)
g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
g_dbus_proxy_call_with_unix_fd_list(
get_screencast_portal_proxy(), "OpenPipeWireRemote",
g_variant_new("(oa{sv})", capture->session_handle, &builder),
G_DBUS_CALL_FLAGS_NONE, -1, NULL, capture->cancellable,
on_pipewire_remote_opened_cb, capture);
g_dbus_proxy_call_with_unix_fd_list(get_screencast_portal_proxy(), "OpenPipeWireRemote",
g_variant_new("(oa{sv})", capture->session_handle, &builder),
G_DBUS_CALL_FLAGS_NONE, -1, NULL, capture->cancellable,
on_pipewire_remote_opened_cb, capture);
}
/* ------------------------------------------------- */
@@ -245,22 +224,19 @@ static void on_start_response_received_cb(GVariant *parameters, void *user_data)
g_variant_get(parameters, "(u@a{sv})", &response, &result);
if (response != 0) {
blog(LOG_WARNING,
"[pipewire] Failed to start screencast, denied or cancelled by user");
blog(LOG_WARNING, "[pipewire] Failed to start screencast, denied or cancelled by user");
return;
}
streams =
g_variant_lookup_value(result, "streams", G_VARIANT_TYPE_ARRAY);
streams = g_variant_lookup_value(result, "streams", G_VARIANT_TYPE_ARRAY);
g_variant_iter_init(&iter, streams);
n_streams = g_variant_iter_n_children(&iter);
if (n_streams != 1) {
blog(LOG_WARNING,
"[pipewire] Received more than one stream when only one was expected. "
"This is probably a bug in the desktop portal implementation you are "
"using.");
blog(LOG_WARNING, "[pipewire] Received more than one stream when only one was expected. "
"This is probably a bug in the desktop portal implementation you are "
"using.");
// The KDE Desktop portal implementation sometimes sends an invalid
// response where more than one stream is attached, and only the
@@ -270,25 +246,20 @@ static void on_start_response_received_cb(GVariant *parameters, void *user_data)
g_autoptr(GVariant) throwaway_properties = NULL;
uint32_t throwaway_pipewire_node;
g_variant_iter_loop(&iter, "(u@a{sv})",
&throwaway_pipewire_node,
&throwaway_properties);
g_variant_iter_loop(&iter, "(u@a{sv})", &throwaway_pipewire_node, &throwaway_properties);
}
}
g_variant_iter_loop(&iter, "(u@a{sv})", &capture->pipewire_node,
&stream_properties);
g_variant_iter_loop(&iter, "(u@a{sv})", &capture->pipewire_node, &stream_properties);
if (get_screencast_version() >= 4) {
g_autoptr(GVariant) restore_token = NULL;
g_clear_pointer(&capture->restore_token, bfree);
restore_token = g_variant_lookup_value(result, "restore_token",
G_VARIANT_TYPE_STRING);
restore_token = g_variant_lookup_value(result, "restore_token", G_VARIANT_TYPE_STRING);
if (restore_token)
capture->restore_token = bstrdup(
g_variant_get_string(restore_token, NULL));
capture->restore_token = bstrdup(g_variant_get_string(restore_token, NULL));
obs_source_save(capture->source);
}
@@ -308,9 +279,7 @@ static void on_started_cb(GObject *source, GAsyncResult *res, void *user_data)
result = g_dbus_proxy_call_finish(G_DBUS_PROXY(source), res, &error);
if (error) {
if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
blog(LOG_ERROR,
"[pipewire] Error selecting screencast source: %s",
error->message);
blog(LOG_ERROR, "[pipewire] Error selecting screencast source: %s", error->message);
return;
}
}
@@ -323,21 +292,16 @@ static void start(struct screencast_portal_capture *capture)
portal_create_request_path(&request_path, &request_token);
blog(LOG_INFO, "[pipewire] Asking for %s",
capture_type_to_string(capture->capture_type));
blog(LOG_INFO, "[pipewire] Asking for %s", capture_type_to_string(capture->capture_type));
portal_signal_subscribe(request_path, capture->cancellable,
on_start_response_received_cb, capture);
portal_signal_subscribe(request_path, capture->cancellable, on_start_response_received_cb, capture);
g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add(&builder, "{sv}", "handle_token",
g_variant_new_string(request_token));
g_variant_builder_add(&builder, "{sv}", "handle_token", g_variant_new_string(request_token));
g_dbus_proxy_call(get_screencast_portal_proxy(), "Start",
g_variant_new("(osa{sv})", capture->session_handle,
"", &builder),
G_DBUS_CALL_FLAGS_NONE, -1, capture->cancellable,
on_started_cb, NULL);
g_variant_new("(osa{sv})", capture->session_handle, "", &builder), G_DBUS_CALL_FLAGS_NONE, -1,
capture->cancellable, on_started_cb, NULL);
bfree(request_token);
bfree(request_path);
@@ -345,8 +309,7 @@ static void start(struct screencast_portal_capture *capture)
/* ------------------------------------------------- */
static void on_select_source_response_received_cb(GVariant *parameters,
void *user_data)
static void on_select_source_response_received_cb(GVariant *parameters, void *user_data)
{
struct screencast_portal_capture *capture = user_data;
g_autoptr(GVariant) ret = NULL;
@@ -357,16 +320,14 @@ static void on_select_source_response_received_cb(GVariant *parameters,
g_variant_get(parameters, "(u@a{sv})", &response, &ret);
if (response != 0) {
blog(LOG_WARNING,
"[pipewire] Failed to select source, denied or cancelled by user");
blog(LOG_WARNING, "[pipewire] Failed to select source, denied or cancelled by user");
return;
}
start(capture);
}
static void on_source_selected_cb(GObject *source, GAsyncResult *res,
void *user_data)
static void on_source_selected_cb(GObject *source, GAsyncResult *res, void *user_data)
{
UNUSED_PARAMETER(user_data);
@@ -376,9 +337,7 @@ static void on_source_selected_cb(GObject *source, GAsyncResult *res,
result = g_dbus_proxy_call_finish(G_DBUS_PROXY(source), res, &error);
if (error) {
if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
blog(LOG_ERROR,
"[pipewire] Error selecting screencast source: %s",
error->message);
blog(LOG_ERROR, "[pipewire] Error selecting screencast source: %s", error->message);
return;
}
}
@@ -392,48 +351,35 @@ static void select_source(struct screencast_portal_capture *capture)
portal_create_request_path(&request_path, &request_token);
portal_signal_subscribe(request_path, capture->cancellable,
on_select_source_response_received_cb, capture);
portal_signal_subscribe(request_path, capture->cancellable, on_select_source_response_received_cb, capture);
g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add(&builder, "{sv}", "types",
g_variant_new_uint32(capture->capture_type));
g_variant_builder_add(&builder, "{sv}", "multiple",
g_variant_new_boolean(FALSE));
g_variant_builder_add(&builder, "{sv}", "handle_token",
g_variant_new_string(request_token));
g_variant_builder_add(&builder, "{sv}", "types", g_variant_new_uint32(capture->capture_type));
g_variant_builder_add(&builder, "{sv}", "multiple", g_variant_new_boolean(FALSE));
g_variant_builder_add(&builder, "{sv}", "handle_token", g_variant_new_string(request_token));
available_cursor_modes = get_available_cursor_modes();
if (available_cursor_modes & PORTAL_CURSOR_MODE_METADATA)
g_variant_builder_add(
&builder, "{sv}", "cursor_mode",
g_variant_new_uint32(PORTAL_CURSOR_MODE_METADATA));
else if ((available_cursor_modes & PORTAL_CURSOR_MODE_EMBEDDED) &&
capture->cursor_visible)
g_variant_builder_add(
&builder, "{sv}", "cursor_mode",
g_variant_new_uint32(PORTAL_CURSOR_MODE_EMBEDDED));
g_variant_builder_add(&builder, "{sv}", "cursor_mode",
g_variant_new_uint32(PORTAL_CURSOR_MODE_METADATA));
else if ((available_cursor_modes & PORTAL_CURSOR_MODE_EMBEDDED) && capture->cursor_visible)
g_variant_builder_add(&builder, "{sv}", "cursor_mode",
g_variant_new_uint32(PORTAL_CURSOR_MODE_EMBEDDED));
else
g_variant_builder_add(
&builder, "{sv}", "cursor_mode",
g_variant_new_uint32(PORTAL_CURSOR_MODE_HIDDEN));
g_variant_builder_add(&builder, "{sv}", "cursor_mode", g_variant_new_uint32(PORTAL_CURSOR_MODE_HIDDEN));
if (get_screencast_version() >= 4) {
g_variant_builder_add(&builder, "{sv}", "persist_mode",
g_variant_new_uint32(2));
g_variant_builder_add(&builder, "{sv}", "persist_mode", g_variant_new_uint32(2));
if (capture->restore_token && *capture->restore_token) {
g_variant_builder_add(
&builder, "{sv}", "restore_token",
g_variant_new_string(capture->restore_token));
g_variant_builder_add(&builder, "{sv}", "restore_token",
g_variant_new_string(capture->restore_token));
}
}
g_dbus_proxy_call(get_screencast_portal_proxy(), "SelectSources",
g_variant_new("(oa{sv})", capture->session_handle,
&builder),
G_DBUS_CALL_FLAGS_NONE, -1, capture->cancellable,
on_source_selected_cb, NULL);
g_variant_new("(oa{sv})", capture->session_handle, &builder), G_DBUS_CALL_FLAGS_NONE, -1,
capture->cancellable, on_source_selected_cb, NULL);
bfree(request_token);
bfree(request_path);
@@ -441,8 +387,7 @@ static void select_source(struct screencast_portal_capture *capture)
/* ------------------------------------------------- */
static void on_create_session_response_received_cb(GVariant *parameters,
void *user_data)
static void on_create_session_response_received_cb(GVariant *parameters, void *user_data)
{
struct screencast_portal_capture *capture = user_data;
g_autoptr(GVariant) session_handle_variant = NULL;
@@ -452,23 +397,19 @@ static void on_create_session_response_received_cb(GVariant *parameters,
g_variant_get(parameters, "(u@a{sv})", &response, &result);
if (response != 0) {
blog(LOG_WARNING,
"[pipewire] Failed to create session, denied or cancelled by user");
blog(LOG_WARNING, "[pipewire] Failed to create session, denied or cancelled by user");
return;
}
blog(LOG_INFO, "[pipewire] Screencast session created");
session_handle_variant =
g_variant_lookup_value(result, "session_handle", NULL);
capture->session_handle =
g_variant_dup_string(session_handle_variant, NULL);
session_handle_variant = g_variant_lookup_value(result, "session_handle", NULL);
capture->session_handle = g_variant_dup_string(session_handle_variant, NULL);
select_source(capture);
}
static void on_session_created_cb(GObject *source, GAsyncResult *res,
void *user_data)
static void on_session_created_cb(GObject *source, GAsyncResult *res, void *user_data)
{
UNUSED_PARAMETER(user_data);
@@ -478,9 +419,7 @@ static void on_session_created_cb(GObject *source, GAsyncResult *res,
result = g_dbus_proxy_call_finish(G_DBUS_PROXY(source), res, &error);
if (error) {
if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
blog(LOG_ERROR,
"[pipewire] Error creating screencast session: %s",
error->message);
blog(LOG_ERROR, "[pipewire] Error creating screencast session: %s", error->message);
return;
}
}
@@ -495,20 +434,14 @@ static void create_session(struct screencast_portal_capture *capture)
portal_create_request_path(&request_path, &request_token);
portal_create_session_path(NULL, &session_token);
portal_signal_subscribe(request_path, capture->cancellable,
on_create_session_response_received_cb,
capture);
portal_signal_subscribe(request_path, capture->cancellable, on_create_session_response_received_cb, capture);
g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT);
g_variant_builder_add(&builder, "{sv}", "handle_token",
g_variant_new_string(request_token));
g_variant_builder_add(&builder, "{sv}", "session_handle_token",
g_variant_new_string(session_token));
g_variant_builder_add(&builder, "{sv}", "handle_token", g_variant_new_string(request_token));
g_variant_builder_add(&builder, "{sv}", "session_handle_token", g_variant_new_string(session_token));
g_dbus_proxy_call(get_screencast_portal_proxy(), "CreateSession",
g_variant_new("(a{sv})", &builder),
G_DBUS_CALL_FLAGS_NONE, -1, capture->cancellable,
on_session_created_cb, NULL);
g_dbus_proxy_call(get_screencast_portal_proxy(), "CreateSession", g_variant_new("(a{sv})", &builder),
G_DBUS_CALL_FLAGS_NONE, -1, capture->cancellable, on_session_created_cb, NULL);
bfree(session_token);
bfree(request_token);
@@ -517,8 +450,7 @@ static void create_session(struct screencast_portal_capture *capture)
/* ------------------------------------------------- */
static gboolean
init_screencast_capture(struct screencast_portal_capture *capture)
static gboolean init_screencast_capture(struct screencast_portal_capture *capture)
{
GDBusConnection *connection;
GDBusProxy *proxy;
@@ -538,8 +470,7 @@ init_screencast_capture(struct screencast_portal_capture *capture)
return TRUE;
}
static bool reload_session_cb(obs_properties_t *properties,
obs_property_t *property, void *data)
static bool reload_session_cb(obs_properties_t *properties, obs_property_t *property, void *data)
{
UNUSED_PARAMETER(properties);
UNUSED_PARAMETER(property);
@@ -551,15 +482,10 @@ static bool reload_session_cb(obs_properties_t *properties,
g_clear_pointer(&capture->obs_pw, obs_pipewire_destroy);
if (capture->session_handle) {
blog(LOG_DEBUG, "[pipewire] Cleaning previous session %s",
capture->session_handle);
g_dbus_connection_call(portal_get_dbus_connection(),
"org.freedesktop.portal.Desktop",
capture->session_handle,
"org.freedesktop.portal.Session",
"Close", NULL, NULL,
G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL,
NULL);
blog(LOG_DEBUG, "[pipewire] Cleaning previous session %s", capture->session_handle);
g_dbus_connection_call(portal_get_dbus_connection(), "org.freedesktop.portal.Desktop",
capture->session_handle, "org.freedesktop.portal.Session", "Close", NULL, NULL,
G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
g_clear_pointer(&capture->session_handle, g_free);
}
@@ -583,32 +509,28 @@ static const char *screencast_portal_window_capture_get_name(void *data)
return obs_module_text("PipeWireWindowCapture");
}
static void *screencast_portal_desktop_capture_create(obs_data_t *settings,
obs_source_t *source)
static void *screencast_portal_desktop_capture_create(obs_data_t *settings, obs_source_t *source)
{
struct screencast_portal_capture *capture;
capture = bzalloc(sizeof(struct screencast_portal_capture));
capture->capture_type = OBS_PORTAL_CAPTURE_TYPE_MONITOR;
capture->cursor_visible = obs_data_get_bool(settings, "ShowCursor");
capture->restore_token =
bstrdup(obs_data_get_string(settings, "RestoreToken"));
capture->restore_token = bstrdup(obs_data_get_string(settings, "RestoreToken"));
capture->source = source;
init_screencast_capture(capture);
return capture;
}
static void *screencast_portal_window_capture_create(obs_data_t *settings,
obs_source_t *source)
static void *screencast_portal_window_capture_create(obs_data_t *settings, obs_source_t *source)
{
struct screencast_portal_capture *capture;
capture = bzalloc(sizeof(struct screencast_portal_capture));
capture->capture_type = OBS_PORTAL_CAPTURE_TYPE_WINDOW;
capture->cursor_visible = obs_data_get_bool(settings, "ShowCursor");
capture->restore_token =
bstrdup(obs_data_get_string(settings, "RestoreToken"));
capture->restore_token = bstrdup(obs_data_get_string(settings, "RestoreToken"));
capture->source = source;
init_screencast_capture(capture);
@@ -616,16 +538,14 @@ static void *screencast_portal_window_capture_create(obs_data_t *settings,
return capture;
}
static void *screencast_portal_capture_create(obs_data_t *settings,
obs_source_t *source)
static void *screencast_portal_capture_create(obs_data_t *settings, obs_source_t *source)
{
struct screencast_portal_capture *capture;
capture = bzalloc(sizeof(struct screencast_portal_capture));
capture->capture_type = OBS_PORTAL_CAPTURE_TYPE_UNIFIED;
capture->cursor_visible = obs_data_get_bool(settings, "ShowCursor");
capture->restore_token =
bstrdup(obs_data_get_string(settings, "RestoreToken"));
capture->restore_token = bstrdup(obs_data_get_string(settings, "RestoreToken"));
capture->source = source;
init_screencast_capture(capture);
@@ -641,13 +561,9 @@ static void screencast_portal_capture_destroy(void *data)
return;
if (capture->session_handle) {
g_dbus_connection_call(portal_get_dbus_connection(),
"org.freedesktop.portal.Desktop",
capture->session_handle,
"org.freedesktop.portal.Session",
"Close", NULL, NULL,
G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL,
NULL);
g_dbus_connection_call(portal_get_dbus_connection(), "org.freedesktop.portal.Desktop",
capture->session_handle, "org.freedesktop.portal.Session", "Close", NULL, NULL,
G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL, NULL);
g_clear_pointer(&capture->session_handle, g_free);
}
@@ -695,11 +611,8 @@ static obs_properties_t *screencast_portal_capture_get_properties(void *data)
}
properties = obs_properties_create();
obs_properties_add_button2(properties, "Reload",
obs_module_text(reload_string_id),
reload_session_cb, capture);
obs_properties_add_bool(properties, "ShowCursor",
obs_module_text("ShowCursor"));
obs_properties_add_button2(properties, "Reload", obs_module_text(reload_string_id), reload_session_cb, capture);
obs_properties_add_bool(properties, "ShowCursor", obs_module_text("ShowCursor"));
return properties;
}
@@ -711,8 +624,7 @@ static void screencast_portal_capture_update(void *data, obs_data_t *settings)
capture->cursor_visible = obs_data_get_bool(settings, "ShowCursor");
if (capture->obs_pw_stream)
obs_pipewire_stream_set_cursor_visible(capture->obs_pw_stream,
capture->cursor_visible);
obs_pipewire_stream_set_cursor_visible(capture->obs_pw_stream, capture->cursor_visible);
}
static void screencast_portal_capture_show(void *data)
@@ -751,23 +663,19 @@ static uint32_t screencast_portal_capture_get_height(void *data)
return 0;
}
static void screencast_portal_capture_video_render(void *data,
gs_effect_t *effect)
static void screencast_portal_capture_video_render(void *data, gs_effect_t *effect)
{
struct screencast_portal_capture *capture = data;
if (capture->obs_pw_stream)
obs_pipewire_stream_video_render(capture->obs_pw_stream,
effect);
obs_pipewire_stream_video_render(capture->obs_pw_stream, effect);
}
void screencast_portal_load(void)
{
uint32_t available_capture_types = get_available_capture_types();
bool desktop_capture_available =
(available_capture_types & PORTAL_CAPTURE_TYPE_MONITOR) != 0;
bool window_capture_available =
(available_capture_types & PORTAL_CAPTURE_TYPE_WINDOW) != 0;
bool desktop_capture_available = (available_capture_types & PORTAL_CAPTURE_TYPE_MONITOR) != 0;
bool window_capture_available = (available_capture_types & PORTAL_CAPTURE_TYPE_WINDOW) != 0;
if (available_capture_types == 0) {
blog(LOG_INFO, "[pipewire] No capture sources available");