You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

iOS使用Linphone4.4.0实现会议通话时通话时长不增加问题求助

问题根因

调用linphone_core_enter_conference()完成通话合并后,Linphone内核的活跃会话主体从单个LinphoneCall实例切换为LinphoneConference实例。原有逻辑中仅通过linphone_core_get_current_call()获取普通P2P通话的时长,此时该接口返回的是已暂停状态的单路通话,或者无返回值,因此读取到的时长始终为0。

修复方案

1. 调整会议创建逻辑(可选优化)

原有先进入会议再发起呼叫的逻辑可能导致新呼叫未正确加入会议,建议调整执行顺序:

LinphoneAddress* linphoneAddress = linphone_core_interpret_url([LinphoneManager getLc], [username cStringUsingEncoding:[NSString defaultCStringEncoding]]);
if (linphoneAddress == NULL) {
    return;
}
// 先发起呼叫
LinphoneCall *call = linphone_core_invite_address(LC, linphoneAddress);
if (call != NULL) {
    // 呼叫发起成功后将通话加入会议
    linphone_core_enter_conference(LC);
}

2. 适配会议场景的时长获取逻辑

修改getCallDuration方法,优先判断是否存在活跃会议,存在时读取会议总时长:

-(NSString *)getCallDuration
{
    LinphoneCore *lc = [LinphoneManager getLc];
    int duration = 0;
    // 优先读取会议时长
    LinphoneConference *conference = linphone_core_get_conference(lc);
    if (conference != NULL) {
        duration = linphone_conference_get_duration(conference);
    } else {
        // 无活跃会议时读取普通单路通话时长
        LinphoneCall *currentCall = linphone_core_get_current_call(lc);
        duration = currentCall ? linphone_call_get_duration(currentCall) : 0;
    }
    return [LinphoneUtils durationToString:duration];
}

兼容低版本SDK说明

如果使用的Linphone SDK版本低于4.4,无linphone_conference_get_duration接口,可遍历会议内所有通话,取最长的单路通话时长作为会议总时长即可。
建议监听LinphoneConferenceStateChanged回调触发时长更新,避免会议刚创建时读取到异常值。

内容的提问来源于stack exchange,提问作者shraddha k vaishanani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.05 05:45:03