我編寫了類似類型的"採樣"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);
}
沒有留言:
張貼留言