Capture Call Audio to Buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 10:37 AM 9/15/2009, Archie Rosenblum wrote:
>Content-Type: multipart/alternative;
>         boundary="----=_NextPart_000_0088_01CA35F8.E071DB00"
>Content-Language: en-us
>
>Would someone mind pointing me in the right direction for capturing 
>audio to a buffer?  I have multiple inbound calls and I would like 
>to check for in-band DTMF (no rfc2833). What is the API order for 
>setting up PJSIP to get the audio data?  I just need some framework 
>help -- I have reviewed the sample files on the web site but I'm 
>having trouble grasping which APIs to use. I do know how to do play 
>audio files, it's the capturing to a buffer that has me confused.  I 
>mostly use the PJSUA APIs.
>
>Global
>---------
>pjsua_pool_create
>[Shared pool used for all calls]
>
>Call comes in (for each call do below)
>-------------
>pjmedia_mem_capture_create
>[What size buffer should I use? Does it matter?]

For FFT analysis I used a buffer size of 2000 bytes.  The idea being 
the bigger the buffer size the more accurate the result.  The smaller 
the buffer the more real time
the data result.

>[How do I get the call information such clockrate, etc, so I can set 
>this API to use the same values as the call?  Does it matter? Or 
>should I use the values in the sample programs?]

Yes I think it matters.  I use the pjsua_conf_get_port_info() 
function to get this data then pass it along.  It looks something like this:
pjsua_conf_get_port_info(sip_data[line].conf_slot, &info);
sip_data[line].cpa_clock_rate=info.clock_rate;
pjmedia_mem_capture_create(sip_data[line].cpa_pool, 
sip_data[line].cpa_int_data, CPA_FFT_SIZE,
                         info.clock_rate, info.channel_count, 
info.samples_per_frame, info.bits_per_sample, 0, &sip_data[line].cpa_port);



>
>pjmedia_mem_capture_set_eof_cb
>
>[How do I connect the call to this media port for so the media port 
>is "listening" and the callback works]

// line_number is supplied by the application to sort out multiple 
line implmentation.
pjmedia_mem_capture_set_eof_cb(sip_data[line].cpa_port, 
&sip_data[line].line_number, cpa_fft_got_data);

// add the memory capture port to the bridge
pjsua_conf_add_port(sip_data[line].cpa_pool, sip_data[line].cpa_port, 
&sip_data[line].cpa_conf_port);

// then connect the conf_slot for the call and the cpa_conf_slot.
pjsua_conf_connect(sip_data[line].conf_slot, sip_data[line].cpa_conf_port);

The callback function will look like this:
pj_status_t cpa_fft_got_data(pjmedia_port *port, void *usr_data)
{

    usr_data will contain the line_number passed int.
    Then I think you call pjmedia_port_get_frame(port, frame);
    and frame->buf I think has your audio data.

    Yea I didn't realize until I typed out this message, my code was 
missing that piece.  So
     helping you helped me.
}

>
>
>Call ends
>----------
>pjmedia_port_destroy
>
>
>Thank you in advance,
>Archie
>
>_______________________________________________
>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 --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20090917/a1dea01f/attachment.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux