0

As per this, I think it is not possible to create GArray using python bindings. To overcome this, I am writing a small library that will return a GArray. This library utilizes gobject introspection and exposes a method 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;
}

When I run g-ir-scanner, I get the following error:

webrtc_interface.c:149: Warning: Webrtc: webrtc_interface_create_codec_array: 
Unknown type: 'GstStructure'

This function is returning a GArray of GstStructure elements, which I am not able to introspect. What should be the element-type annotation in this case?

Many thanks!

Community
  • 1
  • 1
Chetan Naik
  • 133
  • 1
  • 9

1 Answers1

0

GstStructure is an introspectable type — it’s defined in Gst-1.0.gir. Are you passing --include Gst-1.0 to g-ir-scanner when you run it to build your GIR?

If you’re using the GIR autotools integration (highly recommended if you’re using autotools), you can do this by adding Gst-1.0 to the *_INCLUDES variable for your GIR module.

Philip Withnall
  • 5,293
  • 14
  • 28