I came up with a patch to enhance the mediaproxy timeout issue I posted
earlier BTW. Mediaproxy will only timeout if there is no reception of
UDP packets from neither side. This modification will make it timeout if
there is none from either side.
After this patch the mediaproxy will timeout when connection to either
side is lost. As was noted it is important there is no silence detection
activated on the UA's or else silence could cause a timeout. These are
my 1st lines in python so excuse the syntax. I simply split up the
IdleTime attribute and added two attributes named IdleTimeCaller and
IdleTimeCalled.
On reception of a UDP packet I am checking where it came from ( sender
=0 or 1 ) and I reset the corresponding timer. ( Called or Caller )
Instead of resetting the main IdleTime to 0 each time a UDP packet is
received, I am giving this timer the value max of both individual
timers.
The result is that as long as we receive packets from both ends it will
not time out. If there is nothing from one end though the main IdleTimer
will be reset and will timeout.
Changes are marked with PVS added. No warranties ofcourse.
In rtphandler.py I changed the following
def run(self):
global byteBucket, Traffic
now = time.time()
if now >= self.next:
period = self.period
## Check sessions and timeout idle ones
for session in Sessions.values():
for stream in session.mediaStreams:
stream.idleTime += period
# PVS added
stream.idleTimeCalled +=period
stream.idleTimeCaller +=period
####
if session.didTimeout:
session.end()
elif forceClose and session.durati
..............
class MediaStream(object):
def __init__(self, session, mediatype='Audio'):
self.session = weakref.proxy(session)
self.type = mediatype.capitalize()
(dataSlot, ctrlSlot) = self.__findRTPSlot()
self.rtpStream = RTPStream(self, dataSlot, 'RTP')
self.rtcpStream = RTPStream(self, ctrlSlot, 'RTCP')
self.idleTime = 0
self.complete = 0
# PVS added
self.idleTimeCaller= 0
self.idleTimeCalled= 0
###################################
if destination:
byteBucket[2] += bytes
self.bytes[2] += bytes
self.packets[2] += 1
self.sendto(data, destination)
# PVS added ######
if sender==0 :
self.stream.idleTimeCalled=0
if sender==1 :
self.stream.idleTimeCaller=0
self.stream.idleTime =
max(self.stream.idleTimeCalled,self.stream.idleTimeCaller)
##############
def handle_close(self):
self.close()
############################################