I am writing a simple make call method using sofia-sip. However, when I test 
the code, he caller can not receive the sound from the
callee.  I am sure the sound configuration on the computer is OK. Must be 
something wrong in the code. I suspect it is something wrong with the tags :

 nua_invite(op,                SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"), 
               NUTAG_URL(to_url),                NUTAG_EARLY_MEDIA(1),          
      TAG_END ());

 Anyone can kindly give me any hints on this? (the complete code is attached 
below).

Thanks and best regards,



/********************************************************************************/
/* include all the header files ....*/

#include <sofia-sip/su_wait.h>
#include <sofia-sip/sip.h>
#include <sofia-sip/sip_header.h>
#include <sofia-sip/tport.h>
#include <sofia-sip/nua.h>

#define SOFSIP_USE_GLIB_EVENT_LOOP 1

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[]);


typedef struct cli_s {
     su_home_t     cli_home[1];    /*  memory home */
     su_root_t    *cli_root;       /*  Pointer to application root object */
     nua_t        *cli_nua;        /*  Pointer to nua stack object */
} cli_t ;

static cli_t cli[1] = {{{{sizeof(cli)}}}};
     
int sipinit(void)
{

    /* step: initialize glib and gstreamer */
     #if HAVE_GLIB
           g_type_init(); 
     #if HAVE_GST
     {
          guint major, minor, micro, nano;
          gst_init (NULL, NULL);
          gst_version (&major, &minor, &micro, &nano);
          g_message ("This program is linked against GStreamer %d.%d.%d\n", 
major, minor, micro);
      }
     #endif
     #endif
   
    su_home_init(cli->cli_home);
    su_init();
    cli->cli_root =su_root_create(cli);
  
     if (cli->cli_root != NULL)
      {
  
        cli->cli_nua = nua_create(cli->cli_root,
                   event_callback, 
                   cli,
           NUTAG_URL("sip:0.0.0.0:5060"), 
                   TAG_END());
      }

    return 0;
}



/* send a text msg */
int send_message(char const *name, url_string_t const *url)
 {
     nua_handle_t *op;
     sip_to_t *to;
 
     op = su_zalloc(cli->cli_home, (sizeof (nua_handle_t *)));
     if (op==NULL) 
     { printf("can not create operation context information\n");
       return 0;
     }
   
      /*Destination address */
     to = sip_to_create(NULL,url);
     if (!to) return 0;

     to->a_display=name;
     
     op = nua_handle(cli->cli_nua, NULL, SIPTAG_TO(to), TAG_END());
      printf (" create operation handle: OK\n");


    if (op==NULL)
       { printf ("can not access operation handle\n");
        return 0;
       }

    nua_message(op, SIPTAG_CONTENT_TYPE_STR("text/plain"),
                 SIPTAG_PAYLOAD_STR("hello exingfa. --exingfa from 
linux"),TAG_END());

     printf (" send msg: OK\n");
  
     return (int) op;
}

/* set up a call */
int makecall(char const *name, url_string_t const *url)
 {
     nua_handle_t *op;
     sip_to_t *to;
 
     op = su_zalloc(cli->cli_home, (sizeof (nua_handle_t *)));
     if (op==NULL) 
     { printf("can not create operation context information\n");
       return 0;
     }
   
      /*Destination address */
     to = sip_to_create(NULL,url);
     if (!to) return 0;

     to->a_display=name;
     
     op = nua_handle(cli->cli_nua, NULL, SIPTAG_TO(to), TAG_END());
      printf (" create operation handle: OK\n");


    if (op==NULL)
       { printf ("can not access operation handle\n");
        return 0;
       }


    nua_invite(op, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"),
               NUTAG_URL(url),
               NUTAG_EARLY_MEDIA(1),
               TAG_END ());

     printf ("make call: OK\n");
  
     return (int) op;
}


int runsipmainloop(void)
{

       if (cli->cli_nua !=NULL)
     {
           printf("entering main loop for processing of messages\n");
       su_root_run(cli->cli_root);
           printf ("entered main loop");
        }
       return 0;
}

int sipcleanup(void)
{
     nua_destroy(cli->cli_nua);
     su_root_destroy(cli->cli_root);
     cli->cli_root=NULL;
     su_home_deinit(cli->cli_home);
     su_deinit();
     return 0;
}


/* 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[])
{   switch (event){
  case nua_i_invite:
       printf("invitation has been sent"); 
      break;

  case nua_i_active:
     printf("receive invitation");  
    break;

  case nua_r_invite:
     printf("responseinvitation");  
     break;

  default:
    printf("unkown event");

  }
}

int tst()
{
  sipinit();
  // send_message("star03", URL_STRING_MAKE("sip:136.225.226.64"));
     makecall("star03", URL_STRING_MAKE("sip:136.225.226.64"));
  runsipmainloop();
  sipcleanup();
  return 0;
} 


_________________________________________________________________
Use video conversation to talk face-to-face with Windows Live Messenger.
http://www.windowslive.com/messenger/connect_your_way.html?ocid=TXT_TAGLM_WL_Refresh_messenger_video_072008
-------------------------------------------------------------------------
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

Reply via email to