<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/10257">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">pjsip: Be aware of allocated RTP ports for direct media sniffer.<br><br>The sniffer module assumed that PJSUA ports would always be below<br>that of Asterisk. As of PJSIP 2.8 this is no longer true as it<br>will use a random port on the system. To continue working an event<br>is now raised when a port is allocated for use in Asterisk and it<br>is used here to record the actual ports that Asterisk is using.<br><br>ASTERISK-28070<br><br>Change-Id: I1c08758a57f2f37977342417494f7ab0b9df2965<br>---<br>M tests/channels/pjsip/transfers/attended_transfer/nominal/packet_sniffer.py<br>1 file changed, 22 insertions(+), 3 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/channels/pjsip/transfers/attended_transfer/nominal/packet_sniffer.py b/tests/channels/pjsip/transfers/attended_transfer/nominal/packet_sniffer.py</span><br><span>index b49f268..69cd380 100755</span><br><span>--- a/tests/channels/pjsip/transfers/attended_transfer/nominal/packet_sniffer.py</span><br><span>+++ b/tests/channels/pjsip/transfers/attended_transfer/nominal/packet_sniffer.py</span><br><span>@@ -63,6 +63,7 @@</span><br><span> </span><br><span>         self.test_object = test_object</span><br><span>         self.ami = None</span><br><span style="color: hsl(120, 100%, 40%);">+        self.ports = []</span><br><span>         self.test_object.register_ami_observer(self.ami_connect)</span><br><span>         self.add_callback('SIP', self.__check_sip_packet)</span><br><span>         self.calls = {'alice': [], 'bob': [], 'charlie': []}</span><br><span>@@ -87,6 +88,25 @@</span><br><span>         """</span><br><span>         self.ami = ami</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+        self.ami.registerEvent('TestEvent', self.on_ami_test_event)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    def on_ami_test_event(self, ami, event):</span><br><span style="color: hsl(120, 100%, 40%);">+        """Handles an AMI TestEvent.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        Routes the test data according to the state of the AMI event.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        Keyword Arguments:</span><br><span style="color: hsl(120, 100%, 40%);">+        sender                 -- The ami instance that raised the event.</span><br><span style="color: hsl(120, 100%, 40%);">+        event                  -- The event payload.</span><br><span style="color: hsl(120, 100%, 40%);">+        """</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        state = event['state']</span><br><span style="color: hsl(120, 100%, 40%);">+        message = "In self.on_test_event. event[state]={0}."</span><br><span style="color: hsl(120, 100%, 40%);">+        LOGGER.debug(message.format(state))</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        if state == 'RTP_PORT_ALLOCATED':</span><br><span style="color: hsl(120, 100%, 40%);">+            self.ports.append(event['port'])</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>     def __check_sip_packet(self, packet):</span><br><span>         """Callback function for when we have a SIP packet</span><br><span> </span><br><span>@@ -222,9 +242,8 @@</span><br><span> </span><br><span>         # We have an INVITE of an already known call from Asterisk (we know</span><br><span>         # it's using port 5060).</span><br><span style="color: hsl(0, 100%, 40%);">-        if self.get_rtp_data(packet) > 10000:</span><br><span style="color: hsl(0, 100%, 40%);">-            # The SDP has an RTP port within Asterisk's range (we know it uses</span><br><span style="color: hsl(0, 100%, 40%);">-            # 10000-20000).</span><br><span style="color: hsl(120, 100%, 40%);">+        if str(self.get_rtp_data(packet)) in self.ports:</span><br><span style="color: hsl(120, 100%, 40%);">+            # The SDP has an RTP port that Asterisk has allocated for use</span><br><span>             if self.get_call_state(callid) == "RTP_RB_STARTED":</span><br><span>                 # If the call is already in a remote RTP bridge, then this</span><br><span>                 # INVITE means the remote RTP bridge is being torn down.</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/10257">change 10257</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/10257"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: testsuite </div>
<div style="display:none"> Gerrit-Branch: 15 </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: I1c08758a57f2f37977342417494f7ab0b9df2965 </div>
<div style="display:none"> Gerrit-Change-Number: 10257 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 (1000185) </div>