0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-19 20:32:15 +02:00

linux-pipewire: Explicitly enumerate portal capture types

This is very much like previous commit, but there's a catch: there
already was an enumeration in place, which is replaced in this
commit. The obs_pw_capture_type enum was introduced before splitting
the portal code into a separate file, and the enum itself is specific
to the screencast portal, so the appropriate place to enumerate it
is in portal.h.

For completude, PORTAL_CAPTURE_TYPE_VIRTUAL was added to the enum,
even though we never used, and probably never will.

The values are still the same, since both the old and this new enum
were extracted from the screencast portal [1].

https://github.com/flatpak/xdg-desktop-portal/blob/main/data/org.freedesktop.portal.ScreenCast.xml#L290-300
This commit is contained in:
Georges Basile Stavracas Neto 2022-04-07 09:31:15 -03:00 committed by Jim
parent e7815dff66
commit 3d7663f417
4 changed files with 29 additions and 20 deletions

View File

@ -38,12 +38,14 @@ static const char *pipewire_window_capture_get_name(void *data)
static void *pipewire_desktop_capture_create(obs_data_t *settings,
obs_source_t *source)
{
return obs_pipewire_create(DESKTOP_CAPTURE, settings, source);
return obs_pipewire_create(PORTAL_CAPTURE_TYPE_MONITOR, settings,
source);
}
static void *pipewire_window_capture_create(obs_data_t *settings,
obs_source_t *source)
{
return obs_pipewire_create(WINDOW_CAPTURE, settings, source);
return obs_pipewire_create(PORTAL_CAPTURE_TYPE_WINDOW, settings,
source);
}
static void pipewire_capture_destroy(void *data)
@ -63,18 +65,19 @@ static void pipewire_capture_get_defaults(obs_data_t *settings)
static obs_properties_t *pipewire_capture_get_properties(void *data)
{
enum obs_pw_capture_type capture_type;
enum portal_capture_type capture_type;
obs_pipewire_data *obs_pw = data;
capture_type = obs_pipewire_get_capture_type(obs_pw);
switch (capture_type) {
case DESKTOP_CAPTURE:
case PORTAL_CAPTURE_TYPE_MONITOR:
return obs_pipewire_get_properties(data,
"PipeWireSelectMonitor");
case WINDOW_CAPTURE:
case PORTAL_CAPTURE_TYPE_WINDOW:
return obs_pipewire_get_properties(data,
"PipeWireSelectWindow");
case PORTAL_CAPTURE_TYPE_VIRTUAL:
default:
return NULL;
}
@ -116,9 +119,9 @@ void pipewire_capture_load(void)
{
uint32_t available_capture_types = portal_get_available_capture_types();
bool desktop_capture_available =
(available_capture_types & DESKTOP_CAPTURE) != 0;
(available_capture_types & PORTAL_CAPTURE_TYPE_MONITOR) != 0;
bool window_capture_available =
(available_capture_types & WINDOW_CAPTURE) != 0;
(available_capture_types & PORTAL_CAPTURE_TYPE_WINDOW) != 0;
if (available_capture_types == 0) {
blog(LOG_INFO, "[pipewire] No captures available");

View File

@ -106,7 +106,7 @@ struct _obs_pipewire_data {
gs_texture_t *texture;
} cursor;
enum obs_pw_capture_type capture_type;
enum portal_capture_type capture_type;
struct obs_video_info video_info;
bool negotiated;
@ -151,13 +151,16 @@ static void update_pw_versions(obs_pipewire_data *obs_pw, const char *version)
blog(LOG_WARNING, "[pipewire] failed to parse server version");
}
static const char *capture_type_to_string(enum obs_pw_capture_type capture_type)
static const char *capture_type_to_string(enum portal_capture_type capture_type)
{
switch (capture_type) {
case DESKTOP_CAPTURE:
case PORTAL_CAPTURE_TYPE_MONITOR:
return "desktop";
case WINDOW_CAPTURE:
case PORTAL_CAPTURE_TYPE_WINDOW:
return "window";
case PORTAL_CAPTURE_TYPE_VIRTUAL:
default:
return "unknown";
}
return "unknown";
}
@ -1400,7 +1403,7 @@ static bool reload_session_cb(obs_properties_t *properties,
/* obs_source_info methods */
void *obs_pipewire_create(enum obs_pw_capture_type capture_type,
void *obs_pipewire_create(enum portal_capture_type capture_type,
obs_data_t *settings, obs_source_t *source)
{
obs_pipewire_data *obs_pw = bzalloc(sizeof(obs_pipewire_data));
@ -1535,7 +1538,7 @@ void obs_pipewire_video_render(obs_pipewire_data *obs_pw, gs_effect_t *effect)
}
}
enum obs_pw_capture_type
enum portal_capture_type
obs_pipewire_get_capture_type(obs_pipewire_data *obs_pw)
{
return obs_pw->capture_type;

View File

@ -23,14 +23,11 @@
#include <obs-module.h>
#include <pipewire/pipewire.h>
#include "portal.h"
typedef struct _obs_pipewire_data obs_pipewire_data;
enum obs_pw_capture_type {
DESKTOP_CAPTURE = 1,
WINDOW_CAPTURE = 2,
};
void *obs_pipewire_create(enum obs_pw_capture_type capture_type,
void *obs_pipewire_create(enum portal_capture_type capture_type,
obs_data_t *settings, obs_source_t *source);
void obs_pipewire_destroy(obs_pipewire_data *obs_pw);
@ -50,5 +47,5 @@ uint32_t obs_pipewire_get_width(obs_pipewire_data *obs_pw);
uint32_t obs_pipewire_get_height(obs_pipewire_data *obs_pw);
void obs_pipewire_video_render(obs_pipewire_data *obs_pw, gs_effect_t *effect);
enum obs_pw_capture_type
enum portal_capture_type
obs_pipewire_get_capture_type(obs_pipewire_data *obs_pw);

View File

@ -23,6 +23,12 @@
#include <stdint.h>
#include <gio/gio.h>
enum portal_capture_type {
PORTAL_CAPTURE_TYPE_MONITOR = 1 << 0,
PORTAL_CAPTURE_TYPE_WINDOW = 1 << 1,
PORTAL_CAPTURE_TYPE_VIRTUAL = 1 << 2,
};
enum portal_cursor_mode {
PORTAL_CURSOR_MODE_HIDDEN = 1 << 0,
PORTAL_CURSOR_MODE_EMBEDDED = 1 << 1,