From e3f68180033ce8ab9c2b60f4849ef143ab2d7875 Mon Sep 17 00:00:00 2001 From: Robert Mader Date: Sun, 22 Oct 2023 11:06:27 +0200 Subject: [PATCH] camerabin: Fix source updates with user filters Take the case into account when user filters have been set before the source gets updated. Note that the further linking of the filters, if present, happens below in the `gst_camera_bin_check_and_replace_filter()` calls. The audio filter is still affected by the same issue but left out for now. Part-of: --- .../gst-plugins-bad/gst/camerabin2/gstcamerabin2.c | 58 ++++++++++++++++------ 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst/camerabin2/gstcamerabin2.c b/subprojects/gst-plugins-bad/gst/camerabin2/gstcamerabin2.c index 3824a4b..6a67194 100644 --- a/subprojects/gst-plugins-bad/gst/camerabin2/gstcamerabin2.c +++ b/subprojects/gst-plugins-bad/gst/camerabin2/gstcamerabin2.c @@ -1751,24 +1751,52 @@ gst_camera_bin_create_elements (GstCameraBin2 * camera) "notify::ready-for-capture", G_CALLBACK (gst_camera_bin_src_notify_readyforcapture), camera); - if (!gst_element_link_pads (camera->src, "vfsrc", - camera->viewfinderbin_queue, "sink")) { - GST_ERROR_OBJECT (camera, - "Failed to link camera source's vfsrc pad to viewfinder queue"); - goto fail; + if (camera->viewfinder_filter) { + if (!gst_element_link_pads (camera->src, "vfsrc", + camera->viewfinder_filter, NULL)) { + GST_ERROR_OBJECT (camera, + "Failed to link camera source's vfsrc pad to viewfinder filter"); + goto fail; + } + } else { + if (!gst_element_link_pads (camera->src, "vfsrc", + camera->viewfinderbin_queue, "sink")) { + GST_ERROR_OBJECT (camera, + "Failed to link camera source's vfsrc pad to viewfinder queue"); + goto fail; + } } - if (!gst_element_link_pads (camera->src, "imgsrc", - camera->imagebin_capsfilter, "sink")) { - GST_ERROR_OBJECT (camera, - "Failed to link camera source's imgsrc pad to image bin capsfilter"); - goto fail; + if (camera->image_filter) { + if (!gst_element_link_pads (camera->src, "imgsrc", + camera->image_filter, NULL)) { + GST_ERROR_OBJECT (camera, + "Failed to link camera source's imgsrc pad to image filter"); + goto fail; + } + } else { + if (!gst_element_link_pads (camera->src, "imgsrc", + camera->imagebin_capsfilter, "sink")) { + GST_ERROR_OBJECT (camera, + "Failed to link camera source's imgsrc pad to image bin capsfilter"); + goto fail; + } } - if (!gst_element_link_pads (camera->src, "vidsrc", - camera->videobin_capsfilter, "sink")) { - GST_ERROR_OBJECT (camera, - "Failed to link camera source's vidsrc pad to video bin capsfilter"); - goto fail; + + if (camera->video_filter) { + if (!gst_element_link_pads (camera->src, "vidsrc", + camera->video_filter, NULL)) { + GST_ERROR_OBJECT (camera, + "Failed to link camera source's vidsrc pad to video filter"); + goto fail; + } + } else { + if (!gst_element_link_pads (camera->src, "vidsrc", + camera->videobin_capsfilter, "sink")) { + GST_ERROR_OBJECT (camera, + "Failed to link camera source's vidsrc pad to video bin capsfilter"); + goto fail; + } } gst_pad_add_probe (imgsrc, GST_PAD_PROBE_TYPE_BUFFER, -- 2.7.4