2016-04-03 6 views
0

Laut this, ich denke, es ist nicht möglich, GArray mit Python-Bindungen zu erstellen. Um dies zu überwinden, schreibe ich eine kleine Bibliothek, die ein GArray zurückgibt. Diese Bibliothek verwendet Gobject-Introspektion und stellt eine Methode create_codec_array zur Verfügung.gobject introspection element-type GstStructure

/** 
* 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; 
} 

Wenn ich laufen g-ir-Scanner, erhalte ich folgende Fehlermeldung:

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

dieser Funktion wird ein garray von GstStructure Elemente zurückgibt, die ich nicht in der Lage bin zu introspect. Was sollte in diesem Fall die Elementtyp-Anmerkung sein?

Vielen Dank!

Antwort

0

GstStructure ist ein introspectable type - es ist in Gst-1.0.gir definiert. Übergeben Sie --include Gst-1.0 an g-ir-scanner, wenn Sie es ausführen, um Ihr GIR zu bauen?

Wenn Sie die GIR autotools integration verwenden (sehr zu empfehlen, wenn Sie Autotools verwenden), können Sie dies tun, indem Gst-1.0 auf die *_INCLUDES Variable für Ihr GIR-Modul hinzufügen.

Verwandte Themen