[v3,2/3] gstreamer: Remove auto-focus-mode property from libcamerasrc
diff mbox series

Message ID 20241017172331.16377-3-jaslo@ziska.de
State Accepted
Headers show
Series
  • gstreamer: Generate controls from control_ids_*.yaml files
Related show

Commit Message

Jaslo Ziska Oct. 17, 2024, 5:04 p.m. UTC
In preparation for generic support of all libcamera controls, remove the
manual handling of the auto-focus-mode property from the libcamerasrc
element.

Signed-off-by: Jaslo Ziska <jaslo@ziska.de>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/gstreamer/gstlibcamerasrc.cpp | 28 ----------------------------
 src/gstreamer/gstlibcamerasrc.h   | 31 -------------------------------
 2 files changed, 59 deletions(-)

Comments

Kieran Bingham Oct. 18, 2024, 2:14 p.m. UTC | #1
Quoting Jaslo Ziska (2024-10-17 18:04:14)
> In preparation for generic support of all libcamera controls, remove the
> manual handling of the auto-focus-mode property from the libcamerasrc
> element.
> 
> Signed-off-by: Jaslo Ziska <jaslo@ziska.de>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>


one out ...

Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

> ---
>  src/gstreamer/gstlibcamerasrc.cpp | 28 ----------------------------
>  src/gstreamer/gstlibcamerasrc.h   | 31 -------------------------------
>  2 files changed, 59 deletions(-)
> 
> diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
> index 912a8d55..40b787c8 100644
> --- a/src/gstreamer/gstlibcamerasrc.cpp
> +++ b/src/gstreamer/gstlibcamerasrc.cpp
> @@ -142,7 +142,6 @@ struct _GstLibcameraSrc {
>         GstTask *task;
>  
>         gchar *camera_name;
> -       controls::AfModeEnum auto_focus_mode = controls::AfModeManual;
>  
>         std::atomic<GstEvent *> pending_eos;
>  
> @@ -154,7 +153,6 @@ struct _GstLibcameraSrc {
>  enum {
>         PROP_0,
>         PROP_CAMERA_NAME,
> -       PROP_AUTO_FOCUS_MODE,
>  };
>  
>  static void gst_libcamera_src_child_proxy_init(gpointer g_iface,
> @@ -663,18 +661,6 @@ gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread,
>                 gst_pad_push_event(srcpad, gst_event_new_segment(&segment));
>         }
>  
> -       if (self->auto_focus_mode != controls::AfModeManual) {
> -               const ControlInfoMap &infoMap = state->cam_->controls();
> -               if (infoMap.find(&controls::AfMode) != infoMap.end()) {
> -                       state->initControls_.set(controls::AfMode, self->auto_focus_mode);
> -               } else {
> -                       GST_ELEMENT_ERROR(self, RESOURCE, SETTINGS,
> -                                         ("Failed to enable auto focus"),
> -                                         ("AfMode not supported by this camera, "
> -                                          "please retry with 'auto-focus-mode=AfModeManual'"));
> -               }
> -       }
> -
>         ret = state->cam_->start(&state->initControls_);
>         if (ret) {
>                 GST_ELEMENT_ERROR(self, RESOURCE, SETTINGS,
> @@ -742,9 +728,6 @@ gst_libcamera_src_set_property(GObject *object, guint prop_id,
>                 g_free(self->camera_name);
>                 self->camera_name = g_value_dup_string(value);
>                 break;
> -       case PROP_AUTO_FOCUS_MODE:
> -               self->auto_focus_mode = static_cast<controls::AfModeEnum>(g_value_get_enum(value));
> -               break;
>         default:
>                 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
>                 break;
> @@ -762,9 +745,6 @@ gst_libcamera_src_get_property(GObject *object, guint prop_id, GValue *value,
>         case PROP_CAMERA_NAME:
>                 g_value_set_string(value, self->camera_name);
>                 break;
> -       case PROP_AUTO_FOCUS_MODE:
> -               g_value_set_enum(value, static_cast<gint>(self->auto_focus_mode));
> -               break;
>         default:
>                 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
>                 break;
> @@ -967,14 +947,6 @@ gst_libcamera_src_class_init(GstLibcameraSrcClass *klass)
>                                                              | G_PARAM_STATIC_STRINGS));
>         g_object_class_install_property(object_class, PROP_CAMERA_NAME, spec);
>  
> -       spec = g_param_spec_enum("auto-focus-mode",
> -                                "Set auto-focus mode",
> -                                "Available options: AfModeManual, "
> -                                "AfModeAuto or AfModeContinuous.",
> -                                gst_libcamera_auto_focus_get_type(),
> -                                static_cast<gint>(controls::AfModeManual),
> -                                G_PARAM_WRITABLE);
> -       g_object_class_install_property(object_class, PROP_AUTO_FOCUS_MODE, spec);
>  }
>  
>  /* GstChildProxy implementation */
> diff --git a/src/gstreamer/gstlibcamerasrc.h b/src/gstreamer/gstlibcamerasrc.h
> index fd1f8193..a27db9ca 100644
> --- a/src/gstreamer/gstlibcamerasrc.h
> +++ b/src/gstreamer/gstlibcamerasrc.h
> @@ -8,8 +8,6 @@
>  
>  #pragma once
>  
> -#include <libcamera/control_ids.h>
> -
>  #include <gst/gst.h>
>  
>  G_BEGIN_DECLS
> @@ -19,32 +17,3 @@ G_DECLARE_FINAL_TYPE(GstLibcameraSrc, gst_libcamera_src,
>                      GST_LIBCAMERA, SRC, GstElement)
>  
>  G_END_DECLS
> -
> -inline GType
> -gst_libcamera_auto_focus_get_type()
> -{
> -       static GType type = 0;
> -       static const GEnumValue values[] = {
> -               {
> -                       static_cast<gint>(libcamera::controls::AfModeManual),
> -                       "AfModeManual",
> -                       "manual-focus",
> -               },
> -               {
> -                       static_cast<gint>(libcamera::controls::AfModeAuto),
> -                       "AfModeAuto",
> -                       "automatic-auto-focus",
> -               },
> -               {
> -                       static_cast<gint>(libcamera::controls::AfModeContinuous),
> -                       "AfModeContinuous",
> -                       "continuous-auto-focus",
> -               },
> -               { 0, NULL, NULL }
> -       };
> -
> -       if (!type)
> -               type = g_enum_register_static("GstLibcameraAutoFocus", values);
> -
> -       return type;
> -}
> -- 
> 2.46.2
>

Patch
diff mbox series

diff --git a/src/gstreamer/gstlibcamerasrc.cpp b/src/gstreamer/gstlibcamerasrc.cpp
index 912a8d55..40b787c8 100644
--- a/src/gstreamer/gstlibcamerasrc.cpp
+++ b/src/gstreamer/gstlibcamerasrc.cpp
@@ -142,7 +142,6 @@  struct _GstLibcameraSrc {
 	GstTask *task;
 
 	gchar *camera_name;
-	controls::AfModeEnum auto_focus_mode = controls::AfModeManual;
 
 	std::atomic<GstEvent *> pending_eos;
 
@@ -154,7 +153,6 @@  struct _GstLibcameraSrc {
 enum {
 	PROP_0,
 	PROP_CAMERA_NAME,
-	PROP_AUTO_FOCUS_MODE,
 };
 
 static void gst_libcamera_src_child_proxy_init(gpointer g_iface,
@@ -663,18 +661,6 @@  gst_libcamera_src_task_enter(GstTask *task, [[maybe_unused]] GThread *thread,
 		gst_pad_push_event(srcpad, gst_event_new_segment(&segment));
 	}
 
-	if (self->auto_focus_mode != controls::AfModeManual) {
-		const ControlInfoMap &infoMap = state->cam_->controls();
-		if (infoMap.find(&controls::AfMode) != infoMap.end()) {
-			state->initControls_.set(controls::AfMode, self->auto_focus_mode);
-		} else {
-			GST_ELEMENT_ERROR(self, RESOURCE, SETTINGS,
-					  ("Failed to enable auto focus"),
-					  ("AfMode not supported by this camera, "
-					   "please retry with 'auto-focus-mode=AfModeManual'"));
-		}
-	}
-
 	ret = state->cam_->start(&state->initControls_);
 	if (ret) {
 		GST_ELEMENT_ERROR(self, RESOURCE, SETTINGS,
@@ -742,9 +728,6 @@  gst_libcamera_src_set_property(GObject *object, guint prop_id,
 		g_free(self->camera_name);
 		self->camera_name = g_value_dup_string(value);
 		break;
-	case PROP_AUTO_FOCUS_MODE:
-		self->auto_focus_mode = static_cast<controls::AfModeEnum>(g_value_get_enum(value));
-		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
 		break;
@@ -762,9 +745,6 @@  gst_libcamera_src_get_property(GObject *object, guint prop_id, GValue *value,
 	case PROP_CAMERA_NAME:
 		g_value_set_string(value, self->camera_name);
 		break;
-	case PROP_AUTO_FOCUS_MODE:
-		g_value_set_enum(value, static_cast<gint>(self->auto_focus_mode));
-		break;
 	default:
 		G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
 		break;
@@ -967,14 +947,6 @@  gst_libcamera_src_class_init(GstLibcameraSrcClass *klass)
 							     | G_PARAM_STATIC_STRINGS));
 	g_object_class_install_property(object_class, PROP_CAMERA_NAME, spec);
 
-	spec = g_param_spec_enum("auto-focus-mode",
-				 "Set auto-focus mode",
-				 "Available options: AfModeManual, "
-				 "AfModeAuto or AfModeContinuous.",
-				 gst_libcamera_auto_focus_get_type(),
-				 static_cast<gint>(controls::AfModeManual),
-				 G_PARAM_WRITABLE);
-	g_object_class_install_property(object_class, PROP_AUTO_FOCUS_MODE, spec);
 }
 
 /* GstChildProxy implementation */
diff --git a/src/gstreamer/gstlibcamerasrc.h b/src/gstreamer/gstlibcamerasrc.h
index fd1f8193..a27db9ca 100644
--- a/src/gstreamer/gstlibcamerasrc.h
+++ b/src/gstreamer/gstlibcamerasrc.h
@@ -8,8 +8,6 @@ 
 
 #pragma once
 
-#include <libcamera/control_ids.h>
-
 #include <gst/gst.h>
 
 G_BEGIN_DECLS
@@ -19,32 +17,3 @@  G_DECLARE_FINAL_TYPE(GstLibcameraSrc, gst_libcamera_src,
 		     GST_LIBCAMERA, SRC, GstElement)
 
 G_END_DECLS
-
-inline GType
-gst_libcamera_auto_focus_get_type()
-{
-	static GType type = 0;
-	static const GEnumValue values[] = {
-		{
-			static_cast<gint>(libcamera::controls::AfModeManual),
-			"AfModeManual",
-			"manual-focus",
-		},
-		{
-			static_cast<gint>(libcamera::controls::AfModeAuto),
-			"AfModeAuto",
-			"automatic-auto-focus",
-		},
-		{
-			static_cast<gint>(libcamera::controls::AfModeContinuous),
-			"AfModeContinuous",
-			"continuous-auto-focus",
-		},
-		{ 0, NULL, NULL }
-	};
-
-	if (!type)
-		type = g_enum_register_static("GstLibcameraAutoFocus", values);
-
-	return type;
-}