Dear all,

 

    I had a very simple voip application using sofia_sip and gstreamer.
However, when I execute the code, the caller can not receive the sound
from the callee (the configuration on the machine is correct, for
example, if I run sofsip_cli, it works). 

 

     I studied the code of sofsip_cli and added the initialization of gstreamer 
in my code.

 #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

    However, I still do not get the sound. 

    What else should be done in the code to make the 'audio' work? The complete 
code is attached below.

Thx for your kind help!

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

   
/* 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 main()
{
  sipinit();
  makecall("star03", URL_STRING_MAKE("sip:136.215.216.64"));
  runsipmainloop();
  sipcleanup();
  return 0;
} 


 


_________________________________________________________________
Your PC, mobile phone, and online services work together like never before.
http://clk.atdmt.com/MRT/go/108587394/direct/01/
-------------------------------------------------------------------------
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