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

本文介绍如何使用PJSIP实现自动语音功能,并详细解释了PJSUA强大的媒体特性,包括利用PJMEDIA会议桥接器高效连接多个媒体端口的方法,以及在不同媒体端口间自由操纵媒体流的技术细节。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用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. 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值