FreeSWITCH 呼叫两个座机并互联(ESL实现)

实现思路

先拨通第一个号码,再桥接到另一个号码

核心代码

    // 初始化一个handle,用于标识到FreeSWITCH的Socket连接
    esl_handle_t handle = {{ 0 }};

    // std::string ip = ...;
    // int port = ...;
    // std::string password = ...;

    // 连接服务器,如果成功 handle 就代表连接成功了
    esl_status_t status = esl_connect(&handle, ip, port, NULL, password);

    // 错误处理
    // ...

    // std::string gatewayName = ...
    // std::string tel1 = ...
    // std::string tel2 = ...

    // 这里为核心命令,即 originate number1 &bridge(number2)
    // tel1 和 tel2 即为要互联的两个电话号码
    std::ostringstream oss;
    oss << "api originate sofia/gateway/" << gatewayName << "/" << tel1 
        << " &bridge(sofia/gateway/" << gatewayName << "/" << tel2 << ")\n\n";
    esl_send_recv(&handle, oss.str().c_str());

    // 错误处理
    // ...

    // 断开连接
    esl_disconnect(&handle);
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值