根据this,我认为使用python绑定创建GArray是不可能的。为了克服这个问题,我正在编写一个小型库,它将返回一个GArray。这个库利用了gobject内省并公开了一个方法create_codec_array。
/**
* webrtc_interface_create_codec_array:
* @interface: a #WebrtcInterface
*
* creates codecs_array.
*
* Returns: (element-type GstStructure) (transfer full): a #GArray of #GstStructure
*/
GArray *
webrtc_interface_create_codec_array (WebrtcInterface * interface)
{
WebrtcInterfacePrivate *priv ;
g_return_if_fail (interface != NULL);
priv = WEBRTC_INTERFACE_GET_PRIVATE (interface);
gchar * codecs[] = {priv->codec, NULL};
GArray *a = g_array_new (FALSE, TRUE, sizeof (GValue));
int i;
for (i=0; i < g_strv_length (codecs); i++) {
GValue v = G_VALUE_INIT;
GstStructure *s;
g_value_init (&v, GST_TYPE_STRUCTURE);
s = gst_structure_new (codecs[i], NULL, NULL);
gst_value_set_structure (&v, s);
gst_structure_free (s);
g_array_append_val (a, v);
}
return a;
}当我运行g-ir-scanner时,我得到以下错误:
webrtc_interface.c:149: Warning: Webrtc: webrtc_interface_create_codec_array:
Unknown type: 'GstStructure'这个函数返回一个GstStructure元素的GArray,我不能自省。在这种情况下,元素类型注释应该是什么?
非常感谢!
发布于 2017-03-03 19:10:28
GstStructure是一种内省类型--它是在Gst-1.0.gir中定义的。当你运行--include Gst-1.0来构建你的GIR时,你会把它传递给g-ir-scanner吗?
如果您正在使用GIR autotools integration (如果您正在使用autotools,则强烈建议您),可以通过将Gst-1.0添加到您的GIR模块的*_INCLUDES变量来完成此操作。
https://stackoverflow.com/questions/36388642
复制相似问题