camerabin: Fix source updates with user filters
authorRobert Mader <robert.mader@collabora.com>
Sun, 22 Oct 2023 09:06:27 +0000 (11:06 +0200)
committerTim-Philipp Müller <tim@centricular.com>
Thu, 16 Nov 2023 18:39:26 +0000 (18:39 +0000)
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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5682>

subprojects/gst-plugins-bad/gst/camerabin2/gstcamerabin2.c

index 3824a4b..6a67194 100644 (file)
@@ -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,