Contenu | Rechercher | Menus

Annonce

Si vous avez des soucis pour rester connecté, déconnectez-vous puis reconnectez-vous depuis ce lien en cochant la case
Me connecter automatiquement lors de mes prochaines visites.

À propos de l'équipe du forum.

#1 Le 09/09/2008, à 09:11

darkweaver87

Python + SWIG + GMainLoop

Bonjour tout le monde,

J'ai un soucis avec Python.
A l'occasion un stage je devais developper un module en C avec sofia-sip. Afin de lier la pile SIP à l'application développée en Python j'ai associé la pile SIP à la boucle d'événements de la glib.

Mon problème c'est que ça ne fonctionne pas via le binding fait avec swig.

Ma fonction C:

void initClientSIPStack(GMainLoop *ptr)
{
  printDebug("\n");
  /* initialize Sofia-SIP library and create connection to the main event loop */  
  su_init();

  appl->main = ptr;

  GSource *gsource;
  su_timer_t *timer;
  
  /* create a sofia event loop using su-glib function su_glib_root_source_create() */
  appl->root = su_glib_root_create(appl); 
  
  /* attach the created GSource to glib event loop */
  gsource = su_glib_root_gsource(appl->root);
  assert(gsource);
  g_source_attach(gsource, g_main_loop_get_context(ptr));
  
  /* use the sofia event loop with libsofia-sip-ua modules */
  timer = su_timer_create(su_root_task(appl->root), 200L);

  /* disable threading */
  su_root_threading(appl->root, 0);

  if (appl->root != NULL) 
    {
      /* create a user agent instance. Caller and callee should bind to different
       * address to avoid conflicts. The stack will call the 'eventCallBack()' 
       * callback when events such as succesful registration to network, 
       * an incoming call, etc, occur. 
       */
      appl->nua = nua_create(appl->root, /* Event loop */
			     eventCallBack, /* Callback for processing events */
			     appl, /* Additional data to pass to callback */
			     NUTAG_URL("sip:0.0.0.0:3456;transport=tcp"), /* Address to bind to */
			     TAG_END()); /* Last tag should always finish the sequence */
    }
}

Mon appel Python:

import gobject
import client
     
if __name__ == '__main__':
    loop = gobject.MainLoop()
    client.initClientSIPStack(loop)
    loop.run()

et la sortie :

Traceback (most recent call last):
  File "testclient.py", line 6, in <module>
    client.initClientSIPStack(loop)
TypeError: in method 'initClientSIPStack', argument 1 of type 'GMainLoop *'

Une idée de comment je pourrais faire ?


Gentoo noyau 2.6.34-r6

Hors ligne