linux-capture: Fallback on older PipeWire versions to SHM

PipeWire server versions older than 0.3.24 can be incompatible with
clients build against a newer library version with respect to DMA-BUF
sharing. So we want to fallback to SHM transfer. This commit adds
checks for older versions.

These are classified as follows:
* PipeWire components older than 0.3.24: Restrict to SHM only
* PipeWire components with version 0.3.24 and newer: Announce DMA-BUF
  support via `SPA_PARAM_BUFFERS_dataType`
This commit is contained in:
columbarius 2021-11-27 04:32:45 +01:00 committed by Georges Basile Stavracas Neto
parent 9f7de79004
commit c1b87e70ef

View File

@ -553,6 +553,7 @@ static void on_param_changed_cb(void *user_data, uint32_t id,
obs_pipewire_data *obs_pw = user_data;
struct spa_pod_builder pod_builder;
const struct spa_pod *params[3];
uint32_t buffer_types;
uint8_t params_buffer[1024];
int result;
@ -570,6 +571,10 @@ static void on_param_changed_cb(void *user_data, uint32_t id,
spa_format_video_raw_parse(param, &obs_pw->format.info.raw);
buffer_types = 1 << SPA_DATA_MemPtr;
if (check_pw_version(&obs_pw->server_version, 0, 3, 24))
buffer_types |= 1 << SPA_DATA_DmaBuf;
blog(LOG_DEBUG, "[pipewire] Negotiated format:");
blog(LOG_DEBUG, "[pipewire] Format: %d (%s)",
@ -606,8 +611,7 @@ static void on_param_changed_cb(void *user_data, uint32_t id,
/* Buffer options */
params[2] = spa_pod_builder_add_object(
&pod_builder, SPA_TYPE_OBJECT_ParamBuffers, SPA_PARAM_Buffers,
SPA_PARAM_BUFFERS_dataType,
SPA_POD_Int((1 << SPA_DATA_MemPtr) | (1 << SPA_DATA_DmaBuf)));
SPA_PARAM_BUFFERS_dataType, SPA_POD_Int(buffer_types));
pw_stream_update_params(obs_pw->stream, params, 3);