linphone win32 SDK在桌面運用(Qt5、C#等)使用教程

環境:

本文用qt5、 LIBLINPHONE-SDK-4.1.1-WIN32.ZIP (下載地址http://www.linphone.org/technical-corner/liblinphone

自己去編譯個也行  下載地址 https://gitlab.linphone.org/BC/public/linphone-sdk

git clone https://gitlab.linphone.org/BC/public/linphone-sdk.git --recursive

創建一個vs qt 項目在項目種導入頭文件和lib   dll考到exe 運行目錄下

你要覺得麻煩或難解決錯誤可到https://item.taobao.com/item.htm?id=592349919838獲取源碼。源碼功能性更好、更完善。羣q羣:261074724)

在sdk文件夾share下有文檔  文檔很重要  

另外的參考https://www.linphone.org/snapshots/docs/liblinphone/multilang/index.html 寫

1.初始化的時候:

    //linphone
    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_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());

上面的兩個文件可以到源碼種去找

2.

LinphoneProxyConfig* proxy_cfg;
    LinphoneAddress *from;
    const char* identity = "sip:1010@ip";/* takes   sip uri  identity from the command line arguments */
    const char* password = "h12345"; 
    //
    
    //remove all 

    proxy_cfg = linphone_core_create_proxy_config(lc);
    from = linphone_address_new(identity);

    LinphoneAuthInfo *authinfo = linphone_auth_info_new("1010", "1010", password, NULL, NULL, "ip");
    linphone_core_add_auth_info(lc, authinfo);
    linphone_auth_info_unref(authinfo);    //sifang

    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);    //sifang

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

    linphone_proxy_config_unref(proxy_cfg);    //sifang

3.創建一個線程一直while運行 註冊成功後回有信息返回

    linphone_core_iterate(lc); 
    ms_usleep(50000);//

4.呼叫

num = "sip:" +num+"@ip"; 
    const char* url = str.c_str();
    LinphoneCall *curentcall = linphone_core_get_current_call(lc);
    if (NULL == curentcall) {
        LinphoneCall *call=linphone_core_invite(lc, url);
        linphone_call_ref(call);
 }

5。接聽

 LinphoneCall *curentcall = linphone_core_get_current_call(lc);
if (NULL != curentcall) { 

    linphone_call_accept(curentcall);

}

c# 使用參考https://blog.csdn.net/Java_lilin/article/details/106311843

交流羣:261074724 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章