From 17193163d847def941eec6eca844ae28a088d795 Mon Sep 17 00:00:00 2001 From: Sergey Lapin Date: Mon, 29 Mar 2021 16:23:32 +0300 Subject: [PATCH] Implemented some properties --- pinesrcbin.c | 34 +++++++++++++++++++++++++++++++++- pinesrcbin.h | 1 + 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/pinesrcbin.c b/pinesrcbin.c index b906e36..e14fbbb 100644 --- a/pinesrcbin.c +++ b/pinesrcbin.c @@ -38,6 +38,8 @@ enum PROP_NUM_BUFFERS, PROP_TEST_PATTERN, PROP_HUE, + PROP_DEVICE, + PROP_MODE }; @@ -158,6 +160,7 @@ gst_pinesrcbin_dispose (GObject * object) { GstPineSrcBin *self = GST_PINESRCBIN (object); + GST_DEBUG_OBJECT (self, "gst_pinesrcbin_dispose: dispose"); gst_pinesrcbin_clear_kid (self); if (self->filter_caps) @@ -197,6 +200,16 @@ gst_pinesrcbin_set_property (GObject * object, guint prop_id, g_print("setting prop hue: %d\n", self->hue); set_camera_control("rear", CONTROL_HUE, self->hue); break; + case PROP_MODE: + self->mode = g_value_get_int (value); + g_print("setting prop mode: %d\n", self->hue); + break; + case PROP_DEVICE: + { + const char * devname = g_value_get_int (value); + g_print("setting prop device: %s\n", devname); + } + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -226,6 +239,14 @@ gst_pinesrcbin_get_property (GObject * object, guint prop_id, g_print("getting prop hue: %d\n", self->hue); g_value_set_int (value, self->hue); break; + case PROP_MODE: + g_print("getting prop mode: %d\n", self->mode); + g_value_set_int (value, self->mode); + break; + case PROP_DEVICE: + g_print("getting prop device: %s\n", ""); + g_value_set_string (value, ""); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -322,6 +343,7 @@ gst_pinesrcbin_change_state (GstElement * element, GstStateChange transition) GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; GstPineSrcBin *sink = GST_PINESRCBIN (element); + GST_DEBUG_OBJECT (sink, "gst_pinesrcbin_change_state: state change"); switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: if (!gst_pinesrcbin_detect (sink)) @@ -379,6 +401,14 @@ gst_pinesrcbin_class_init (GstPineSrcBinClass * klass) g_param_spec_int ("hue", "Hue", "Set image hue", 0, 65535, 128, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, PROP_DEVICE, + g_param_spec_string ("device", "Device", + "Device", "", + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, PROP_MODE, + g_param_spec_int ("mode", "Mode", + "Set image hue", 1, 2, 1, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); } GST_DEBUG_CATEGORY (pinesrcbin_debug); @@ -391,6 +421,7 @@ gst_pinesrcbin_init (GstPineSrcBin * self) self->num_buffers = -1; self->test_pattern = 0; self->hue = 128; + self->mode = 1; g_print("initial hue: %d\n", self->hue); GST_DEBUG_OBJECT (self, "Starting device configuration"); gst_pinesrcbin_configure_device(self, "rear"); @@ -401,8 +432,9 @@ plugin_init (GstPlugin * plugin) { GST_DEBUG_CATEGORY_INIT (pinesrcbin_debug, "pinesrcbin", 0, "pinephone v4lsrc camera wrapper"); - return gst_element_register (plugin, "pinesrcbin", + gst_element_register (plugin, "pinesrcbin", GST_RANK_NONE, GST_TYPE_PINESRCBIN); + return TRUE; } GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, diff --git a/pinesrcbin.h b/pinesrcbin.h index 88f8407..d21a01e 100644 --- a/pinesrcbin.h +++ b/pinesrcbin.h @@ -33,6 +33,7 @@ typedef struct _GstPineSrcBin int num_buffers; int test_pattern; int hue; + int mode; } GstPineSrcBin; #endif