Hi all I am currently able to set one property at a time to gstreamer plugin like as fallow.
GstElement *source = gst_bin_get_by_name (GST_BIN (m_pu_pipeline), "ue");
g_object_set(G_OBJECT(source), "objectLeftEnabled", settings.m_b_left, NULL);
g_object_set(G_OBJECT(source), "objectRemovedEnabled", settings.m_b_removed, NULL);
But I want to set whole structure at a time like as fallow.
g_object_set (G_OBJECT (source), "lettremoved-settings", settings, NULL);
Following is What I have done so far to set structure directly to gstreamer plugin.
struct _LeftRemoved
{
bool left;
bool removed;
};
//Declaration of copy and free function.
static gpointer lr_copy (gpointer data);
static void lr_free (gpointer data);
G_DEFINE_BOXED_TYPE (_Leftremoved, lettremoved_settings,
lr_copy,
lr_free);
//Defination of copy and free.
static gpointer lr_copy (gpointer data)
{
struct _LeftRemoved *details = (struct _LeftRemoved *)data;
struct _LeftRemoved *copy = g_new (struct _LeftRemoved, 1);
// We need to copy
copy->left= details->left;
copy->removed = details->removed;
g_print("Set Property From Copy left=%d\n",copy->left);
g_print("Set Property From Copy removed=%d\n",copy->removed);
return (gpointer) copy;
}
static void lr_free (gpointer data)
{
//code for free memory.
}
enum ePropertyType
{
PROP_OBJ_LR
}
static void gst_ivue_class_init (GstIVUEClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gobject_class->set_property = gst_ivue_set_property;
gobject_class->get_property = gst_ivue_get_property;
gobject_class->finalize = gst_ivue_finalize;
GParamSpec *pspec;
pspec = g_param_spec_boxed ("lettremoved_settings", "lettremoved_settings", "Left Removed Settings",lettremoved_settings_get_type(), (GParamFlags)G_PARAM_READWRITE);
g_object_class_install_property (gobject_class, PROP_OBJ_LR, pspec);
}
static void gst_ivue_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec)
{
GstIVUE *filter = GST_IVUE (object);
switch (prop_id)
{
case PROP_OBJ_LR:
g_boxed_copy(lettremoved_settings_get_type(),&value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void gst_ivue_get_property( GObject* object, guint prop_id, GValue* value, GParamSpec* pspec )
{
GstIVUE* filter = GST_IVUE (object);
switch (prop_id)
{
case PROP_OBJ_LR:
// Also I don't know how to get value
}
}
The above code run successfully but it is not setting value which is provided by me. For example If I called g_object_set() function as :
settings.left=true;
settings.removed=true;
g_object_set (G_OBJECT (source), "lettremoved-settings", settings, NULL);
Then in copy function, This code setting the default value as false for both left and removed. Please help me where I am going wrong.
g_object_set and g_object_get are varrag functions. That means you can set both in one call:
g_object_set(G_OBJECT(source),
"objectLeftEnabled", settings.m_b_left,
"objectRemovedEnabled", settings.m_b_removed,
NULL);
Also FYI. in instead of g_new and manually copying you can use g_memdup().
When you tried your boxed type, did you pass a pointer? It could be that you need to call
g_object_set (G_OBJECT (source), "lettremoved-settings", &settings, NULL);