[Asterisk-code-review] pjsip: Be aware of allocated RTP ports for direct media snif... (testsuite[15])

Jenkins2 asteriskteam at digium.com
Thu Sep 27 09:30:39 CDT 2018


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/10257 )

Change subject: pjsip: Be aware of allocated RTP ports for direct media sniffer.
......................................................................

pjsip: Be aware of allocated RTP ports for direct media sniffer.

The sniffer module assumed that PJSUA ports would always be below
that of Asterisk. As of PJSIP 2.8 this is no longer true as it
will use a random port on the system. To continue working an event
is now raised when a port is allocated for use in Asterisk and it
is used here to record the actual ports that Asterisk is using.

ASTERISK-28070

Change-Id: I1c08758a57f2f37977342417494f7ab0b9df2965
---
M tests/channels/pjsip/transfers/attended_transfer/nominal/packet_sniffer.py
1 file changed, 22 insertions(+), 3 deletions(-)

Approvals:
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/tests/channels/pjsip/transfers/attended_transfer/nominal/packet_sniffer.py b/tests/channels/pjsip/transfers/attended_transfer/nominal/packet_sniffer.py
index b49f268..69cd380 100755
--- a/tests/channels/pjsip/transfers/attended_transfer/nominal/packet_sniffer.py
+++ b/tests/channels/pjsip/transfers/attended_transfer/nominal/packet_sniffer.py
@@ -63,6 +63,7 @@
 
         self.test_object = test_object
         self.ami = None
+        self.ports = []
         self.test_object.register_ami_observer(self.ami_connect)
         self.add_callback('SIP', self.__check_sip_packet)
         self.calls = {'alice': [], 'bob': [], 'charlie': []}
@@ -87,6 +88,25 @@
         """
         self.ami = ami
 
+        self.ami.registerEvent('TestEvent', self.on_ami_test_event)
+
+    def on_ami_test_event(self, ami, event):
+        """Handles an AMI TestEvent.
+
+        Routes the test data according to the state of the AMI event.
+
+        Keyword Arguments:
+        sender                 -- The ami instance that raised the event.
+        event                  -- The event payload.
+        """
+
+        state = event['state']
+        message = "In self.on_test_event. event[state]={0}."
+        LOGGER.debug(message.format(state))
+
+        if state == 'RTP_PORT_ALLOCATED':
+            self.ports.append(event['port'])
+
     def __check_sip_packet(self, packet):
         """Callback function for when we have a SIP packet
 
@@ -222,9 +242,8 @@
 
         # We have an INVITE of an already known call from Asterisk (we know
         # it's using port 5060).
-        if self.get_rtp_data(packet) > 10000:
-            # The SDP has an RTP port within Asterisk's range (we know it uses
-            # 10000-20000).
+        if str(self.get_rtp_data(packet)) in self.ports:
+            # The SDP has an RTP port that Asterisk has allocated for use
             if self.get_call_state(callid) == "RTP_RB_STARTED":
                 # If the call is already in a remote RTP bridge, then this
                 # INVITE means the remote RTP bridge is being torn down.

-- 
To view, visit https://gerrit.asterisk.org/10257
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: I1c08758a57f2f37977342417494f7ab0b9df2965
Gerrit-Change-Number: 10257
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2 (1000185)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180927/89d8b0b5/attachment.html>


More information about the asterisk-code-review mailing list