Linphone c++


初始化
LinphoneFactory *factory = linphone_factory_get();
LinphoneCoreCbs *cbs = linphone_factory_create_core_cbs(factory);
linphone_core_cbs_set_call_state_changed(cbs, call_state_changed);
linphone_core_cbs_set_registration_state_changed(cbs, registration_state_changed);
linphone_core_cbs_set_message_received(cbs, linphoneCoreCbsMessageReceivedCb);
linphone_core_cbs_set_user_data(cbs, &ui);
LinphoneConfig*config = linphone_config_new_with_factory("linphonerc", "linphonerc-factory");
lc = linphone_factory_create_core_with_config(factory, cbs, config);
linphone_core_cbs_ref(cbs);
linphone_core_reload_ms_plugins(lc, NULL);
linphone_core_set_user_agent(lc, "mylinphone", linphone_core_get_version());
const char** video_devices = linphone_core_get_video_devices(lc);
linphone_core_set_video_device(lc, video_devices[index]);
linphone_core_set_native_video_window_id(lc, (void *)ui.graphicsView->winId());
linphone_core_set_avpf_mode(lc, LinphoneAVPFDisabled);

注册
LinphoneProxyConfig* proxy_cfg;
LinphoneAddress *from;
proxy_cfg = linphone_core_create_proxy_config(lc);
from = linphone_address_new(identity);
LinphoneAuthInfo *authinfo = linphone_auth_info_new(user .c_str(), user .c_str(), psd.c_str(), NULL, NULL, host.c_str());
linphone_core_add_auth_info(lc, authinfo);
linphone_auth_info_unref(authinfo);

linphone_proxy_config_set_identity_address(proxy_cfg, from);
linphone_proxy_config_set_server_addr(proxy_cfg, identity);

linphone_proxy_config_edit(proxy_cfg);
linphone_proxy_config_enable_publish(proxy_cfg, TRUE);
linphone_proxy_config_enable_register(proxy_cfg, TRUE);
linphone_proxy_config_done(proxy_cfg);

linphone_address_unref(from);

linphone_core_add_proxy_config(lc, proxy_cfg);
linphone_core_set_default_proxy_config(lc, proxy_cfg);

linphone_proxy_config_unref(proxy_cfg);

呼叫
LinphoneCall *curentcall = linphone_core_get_current_call(lc);
LinphoneCallParams *callpa = linphone_core_create_call_params(lc, curentcall);
linphone_call_params_enable_video(callpa, FALSE);//视频呼叫TRUE
LinphoneCall *call = linphone_core_invite_with_params(lc, url, callpa);//url:sip:ip:port
linphone_call_ref(call);

呼叫状态
LinphoneCoreCbs* cbs = linphone_core_get_current_callbacks(lc);
    switch (LinphoneCallState) {
    case LinphoneCallIncomingReceived:
            ...
        break;
    case LinphoneCallOutgoingRinging:
        ...
        break;
    case LinphoneCallOutgoingEarlyMedia:
        ...
        break;
    case LinphoneCallConnected:
        ...
        break;
    case LinphoneCallStreamsRunning:
        ...
        break;
    case LinphoneCallEnd:
        ...
        break;
    case LinphoneCallError:
        ...
        break;
    default:
        ...
    }

接听
LinphoneCall *curentcall = linphone_core_get_current_call(lc);
const LinphoneCallParams * remotecpa = linphone_call_get_remote_params(curentcall);
if (linphone_call_params_video_enabled(remotecpa)) {
    LinphoneCallParams * callpa = linphone_core_create_call_params(lc, curentcall);
    linphone_call_params_enable_video(callpa, TRUE);
    linphone_core_accept_call_with_params(lc, curentcall, callpa);
}
else {
    linphone_call_accept(curentcall);
}

挂断
LinphoneCall *curentcall = linphone_core_get_current_call(lc);
if (NULL != curentcall) {
    linphone_call_terminate(curentcall);
}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 前言 Voip即网络电话,voice over internet Protocol,将模拟的声音讯号经过压缩与封包...
    天下林子阅读 11,319评论 5 29
  • 一、SIP业务基本知识 1、业务介绍 会话初始协议(Session Initiation Protocol)是一种...
    阿七笔记阅读 1,422评论 0 10
  • 一、集成的三方平台是容联云通讯 集成该平台的原因是公司领导去选择的,理由是开始是2000个账号以内是免费使用的。 ...
    骑着蜗牛溜北二环阅读 3,397评论 0 0
  • 父亲受伤,一天把所有事情安排到位,手术时间也确定。然后叔叔长辈们就开始各种希望更好些的选择等等,我知道叔叔们的好意...
    吴世平阅读 281评论 0 0
  • 每次爸爸问我觉得你最大的优点是什么呢,回答总是善解人意。我愿意站在任何人的角度上去看问题,这也是我常提醒自己的,感...
    云时之间阅读 255评论 1 2