On date Friday 2008-06-06 13:38:57 +0200, Timo Bruhn wrote: [...] > Hi Stefano, > > maybe this helps you: > > nua_invite(handle, NUTAG_MEDIA_ENABLE(0), TAG_END()); > > As far as i know this deactivates the SDP offer/answer engine for the call, > which would wait for user sdp and won't > send the invite if none is provided. You can activate the engine later in the > call with: > nua_set_hparams(handle, NUTAG_MEDIA_ENABLE(1), TAG_END());
Yes in this way it worked fine. > By the way: if you destroy the handle directly after calling nua_invite(), > sofia will end the call. Maybe this causes some > trouble, two. Perhaps it would be better to destroy the handle in the event > callback. Good point, I'll simply leave that for now (I still have to understand how to associate an arriving message of a dialog to an already sent one). BTW, which is the simpler way to print an incoming message in the event callback function? Here it is my new try: ------------------------------------8<------------------------------------- #include <stdlib.h> #include <stdio.h> #include <sofia-sip/nua.h> #include <sofia-sip/su_log.h> /* 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[]) { static unsigned int count = 1; printf ("arrived request number %d\n" "I have received an event %s status %d %s\n", count++, nua_event_name(event), status, phrase); nua_handle_destroy(handle); } /** * Creates a communication handle, sends an INVITE request and destroys it. */ int send_invite (nua_t *nua, const char* callee) { nua_handle_t *handle; /* create an handle */ handle = nua_handle(nua, NULL, SIPTAG_TO_STR(callee), TAG_END()); if (!handle) { fprintf(stderr, "Failed to instantiate an handle for the invite\n"); fprintf(stderr, "Maybe another instance of a sip client running on the same port?\n"); return -1; } fprintf(stderr, "Sending the invite to %s...\n", callee); nua_invite(handle, NUTAG_MEDIA_ENABLE(0), /* disable SDP media offer TAG_END()); nua_handle_destroy(handle); return 0; } int main (int argc, char *argv[]) { su_root_t *root; nua_t *nua; su_log_set_level(NULL, 9); if (argc <= 1) { fprintf(stderr, "Missing the destination target"); exit(1); } const char* callee = argv[1]; /* Initialize Sofia-SIP library and create event loop */ su_init (); root = su_root_create (NULL); nua = nua_create(root, /* Event loop */ event_callback, /* Callback for processing events */ NULL, /* Additional data to pass to callback */ NUTAG_URL("sip:localhost:5060"), TAG_END()); /* Last tag should always finish the sequence */ /* send an invite to a remote sip client */ send_invite (nua, callee); /* Run event loop */ su_root_run (root); /* Destroy allocated resources */ nua_destroy (nua); su_root_destroy (root); su_deinit (); return 0; } ------------------------------------8<------------------------------------- Since I enabled the sofia-sip logging facility, now I can see: make sip-inviter; and env TPORT_DEBUG=1 sip-inviter sip:xx.xx.x.204:5060 gcc -g -O0 -I/home/stefano/include/sofia-sip-1.12 -L/home/stefano/lib -lsofia-sip-ua -o sip-inviter sip-inviter.c su_port_create(0x804a008): epoll_create() => 0: OK su_socket_port_init(0x804a008, 0xb7f62f80) called su_pthread_port_init(0x804a008, 0xb7f62f80) called nua: nua_create: entering su_port_create(0x804a790): epoll_create() => 0: OK su_socket_port_init(0x804a790, 0xb7f62f80) called su_pthread_port_init(0x804a790, 0xb7f62f80) called nua: nua_stack_init: entering nua: nua_stack_set_params: entering soa_create("default", 0x804ac18, 0x804acb0) called soa_set_params(static::0x804b0a0, ...) called soa_set_params(static::0x804b0a0, ...) called nta_agent_create: initialized hash tables nta_agent_create: initialized transports nta_agent_create: initialized random identifiers nta_agent_create: initialized timer nta_agent_create: initialized resolver nta: master transport created nta: bound to (localhost:5060;transport=*) nta: agent_init_via: SIP/2.0/udp localhost (sip) nta: agent_init_via: SIP/2.0/tcp localhost (sip) nta: Via fields initialized nta: Contact header created nua_register: Adding contact URL 'localhost' to list. nua: nh_create_handle: entering Sending the invite to sip:10.88.3.204:5060... nua: nua_invite: entering nua(0x804d8b8): sent signal r_invite nua: nua_handle_destroy: entering nua(0x804d8b8): sent signal r_destroy nua: nua_stack_set_params: entering nta_leg_tcreate(0x804e050) nua(0x804d8b8): adding session usage nta: selecting scheme sip nta: INVITE (100259833): Invalid argument (22) with */[xx.xx.x.204]:5060 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Do you have any hint about this? What's the meaning of the 22 code? nta: timer set to 32000 ms nua(0x804d8b8): call state changed: init -> calling nua: nua_stack_set_params: entering nta: delayed sending CANCEL (100259833) nta_outgoing_tcancel: trying to cancel cancelled request nua(0x804d8b8): removing session usage nua(0x804d8b8): call state changed: calling -> terminated nta_leg_destroy(0x804e050) nta: timer shortened to 5000 ms nta: timer K fired, terminate CANCEL (100259833) outgoing_reclaim_all((nil), (nil), 0xb7ae7208) nta_outgoing_timer: 0/0 resent, 0/0 tout, 1/2 term, 1/2 free nta: timer set next to 26998 ms nta: timer D fired, terminate INVITE (100259833) outgoing_reclaim_all((nil), (nil), 0xb7ae7208) nta_outgoing_timer: 0/0 resent, 0/0 tout, 1/1 term, 1/1 free nta: timer not set Anyway thanks so far Timo for your precious help. Best regards. ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Sofia-sip-devel mailing list Sofia-sip-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sofia-sip-devel