[pjsip] Example "Simple PJSUA" without soundcard

Lafras Henning lafras at xietel.com
Sat Sep 29 02:35:43 EDT 2007

Hope, this helps

Previosly I wanted to use my thread that gets the samples from the PABX to
also push the voice data to pjsip so I used the splitcomb port, The quality
was poor as the thread was now missing some of the pabx packets due to
spending time at pjsip.
My revised scheme is pjsip using a 'active' port and a fifo between the two

The attached file is the port, It calls zxFifo_GetByte() and
zxFifo_PostByte() which your application needs to provide
  with a context such as struct zxSimpleFifoPair *Fifo;

You can use code similar to the following to create the ports

static void RegisterZxTDMPorts(void)
   pjmedia_port *ConfPort;
   pj_status_t status;

   PJ_LOG(1,(THIS_FILE, "adding zxTDMport's "));

   int i;
    /* Create a media port to interface with TDM samples. */
    status = create_zxTDM_port( app_config.pool,/* memory pool       */
          8000,         /* sampling rate     */
          1,               /* # of channels     */
          &ConfPort        /* returned port     */
    if (status != PJ_SUCCESS) {
 return ;

    /* .. and register it to conference bridge */
    unsigned p_port;
    status = pjsua_conf_add_port(app_config.pool, ConfPort, &p_port);
    pj_assert(status == PJ_SUCCESS);
    zxChannel[i].ConfPort = ConfPort;
    zxChannel[i].Created = 1;
    zxChannel[i].InUse = 0;
    PJ_LOG(1,(THIS_FILE, "      ConfPort=%i,ConfSlot=%i",ConfPort,p_port));
   PJ_LOG(1,(THIS_FILE, "done adding zxTDM sound ports"));

To connect to the port , I use a modified version of pjsua_app.c and at line
1607+- I mod the code as follows:
(The original code simply connected to the sound card )
 /* Otherwise connect to sound device */
 if (connect_sound) {
            int zxslot = zxpjsua_getzxslot(call_info.id); //zx here we must
determine the slot of a free or desired zx port
     pjsua_conf_connect(call_info.conf_slot, zxslot);
     pjsua_conf_connect(zxslot, call_info.conf_slot);
            PJ_LOG(1, (THIS_FILE, " connect slot %i to slot %i ",

     /* Automatically record conversation, if desired */


----- Original Message -----
From: "B. van Klinken" <b.vklinken at rohill.nl>
To: "'pjsip embedded/DSP SIP discussion'" <pjsip at lists.pjsip.org>
Sent: Friday, September 28, 2007 5:43 PM
Subject: Re: [pjsip] Example "Simple PJSUA" without soundcard

> Hello Benny,
> Last week if been trying to make the "Simple PJSUA" without the soundcard,
> but with a "Memory/Buffer-based Capture Port" and a "Memory/Buffer-based
> Playback Port", but it don't get it working, and also I don't really know
> about what I do is correct. E.g. do I also have to create a conference
> bridge in the "Simple PJSUA" or is it already created in the PJSUA
> Also I don's know about clearing and deleting what object at the end of
> program.
> Is it possible that you modify the "Simple PJSUA" and send this file to
> For you it is propably very easy and propably does not take much time.
> I would very much appreciate it. When i have such a working example, i'm
> pretty sure that i then can create the things we like to make.
> So if possible modify the PJSUA in such a way that the audio in received
> into a callback function where the audio bytes are e.g. only send to
> And for the other audio direction, to have a callback function where e.g.
> you have an array of nn bytes which are cylic send into the pjsip stack.
> I hope you can (and will) help me.
> Regards,
> B. van Klinken
> -----Original Message-----
> From: pjsip-bounces at lists.pjsip.org
> [mailto:pjsip-bounces at lists.pjsip.org]On Behalf Of Benny Prijono
> Sent: 07-09-21 16:37
> To: pjsip embedded/DSP SIP discussion
> Subject: Re: [pjsip] Example "Simple PJSUA" without soundcard
> B. van Klinken wrote:
> > Hello Benny,
> >
> > Thanks, i had seen the pages already, but somehow it's not clear for me
> how
> > to realize the requested functionality (my problem).
> >
> > I understood that i had to use a splitcomb.
> You don't have to, actually. You only need to use splitcomb when
> your application wants to *actively* get and put frames from/to pjmedia.
> Alternatively, you can let pjmedia get and put frames from/to your
> application instead. To do this, you'll just need to implement a
> pjmedia_port, and provide two callbacks (get_frame and put_frame) to
> be called by pjmedia. Then register your media port to the
> conference bridge by using pjsua_conf_add_port(). This in fact is
> the easiest way to manipulate audio frames.
> See playsine.c in samples directory for a simple pjmedia_port
> implementation.
> > I think that it must be for you only a couple of minutes and copy/paste
> > modify the "Simple PJSUA", where it works with external data (e.g. store
> > info a memory bufer and read from another memory buffer.
> For a splitcomb sample, see stereo_demo() in pjsua_app.c.
> For pjmedia_port's that operate on buffer, see mem_capture.c and
> mem_player.c in pjmedia. There are a whole bunch of other
> pjmedia_port implementations to look at in pjmedia, of course.
> cheers,
>   -benny
> _______________________________________________
> Visit our blog: http://blog.pjsip.org
> pjsip mailing list
> pjsip at lists.pjsip.org
> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
> _______________________________________________
> Visit our blog: http://blog.pjsip.org
> pjsip mailing list
> pjsip at lists.pjsip.org
> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: zxTDMport.c
Type: application/octet-stream
Size: 5398 bytes
Desc: not available
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20070929/a067c715/attachment.c>

More information about the pjsip mailing list