mirror of
https://github.com/hyprwm/xdg-desktop-portal-hyprland.git
synced 2024-11-22 06:35:57 +01:00
screencast: introduce build_formats
We build EnumFormats from our supported format multiple times. This commit just creates a function to do that. This makes it easier to handle the announcement of multiple buffer types.
This commit is contained in:
parent
ba0f40e45c
commit
0835d8287b
1 changed files with 14 additions and 10 deletions
|
@ -44,6 +44,15 @@ static struct spa_pod *build_format(struct spa_pod_builder *b, enum spa_video_fo
|
|||
return spa_pod_builder_pop(b, &f[0]);
|
||||
}
|
||||
|
||||
static uint32_t build_formats(struct spa_pod_builder *b, struct xdpw_screencast_instance *cast,
|
||||
const struct spa_pod *params[static 1]) {
|
||||
uint32_t param_count = 1;
|
||||
params[0] = build_format(b, xdpw_format_pw_from_drm_fourcc(cast->screencopy_frame_info.format),
|
||||
cast->screencopy_frame_info.width, cast->screencopy_frame_info.height, cast->framerate);
|
||||
|
||||
return param_count;
|
||||
}
|
||||
|
||||
static void pwr_handle_stream_on_process(void *data) {
|
||||
logprint(TRACE, "pipewire: stream process");
|
||||
struct xdpw_screencast_instance *cast = data;
|
||||
|
@ -268,12 +277,9 @@ void pwr_update_stream_param(struct xdpw_screencast_instance *cast) {
|
|||
SPA_POD_BUILDER_INIT(params_buffer, sizeof(params_buffer));
|
||||
const struct spa_pod *params[1];
|
||||
|
||||
enum spa_video_format format = xdpw_format_pw_from_drm_fourcc(cast->screencopy_frame_info.format);
|
||||
uint32_t n_params = build_formats(&b, cast, params);
|
||||
|
||||
params[0] = build_format(&b, format,
|
||||
cast->screencopy_frame_info.width, cast->screencopy_frame_info.height, cast->framerate);
|
||||
|
||||
pw_stream_update_params(stream, params, 1);
|
||||
pw_stream_update_params(stream, params, n_params);
|
||||
}
|
||||
|
||||
void xdpw_pwr_stream_create(struct xdpw_screencast_instance *cast) {
|
||||
|
@ -284,6 +290,7 @@ void xdpw_pwr_stream_create(struct xdpw_screencast_instance *cast) {
|
|||
|
||||
uint8_t buffer[1024];
|
||||
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
|
||||
const struct spa_pod *params[1];
|
||||
|
||||
char name[] = "xdpw-stream-XXXXXX";
|
||||
randname(name + strlen(name) - 6);
|
||||
|
@ -298,10 +305,7 @@ void xdpw_pwr_stream_create(struct xdpw_screencast_instance *cast) {
|
|||
}
|
||||
cast->pwr_stream_state = false;
|
||||
|
||||
enum spa_video_format format = xdpw_format_pw_from_drm_fourcc(cast->screencopy_frame_info.format);
|
||||
|
||||
const struct spa_pod *param = build_format(&b, format,
|
||||
cast->screencopy_frame_info.width, cast->screencopy_frame_info.height, cast->framerate);
|
||||
uint32_t param_count = build_formats(&b, cast, params);
|
||||
|
||||
pw_stream_add_listener(cast->stream, &cast->stream_listener,
|
||||
&pwr_stream_events, cast);
|
||||
|
@ -311,7 +315,7 @@ void xdpw_pwr_stream_create(struct xdpw_screencast_instance *cast) {
|
|||
PW_ID_ANY,
|
||||
(PW_STREAM_FLAG_DRIVER |
|
||||
PW_STREAM_FLAG_ALLOC_BUFFERS),
|
||||
¶m, 1);
|
||||
params, param_count);
|
||||
}
|
||||
|
||||
void xdpw_pwr_stream_destroy(struct xdpw_screencast_instance *cast) {
|
||||
|
|
Loading…
Reference in a new issue