FreeSWITCH rtp endpoint recvonly

查了下rtp.c的源码,远端端口为0就意味着recvonly,但其实不然,调用switch_rtp_new会马上返回失败

经过反复测试,增加下面几行代码之后终于变成了recvonly:

tech_pvt->mode = RTP_RECVONLY;

rtp_flags[SWITCH_RTP_FLAG_AUTOADJ]++;

switch_channel_set_variable(channel, "rtp_auto_adjust_threshold", "1");

有什么用?

用处大了,可以做录音呀监听呀什么的,接收别人的rtp流,下面是一个lua例子:

function debug(s)

freeswitch.consoleLog("ERR", s or "")

end

local api = freeswitch.API()

local uuid = api:executeString("create_uuid")

debug("uuid = " .. uuid .. "\n")

local local_addr = api:executeString("global_getvar local_ip_v4")

local local_port = 2000

local remote_addr = local_addr -- 必须给远端地址和远端端口赋值,尽管实际不发送rtp流

local remote_port = 3000 --

local ptime = 20

local codec = "PCMA"

local pt = 8

local rate = 8000

local cmd = "bgapi originate "

cmd = cmd .. "[origination_uuid=" .. uuid .. "]"

cmd = cmd .. string.format("[local_addr=%s,local_port=%d,remote_addr=%s,remote_port=%d,ptime=%d,codec=%s,pt=%d,rate=%d]", local_addr, local_port, remote_addr, remote_port, ptime, codec, pt, rate)

cmd = cmd .. "rtp"

cmd = cmd .. " &lua(asr.lua)"

debug(cmd)

local reply = api:executeString(cmd)

debug("reply = " .. reply)

stream:write(reply)

呼叫成功后就执行lua asr.lua,至于asr.lua要怎么写,得您自己脑补了

相关推荐
Mike_Zhang4 天前
一种FreeSWITCH流量镜像WebSocket音频推流方案
voip·freeswitch
c_zyer18 天前
FreeSWITCH与Java交互实战:从EslEvent解析到Spring Boot生态整合的全指南
spring boot·netty·freeswitch·eslevent
c_zyer1 个月前
从零构建实时通信引擎:Freeswitch源码编译与深度优化指南
运维·freeswitch·sip
todoitbo1 个月前
docker搭建freeswitch实现点对点视频,多人视频
docker·容器·音视频·freeswitch·视频聊天
贾宝玉的玉宝贾3 个月前
FreeSWITCH 简单图形化界面43 - 使用百度的unimrcp搞个智能话务台,用的在线的ASR和TTS
百度·voip·freeswitch·ippbx
谢平康5 个月前
使用firewall-cmd配置SIP端口转发,实现双网卡互通,内外网方式
freeswitch·sip·双网卡互通
贾宝玉的玉宝贾5 个月前
FreeSWITCH 简单图形化界面40 - 使用mod_curl模块进行http请求
python·http·voip·freeswitch·sip
狂爱代码的码农6 个月前
FreeSwitch之mod_cidlookup 和 mod_blacklist和mod_curl的抉择
freeswitch