Skip to content

Commit

Permalink
Allow UA.on_remote_sdp_change() execute synchronously by
Browse files Browse the repository at this point in the history
returning processed body instead of None.
  • Loading branch information
sobomax committed Jul 28, 2024
1 parent 2291575 commit 339926c
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 38 deletions.
6 changes: 2 additions & 4 deletions sippy/Rtp_proxy/Session/side.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,14 @@ def _on_sdp_change(self, rtpps, sdp_body, result_callback, en_excpt):
sdp_bc = sdp_body.content
if isinstance(sdp_bc, strtypes):
sdp_body.needs_update = False
result_callback(sdp_body)
return
return sdp_body
for i, sect in enumerate(sdp_bc.sections):
if sect.m_header.transport.lower() not in rtpps.SUPPORTED_TRTYPES:
continue
sects.append(sect)
if len(sects) == 0:
sdp_body.needs_update = False
result_callback(sdp_body)
return
return sdp_body
formats = sects[0].m_header.formats
self.codecs = ','.join([ str(x) for x in formats ])
if self.repacketize is not None and not self.soft_repacketize:
Expand Down
16 changes: 8 additions & 8 deletions sippy/UaStateConnected.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ def recvRequest(self, req):
pass
if body is not None:
if self.ua.on_remote_sdp_change != None:
self.ua.on_remote_sdp_change(body, partial(self.ua.delayed_remote_sdp_update, event))
return (UasStateUpdating,)
else:
self.ua.rSDP = body.getCopy()
body = self.ua.on_remote_sdp_change(body, partial(self.ua.delayed_remote_sdp_update, event))
if body is None:
return (UasStateUpdating,)
self.ua.rSDP = body.getCopy()
else:
self.ua.rSDP = None
self.ua.equeue.append(event)
Expand Down Expand Up @@ -139,10 +139,10 @@ def recvACK(self, req):
callback(self.ua, req.rtime, self.ua.origin)
if body is not None:
if self.ua.on_remote_sdp_change != None:
self.ua.on_remote_sdp_change(body, partial(self.ua.delayed_remote_sdp_update, event))
return None
else:
self.ua.rSDP = body.getCopy()
body = self.ua.on_remote_sdp_change(body, partial(self.ua.delayed_remote_sdp_update, event))
if body is None:
return None
self.ua.rSDP = body.getCopy()
else:
self.ua.rSDP = None
self.ua.equeue.append(event)
Expand Down
16 changes: 8 additions & 8 deletions sippy/UacStateRinging.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ def recvResponse(self, resp, tr):
ring_cb(self.ua, resp.rtime, self.ua.origin, code)
if body is not None:
if self.ua.on_remote_sdp_change != None:
self.ua.on_remote_sdp_change(body, partial(self.ua.delayed_remote_sdp_update, event))
return None
else:
self.ua.rSDP = body.getCopy()
body = self.ua.on_remote_sdp_change(body, partial(self.ua.delayed_remote_sdp_update, event))
if body is None:
return None
self.ua.rSDP = body.getCopy()
else:
self.ua.rSDP = None
self.ua.equeue.append(event)
Expand Down Expand Up @@ -123,10 +123,10 @@ def recvResponse(self, resp, tr):
rval = (UaStateConnected,)
if body is not None:
if self.ua.on_remote_sdp_change != None:
self.ua.on_remote_sdp_change(body, partial(self.ua.delayed_remote_sdp_update, event))
return rval
else:
self.ua.rSDP = body.getCopy()
body = self.ua.on_remote_sdp_change(body, partial(self.ua.delayed_remote_sdp_update, event))
if body is None:
return rval
self.ua.rSDP = body.getCopy()
else:
self.ua.rSDP = None
self.ua.equeue.append(event)
Expand Down
18 changes: 9 additions & 9 deletions sippy/UacStateTrying.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ def recvResponse(self, resp, tr):
event = CCEventRing(scode, rtime = resp.rtime, origin = self.ua.origin)
if body is not None:
if self.ua.on_remote_sdp_change != None:
self.ua.on_remote_sdp_change(body, partial(self.ua.delayed_remote_sdp_update, event))
self.ua.p1xx_ts = resp.rtime
return (UacStateRinging, self.ua.ring_cbs, resp.rtime, self.ua.origin, code)
else:
self.ua.rSDP = body.getCopy()
body = self.ua.on_remote_sdp_change(body, partial(self.ua.delayed_remote_sdp_update, event))
if body is None:
self.ua.p1xx_ts = resp.rtime
return (UacStateRinging, self.ua.ring_cbs, resp.rtime, self.ua.origin, code)
self.ua.rSDP = body.getCopy()
else:
self.ua.rSDP = None
self.ua.equeue.append(event)
Expand Down Expand Up @@ -141,10 +141,10 @@ def recvResponse(self, resp, tr):
rval = (UaStateConnected,)
if body is not None:
if self.ua.on_remote_sdp_change != None:
self.ua.on_remote_sdp_change(body, partial(self.ua.delayed_remote_sdp_update, event))
return rval
else:
self.ua.rSDP = body.getCopy()
body = self.ua.on_remote_sdp_change(body, partial(self.ua.delayed_remote_sdp_update, event))
if body is None:
return rval
self.ua.rSDP = body.getCopy()
else:
self.ua.rSDP = None
self.ua.equeue.append(event)
Expand Down
8 changes: 4 additions & 4 deletions sippy/UacStateUpdating.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ def recvResponse(self, resp, tr):
if self.ua.on_remote_sdp_change != None:
cb_func = partial(self.ua.delayed_remote_sdp_update, event)
try:
self.ua.on_remote_sdp_change(body, cb_func)
body = self.ua.on_remote_sdp_change(body, cb_func)
except Exception as e:
event = CCEventFail((502, 'Bad Gateway'), rtime = event.rtime)
event.setWarning('Malformed SDP Body received from ' \
'downstream: "%s"' % str(e))
return self.updateFailed(event)
return (UaStateConnected,)
else:
self.ua.rSDP = body.getCopy()
if body is None:
return (UaStateConnected,)
self.ua.rSDP = body.getCopy()
else:
self.ua.rSDP = None
self.ua.equeue.append(event)
Expand Down
10 changes: 5 additions & 5 deletions sippy/UasStateIdle.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ def recvRequest(self, req):
self.ua.expire_timer = TimeoutAbsMono(self.ua.expires, self.ua.expire_mtime)
if body is not None:
if self.ua.on_remote_sdp_change != None:
self.ua.on_remote_sdp_change(body, partial(self.ua.delayed_remote_sdp_update, event))
self.ua.setup_ts = req.rtime
return (UasStateTrying,)
else:
self.ua.rSDP = body.getCopy()
body = self.ua.on_remote_sdp_change(body, partial(self.ua.delayed_remote_sdp_update, event))
if body is None:
self.ua.setup_ts = req.rtime
return (UasStateTrying,)
self.ua.rSDP = body.getCopy()
else:
self.ua.rSDP = None
self.ua.equeue.append(event)
Expand Down

0 comments on commit 339926c

Please sign in to comment.