Hi everyone, I'm new in sofia sip so don't be hard on me if my questions are boring ;-)
I have to write a RTSP client/server like program using sip messages. First of all I would like to write a server which accept connexion of the clients and do a task switch the content of the message (which can be XML like cc//pp or just <play/>). I think I succeed in writing it but the client doesn't stop properly. I got this message : nua_destroy(0x804b4b8): FATAL: nua_shutdown not completed client: nua.c:235: nua_destroy: Assertion `nua->nua_shutdown' failed. Aborted Here is my code (client) : #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sofia-sip/nua.h> /*******************************/ /* Variables declaration */ /*******************************/ static su_root_t *root = NULL; /*******************************/ /* Functions declaration */ /*******************************/ static void event_callback(nua_event_t event, int status, char const *phrase, nua_t *nua, nua_magic_t *magic, nua_handle_t *nh, nua_hmagic_t *hmagic, sip_t const *sip, tagi_t tags[]); static void sendClientInformations(void); /*******************************/ /* Main function */ /*******************************/ int main(int argc, char **argv){ sendClientInformations(); return EXIT_SUCCESS; } /*******************************/ /* Implementation of functions */ /*******************************/ static void sendClientInformations(void) { nua_t *nua; nua_handle_t *handle; /* Initialize Sofia-SIP library and create event loop */ su_init (); root = su_root_create (NULL); /* Create a user agent instance. Caller and callee should bind to different * address to avoid conflicts. The stack will call the 'event_callback()' * callback when events such as succesful registration to network, * an incoming call, etc, occur. */ nua = nua_create(root, /* Event loop */ event_callback, /* Callback for processing events */ NULL, /* Additional data to pass to callback */ NUTAG_URL("sip:0.0.0.0:2345;transport=tcp"), /* Address to bind to */ TAG_END()); /* Last tag should always finish the sequence */ /* Send the informations */ handle = nua_handle(nua, NULL, SIPTAG_TO_STR("sip:[EMAIL PROTECTED]:1234"), TAG_END()); nua_message(handle, SIPTAG_CONTENT_TYPE_STR("application/XML"), SIPTAG_PAYLOAD_STR("PLAY"), TAG_END()); nua_handle_destroy (handle); /* Run event loop */ su_root_run (root); /* Destroy allocated resources */ nua_destroy (nua); su_root_destroy (root); su_deinit (); } /* This callback will be called by SIP stack to * process incoming events */ void event_callback(nua_event_t event, int status, char const *phrase, nua_t *nua, nua_magic_t *magic, nua_handle_t *nh, nua_hmagic_t *hmagic, sip_t const *sip, tagi_t tags[]) { printf("%s received MESSAGE: %03d %s\n", __FILE__, status, phrase); printf("From: %s%s" URL_PRINT_FORMAT "\n", sip->sip_from->a_display ? sip->sip_from->a_display : "", sip->sip_from->a_display ? " " : "", URL_PRINT_ARGS(sip->sip_from->a_url)); if (sip->sip_subject) { printf("Subject: %s\n", sip->sip_subject->g_value); } if (sip->sip_content_type) { printf("Content-type: %s\n", sip->sip_content_type->c_type); } if (sip->sip_payload) { fwrite(sip->sip_payload->pl_data, sip->sip_payload->pl_len, 1, stdout); fputs("\n", stdout); } if(sip->sip_payload && strcmp(sip->sip_payload->pl_data, "OK") == 0) { su_root_break(root); } } server : #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sofia-sip/nua.h> #include <sofia-sip/sip_status.h> #include "server_gstreamer.h" #include "constants.h" /*******************************/ /* Variables declaration */ /*******************************/ static su_root_t *root = NULL; static nua_t *nua = NULL; /*******************************/ /* Functions declaration */ /*******************************/ static void event_callback(nua_event_t event, int status, char const *phrase, nua_t *nua, nua_magic_t *magic, nua_handle_t *nh, nua_hmagic_t *hmagic, sip_t const *sip, tagi_t tags[]); static void confirmAction(void); /*******************************/ /* Main function */ /*******************************/ int main(int argc, char **argv){ /* Initialize Sofia-SIP library and create event loop */ su_init (); root = su_root_create (NULL); /* Create a user agent instance. Caller and callee should bind to different * address to avoid conflicts. The stack will call the 'event_callback()' * callback when events such as succesful registration to network, * an incoming call, etc, occur. */ nua = nua_create(root, /* Event loop */ event_callback, /* Callback for processing events */ NULL, /* Additional data to pass to callback */ NUTAG_URL("sip:0.0.0.0:1234;transport=tcp"), TAG_END()); /* Last tag should always finish the sequence */ /* Run event loop */ su_root_run (root); /* Destroy allocated resources */ nua_destroy (nua); su_root_destroy (root); su_deinit (); return EXIT_SUCCESS; } /*******************************/ /* Implementation of functions */ /*******************************/ /* This callback will be called by SIP stack to * process incoming events */ void event_callback(nua_event_t event, int status, char const *phrase, nua_t *nua, nua_magic_t *magic, nua_handle_t *nh, nua_hmagic_t *hmagic, sip_t const *sip, tagi_t tags[]) { char buff[BUFFER_SIZE]; printf("%s received MESSAGE: %03d %s\n", __FILE__, status, phrase); printf("From: %s%s" URL_PRINT_FORMAT "\n", sip->sip_from->a_display ? sip->sip_from->a_display : "", sip->sip_from->a_display ? " " : "", URL_PRINT_ARGS(sip->sip_from->a_url)); if(sip->sip_subject) { printf("Subject: %s\n", sip->sip_subject->g_value); } if(sip->sip_content_type) { printf("Content-type: %s\n", sip->sip_content_type->c_type); } if(sip->sip_payload && strcmp(sip->sip_payload->pl_data, "PLAY") == 0) { printf("PLAY\n"); confirmAction(); /*fwrite(sip->sip_payload->pl_data, sip->sip_payload->pl_len, 1, stdout); fputs("\n", stdout); */ } } void confirmAction(void) { nua_handle_t *handle; /* Send the informations */ handle = nua_handle(nua, NULL, SIPTAG_TO_STR("sip:[EMAIL PROTECTED]:2345"), TAG_END()); nua_message(handle, SIPTAG_CONTENT_TYPE_STR("application/XML"), SIPTAG_PAYLOAD_STR("OK"), TAG_END()); printf("SENT\n"); nua_handle_destroy (handle); } If my code doesn't permit doing what I want, what is the better mean to do it ? sample code ? Thanks in advance. Rémi ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Sofia-sip-devel mailing list Sofia-sip-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel