[pjsip] Resampling module add

Benny Prijono bennylp at pjsip.org
Wed Nov 21 10:12:58 EST 2007


Gianluca Crucillà wrote:
> 
> Hi all,
> 
> I'm working on an application with PJMEDIA under uClinux on Nios2 
> environment.
> 
> I have a stream audio with codec L16 48000 stereo and mono.This works good.
> 
> Now I must added Resampling and I saw that for make this I have 2 way:
> 1-  Resample module add
> 2-  Conference module add
> 
> I read some documents and the two example (confsample.c and 
> resampleplay.c) but I don't have clear this.
> I tried all two ways but they didn't work
> 
> In attach there is my source code.
> 
> 
> In normal mode (without resampling) I make this:
> 
>     status = pjmedia_session_create( g_med_endpt, &sess_info,
>                      &g_med_transport, NULL, &g_med_session );
>     if (status != PJ_SUCCESS) {
>     app_perror( THIS_FILE, "Unable to create media session", status);
>     return;
>     }
> 
>     pjmedia_session_get_port(g_med_session, 0, &media_port);
>     
>     status = pjmedia_snd_port_create(
>                      inv->pool,              // pool        
>                      -1,
>                      -1,
>                      media_port->info.clock_rate,        // clock 
> rate      
>                      media_port->info.channel_count,     // channel 
> count   
>                      media_port->info.samples_per_frame, // samples per 
> frame
>                      media_port->info.bits_per_sample,   // bits per 
> sample 
>                      0,                                  // options     
>                      &g_snd_player);
> 
>     if (status != PJ_SUCCESS) printf("\n=====> 
> pjmedia_snd_port_create()....... [ KO ]\n");
> 
>      
>     status = pjmedia_snd_port_connect(g_snd_player, media_port);
>     if (status != PJ_SUCCESS) printf("\n=====> 
> pjmedia_snd_port_connect()...... [ KO ]\n");
> 
> Now I tried to make this
> 
>     status = pjmedia_session_create( g_med_endpt, &sess_info,
>                      &g_med_transport, NULL, &g_med_session );
>     if (status != PJ_SUCCESS) {
>     app_perror( THIS_FILE, "Unable to create media session", status);
>     return;
>     }
> 
>     pjmedia_session_get_port(g_med_session, 0, &media_port);
>  
>     status = pjmedia_conf_create( inv->pool,                          // 
> pool
>                                   3,                                  // 
> max port count
>                                   media_port->info.clock_rate,        // 
> clock rate
>                                   media_port->info.channel_count,     // 
> channel count   
>                                   media_port-> info.samples_per_frame, 
> // samples per frame
>                                   media_port->info.bits_per_sample,   // 
> bits per sample
>                                   0,                                  // 
> option
>                                   &conf 
>                                   );
>     if (status != PJ_SUCCESS) {
>       printf("\n=====> UNABLE TO CREATE CONFERENCE BRIDGE !!!\n");
>       return 1;
>     }
> 
>     status = pjmedia_conf_add_port(conf,inv->pool,media_port,NULL,NULL);
>     if (status != PJ_SUCCESS) {
>       printf("\n=====> UNABLE TO ADD CONFERENCE PORT !!!\n");
>       return 1;
>     }      
>   
> but this don't work..
> 
> I tried with pjmedia_resample_port_create but this don't work..
> 
> 
> WHAT I MAKE WRONG?

Please do not shout on this list. ;-)

What seems to be missing is the part to connect the media session's 
slot to the sound device slot, in the conference bridge. When a slot 
is not connected to other slots, no media will be flowing to/from 
that slot.

So in pjmedia_conf_add_port() above, you should fill up the last 
argument to get the slot number of the media session. Something like:

    unsigned slot;
    pjmedia_conf_add_port(conf,inv->pool,media_port,NULL,&slot);

Then establish bidirectional media flow from/to the media session 
to/from the sound device:

    pjmedia_conf_connect_port(conf, 0, slot, 0);
    pjmedia_conf_connect_port(conf, slot, 0, 0);

Note that I didn't check the syntax validity of your code (nor did I 
check your complete source program ;-)). I assume you've taken care 
of it from reading the documentation.

cheers,
  -benny


> Can somebody help me?
> 
> Thanks Gianluca
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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


-- 
Benny Prijono
http://www.pjsip.org





More information about the pjsip mailing list