【问题标题】:gobject introspection element-type GstStructuregobject 自省元素类型 GstStructure
【发布时间】: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


    【解决方案1】:

    GstStructure 是一个可自省的类型——它在Gst-1.0.gir 中定义。当您运行它来构建 GIR 时,您是否将 --include Gst-1.0 传递给 g-ir-scanner

    如果您使用GIR autotools integration(如果您使用自动工具,强烈推荐),您可以通过将Gst-1.0 添加到您的 GIR 模块的*_INCLUDES 变量来做到这一点。

    【讨论】:

      猜你喜欢
      • 2020-08-21
      • 1970-01-01
      • 1970-01-01
      • 2016-01-21
      • 2010-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-07
      相关资源
      最近更新 更多