diff --git a/test/holdtest1.py b/test/holdtest1.py old mode 100644 new mode 100755 index 70af174..ccdcc24 --- a/test/holdtest1.py +++ b/test/holdtest1.py @@ -1,126 +1,126 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates a session that starts with 1 audio stream, then gets put on hold by the caller for 5 minutes, the gets taken out of hold again. This test uses the newer 'sendonly' direction attribute to indicate hold status. """ from common import * def phase1(protocol, session): print('setting up audio stream') caller_media = session.caller.set_media([('audio', 40000, 'sendrecv', {})]) callee_media = session.callee.set_media([('audio', 30000, 'sendrecv', {})]) media_defer = DeferredList([caller_media, callee_media]) defer = succeed(None) defer.addCallback(caller_update, protocol, session, media_defer, phase2) return defer def phase2(result, protocol, session): print('setting stream on hold') session.caller.set_media([('audio', 40000, 'sendonly', {})]) session.callee.set_media([('audio', 30000, 'recvonly', {})]) defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update_hold, protocol, session) return defer def callee_update_hold(result, protocol, session): print('updating hold for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(wait_hold, protocol, session) return defer def wait_hold(result, protocol, session): print('on hold, waiting 5 minutes...') defer = Deferred() defer.addCallback(stop_media_hold, protocol, session) reactor.callLater(300, defer.callback, None) return defer def stop_media_hold(result, protocol, session): print('stopping media for hold') defer = DeferredList([session.caller.stop_media(), session.callee.stop_media()]) defer.addCallback(phase3, protocol, session) return defer def phase3(result, protocol, session): print('continuing audio stream') caller_media = session.caller.set_media([('audio', 40000, 'sendrecv', {})]) callee_media = session.callee.set_media([('audio', 30000, 'sendrecv', {})]) media_defer = DeferredList([caller_media, callee_media]) defer = succeed(None) defer.addCallback(caller_update, protocol, session, media_defer, kthxbye) return defer def caller_update(result, protocol, session, media_defer, do_after): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, media_defer, do_after) return defer def callee_update(callee_addr, protocol, session, media_defer, do_after): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(do_media, callee_addr, protocol, session, media_defer, do_after) return defer def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, media_defer, do_after): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) media_defer.addCallback(wait, protocol, session, do_after) return media_defer def wait(result, protocol, session, do_after): print('got media, waiting 5 seconds') defer = Deferred() defer.addCallback(stop_media, protocol, session, do_after) reactor.callLater(5, defer.callback, None) return defer def stop_media(result, protocol, session, do_after): print('stopping media') defer = DeferredList([session.caller.stop_media(), session.callee.stop_media()]) defer.addCallback(do_after, protocol, session) return defer def kthxbye(result, protocol, session): print('sending remove') return session.do_remove(protocol, 'caller') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) callee = Endpoint('Bob ', 'Callee UA', False) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(phase1, session) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/holdtest2.py b/test/holdtest2.py old mode 100644 new mode 100755 index a282b82..6f27731 --- a/test/holdtest2.py +++ b/test/holdtest2.py @@ -1,126 +1,126 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates a session that starts with 1 audio stream, then gets put on hold by the caller for 5 minutes, the gets taken out of hold again. This test uses the older 0.0.0.0 IP address to indicate hold status. """ from common import * def phase1(protocol, session): print('setting up audio stream') caller_media = session.caller.set_media([('audio', 40000, 'sendrecv', {})]) callee_media = session.callee.set_media([('audio', 30000, 'sendrecv', {})]) media_defer = DeferredList([caller_media, callee_media]) defer = succeed(None) defer.addCallback(caller_update, protocol, session, media_defer, phase2) return defer def phase2(result, protocol, session): print('setting stream on hold') session.caller.set_media([('audio', 40000, 'sendrecv', {})]) session.callee.set_media([('audio', 30000, 'sendrecv', {})]) defer = session.do_update(protocol, 'caller', 'request', False, True) defer.addCallback(callee_update_hold, protocol, session) return defer def callee_update_hold(result, protocol, session): print('updating hold for callee') defer = session.do_update(protocol, 'callee', 'reply', True, True) defer.addCallback(wait_hold, protocol, session) return defer def wait_hold(result, protocol, session): print('on hold, waiting 5 minutes...') defer = Deferred() defer.addCallback(stop_media_hold, protocol, session) reactor.callLater(300, defer.callback, None) return defer def stop_media_hold(result, protocol, session): print('stopping media for hold') defer = DeferredList([session.caller.stop_media(), session.callee.stop_media()]) defer.addCallback(phase3, protocol, session) return defer def phase3(result, protocol, session): print('continuing audio stream') caller_media = session.caller.set_media([('audio', 40000, 'sendrecv', {})]) callee_media = session.callee.set_media([('audio', 30000, 'sendrecv', {})]) media_defer = DeferredList([caller_media, callee_media]) defer = succeed(None) defer.addCallback(caller_update, protocol, session, media_defer, kthxbye) return defer def caller_update(result, protocol, session, media_defer, do_after): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, media_defer, do_after) return defer def callee_update(callee_addr, protocol, session, media_defer, do_after): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(do_media, callee_addr, protocol, session, media_defer, do_after) return defer def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, media_defer, do_after): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) media_defer.addCallback(wait, protocol, session, do_after) return media_defer def wait(result, protocol, session, do_after): print('got media, waiting 5 seconds') defer = Deferred() defer.addCallback(stop_media, protocol, session, do_after) reactor.callLater(5, defer.callback, None) return defer def stop_media(result, protocol, session, do_after): print('stopping media') defer = DeferredList([session.caller.stop_media(), session.callee.stop_media()]) defer.addCallback(do_after, protocol, session) return defer def kthxbye(result, protocol, session): print('sending remove') return session.do_remove(protocol, 'caller') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) callee = Endpoint('Bob ', 'Callee UA', False) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(phase1, session) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/holdtest3.py b/test/holdtest3.py old mode 100644 new mode 100755 index 1b9729a..a0734fb --- a/test/holdtest3.py +++ b/test/holdtest3.py @@ -1,103 +1,103 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates a session that starts with 1 audio stream, then gets put on hold by the caller and stops without a BYE after 10 seconds. It is meant to test the on hold timeout. """ from common import * def phase1(protocol, session): print('setting up audio stream') caller_media = session.caller.set_media([('audio', 40000, 'sendrecv', {})]) callee_media = session.callee.set_media([('audio', 30000, 'sendrecv', {})]) media_defer = DeferredList([caller_media, callee_media]) defer = succeed(None) defer.addCallback(caller_update, protocol, session, media_defer, phase2) return defer def phase2(result, protocol, session): print('setting stream on hold') session.caller.set_media([('audio', 40000, 'sendonly', {})]) session.callee.set_media([('audio', 30000, 'recvonly', {})]) defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update_hold, protocol, session) return defer def callee_update_hold(result, protocol, session): print('updating hold for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(wait_hold, protocol, session) return defer def wait_hold(result, protocol, session): print('on hold, waiting 10 seconds...') defer = Deferred() reactor.callLater(10, defer.callback, None) return defer def caller_update(result, protocol, session, media_defer, do_after): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, media_defer, do_after) return defer def callee_update(callee_addr, protocol, session, media_defer, do_after): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(do_media, callee_addr, protocol, session, media_defer, do_after) return defer def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, media_defer, do_after): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) media_defer.addCallback(wait, protocol, session, do_after) return media_defer def wait(result, protocol, session, do_after): print('got media, waiting 5 seconds') defer = Deferred() defer.addCallback(stop_media, protocol, session, do_after) reactor.callLater(5, defer.callback, None) return defer def stop_media(result, protocol, session, do_after): print('stopping media') defer = DeferredList([session.caller.stop_media(), session.callee.stop_media()]) defer.addCallback(do_after, protocol, session) return defer def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) callee = Endpoint('Bob ', 'Callee UA', False) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(phase1, session) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/icetest1.py b/test/icetest1.py old mode 100644 new mode 100755 index f7c2be5..3815444 --- a/test/icetest1.py +++ b/test/icetest1.py @@ -1,96 +1,96 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2009 AG Projects # """ This test simulates a call flow with ICE where the relay is NOT selected as a candidate: - The caller sends an INVITE - the callee sends a 200 OK - Both parties will send probing STUN requests for a few seconds - Both parties will stop the probes and not send media through the relay - After 4 minutes, the callee will send a BYE """ from common import * def caller_update(protocol, session, caller_media, callee_media): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, caller_media, callee_media) return defer def callee_update(callee_addr, protocol, session, caller_media, callee_media): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(do_stun, callee_addr, protocol, session, caller_media, callee_media) return defer def do_stun((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, caller_media, callee_media): print('starting STUN probes for both parties') session.caller.start_media(caller_ip, caller_ports, send_stun=True) session.callee.start_media(callee_ip, callee_ports, send_stun=True) defer = DeferredList([caller_media, callee_media]) defer.addCallback(wait_stun, session, protocol) return defer def wait_stun(result, session, protocol): print('got STUN probes, waiting 3 seconds') defer = Deferred() defer.addCallback(stop_stun_caller, session, protocol) reactor.callLater(3, defer.callback, None) return defer def stop_stun_caller(result, session, protocol): print('stopping STUN probes for caller') defer = session.caller.stop_media() defer.addCallback(stop_stun_callee, session, protocol) return defer def stop_stun_callee(result, session, protocol): print('stopping STUN probes for callee') defer = session.callee.stop_media() defer.addCallback(wait_end, session, protocol) return defer def wait_end(result, session, protocol): print('media is flowing via a different path than the relay for 4 minutes') defer = Deferred() defer.addCallback(end, session, protocol) reactor.callLater(240, defer.callback, None) return defer def end(result, session, protocol): print('sending remove') return session.do_remove(protocol, 'callee') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) caller_media = caller.set_media([('audio', 40000, 'sendrecv', {'ice': 'yes'})]) callee = Endpoint('Bob ', 'Callee UA', False) callee_media = callee.set_media([('audio', 30000, 'sendrecv', {'ice': 'yes'})]) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(caller_update, session, caller_media, callee_media) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/icetest2.py b/test/icetest2.py old mode 100644 new mode 100755 index 2f29204..1e13d5d --- a/test/icetest2.py +++ b/test/icetest2.py @@ -1,115 +1,115 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2009 AG Projects # """ This test simulates a call flow with ICE where the relay is selected as a candidate: - The caller sends an INVITE - the callee sends a 200 OK - Both parties will send probing STUN requests for a few seconds - Both parties will stop the probes and start sending media through the relay (Note that a re-INVITE will be sent, this is due to a limitatin in the test framework) - After 5 seconds, the caller will send a BYE """ from common import * def caller_update(protocol, session, caller_media, callee_media): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, caller_media, callee_media) return defer def callee_update(callee_addr, protocol, session, caller_media, callee_media): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(do_media, callee_addr, protocol, session, caller_media, callee_media) return defer def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, caller_media, callee_media): print('starting STUN probes for both parties') session.caller.start_media(caller_ip, caller_ports, send_stun=True) session.callee.start_media(callee_ip, callee_ports, send_stun=True) defer = DeferredList([caller_media, callee_media]) defer.addCallback(wait, protocol, session) return defer def wait(result, protocol, session): print('got STUN, waiting 5 seconds') defer = Deferred() defer.addCallback(stop_media, protocol, session) reactor.callLater(5, defer.callback, None) return defer def stop_media(result, protocol, session): print('stopping STUN probes') defer = DeferredList([session.caller.stop_media(), session.callee.stop_media()]) defer.addCallback(change_callee, protocol, session) return defer def change_callee(result, protocol, session): print('sending new update for callee') caller_media = session.caller.set_media([('audio', 40000, 'sendrecv', {'ice': 'yes'})]) callee_media = session.callee.set_media([('audio', 30000, 'sendrecv', {'ice': 'yes'})]) media_defer = DeferredList([caller_media, callee_media]) defer = session.do_update(protocol, 'callee', 'request', False) defer.addCallback(change_caller, protocol, session, media_defer) return defer def change_caller((caller_ip, caller_ports), protocol, session, media_defer): print('sending new update for caller') defer = session.do_update(protocol, 'caller', 'reply', True) defer.addCallback(start_new_media, protocol, session, media_defer, caller_ip, caller_ports) return defer def start_new_media((callee_ip, callee_ports), protocol, session, media_defer, caller_ip, caller_ports): print('starting media') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) media_defer.addCallback(wait2, protocol, session) return media_defer def wait2(result, protocol, session): print('got media, waiting 5 seconds') defer = Deferred() defer.addCallback(kthxbye, protocol, session) reactor.callLater(5, defer.callback, None) return defer def kthxbye(result, protocol, session): print('sending remove') return session.do_remove(protocol, 'caller') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) caller_media = caller.set_media([('audio', 40000, 'sendrecv', {'ice': 'yes'})]) callee = Endpoint('Bob ', 'Callee UA', False) callee_media = callee.set_media([('audio', 30000, 'sendrecv', {'ice': 'yes'})]) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(caller_update, session, caller_media, callee_media) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/multitest1.py b/test/multitest1.py old mode 100644 new mode 100755 index 99b7cc9..f1ffe13 --- a/test/multitest1.py +++ b/test/multitest1.py @@ -1,74 +1,74 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates a normal call flow: - The caller sends an INVITE - the callee sends a 200 OK - Both parties will start sending media - Media will flow for 5 seconds - The callee will send a BYE """ from common import * def caller_update(protocol, session, caller_media, callee_media): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, caller_media, callee_media) return defer def callee_update(callee_addr, protocol, session, caller_media, callee_media): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(do_media, callee_addr, protocol, session, caller_media, callee_media) return defer def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, caller_media, callee_media): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) defer = DeferredList([caller_media, callee_media]) defer.addCallback(wait, protocol, session) return defer def wait(result, protocol, session): print('got media, waiting 30 seconds') defer = Deferred() defer.addCallback(kthxbye, protocol, session) reactor.callLater(30, defer.callback, None) return defer def kthxbye(result, protocol, session): print('sending remove') return session.do_remove(protocol, 'callee') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) caller_media = caller.set_media([('audio', 40000, 'sendrecv', {})]) callee = Endpoint('Bob ', 'Callee UA', False) callee_media = callee.set_media([('audio', 30000, 'sendrecv', {})]) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(caller_update, session, caller_media, callee_media) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/multitest2.py b/test/multitest2.py old mode 100644 new mode 100755 index 2b43981..e29352b --- a/test/multitest2.py +++ b/test/multitest2.py @@ -1,74 +1,74 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates a normal call flow: - The caller sends an INVITE - the callee sends a 200 OK - Both parties will start sending media - Media will flow for 5 seconds - The callee will send a BYE """ from common import * def caller_update(protocol, session, caller_media, callee_media): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, caller_media, callee_media) return defer def callee_update(callee_addr, protocol, session, caller_media, callee_media): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(do_media, callee_addr, protocol, session, caller_media, callee_media) return defer def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, caller_media, callee_media): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) defer = DeferredList([caller_media, callee_media]) defer.addCallback(wait, protocol, session) return defer def wait(result, protocol, session): print('got media, waiting 35 seconds') defer = Deferred() defer.addCallback(kthxbye, protocol, session) reactor.callLater(35, defer.callback, None) return defer def kthxbye(result, protocol, session): print('sending remove') return session.do_remove(protocol, 'callee') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) caller_media = caller.set_media([('audio', 40001, 'sendrecv', {})]) callee = Endpoint('Bob ', 'Callee UA', False) callee_media = callee.set_media([('audio', 30001, 'sendrecv', {})]) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(caller_update, session, caller_media, callee_media) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/multitest3.py b/test/multitest3.py old mode 100644 new mode 100755 index 85ed5f1..bb98f89 --- a/test/multitest3.py +++ b/test/multitest3.py @@ -1,74 +1,74 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates a normal call flow: - The caller sends an INVITE - the callee sends a 200 OK - Both parties will start sending media - Media will flow for 5 seconds - The callee will send a BYE """ from common import * def caller_update(protocol, session, caller_media, callee_media): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, caller_media, callee_media) return defer def callee_update(callee_addr, protocol, session, caller_media, callee_media): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(do_media, callee_addr, protocol, session, caller_media, callee_media) return defer def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, caller_media, callee_media): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) defer = DeferredList([caller_media, callee_media]) defer.addCallback(wait, protocol, session) return defer def wait(result, protocol, session): print('got media, waiting 25 seconds') defer = Deferred() defer.addCallback(kthxbye, protocol, session) reactor.callLater(25, defer.callback, None) return defer def kthxbye(result, protocol, session): print('sending remove') return session.do_remove(protocol, 'callee') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) caller_media = caller.set_media([('audio', 40002, 'sendrecv', {})]) callee = Endpoint('Bob ', 'Callee UA', False) callee_media = callee.set_media([('audio', 30002, 'sendrecv', {})]) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(caller_update, session, caller_media, callee_media) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/multitest4.py b/test/multitest4.py old mode 100644 new mode 100755 index 65d7cd5..d35752f --- a/test/multitest4.py +++ b/test/multitest4.py @@ -1,74 +1,74 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates a normal call flow: - The caller sends an INVITE - the callee sends a 200 OK - Both parties will start sending media - Media will flow for 5 seconds - The callee will send a BYE """ from common import * def caller_update(protocol, session, caller_media, callee_media): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, caller_media, callee_media) return defer def callee_update(callee_addr, protocol, session, caller_media, callee_media): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(do_media, callee_addr, protocol, session, caller_media, callee_media) return defer def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, caller_media, callee_media): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) defer = DeferredList([caller_media, callee_media]) defer.addCallback(wait, protocol, session) return defer def wait(result, protocol, session): print('got media, waiting 40 seconds') defer = Deferred() defer.addCallback(kthxbye, protocol, session) reactor.callLater(40, defer.callback, None) return defer def kthxbye(result, protocol, session): print('sending remove') return session.do_remove(protocol, 'callee') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) caller_media = caller.set_media([('audio', 40004, 'sendrecv', {})]) callee = Endpoint('Bob ', 'Callee UA', False) callee_media = callee.set_media([('audio', 30004, 'sendrecv', {})]) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(caller_update, session, caller_media, callee_media) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/setuptest1.py b/test/setuptest1.py old mode 100644 new mode 100755 index 43f26f7..048fd9b --- a/test/setuptest1.py +++ b/test/setuptest1.py @@ -1,39 +1,39 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test scenario simulates the caller sending an INVITE, nothing is received in return. The relay should discard the session after a while. """ from common import * def caller_update(protocol, session): print('doing update for caller') return session.do_update(protocol, 'caller', 'request', False) def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) caller.set_media([('audio', 40000, 'sendrecv', {})]) callee = Endpoint('Bob ', 'Callee UA', False) callee.set_media([('audio', 30000, 'sendrecv', {})]) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(caller_update, session) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/setuptest2.py b/test/setuptest2.py old mode 100644 new mode 100755 index 19e552f..1cd1f7a --- a/test/setuptest2.py +++ b/test/setuptest2.py @@ -1,74 +1,74 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates a normal call flow: - The caller sends an INVITE - the callee sends a 200 OK - Both parties will start sending media - Media will flow for 5 seconds - The callee will send a BYE """ from common import * def caller_update(protocol, session, caller_media, callee_media): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, caller_media, callee_media) return defer def callee_update(callee_addr, protocol, session, caller_media, callee_media): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(do_media, callee_addr, protocol, session, caller_media, callee_media) return defer def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, caller_media, callee_media): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) defer = DeferredList([caller_media, callee_media]) defer.addCallback(wait, protocol, session) return defer def wait(result, protocol, session): print('got media, waiting 5 seconds') defer = Deferred() defer.addCallback(kthxbye, protocol, session) reactor.callLater(5, defer.callback, None) return defer def kthxbye(result, protocol, session): print('sending remove') return session.do_remove(protocol, 'callee') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) caller_media = caller.set_media([('audio', 40000, 'sendrecv', {})]) callee = Endpoint('Bob ', 'Callee UA', False) callee_media = callee.set_media([('audio', 30000, 'sendrecv', {})]) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(caller_update, session, caller_media, callee_media) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/setuptest3.py b/test/setuptest3.py old mode 100644 new mode 100755 index 0cb6f21..76934c6 --- a/test/setuptest3.py +++ b/test/setuptest3.py @@ -1,74 +1,74 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates a normal call flow without a BYE: - The caller sends an INVITE - the callee sends a 200 OK - Both parties will start sending media - Media will flow for 5 seconds - Both parties will stop sending media """ from common import * def caller_update(protocol, session, caller_media, callee_media): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, caller_media, callee_media) return defer def callee_update(callee_addr, protocol, session, caller_media, callee_media): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(do_media, callee_addr, protocol, session, caller_media, callee_media) return defer def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, caller_media, callee_media): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) defer = DeferredList([caller_media, callee_media]) defer.addCallback(wait, protocol, session) return defer def wait(result, protocol, session): print('got media, waiting 5 seconds') defer = Deferred() defer.addCallback(stop_media, protocol, session) reactor.callLater(5, defer.callback, None) return defer def stop_media(result, protocol, session): print('stopping media for callee') return session.callee.stop_media() def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) caller_media = caller.set_media([('audio', 40000, 'sendrecv', {})]) callee = Endpoint('Bob ', 'Callee UA', False) callee_media = callee.set_media([('audio', 30000, 'sendrecv', {})]) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(caller_update, session, caller_media, callee_media) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/setuptest4.py b/test/setuptest4.py old mode 100644 new mode 100755 index 070cd2a..d8c6228 --- a/test/setuptest4.py +++ b/test/setuptest4.py @@ -1,85 +1,85 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates a normal call flow, with an added ACK confirming the SDP: - The caller sends an INVITE - the callee sends a 200 OK - Both parties will start sending media - the caller sends an ACK with SDP - Media will flow for 5 seconds - The callee will send a BYE """ from common import * def caller_update(protocol, session, caller_media, callee_media): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, caller_media, callee_media) return defer def callee_update(callee_addr, protocol, session, caller_media, callee_media): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', False) defer.addCallback(do_media, callee_addr, protocol, session, caller_media, callee_media) return defer def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, caller_media, callee_media): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) defer = DeferredList([caller_media, callee_media]) defer.addCallback(caller_ack, protocol, session, callee_ip, callee_ports) return defer def caller_ack(result, protocol, session, callee_ip, callee_ports): print('got media, doing ACK for caller') defer = session.do_update(protocol, 'caller', 'request', True) defer.addCallback(wait, protocol, session, callee_ip, callee_ports) return defer def wait((callee_ack_ip, callee_ack_ports), protocol, session, callee_ip, callee_ports): print('waiting 5 seconds') assert (callee_ack_ip == callee_ip) assert (callee_ack_ports == callee_ports) defer = Deferred() defer.addCallback(kthxbye, protocol, session) reactor.callLater(5, defer.callback, None) return defer def kthxbye(result, protocol, session): print('sending remove') return session.do_remove(protocol, 'callee') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) caller_media = caller.set_media([('audio', 40000, 'sendrecv', {})]) callee = Endpoint('Bob ', 'Callee UA', False) callee_media = callee.set_media([('audio', 30000, 'sendrecv', {})]) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(caller_update, session, caller_media, callee_media) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/setuptest5.py b/test/setuptest5.py old mode 100644 new mode 100755 index 3a7b894..b82a708 --- a/test/setuptest5.py +++ b/test/setuptest5.py @@ -1,74 +1,74 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates call setup where no SDP is sent in the INVITE: - the callee sends a 200 OK - the caller sends a ACK with SDP - Both parties will start sending media - Media will flow for 5 seconds - The callee will send a BYE """ from common import * def callee_update(protocol, session, caller_media, callee_media): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', False) defer.addCallback(caller_update, protocol, session, caller_media, callee_media) return defer def caller_update(caller_addr, protocol, session, caller_media, callee_media): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', True) defer.addCallback(do_media, caller_addr, protocol, session, caller_media, callee_media) return defer def do_media((callee_ip, callee_ports), (caller_ip, caller_ports), protocol, session, caller_media, callee_media): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) defer = DeferredList([caller_media, callee_media]) defer.addCallback(wait, protocol, session) return defer def wait(result, protocol, session): print('got media, waiting 5 seconds') defer = Deferred() defer.addCallback(kthxbye, protocol, session) reactor.callLater(5, defer.callback, None) return defer def kthxbye(result, protocol, session): print('sending remove') return session.do_remove(protocol, 'callee') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) caller_media = caller.set_media([('audio', 40000, 'sendrecv', {})]) callee = Endpoint('Bob ', 'Callee UA', False) callee_media = callee.set_media([('audio', 30000, 'sendrecv', {})]) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(callee_update, session, caller_media, callee_media) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/setuptest6.py b/test/setuptest6.py old mode 100644 new mode 100755 index 549202b..dea99c5 --- a/test/setuptest6.py +++ b/test/setuptest6.py @@ -1,88 +1,88 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates a session in which the caller proposes 3 streams in the INVITE and the callee rejects two of these. - The caller sends an INVITE with 1 video stream and 2 audio streams - the callee sends a 200 OK with the ports for two of the streams set to 0 - Both parties start sending media - Media flows for 5 seconds - The callee sends a BYE """ from common import * def caller_update(protocol, session, caller_media, callee_media): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, caller_media, callee_media) return defer def callee_update(callee_addr, protocol, session, caller_media, callee_media): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(change_caller1, callee_addr, protocol, session, caller_media, callee_media) return defer def change_caller1(caller_addr, callee_addr, protocol, session, caller_media, callee_media): print('stopping media for caller') defer = session.caller.stop_media() defer.addCallback(change_caller2, caller_addr, callee_addr, protocol, session, callee_media) return defer def change_caller2(result, caller_addr, callee_addr, protocol, session, callee_media): print('setting new media for caller') caller_media = caller.set_media([('audio', 0, 'sendrecv', {}), ('video', 0, 'sendrecv', {}), ('audio', 40020, 'sendrecv', {})]) return do_media(caller_addr, callee_addr, protocol, session, caller_media, callee_media) def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, caller_media, callee_media): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) defer = DeferredList([caller_media, callee_media]) defer.addCallback(wait, protocol, session) return defer def wait(result, protocol, session): print('got media, waiting 5 seconds') defer = Deferred() defer.addCallback(kthxbye, protocol, session) reactor.callLater(5, defer.callback, None) return defer def kthxbye(result, protocol, session): print('sending remove') return session.do_remove(protocol, 'callee') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) caller_media = caller.set_media([('audio', 40000, 'sendrecv', {}), ('video', 40010, 'sendrecv', {}), ('audio', 40020, 'sendrecv', {})]) callee = Endpoint('Bob ', 'Callee UA', False) callee_media = callee.set_media([('audio', 0, 'sendrecv', {}), ('video', 0, 'sendrecv', {}), ('audio', 30020, 'sendrecv', {})]) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(caller_update, session, caller_media, callee_media) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/setuptest7.py b/test/setuptest7.py old mode 100644 new mode 100755 index c0950ec..fa7ccc5 --- a/test/setuptest7.py +++ b/test/setuptest7.py @@ -1,72 +1,72 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates a normal call flow: - The caller sends an INVITE with a media stream with port=0 - The callee sends a 200 OK - The callee will send a BYE after 5 seconds """ from common import * def caller_update(protocol, session, caller_media, callee_media): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, caller_media, callee_media) return defer def callee_update(callee_addr, protocol, session, caller_media, callee_media): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(do_media, callee_addr, protocol, session, caller_media, callee_media) return defer def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, caller_media, callee_media): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) defer = DeferredList([caller_media, callee_media]) defer.addCallback(wait, protocol, session) return defer def wait(result, protocol, session): print('got media, waiting 5 seconds') defer = Deferred() defer.addCallback(kthxbye, protocol, session) reactor.callLater(5, defer.callback, None) return defer def kthxbye(result, protocol, session): print('sending remove') return session.do_remove(protocol, 'callee') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) caller_media = caller.set_media([('audio', 0, 'sendrecv', {})]) callee = Endpoint('Bob ', 'Callee UA', False) callee_media = callee.set_media([('audio', 40000, 'sendrecv', {})]) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(caller_update, session, caller_media, callee_media) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/updatetest1.py b/test/updatetest1.py old mode 100644 new mode 100755 index 0c553bd..344dd05 --- a/test/updatetest1.py +++ b/test/updatetest1.py @@ -1,110 +1,110 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates a call setup with an updated reply from the callee: - The caller sends an INVITE - The callee replies with .e.g a 183 - Both parties start sending media - Media flows for 5 seconds - Media stops - The callee sends a 200 OK with a new port - Media flows again for 5 seconds - The caller sends a BYE """ from common import * def caller_update(protocol, session, caller_media, callee_media): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, caller_media, callee_media) return defer def callee_update(callee_addr, protocol, session, caller_media, callee_media): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', False) defer.addCallback(do_media, callee_addr, protocol, session, caller_media, callee_media) return defer def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, caller_media, callee_media): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) defer = DeferredList([caller_media, callee_media]) defer.addCallback(wait, protocol, session, callee_ip, callee_ports) return defer def wait(result, protocol, session, callee_ip, callee_ports): print('got media, waiting 5 seconds') defer = Deferred() defer.addCallback(stop_media, protocol, session, callee_ip, callee_ports) reactor.callLater(5, defer.callback, None) return defer def stop_media(result, protocol, session, callee_ip, callee_ports): print('stopping media') defer = DeferredList([session.caller.stop_media(), session.callee.stop_media()]) defer.addCallback(change_callee, protocol, session, callee_ip, callee_ports) return defer def change_callee(result, protocol, session, callee_ip, callee_ports): print('sending new update for callee') caller_media = session.caller.set_media([('audio', 40000, 'sendrecv', {})]) callee_media = session.callee.set_media([('audio', 30020, 'sendrecv', {})]) media_defer = DeferredList([caller_media, callee_media]) defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(start_new_media, protocol, session, media_defer, callee_ip, callee_ports) return defer def start_new_media((caller_ip, caller_ports), protocol, session, media_defer, callee_ip, callee_ports): print('starting new media') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) media_defer.addCallback(wait2, protocol, session) return media_defer def wait2(result, protocol, session): print('got new media, waiting 5 seconds') defer = Deferred() defer.addCallback(kthxbye, protocol, session) reactor.callLater(5, defer.callback, None) return defer def kthxbye(result, protocol, session): print('sending remove') return session.do_remove(protocol, 'caller') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) caller_media = caller.set_media([('audio', 40000, 'sendrecv', {})]) callee = Endpoint('Bob ', 'Callee UA', False) callee_media = callee.set_media([('audio', 30000, 'sendrecv', {})]) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(caller_update, session, caller_media, callee_media) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/updatetest2.py b/test/updatetest2.py old mode 100644 new mode 100755 index 869369e..edc1671 --- a/test/updatetest2.py +++ b/test/updatetest2.py @@ -1,116 +1,116 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates a session with audio and video media flowing, after which the callee removes the video stream and only audio flows: - caller sends INVITE, callee sends 200 ok - audio and video media flows for 5 seconds - callee proposes to keep only the audio stream using a re-INVITE, caller sends OK - audio media flows for 5 seconds - caller sends BYE """ from common import * def caller_update(protocol, session, caller_media, callee_media): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, caller_media, callee_media) return defer def callee_update(callee_addr, protocol, session, caller_media, callee_media): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(do_media, callee_addr, protocol, session, caller_media, callee_media) return defer def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, caller_media, callee_media): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) defer = DeferredList([caller_media, callee_media]) defer.addCallback(wait, protocol, session) return defer def wait(result, protocol, session): print('got media, waiting 5 seconds') defer = Deferred() defer.addCallback(stop_media, protocol, session) reactor.callLater(5, defer.callback, None) return defer def stop_media(result, protocol, session): print('stopping media') defer = DeferredList([session.caller.stop_media(), session.callee.stop_media()]) defer.addCallback(change_callee, protocol, session) return defer def change_callee(result, protocol, session): print('sending new update for callee') caller_media = session.caller.set_media([('audio', 40000, 'sendrecv', {})]) callee_media = session.callee.set_media([('audio', 30000, 'sendrecv', {})]) media_defer = DeferredList([caller_media, callee_media]) defer = session.do_update(protocol, 'callee', 'request', False) defer.addCallback(change_caller, protocol, session, media_defer) return defer def change_caller((caller_ip, caller_ports), protocol, session, media_defer): print('sending new update for caller') defer = session.do_update(protocol, 'caller', 'reply', True) defer.addCallback(start_new_media, protocol, session, media_defer, caller_ip, caller_ports) return defer def start_new_media((callee_ip, callee_ports), protocol, session, media_defer, caller_ip, caller_ports): print('starting new media') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) media_defer.addCallback(wait2, protocol, session) return media_defer def wait2(result, protocol, session): print('got new media, waiting 5 seconds') defer = Deferred() defer.addCallback(kthxbye, protocol, session) reactor.callLater(5, defer.callback, None) return defer def kthxbye(result, protocol, session): print('sending remove') return session.do_remove(protocol, 'caller') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) caller_media = caller.set_media([('audio', 40000, 'sendrecv', {}), ('video', 40010, 'sendrecv', {})]) callee = Endpoint('Bob ', 'Callee UA', False) callee_media = callee.set_media([('audio', 30000, 'sendrecv', {}), ('video', 30010, 'sendrecv', {})]) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(caller_update, session, caller_media, callee_media) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/updatetest3.py b/test/updatetest3.py old mode 100644 new mode 100755 index 3cd3e0a..54fa48e --- a/test/updatetest3.py +++ b/test/updatetest3.py @@ -1,104 +1,104 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates a session that starts with only video, then two audio streams are added and finally only one of the audio streams remains. """ from common import * def phase1(protocol, session): print('setting up 1 video stream') caller_media = session.caller.set_media([('video', 40000, 'sendrecv', {})]) callee_media = session.callee.set_media([('video', 30000, 'sendrecv', {})]) media_defer = DeferredList([caller_media, callee_media]) defer = succeed(None) defer.addCallback(caller_update, protocol, session, media_defer, phase2) return defer def phase2(result, protocol, session): print('adding 2 audio streams') caller_media = session.caller.set_media([('video', 40000, 'sendrecv', {}), ('audio', 40010, 'sendrecv', {}), ('audio', 40020, 'sendrecv', {})]) callee_media = session.callee.set_media([('video', 30000, 'sendrecv', {}), ('audio', 30010, 'sendrecv', {}), ('audio', 30020, 'sendrecv', {})]) media_defer = DeferredList([caller_media, callee_media]) defer = succeed(None) defer.addCallback(caller_update, protocol, session, media_defer, phase3) return defer def phase3(result, protocol, session): print('removing 1 video and 1 audio stream') caller_media = session.caller.set_media([('audio', 40020, 'sendrecv', {})]) callee_media = session.callee.set_media([('audio', 30020, 'sendrecv', {})]) media_defer = DeferredList([caller_media, callee_media]) defer = succeed(None) defer.addCallback(caller_update, protocol, session, media_defer, kthxbye) return defer def caller_update(result, protocol, session, media_defer, do_after): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, media_defer, do_after) return defer def callee_update(callee_addr, protocol, session, media_defer, do_after): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(do_media, callee_addr, protocol, session, media_defer, do_after) return defer def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, media_defer, do_after): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) media_defer.addCallback(wait, protocol, session, do_after) return media_defer def wait(result, protocol, session, do_after): print('got media, waiting 5 seconds') defer = Deferred() defer.addCallback(stop_media, protocol, session, do_after) reactor.callLater(5, defer.callback, None) return defer def stop_media(result, protocol, session, do_after): print('stopping media') defer = DeferredList([session.caller.stop_media(), session.callee.stop_media()]) defer.addCallback(do_after, protocol, session) return defer def kthxbye(result, protocol, session): print('sending remove') return session.do_remove(protocol, 'caller') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) callee = Endpoint('Bob ', 'Callee UA', False) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(phase1, session) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/updatetest4.py b/test/updatetest4.py old mode 100644 new mode 100755 index 31dfbbc..a258450 --- a/test/updatetest4.py +++ b/test/updatetest4.py @@ -1,115 +1,115 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates a session with audio media flowing, after which the callee changes the port of the media, e.g. through an UPDATE: - caller sends INVITE, callee sends 200 ok - audio and video media flows for 5 seconds - callee changes the port of the audio stream through an UPATE or re-INVITE - audio media flows for 5 seconds - caller sends BYE """ from common import * def caller_update(protocol, session, caller_media, callee_media): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, caller_media, callee_media) return defer def callee_update(callee_addr, protocol, session, caller_media, callee_media): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(do_media, callee_addr, protocol, session, caller_media, callee_media) return defer def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, caller_media, callee_media): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) defer = DeferredList([caller_media, callee_media]) defer.addCallback(wait, protocol, session) return defer def wait(result, protocol, session): print('got media, waiting 5 seconds') defer = Deferred() defer.addCallback(stop_media, protocol, session) reactor.callLater(5, defer.callback, None) return defer def stop_media(result, protocol, session): print('stopping media') defer = DeferredList([session.caller.stop_media(), session.callee.stop_media()]) defer.addCallback(change_callee, protocol, session) return defer def change_callee(result, protocol, session): print('sending new update for callee') caller_media = session.caller.set_media([('audio', 40000, 'sendrecv', {})]) callee_media = session.callee.set_media([('audio', 30010, 'sendrecv', {})]) media_defer = DeferredList([caller_media, callee_media]) defer = session.do_update(protocol, 'callee', 'request', False) defer.addCallback(change_caller, protocol, session, media_defer) return defer def change_caller((caller_ip, caller_ports), protocol, session, media_defer): print('sending new update for caller') defer = session.do_update(protocol, 'caller', 'reply', True) defer.addCallback(start_new_media, protocol, session, media_defer, caller_ip, caller_ports) return defer def start_new_media((callee_ip, callee_ports), protocol, session, media_defer, caller_ip, caller_ports): print('starting new media') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) media_defer.addCallback(wait2, protocol, session) return media_defer def wait2(result, protocol, session): print('got new media, waiting 5 seconds') defer = Deferred() defer.addCallback(kthxbye, protocol, session) reactor.callLater(5, defer.callback, None) return defer def kthxbye(result, protocol, session): print('sending remove') return session.do_remove(protocol, 'caller') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) caller_media = caller.set_media([('audio', 40000, 'sendrecv', {})]) callee = Endpoint('Bob ', 'Callee UA', False) callee_media = callee.set_media([('audio', 30000, 'sendrecv', {})]) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(caller_update, session, caller_media, callee_media) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/updatetest5.py b/test/updatetest5.py old mode 100644 new mode 100755 index 2e3f49f..34a2482 --- a/test/updatetest5.py +++ b/test/updatetest5.py @@ -1,148 +1,148 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates a call setup with an updated reply from the callee: - The caller sends an INVITE - The callee replies with a provisional response containg SDP e.g. 183 - Both parties start sending media - Media flows for 5 seconds - Media stops - The callee sends another 183 with new port and to-tag (e.g. when the first PSTN gateway failed) - Both parties start sending media - Media flows for 5 seconds - Media stops - The callee sends a 200 OK with a new port - Media flows again for 5 seconds - The caller sends a BYE """ from common import * def caller_update(protocol, session, caller_media, callee_media): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, caller_media, callee_media) return defer def callee_update(callee_addr, protocol, session, caller_media, callee_media): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', False) defer.addCallback(do_media, callee_addr, protocol, session, caller_media, callee_media) return defer def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, caller_media, callee_media): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) defer = DeferredList([caller_media, callee_media]) defer.addCallback(wait, protocol, session, callee_ip, callee_ports) return defer def wait(result, protocol, session, callee_ip, callee_ports): print('got media, waiting 5 seconds') defer = Deferred() defer.addCallback(stop_media, protocol, session, callee_ip, callee_ports) reactor.callLater(5, defer.callback, None) return defer def stop_media(result, protocol, session, callee_ip, callee_ports): print('stopping media') defer = DeferredList([session.caller.stop_media(), session.callee.stop_media()]) defer.addCallback(change_callee_prov, protocol, session, callee_ip, callee_ports) return defer def change_callee_prov(result, protocol, session, callee_ip, callee_ports): print('sending new provisional update for callee') session.callee.tag = 'newtotag' caller_media = session.caller.set_media([('audio', 40000, 'sendrecv', {})]) callee_media = session.callee.set_media([('audio', 30010, 'sendrecv', {})]) media_defer = DeferredList([caller_media, callee_media]) defer = session.do_update(protocol, 'callee', 'reply', False) defer.addCallback(start_new_media_prov, protocol, session, media_defer, callee_ip, callee_ports) return defer def start_new_media_prov((caller_ip, caller_ports), protocol, session, media_defer, callee_ip, callee_ports): print('starting new media') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) media_defer.addCallback(wait2, protocol, session, callee_ip, callee_ports) return media_defer def wait2(result, protocol, session, callee_ip, callee_ports): print('got new media, waiting 5 seconds') defer = Deferred() defer.addCallback(stop_media_prov, protocol, session, callee_ip, callee_ports) reactor.callLater(5, defer.callback, None) return defer def stop_media_prov(result, protocol, session, callee_ip, callee_ports): print('stopping media') defer = DeferredList([session.caller.stop_media(), session.callee.stop_media()]) defer.addCallback(change_callee, protocol, session, callee_ip, callee_ports) return defer def change_callee(result, protocol, session, callee_ip, callee_ports): print('sending new update for callee') caller_media = session.caller.set_media([('audio', 40000, 'sendrecv', {})]) callee_media = session.callee.set_media([('audio', 30020, 'sendrecv', {})]) media_defer = DeferredList([caller_media, callee_media]) defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(start_new_media, protocol, session, media_defer, callee_ip, callee_ports) return defer def start_new_media((caller_ip, caller_ports), protocol, session, media_defer, callee_ip, callee_ports): print('starting new media') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) media_defer.addCallback(wait3, protocol, session) return media_defer def wait3(result, protocol, session): print('got new media, waiting 5 seconds') defer = Deferred() defer.addCallback(kthxbye, protocol, session) reactor.callLater(5, defer.callback, None) return defer def kthxbye(result, protocol, session): print('sending remove') return session.do_remove(protocol, 'caller') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) caller_media = caller.set_media([('audio', 40000, 'sendrecv', {})]) callee = Endpoint('Bob ', 'Callee UA', False) callee_media = callee.set_media([('audio', 30000, 'sendrecv', {})]) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(caller_update, session, caller_media, callee_media) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run() diff --git a/test/updatetest6.py b/test/updatetest6.py old mode 100644 new mode 100755 index b08e025..8ab6efe --- a/test/updatetest6.py +++ b/test/updatetest6.py @@ -1,160 +1,160 @@ -#!/usr/bin/env python +#!/usr/bin/python2 # Copyright (C) 2008 AG Projects # """ This test simulates a session with audio and video media flowing, after which the callee removes the video stream and only audio flows. After a while, the video stream is introduced back and both audio and video flow for a while: - caller sends INVITE, callee sends 200 ok - audio and video media flows for 15 seconds - callee proposes to keep only the audio stream using a re-INVITE, caller sends OK - audio media flows for 15 seconds - callee proposes to reintroduce a video stream using a re-INVITE, caller sends OK - audio and video media flows for 15 seconds - caller sends BYE """ from common import * def caller_update(protocol, session, caller_media, callee_media): print('doing update for caller') defer = session.do_update(protocol, 'caller', 'request', False) defer.addCallback(callee_update, protocol, session, caller_media, callee_media) return defer def callee_update(callee_addr, protocol, session, caller_media, callee_media): print('doing update for callee') defer = session.do_update(protocol, 'callee', 'reply', True) defer.addCallback(do_media, callee_addr, protocol, session, caller_media, callee_media) return defer def do_media((caller_ip, caller_ports), (callee_ip, callee_ports), protocol, session, caller_media, callee_media): print('starting media for both parties') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) defer = DeferredList([caller_media, callee_media]) defer.addCallback(wait, protocol, session) return defer def wait(result, protocol, session): print('got media, waiting 15 seconds') defer = Deferred() defer.addCallback(stop_media, protocol, session) reactor.callLater(15, defer.callback, None) return defer def stop_media(result, protocol, session): print('stopping media') defer = DeferredList([session.caller.stop_media(), session.callee.stop_media()]) defer.addCallback(change_callee, protocol, session) return defer def change_callee(result, protocol, session): print('sending new update for callee') caller_media = session.caller.set_media([('audio', 40000, 'sendrecv', {}), ('video', 0, 'sendrecv', {})]) callee_media = session.callee.set_media([('audio', 30000, 'sendrecv', {}), ('video', 0, 'sendrecv', {})]) media_defer = DeferredList([caller_media, callee_media]) defer = session.do_update(protocol, 'callee', 'request', False) defer.addCallback(change_caller, protocol, session, media_defer) return defer def change_caller((caller_ip, caller_ports), protocol, session, media_defer): print('sending new update for caller') defer = session.do_update(protocol, 'caller', 'reply', True) defer.addCallback(start_new_media, protocol, session, media_defer, caller_ip, caller_ports) return defer def start_new_media((callee_ip, callee_ports), protocol, session, media_defer, caller_ip, caller_ports): print('starting new media') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) media_defer.addCallback(wait2, protocol, session) return media_defer def wait2(result, protocol, session): print('got new media, waiting 15 seconds') defer = Deferred() defer.addCallback(stop_media2, protocol, session) reactor.callLater(15, defer.callback, None) return defer def stop_media2(result, protocol, session): print('stopping media') defer = DeferredList([session.caller.stop_media(), session.callee.stop_media()]) defer.addCallback(change_callee2, protocol, session) return defer def change_callee2(result, protocol, session): print('sending new update for callee') caller_media = session.caller.set_media([('audio', 40000, 'sendrecv', {}), ('video', 40010, 'sendrecv', {})]) callee_media = session.callee.set_media([('audio', 30000, 'sendrecv', {}), ('video', 30010, 'sendrecv', {})]) media_defer = DeferredList([caller_media, callee_media]) defer = session.do_update(protocol, 'callee', 'request', False) defer.addCallback(change_caller2, protocol, session, media_defer) return defer def change_caller2((caller_ip, caller_ports), protocol, session, media_defer): print('sending new update for caller') defer = session.do_update(protocol, 'caller', 'reply', True) defer.addCallback(start_new_media2, protocol, session, media_defer, caller_ip, caller_ports) return defer def start_new_media2((callee_ip, callee_ports), protocol, session, media_defer, caller_ip, caller_ports): print('starting new media') session.caller.start_media(caller_ip, caller_ports) session.callee.start_media(callee_ip, callee_ports) media_defer.addCallback(wait3, protocol, session) return media_defer def wait3(result, protocol, session): print('got new media, waiting 15 seconds') defer = Deferred() defer.addCallback(kthxbye, protocol, session) reactor.callLater(15, defer.callback, None) return defer def kthxbye(result, protocol, session): print('sending remove') return session.do_remove(protocol, 'caller') def disconnect(result, connector): print('disconnecting') connector.disconnect() reactor.callLater(1, reactor.stop) def catch_all_err(failure): print(failure) if __name__ == '__main__': caller = Endpoint('Alice ', 'Caller UA', True) caller_media = caller.set_media([('audio', 40000, 'sendrecv', {}), ('video', 40010, 'sendrecv', {})]) callee = Endpoint('Bob ', 'Callee UA', False) callee_media = callee.set_media([('audio', 30000, 'sendrecv', {}), ('video', 30010, 'sendrecv', {})]) session = Session(caller, callee) connector, defer = connect_to_dispatcher() defer.addCallback(caller_update, session, caller_media, callee_media) defer.addCallback(disconnect, connector) defer.addErrback(catch_all_err) reactor.run()