diff --git a/test/holdtest1.py b/test/holdtest1.py index 407a356..70af174 100644 --- a/test/holdtest1.py +++ b/test/holdtest1.py @@ -1,126 +1,126 @@ #!/usr/bin/env python # 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', 50000, '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', 50000, 'recvonly', {})]) + 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', 50000, '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 index 95038df..a282b82 100644 --- a/test/holdtest2.py +++ b/test/holdtest2.py @@ -1,126 +1,126 @@ #!/usr/bin/env python # 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', 50000, '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', 50000, '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', 50000, '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 index 0d519c2..1b9729a 100644 --- a/test/holdtest3.py +++ b/test/holdtest3.py @@ -1,103 +1,103 @@ #!/usr/bin/env python # 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', 50000, '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', 50000, 'recvonly', {})]) + 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 index 6110cbf..f7c2be5 100644 --- a/test/icetest1.py +++ b/test/icetest1.py @@ -1,96 +1,96 @@ #!/usr/bin/env python # 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', 50000, 'sendrecv', {'ice': 'yes'})]) + 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 index 056ee88..2f29204 100644 --- a/test/icetest2.py +++ b/test/icetest2.py @@ -1,115 +1,115 @@ #!/usr/bin/env python # 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', 50000, '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', 50000, 'sendrecv', {'ice': 'yes'})]) + 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 index a7a9920..99b7cc9 100644 --- a/test/multitest1.py +++ b/test/multitest1.py @@ -1,74 +1,74 @@ #!/usr/bin/env python # 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', 50000, 'sendrecv', {})]) + 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 index 1ce37f0..2b43981 100644 --- a/test/multitest2.py +++ b/test/multitest2.py @@ -1,74 +1,74 @@ #!/usr/bin/env python # 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', 50001, 'sendrecv', {})]) + 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 index 75dd3d6..85ed5f1 100644 --- a/test/multitest3.py +++ b/test/multitest3.py @@ -1,74 +1,74 @@ #!/usr/bin/env python # 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', 50002, 'sendrecv', {})]) + 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 index 0f19140..65d7cd5 100644 --- a/test/multitest4.py +++ b/test/multitest4.py @@ -1,74 +1,74 @@ #!/usr/bin/env python # 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', 50004, 'sendrecv', {})]) + 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 index 6239ea3..43f26f7 100644 --- a/test/setuptest1.py +++ b/test/setuptest1.py @@ -1,39 +1,39 @@ #!/usr/bin/env python # 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', 50000, 'sendrecv', {})]) + 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 index efed2cb..19e552f 100644 --- a/test/setuptest2.py +++ b/test/setuptest2.py @@ -1,74 +1,74 @@ #!/usr/bin/env python # 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', 50000, 'sendrecv', {})]) + 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 index 9bba743..0cb6f21 100644 --- a/test/setuptest3.py +++ b/test/setuptest3.py @@ -1,74 +1,74 @@ #!/usr/bin/env python # 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', 50000, 'sendrecv', {})]) + 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 index 3b9ab00..070cd2a 100644 --- a/test/setuptest4.py +++ b/test/setuptest4.py @@ -1,85 +1,85 @@ #!/usr/bin/env python # 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', 50000, 'sendrecv', {})]) + 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 index 23e6993..3a7b894 100644 --- a/test/setuptest5.py +++ b/test/setuptest5.py @@ -1,74 +1,74 @@ #!/usr/bin/env python # 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', 50000, 'sendrecv', {})]) + 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 index 4676a25..549202b 100644 --- a/test/setuptest6.py +++ b/test/setuptest6.py @@ -1,88 +1,88 @@ #!/usr/bin/env python # 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', 50020, 'sendrecv', {})]) + 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/updatetest1.py b/test/updatetest1.py index 423dbd4..0c553bd 100644 --- a/test/updatetest1.py +++ b/test/updatetest1.py @@ -1,110 +1,110 @@ #!/usr/bin/env python # 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', 50020, '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', 50000, 'sendrecv', {})]) + 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 index c354ed3..869369e 100644 --- a/test/updatetest2.py +++ b/test/updatetest2.py @@ -1,116 +1,116 @@ #!/usr/bin/env python # 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', 50000, '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', 50000, 'sendrecv', {}), ('video', 50010, 'sendrecv', {})]) + 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 index aaf24fd..3cd3e0a 100644 --- a/test/updatetest3.py +++ b/test/updatetest3.py @@ -1,104 +1,104 @@ #!/usr/bin/env python # 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', 50000, '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', 50000, 'sendrecv', {}), ('audio', 50010, 'sendrecv', {}), ('audio', 50020, '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', 50020, '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 index 07fa848..31dfbbc 100644 --- a/test/updatetest4.py +++ b/test/updatetest4.py @@ -1,115 +1,115 @@ #!/usr/bin/env python # 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', 50010, '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', 50000, 'sendrecv', {})]) + 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 index c00bb70..2e3f49f 100644 --- a/test/updatetest5.py +++ b/test/updatetest5.py @@ -1,148 +1,148 @@ #!/usr/bin/env python # 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', 50010, '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', 50020, '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', 50000, 'sendrecv', {})]) + 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 index a090cab..b08e025 100644 --- a/test/updatetest6.py +++ b/test/updatetest6.py @@ -1,160 +1,160 @@ #!/usr/bin/env python # 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', 50000, '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', 50000, 'sendrecv', {}), ('video', 50010, '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', 50000, 'sendrecv', {}), ('video', 50010, 'sendrecv', {})]) + 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()