我编写了类似的“示例”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);
}