From a9bf5fa24a1ce75ff3e23b0bd153c3cfe334bc31 Mon Sep 17 00:00:00 2001 From: Michael Tretter Date: Tue, 11 Jun 2024 15:09:28 +0200 Subject: [PATCH] gst: fix JPEG format Since commit f400ff20504d ("gst: Check for video/ caps before parsing for info") JPEG support in the GStreamer elements is broken as JPEG is not recognized as a video format anymore. gst_video_info_from_caps is able to handle "video/" and "image/" formats. Therefore, the check needs to allow "image/" too. While at it, cleanup the formatting to make the check more readable. --- src/gst/gstpipewirepool.c | 7 ++++--- src/gst/gstpipewiresrc.c | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/gst/gstpipewirepool.c b/src/gst/gstpipewirepool.c index 10013080b..dc74f60d4 100644 --- a/src/gst/gstpipewirepool.c +++ b/src/gst/gstpipewirepool.c @@ -204,6 +204,7 @@ set_config (GstBufferPool * pool, GstStructure * config) { GstPipeWirePool *p = GST_PIPEWIRE_POOL (pool); GstCaps *caps; + GstStructure *structure; guint size, min_buffers, max_buffers; gboolean has_video; @@ -217,9 +218,9 @@ set_config (GstBufferPool * pool, GstStructure * config) return FALSE; } - if (g_str_has_prefix (gst_structure_get_name ( - gst_caps_get_structure (caps, 0)), - "video/")) { + structure = gst_caps_get_structure (caps, 0); + if (g_str_has_prefix (gst_structure_get_name (structure), "video/") || + g_str_has_prefix (gst_structure_get_name (structure), "image/")) { has_video = TRUE; gst_video_info_from_caps (&p->video_info, caps); } else { diff --git a/src/gst/gstpipewiresrc.c b/src/gst/gstpipewiresrc.c index 5297bf060..270567302 100644 --- a/src/gst/gstpipewiresrc.c +++ b/src/gst/gstpipewiresrc.c @@ -1019,6 +1019,7 @@ static void handle_format_change (GstPipeWireSrc *pwsrc, const struct spa_pod *param) { + GstStructure *structure; g_autoptr (GstCaps) pw_peer_caps = NULL; g_clear_pointer (&pwsrc->caps, gst_caps_unref); @@ -1040,9 +1041,9 @@ handle_format_change (GstPipeWireSrc *pwsrc, if (pwsrc->caps && gst_caps_is_fixed (pwsrc->caps)) { pwsrc->negotiated = TRUE; - if (g_str_has_prefix (gst_structure_get_name ( - gst_caps_get_structure (pwsrc->caps, 0)), - "video/")) { + structure = gst_caps_get_structure (pwsrc->caps, 0); + if (g_str_has_prefix (gst_structure_get_name (structure), "video/") || + g_str_has_prefix (gst_structure_get_name (structure), "image/")) { pwsrc->is_video = TRUE; #ifdef HAVE_GSTREAMER_DMA_DRM @@ -1062,8 +1063,7 @@ handle_format_change (GstPipeWireSrc *pwsrc, } else { gst_video_info_dma_drm_init (&pwsrc->drm_info); #endif - gst_video_info_from_caps (&pwsrc->video_info, - pwsrc->caps); + gst_video_info_from_caps (&pwsrc->video_info, pwsrc->caps); #ifdef HAVE_GSTREAMER_DMA_DRM } #endif