【发布时间】:2017-03-03 19:10:28
【问题描述】:
根据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,我无法自省。这种情况下元素类型注解应该是什么?
非常感谢!
【问题讨论】:
标签: glib kurento gobject-introspection