无法使用gstreamer插件中的g_value_set_object()在gstreamer应用程序中获取对象

无法使用gstreamer插件中的g_value_set_object()在gstreamer应用程序中获取对象,gstreamer,Gstreamer,我有一个gstreamer测试应用程序。我的目的是在我的一个gstreamer插件中为我的应用程序定义一个结构。但我有错 测试应用程序代码段: notify_func(GObject *obj) { GObject *myobj; g_object_get(obj, "my-prop", &myobj,NULL); } 插件代码段: get_property() { case MY_PROP: g_value_set_object(value, obj1->m

我有一个gstreamer测试应用程序。我的目的是在我的一个gstreamer插件中为我的应用程序定义一个结构。但我有错

测试应用程序代码段:

notify_func(GObject *obj)
{
  GObject *myobj;
  g_object_get(obj, "my-prop", &myobj,NULL);  
}
插件代码段:

get_property()
{
  case MY_PROP:
  g_value_set_object(value, obj1->myStructure);
  break;
}
结构:

struct obj1 {
  MyStructure *myStructure;
  ...
};

但我从g_值_集_对象中得到了分割错误。确切地说,G_IS_OBJECT(obj)崩溃了。我的obj1实例的类型为GST\U类型\U元素。有人能告诉我发生了什么吗?

我编写了类似的“示例”Gstreamer插件和Gstreamer应用程序来测试插件。希望它能帮助你,也能回答你的问题:)

Gstreamer插件代码:-

头文件:

typedef struct _test
{
    gchar *filename;
    guint width;
    guint height;
}TEST;

struct _GstSample 
{
    GstElement element;
    GstPad *src;
    GstPad *sink;
#ifndef STRUCTURE   
    gchar *filename;
    guint width;
    guint height;
#else
    TEST *test;
#endif  
    gboolean test_arg;
};
C文件

gst_sample_class_init(GstSampleClass *klass)
{
  ....
  g_object_class_install_property(gobject_class, PROP_TEST,
    g_param_spec_pointer("test", "test", "Structure Testing", G_PARAM_READWRITE));
}

gst_sample_set_property()
{
  ...
  case PROP_TEST:
   sample->test = (TEST *) g_value_get_pointer(value);
   g_print("Struct filename:%s \t width:%u \t height:%u \n", 
        sample->test->filename,
        sample->test->width, 
        sample->test->height);
}

gst_sample_get_property()
{
  ...
  case PROP_TEST:
   g_value_set_pointer(value, sample->test);
   break;
}
Gstreamer应用程序代码:-

typedef struct _test
{
    gchar *filename;
    guint width;
    guint height;
}TEST;

main()
{
  ...
  TEST test, *test1;

  test.filename = "Structure";
  test.width = 14;
  test.height = 50;
  g_object_set(G_OBJECT(sample), "test", &test, NULL);  
  ...
  g_object_get(G_OBJECT(sample), "test", &test1, NULL);
  g_print("Struct Addr:%p \t filename:%s \t width:%u \t height:%u \n",
           &test1, test1->filename, test1->width, test1->height); 
}

首先,您提供的代码比任何人实际需要帮助的代码都要少得多。但我还是要尝试一下:问题似乎是
g_value\u set_object
中的参数
value
不是
GObject
(或
GstElement
或其他扩展结构之一)。确保已使用
gst\u element\u factory\u Make()
或类似工具正确初始化它。还请显示MY\u PROP属性(对于_class\u init)的定义。