pipewire: add the striped format inside of build_format

This commit is contained in:
columbarius 2021-05-26 00:54:30 +02:00 committed by Simon Ser
parent 773186d2ed
commit dee06d015d

View file

@ -26,18 +26,21 @@ static void writeFrameData(void *pwFramePointer, void *wlrFramePointer,
return; return;
} }
static struct spa_pod *build_format(struct spa_pod_builder *b, enum spa_video_format format, enum spa_video_format format_without_alpha, static struct spa_pod *build_format(struct spa_pod_builder *b, enum spa_video_format format,
uint32_t width, uint32_t height, uint32_t framerate) { uint32_t width, uint32_t height, uint32_t framerate) {
struct spa_pod_frame f; struct spa_pod_frame f[1];
spa_pod_builder_push_object(b, &f, SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat);
enum spa_video_format format_without_alpha = xdpw_format_pw_strip_alpha(format);
spa_pod_builder_push_object(b, &f[0], SPA_TYPE_OBJECT_Format, SPA_PARAM_EnumFormat);
spa_pod_builder_add(b, SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_video), 0); spa_pod_builder_add(b, SPA_FORMAT_mediaType, SPA_POD_Id(SPA_MEDIA_TYPE_video), 0);
spa_pod_builder_add(b, SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw), 0); spa_pod_builder_add(b, SPA_FORMAT_mediaSubtype, SPA_POD_Id(SPA_MEDIA_SUBTYPE_raw), 0);
if (format_without_alpha != SPA_VIDEO_FORMAT_UNKNOWN) { /* format */
spa_pod_builder_add(b, SPA_FORMAT_VIDEO_format, if (format_without_alpha == SPA_VIDEO_FORMAT_UNKNOWN) {
SPA_POD_CHOICE_ENUM_Id(3, format, format, format_without_alpha), 0); spa_pod_builder_add(b, SPA_FORMAT_VIDEO_format, SPA_POD_Id(format), 0);
} else { } else {
spa_pod_builder_add(b, SPA_FORMAT_VIDEO_format, spa_pod_builder_add(b, SPA_FORMAT_VIDEO_format,
SPA_POD_CHOICE_ENUM_Id(2, format, format), 0); SPA_POD_CHOICE_ENUM_Id(3, format, format, format_without_alpha), 0);
} }
spa_pod_builder_add(b, SPA_FORMAT_VIDEO_size, spa_pod_builder_add(b, SPA_FORMAT_VIDEO_size,
SPA_POD_CHOICE_RANGE_Rectangle( SPA_POD_CHOICE_RANGE_Rectangle(
@ -54,7 +57,7 @@ static struct spa_pod *build_format(struct spa_pod_builder *b, enum spa_video_fo
&SPA_FRACTION(1, 1), &SPA_FRACTION(1, 1),
&SPA_FRACTION(framerate, 1)), &SPA_FRACTION(framerate, 1)),
0); 0);
return spa_pod_builder_pop(b, &f); return spa_pod_builder_pop(b, &f[0]);
} }
static void pwr_on_event(void *data, uint64_t expirations) { static void pwr_on_event(void *data, uint64_t expirations) {
@ -196,10 +199,8 @@ void xdpw_pwr_stream_create(struct xdpw_screencast_instance *cast) {
logprint(DEBUG, "pipewire: registered event %p", cast->event); logprint(DEBUG, "pipewire: registered event %p", cast->event);
enum spa_video_format format = xdpw_format_pw_from_wl_shm(cast->simple_frame.format); enum spa_video_format format = xdpw_format_pw_from_wl_shm(cast->simple_frame.format);
enum spa_video_format format_without_alpha =
xdpw_format_pw_strip_alpha(format);
const struct spa_pod *param = build_format(&b, format, format_without_alpha, const struct spa_pod *param = build_format(&b, format,
cast->simple_frame.width, cast->simple_frame.height, cast->framerate); cast->simple_frame.width, cast->simple_frame.height, cast->framerate);
pw_stream_add_listener(cast->stream, &cast->stream_listener, pw_stream_add_listener(cast->stream, &cast->stream_listener,