[SIP Beyond VoIP] Problem with SIP Simple SDK notification handling

Alexey Nikitenko alexeynikitenko1927 at gmail.com
Thu Mar 14 12:47:48 CET 2019


I try to handle notifications in my simple sip application. I can handle
many notifications connected with session, application end engine, but I
can't handle notifications, connected with incoming and outgoing low-level
requests.

There is incoming INFO messages is session, I can see in Wireshark, but it
not handled with _NH_SIPIncomingRequestGotRequest.

Full listing of class:

class SimpleCallApplication(SIPApplication):

def __init__(self, number, password, server_ip, server_port, logger):
SIPApplication.__init__(self)
self.logger = logger
self.ended = Event()
self.session = None
self.uri = None
self.player = None
self._wave_file = None
self.number = number
self.password = password
self.domain = '{}:{}'.format(server_ip, server_port)
self.number_with_domain = '{}@{}'.format(number, self.domain)
self.notification_center = NotificationCenter()
self.notification_center.add_observer(self)

def call(self, uri, filename):
self.uri = uri
self._wave_file = filename
self.start(FileStorage('config'))

@run_in_green_thread
def _NH_SIPApplicationDidStart(self, notification):

acc = None
try:
acc = AccountManager().get_account(self.number_with_domain)
except KeyError:
pass
if acc is not None:
self.account = acc
else:
self.account = Account(self.number_with_domain)

self.account.__setstate__({'password': self.password})
self.account.enabled = True
self.account.save()

to = ToHeader(SIPURI.parse(self.uri))
settings = SIPSimpleSettings()
settings.audio.input_device = None
settings.audio.output_device = None
settings.save()
self.player = WavePlayer(SIPApplication.voice_audio_mixer, self._wave_file,
loop_count=1)
try:
lookup = DNSLookup()
routes = lookup.lookup_sip_proxy(to.uri, ['udp']).wait()
except DNSLookupError, e:
print 'DNS lookup failed: %s' % str(e)
else:
self.session = Session(self.account)
stream = AudioStream()

self.session.connect(to, routes, [stream])

def _NH_SIPSessionGotRingIndication(self, notification):
print 'Ringing!'
session = notification.sender
session.send(struct.pack('>BBBB', 1, 2, 3, 4))

def _NH_SIPSessionDidStart(self, notification):
print 'Session started!'
session = notification.sender
audio_stream = session.streams[0]
audio_stream.bridge.add(self.player)
self.player.play()

def _NH_SIPSessionDidFail(self, notification):
print 'Failed to connect'
self.stop()

def _NH_SIPSessionWillEnd(self, notification):
session = notification.sender
audio_stream = session.streams[0]
self.player.stop()
audio_stream.bridge.remove(self.player)

def _NH_SIPSessionDidEnd(self, notification):
print 'Session ended'
self.stop()

def _NH_SIPApplicationDidEnd(self, notification):
self.ended.set()

def _NH_AudioStreamGotDTMF(self, notification):
print 'DTMF detected! {}'.format(notification.data.__dict__)

def _NH_SIPIncomingRequestGotRequest(self, notification):
print 'Incoming request'

def _NH_SIPInvitationGotSDPUpdate(self, notification):
print 'SDP update: {}'.format(notification.sender.state)

def _NH_SIPRequestDidEnd(self, notification):
print 'request ended'

def _NH_SIPEngineLog(self, notification):
print 'got a log!'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20190314/7117451d/attachment.html>


More information about the SIPBeyondVoIP mailing list