freeswitch audio recording module and kernel

freeswitch supports audio recording and video recording functions. The audio recording function is mainly realized through mod_sndfile, mod_shout and other modules, and the video recording module is realized through mod_mp4v2 and mod_av modules.

        mod_sndfile record wav

        mod_shout record mp3

        mod_mp4v2 records MP4 files

        mod_av is a new module provided in version 1.6.x

       Put mod_av into the 1.5.x version, and use this module to realize functions such as playing video files and connecting cameras. The video recording function is implemented by the mod_mp4v2 module, and the concurrency can reach dozens of vga channels at the same time. The audio and video are relatively synchronized under high concurrency, and the CPU consumption is not high. The bottleneck is mainly reflected in the bandwidth.

The core of Freeswitch  recording

 1. Register the callback function

Application calls switch_ivr_record_session->

switch_core_media_bug_add registers the mediabug interface callback function record_callback with the fs kernel to monitor streaming media (read and write mode)

2. The kernel calls switch_core_session_read_frame to get the incoming voice

1. Call the read_frame function of the endpoint to obtain the voice of the endpoint.

2. Call the callback function record_callback of the media bug to notify the application to obtain the voice data.

3. If the application program sets the channel variable RECORD_USE_THREAD to true, the kernel enables thread recording, the kernel will buffer the recording data to thread_buffer, and then read the buffered write file through the thread. Otherwise, write the file directly. (If the recording loses data, you can use thread recording)

4. Kernel writes files

内核为每个录音缓冲池pre_buffer,将需要写入文件的数据写入到此缓冲内,当缓冲数据大小大于 SWITCH_DEFAULT_FILE_BUFFER_LEN = 65536时,内核从缓冲池中获取数据写文件。应用程序可以通过设置通道变量enable_file_write_buffering来设置 SWITCH_DEFAULT_FILE_BUFFER_LEN的大小。

三、内核调用switch_core_session_write_frame写入语音

1、调用endpoint的write_frame函数给endpoint发送语音

2、调用media bug的回调函数record_callback通知应用程序获取语音数据

3、同步骤二(3)。


freeswitch 接通后再录音:

需求:录音时不要将前置媒体录制进去.

用法:

<action application="set" data="media_bug_answer_req=true"/>


freeSwitch录音

http://blog.csdn.net/whyhonest/article/details/7660421

http://blog.163.com/lorraine_gu/blog/static/24348001020167385347309?ignoreua

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324613922&siteId=291194637