天天看點

freeswitch系列三 SIP軟電話xlite、linphonec接入kamailio+freeswitch

1. 概述

在本系列的文章一、二中,我們介紹kamailo,freeswitch SIP服務端的搭建,本節我們介紹SIP用戶端和服務端進行通話。

本節我們介紹2個SIP用戶端:xlite和linphonec.

如果你在windows下開發,推薦使用xlite。xlite是圖形化界面,簡單易用。

如果你的SIP服務已經部署到生産環境(通常使用linux作業系統),這時我們通常隻能使用指令行模式,那麼xlite就無法使用。此時我推薦使用linphonec。

2. SIP軟電話接入

2.1. 伺服器資訊

因為kamailo和freeswitch本質都是SIP服務,是以xlite和linphonec接入兩者配置是相同的,這裡隻介紹如何接入kamailio。

這裡使用上節搭建的服務作為測試服務freeswitch系列二 kamailio 5.0安裝及實作kamailio內建freeswitch

kamalio資訊

IP: 10.240.80.153
PORT: 5060
           

兩個測試帳号: 1081和1082,密碼都是1234

2.2. xlite

使用xlite和SIP伺服器通信

從xlite官網下載下傳,安裝,并啟動。進行如下配置

菜單 –> softphone –> Account Settings

freeswitch系列三 SIP軟電話xlite、linphonec接入kamailio+freeswitch

然後你在另外機器上搭建xlite,配置另一個帳号并注冊到相同有伺服器。

最後就可以實作兩者的通信

3. linphonec

使用指令行linphonec模拟1081和1082通話

3.1. 安裝linphonec

sudo apt-get install linphone
           

3.2. 修改配置: vim ~/.linphonerc

  • 如果你的伺服器上沒有這個檔案,則執行linphonec指令,此指令會自動生成該檔案
[sip]
# 修改linphonec的啟動端口
sip_port=5560
media_encryption=none
guess_hostname=1
# 配置帳号資訊
contact=sip:[email protected]
inc_timeout=30
in_call_timeout=0
delayed_timeout=4
use_ipv6=0
register_only_when_network_is_up=1
register_only_when_upnp_is_ok=1


[proxy_0]
# 配置注冊服務,這裡配置kamailio服務
reg_proxy=sip:10.240.80.153:5060
# 配置帳号資訊
reg_identity=sip:[email protected]:5060
reg_expires=900
reg_sendregister=1
publish=0
           

根據以上的配置資訊在另一台服務上配置另一個帳号1082

執行指令

linphonec 
或
# 可以不使用預設配置檔案,也可以在啟動時,指定配置檔案
linphonec -c myconfig
           

3.3. 模拟通話

下面使用linphonec模拟1081和1082通話

向kamailio注冊1081和1082

## 1081注冊
$> linphonec
Warning: video is disabled in linphonec, use -V or -C or -D to enable.
linphonec> Registration on <sip::> successful.

## 1082注冊
$> linphonec 
Ready
Warning: video is disabled in linphonec, use -V or -C or -D to enable.
linphonec> Registration on <sip:> successful.
           

1081使用call指令呼叫1082, 1082使用answer進行應答

## 1081信令資訊
# 呼叫1082
linphonec> call sip:@
Establishing call id to <sip:@>, assigned id 
Contacting <sip:@>
linphonec> Call  to <sip:@> in progress.
linphonec> Remote ringing.
linphonec> Early media.
# 當1082使用answer應答後,會出現如下資訊,就可以進行通話
linphonec> Call  with <sip:@> early media.
Call  with <sip:@> connected.
Call answered by <sip:@>.
linphonec> Media streams established with <sip:@> for call  (audio).

## 1082信令資訊
# 當被呼叫時出現如下資訊
linphonec> Receiving new incoming call from "1081" <sip:@>, assigned id 
# 執行answer,進行應答,如果成功,則輸出如下資訊
answer
Connected.
linphonec> Call  with "1081" <sip:@> connected.
Media streams established with "1081" <sip:@> for call  (audio).
           

如果要結束通話,在1081和1082端任何一端執行terminate,都可以結束指令。

使用quit指令可以退出linphonec的指令模式

繼續閱讀