您的位置:首页 > Web前端 > JavaScript

PJSIP自动语音功能,WAV文件远程播放,可以与TTS整合

2014-01-07 16:06 726 查看
使用PJSIP进行自动语音功能,卡了好久,最终发现其实还是比较简单的。
PJSIP就是比较强大,很多都实现好了,都不需要去很深地了解协议。
说实在的话,我就不了解SIP协议的细节。

PJSUA has rather powerful media features, which are built around the PJMEDIA conference bridge. Basically, all media "ports" (such as calls, WAV players, WAV playlist, file recorders, sound device, tone generators, etc) are terminated in the conference
bridge, and application can manipulate the interconnection between these terminations freely.

The conference bridge provides powerful switching and mixing functionality for application. With the conference bridge, each conference slot (e.g. a call) can transmit to multiple destinations, and one destination can receive from multiple sources.
If more than one media terminations are terminated in the same slot, the conference bridge will mix the signal automatically.

Application connects one media termination/slot to another by calling pjsua_conf_connect() function. This will establish unidirectional media flow from the source termination to the sink termination. To establish bidirectional media flow, application
wound need to make another call to pjsua_conf_connect(), this time inverting the source and destination slots in the parameter.

For example, to stream a WAV file to remote call, application may use the following steps:

  pj_status_t stream_to_call( pjsua_call_id call_id )
  {
     pjsua_player_id player_id;
     
     status = pjsua_player_create("mysong.wav", 0, NULL, &player_id);
     if (status != PJ_SUCCESS)
        return status;

     status = pjsua_conf_connect( pjsua_player_get_conf_port(),
                                  pjsua_call_get_conf_port() );
  }

Other features of PJSUA media:

efficient N to M interconnections between media terminations. 
media termination can be connected to itself to create loopback media. 
the media termination may have different clock rates, and resampling will be done automatically by conference bridge. 
media terminations may also have different frame time; the conference bridge will perform the necessary bufferring to adjust the difference between terminations. 
interconnections are removed automatically when media termination is removed from the bridge. 
sound device may be changed even when there are active media interconnections. 
correctly report call's media quality (in pjsua_call_dump()) from RTCP packet exchange. 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  source code
相关文章推荐