Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
64a8b950
Commit
64a8b950
authored
Mar 05, 2010
by
Alexandre Savard
Browse files
[#2536] Added an event loop in sflphone python client
parent
d0fe2fe3
Changes
4
Hide whitespace changes
Inline
Side-by-side
sippxml/accountcalluac.xml
View file @
64a8b950
...
...
@@ -22,14 +22,14 @@
<send
retrans=
"500"
>
<![CDATA[
REGISTER sip:
192.168.50.79
SIP/2.0
REGISTER sip:
[remote_ip]
SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch]
Max-Forward: 70
From: <sip:27182@[
local_ip]:[local
_port]>
;tag=[call_number]
To:
<sip:27182
@
192.168.50.79:[local
_port]
>
Call-ID: [call_id]
From: <sip:27182@[
remote_ip]:[remote
_port]>
;tag=[call_number]
To:
<sip:27182
@
[remote_ip]:[remote
_port]
>
Call-ID:
REG///
[call_id]
CSeq: 1 REGISTER
Contact:
<sip:27182
@[
local_ip]:[local
_port]
>
Contact:
<sip:27182
@[
remote_ip]:[remote
_port]
>
Content-Length: 0
Expires: 300
...
...
@@ -42,14 +42,14 @@
<send
retrans=
"500"
>
<![CDATA[
REGISTER sip:
192.168.50.79
SIP/2.0
REGISTER sip:
[remote_ip]
SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch]
Max-Forwards: 70
From: <sip:27182@[
local_ip]:[local
_port]>
;tag=[call_number]
To:
<sip:27182
@
192.168.50.79:[local
_port]
>
Call-ID: [call_id]
CSeq:
1
REGISTER
Contact:
<sip:27182
@[
local_ip]:[local
_port]
>
From: <sip:27182@[
remote_ip]:[remote
_port]>
;tag=[call_number]
To:
<sip:27182
@
[remote_ip]:[remote
_port]
>
Call-ID:
REG///
[call_id]
CSeq:
2
REGISTER
Contact:
<sip:27182
@[
remote_ip]:[remote
_port]
>
Content-Length: 0
Expires: 300
[authentication username=27182 password=1234]
...
...
@@ -60,16 +60,17 @@
<recv
response=
"200"
>
</recv>
<pause
milliseconds=
"200"
/>
<send
retrans=
"500"
>
<![CDATA[
INVITE sip:
31416@192.168.50.79
SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:27182@[
local_ip]:[local
_port]>
;tag=[call_number]
To:
<sip:
31416
@192.168.50.79
:[remote_port]
>
INVITE sip:
2000@[remote_ip]
SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];
rport;
branch=[branch]
From: <sip:27182@[
remote_ip]:[remote
_port]>
;tag=[call_number]
To:
<sip:
2000
@[remote_ip]
:[remote_port]
>
Call-ID: [call_id]
CSeq:
1
INVITE
CSeq:
3
INVITE
Contact: sip:27182@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Functional Test
...
...
@@ -87,36 +88,73 @@
]]>
</send>
<recv
response=
"
100"
optional
=
"true"
>
<recv
response=
"
401"
auth
=
"true"
>
</recv>
<recv
response=
"180"
optional=
"true"
>
</recv>
<pause
milliseconds=
"200"
/>
<send>
<![CDATA[
ACK sip:27182@[remote_ip] SIP/2.0
Max-Forwards: 70
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:27182@[remote_ip]:[remote_port]>
;tag=[call_number]
To:
<sip:2000
@[remote_ip]:[remote_port]
>
Call-ID: [call_id]
CSeq: 4 ACK
Subject: Functional Test
Content-Length: 0
]]>
</send>
<send
retrans=
"500"
>
<![CDATA[
INVITE sip:2000@[remote_ip] SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];rport;branch=[branch]
From: <sip:27182@:[remote_ip]:[remote_port]>
;tag=[call_number]
To:
<sip:2000
@[remote_ip]:[remote_port]
>
Call-ID: [call_id]
CSeq: 5 INVITE
Contact: sip:27182@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Functional Test
Content-Type: application/sdp
Content-Length: [len]
[authentication username=27182 password=1234]
v=0
o=user1 53655765 2353687637 IN IP[local_ip_type] [local_ip]
s=-
c=IN IP[media_ip_type] [media_ip]
t=0 0
m=audio [media_port] RTP/AVP 0
a=rtpmap:0 PCMU/8000
]]>
</send>
<!-- Do something different on an optional receive -->
<recv
response=
"403"
optional=
"true"
next=
"1"
>
<recv
response=
"100"
>
</recv>
<recv
response=
"180"
>
</recv>
<recv
response=
"200"
>
<action>
<ereg
regexp=
"ua25"
search_in=
"hdr"
header=
"From: "
assign_to=
"8"
/>
</action>
</recv>
<!-- set variable 8 above on 25th call, send the ACK but skip the pause for it -->
<send
next=
"1"
test=
"8"
>
<send>
<![CDATA[
ACK sip:
31416
@192.168.50.79 SIP/2.0
ACK sip:
2000
@192.168.50.79 SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:27182@[local_ip]:[local_port]>
;tag=[call_number]
To:
<sip:
31416
@192.168.50.79:[remote_port]
>
To:
<sip:
2000
@192.168.50.79:[remote_port]
>
Call-ID: [call_id]
CSeq:
1
ACK
CSeq:
5
ACK
Contact: sip:27182@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Functional Test
...
...
@@ -125,19 +163,15 @@
]]>
</send>
<pause
milliseconds=
"5000"
/>
<label
id=
"1"
/>
<send
retrans=
"500"
>
<![CDATA[
BYE sip:
31416
@192.168.50.79 SIP/2.0
BYE sip:
2000
@192.168.50.79 SIP/2.0
Via: SIP/2.0/[transport] [local_ip]:[local_port];branch=[branch]
From: <sip:27182@[local_ip]:[local_port]>
;tag=[call_number]
To:
<sip:
31416
@192.168.50.79:[remote_port]
>
To:
<sip:
2000
@192.168.50.79:[remote_port]
>
Call-ID: [call_id]
CSeq:
2
BYE
CSeq:
6
BYE
Contact: sip:27182@[local_ip]:[local_port]
Max-Forwards: 70
Subject: Functional Test
...
...
@@ -146,16 +180,7 @@
]]>
</send>
<recv
response=
"200"
crlf=
"true"
>
</recv>
<pause
milliseconds=
"4000"
/>
<!-- definition of the response time repartition table (unit is ms) -->
<ResponseTimeRepartition
value=
"10, 20, 30, 40, 50, 100, 150, 200"
/>
<!-- definition of the call length repartition table (unit is ms) -->
<CallLengthRepartition
value=
"10, 50, 100, 500, 1000, 5000, 10000"
/>
<pause
milliseconds=
"1000"
/>
</scenario>
sippxml/testsuiteuac.sh
View file @
64a8b950
...
...
@@ -5,27 +5,41 @@ SERVERPORT=5062
function
test_ip2ipcall
{
#start sipp server to receive calls from sflphone
#
start sipp server to receive calls from sflphone
sipp
-sf
ip2ipcalluas.xml
-p
${
SERVERPORT
}
&
#start sflphoned
#
start sflphoned
/usr/lib/sflphone/sflphoned&
#wait some time to make sure sflphone is started
#
wait some time to make sure sflphone
d
is started
sleep
2
;
#run python client and
associated script
#
run python client and
script to make calls
python ../tools/pysflphone/pysflphone_testdbus.py
#kill every one
#
kill every one
killall sipp
killall sflphoned
}
function
test_accountcall
{
sipp
-sf
accountcalluac.xml 192.168.50.79
-i
192.168.50.182
-p
${
SERVERPORT
}
# start sflphoned
# /usr/lib/sflphone/sflphoned&
# wait some time to make sure sflphoned is started
#sleep 2;
# python ../tools/pysflphone/pysflphone_testdbus.py &
#sleep 2;
# start sipp client and send calls
sipp
-sf
accountcalluac.xml 192.168.50.79
-i
192.168.50.182
-p
${
SERVERPORT
}
-l
1
# kill every one
killall sipp
killall sflphoned
}
# function called if CTRL-C detected
...
...
@@ -38,4 +52,6 @@ bashtrap()
# Here Start the Test suite
test_ip2ipcall
\ No newline at end of file
# test_ip2ipcall
test_accountcall
\ No newline at end of file
tools/pysflphone/pysflphone_testdbus.py
View file @
64a8b950
...
...
@@ -4,6 +4,8 @@ import sys
import
getopt
from
threading
import
Event
from
sflphonectrlsimple
import
SflPhoneCtrlSimple
...
...
@@ -82,16 +84,27 @@ class SflPhoneTests(SflPhoneCtrlSimple):
print
"Account with ID "
+
accountID
+
" removed"
# Open sflphone and connect to sflphoned through dbus
sflphone
=
SflPhoneTests
()
sflphone
.
start
()
# Test 1: Makke approximately one IP2IP call per second
# to a sipp uas on local addrress
#sflphone.test_make_iptoip_call()
# Test 2:
accountID
=
sflphone
.
test_create_account
()
# Test 2: - Create an account on Asterisk
# - Wait for incoming calls
# - Once a call is received, answer
# - The call should then be hung up by caller
# accountID = sflphone.test_create_account()
# sflphone.test_make_account_call()
time
.
sleep
(
0.3
)
# time.sleep(0.3)
# sflphone.test_remove_account(accountID)
tools/pysflphone/sflphonectrlsimple.py
View file @
64a8b950
...
...
@@ -32,6 +32,7 @@ import time
import
hashlib
from
threading
import
Thread
from
threading
import
Event
from
Errors
import
*
...
...
@@ -42,21 +43,23 @@ except ImportError, e:
raise
SflPhoneError
(
"No python-dbus module found"
)
class
SflPhoneCtrlSimple
(
object
):
class
SflPhoneCtrlSimple
(
Thread
):
"""Simple class for controlling SflPhoned through DBUS"""
# list of active calls (known by the client)
activeCalls
=
{}
def
__init__
(
self
,
name
=
sys
.
argv
[
0
]):
Thread
.
__init__
(
self
)
# current active account
self
.
account
=
None
# client name
self
.
name
=
name
# client registered to sflphoned ?
self
.
registered
=
False
self
.
register
()
self
.
event
=
Event
()
self
.
currentCallId
=
""
def
__del__
(
self
):
...
...
@@ -139,6 +142,9 @@ class SflPhoneCtrlSimple(object):
def
onIncomingCall
(
self
,
account
,
callid
,
to
):
print
"Incoming call: "
+
account
+
", "
+
callid
+
", "
+
to
self
.
activeCalls
[
callid
]
=
{
'Account'
:
account
,
'To'
:
to
,
'State'
:
''
}
self
.
currentCallId
=
callid
self
.
event
.
set
()
Answer
(
callid
)
# On call state changed event, set the values for new calls,
# or delete the call from the list of active calls
...
...
@@ -559,3 +565,13 @@ class SflPhoneCtrlSimple(object):
m
.
update
(
str
(
t
)
+
str
(
r
))
callid
=
m
.
hexdigest
()
return
callid
def
run
(
self
):
while
(
True
):
print
"Waiting Event"
self
.
event
.
wait
()
sflphone
.
Accept
(
sflphone
.
currentCallId
)
self
.
event
.
clear
()
print
"Call Accepted"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment