gst: fix JPEG format

Since commit f400ff2050 ("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.
This commit is contained in:
Michael Tretter 2024-06-11 15:09:28 +02:00 committed by Wim Taymans
parent 3b68b5088b
commit a9bf5fa24a
2 changed files with 9 additions and 8 deletions

View file

@ -204,6 +204,7 @@ set_config (GstBufferPool * pool, GstStructure * config)
{ {
GstPipeWirePool *p = GST_PIPEWIRE_POOL (pool); GstPipeWirePool *p = GST_PIPEWIRE_POOL (pool);
GstCaps *caps; GstCaps *caps;
GstStructure *structure;
guint size, min_buffers, max_buffers; guint size, min_buffers, max_buffers;
gboolean has_video; gboolean has_video;
@ -217,9 +218,9 @@ set_config (GstBufferPool * pool, GstStructure * config)
return FALSE; return FALSE;
} }
if (g_str_has_prefix (gst_structure_get_name ( structure = gst_caps_get_structure (caps, 0);
gst_caps_get_structure (caps, 0)), if (g_str_has_prefix (gst_structure_get_name (structure), "video/") ||
"video/")) { g_str_has_prefix (gst_structure_get_name (structure), "image/")) {
has_video = TRUE; has_video = TRUE;
gst_video_info_from_caps (&p->video_info, caps); gst_video_info_from_caps (&p->video_info, caps);
} else { } else {

View file

@ -1019,6 +1019,7 @@ static void
handle_format_change (GstPipeWireSrc *pwsrc, handle_format_change (GstPipeWireSrc *pwsrc,
const struct spa_pod *param) const struct spa_pod *param)
{ {
GstStructure *structure;
g_autoptr (GstCaps) pw_peer_caps = NULL; g_autoptr (GstCaps) pw_peer_caps = NULL;
g_clear_pointer (&pwsrc->caps, gst_caps_unref); 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)) { if (pwsrc->caps && gst_caps_is_fixed (pwsrc->caps)) {
pwsrc->negotiated = TRUE; pwsrc->negotiated = TRUE;
if (g_str_has_prefix (gst_structure_get_name ( structure = gst_caps_get_structure (pwsrc->caps, 0);
gst_caps_get_structure (pwsrc->caps, 0)), if (g_str_has_prefix (gst_structure_get_name (structure), "video/") ||
"video/")) { g_str_has_prefix (gst_structure_get_name (structure), "image/")) {
pwsrc->is_video = TRUE; pwsrc->is_video = TRUE;
#ifdef HAVE_GSTREAMER_DMA_DRM #ifdef HAVE_GSTREAMER_DMA_DRM
@ -1062,8 +1063,7 @@ handle_format_change (GstPipeWireSrc *pwsrc,
} else { } else {
gst_video_info_dma_drm_init (&pwsrc->drm_info); gst_video_info_dma_drm_init (&pwsrc->drm_info);
#endif #endif
gst_video_info_from_caps (&pwsrc->video_info, gst_video_info_from_caps (&pwsrc->video_info, pwsrc->caps);
pwsrc->caps);
#ifdef HAVE_GSTREAMER_DMA_DRM #ifdef HAVE_GSTREAMER_DMA_DRM
} }
#endif #endif