1
# $Id: mod_call.py 2078 2008-06-27 21:12:12Z nanang $
5
import inc_const as const
9
cfg_file = imp.load_source("cfg_file", ARGS[1])
11
# Check media flow between ua1 and ua2
12
def check_media(ua1, ua2):
16
ua2.expect(const.RX_DTMF + "1")
17
ua2.expect(const.RX_DTMF + "1")
18
ua2.expect(const.RX_DTMF + "2")
19
ua2.expect(const.RX_DTMF + "2")
27
# if have_reg then wait for couple of seconds for PUBLISH
28
# to complete (just in case pUBLISH is used)
29
if callee.inst_param.have_reg:
31
if caller.inst_param.have_reg:
36
caller.send(t.inst_params[0].uri)
37
caller.expect(const.STATE_CALLING)
39
# Callee waits for call and answers with 180/Ringing
41
callee.expect(const.EVENT_INCOMING_CALL)
44
callee.expect("SIP/2.0 180")
45
caller.expect("SIP/2.0 180")
51
# Callee answers with 200/OK
55
# Wait until call is connected in both endpoints
57
caller.expect(const.STATE_CONFIRMED)
58
callee.expect(const.STATE_CONFIRMED)
67
# Test that media is okay
69
check_media(caller, callee)
70
check_media(callee, caller)
74
caller.expect("INVITE sip:")
75
callee.expect("INVITE sip:")
76
caller.expect(const.MEDIA_HOLD)
77
callee.expect(const.MEDIA_HOLD)
86
caller.expect("INVITE sip:")
87
callee.expect("INVITE sip:")
88
caller.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold")
89
callee.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold")
95
# Test that media is okay
96
check_media(caller, callee)
97
check_media(callee, caller)
103
# Hold call by callee
105
callee.expect("INVITE sip:")
106
caller.expect("INVITE sip:")
107
caller.expect(const.MEDIA_HOLD)
108
callee.expect(const.MEDIA_HOLD)
117
callee.expect("INVITE sip:")
118
caller.expect("INVITE sip:")
119
callee.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold")
120
caller.expect(const.MEDIA_ACTIVE, title="waiting for media active after call hold")
126
# Test that media is okay
127
# Wait for some time for ICE negotiation
129
check_media(caller, callee)
130
check_media(callee, caller)
138
#caller.sync_stdout()
139
callee.expect(const.MEDIA_ACTIVE, title="waiting for media active with UPDATE")
140
caller.expect(const.MEDIA_ACTIVE, title="waiting for media active with UPDATE")
146
# Test that media is okay
148
check_media(caller, callee)
149
check_media(callee, caller)
153
callee.expect("UPDATE sip:")
154
caller.expect("UPDATE sip:")
155
caller.expect(const.MEDIA_ACTIVE, title="waiting for media active with UPDATE")
156
callee.expect(const.MEDIA_ACTIVE, title="waiting for media active with UPDATE")
162
# Test that media is okay
164
check_media(caller, callee)
165
check_media(callee, caller)
171
# Set codecs in both caller and callee so that there is
172
# no common codec between them.
173
# In caller we only enable PCMU, in callee we only enable PCMA
175
caller.expect("Enter codec")
178
caller.expect("Enter codec")
179
caller.send("pcmu 120")
182
callee.expect("Enter codec")
185
callee.expect("Enter codec")
186
callee.send("pcma 120")
188
# Test when UPDATE fails (by callee)
190
caller.expect("SIP/2.0 488")
191
callee.expect("SIP/2.0 488")
195
# Test that media is still okay
197
check_media(caller, callee)
198
check_media(callee, caller)
200
# Test when UPDATE fails (by caller)
202
caller.expect("UPDATE sip:")
203
callee.expect("UPDATE sip:")
204
callee.expect("SIP/2.0 488")
205
caller.expect("SIP/2.0 488")
209
# Test that media is still okay
211
check_media(callee, caller)
212
check_media(caller, callee)
218
# Wait until calls are cleared in both endpoints
219
caller.expect(const.STATE_DISCONNECTED)
220
callee.expect(const.STATE_DISCONNECTED)
223
# Here where it all comes together
224
test = cfg_file.test_param
225
test.test_func = test_func