Привет всем. В настоящее время я могу установить одно свойство за раз для плагина gstreamer, например, парного.
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);
Но я хочу установить всю структуру за раз, как под паром.
g_object_set (G_OBJECT (source), "lettremoved-settings", settings, NULL);
Ниже приведено то, что я сделал до сих пор, чтобы установить структуру непосредственно в плагин gstreamer.
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
}
}
Вышеприведенный код работает успешно, но это не заданное мной значение. Например, если я вызвал функцию g_object_set() как:
settings.left=true;
settings.removed=true;
g_object_set (G_OBJECT (source), "lettremoved-settings", settings, NULL);
Затем в функции копирования этот код устанавливает значение по умолчанию как false как для оставленного, так и для удаленного. Пожалуйста, помогите мне, где я ошибаюсь.