[SIP Beyond VoIP] Missing incoming RTP stream
Janusz Kowalczyk
kowalczykjanusz at gmail.com
Tue Jun 25 16:55:23 CEST 2013
Hi Guys,
I'm trying to use SipSimple SDK write test scripts that will be executed
with fabric on a remote machine without a soundcard (ie. Amazon EC2) and
which would dial in to our voice service and play back some wav files
and/or DTMF's.
At the moment I'm trying to use modified version of Saul's "jamesbond"
script
https://github.com/saghul/sipsimple-examples/tree/master/jamesbond
to make a call and play a wav file once call is established. Modified
script is at the end of email.
The problem is that there's no incoming RTP stream. I doubled check
firewall rules and UDP traffic is allowed on all ports. I've attached a
pcap file from an example call.
I'd be grateful if you could help me to figure out what's the problem.
btw. Is there a good and simple example script that would make unattended
calls, play wav files and DTMF tones?
Many thanks,
Janusz
*caller.py:*
#! /usr/bin/env python
import os
import sys
from datetime import datetime
from application.notification import NotificationCenter
from optparse import OptionParser
from threading import Event
from select import select
from sipsimple.account import AccountManager
from sipsimple.application import SIPApplication
from sipsimple.audio import WavePlayer
from sipsimple.configuration.settings import SIPSimpleSettings
from sipsimple.core import SIPURI, SIPCoreError, ToHeader
from sipsimple.lookup import DNSLookup, DNSLookupError
from sipsimple.session import Session
from sipsimple.streams import AudioStream
from sipsimple.threading.green import run_in_green_thread
from sipsimple.storage import FileStorage
class SimpleCallApplication(SIPApplication):
def __init__(self):
SIPApplication.__init__(self)
self.ended = Event()
self.callee = None
self.player = None
self._wave_file = None
self.session = None
self.voice_audio_device = None
self.voice_audio_bridge = None
notification_center = NotificationCenter()
notification_center.add_observer(self)
def call(self, options):
self.callee = options.target
self._wave_file = options.filename
self.start(FileStorage(os.path.expanduser('~/.sipclient')))
@run_in_green_thread
def _NH_SIPApplicationDidStart(self, notification):
settings = SIPSimpleSettings()
# We don't need speakers or microphone
settings.audio.input_device = None
settings.audio.output_device = None
settings.rtp.port_range.start=5000
settings.rtp.port_range.end=5500
print 'RTP portRange: %s' % settings.rtp.port_range
settings.save()
self.player = WavePlayer(SIPApplication.voice_audio_mixer,
self._wave_file, loop_count=0, initial_play=False)
try:
self.callee = ToHeader(SIPURI.parse(self.callee))
except SIPCoreError:
print 'Specified SIP URI is not valid'
self.stop()
return
try:
routes = DNSLookup().lookup_sip_proxy(self.callee.uri,
['udp']).wait()
except DNSLookupError, e:
print 'DNS lookup failed: %s' % str(e)
else:
account = AccountManager().default_account
print account
self.session = Session(account)
self.session.connect(self.callee, routes, [AudioStream()])
def _NH_SIPSessionGotRingIndication(self, notification):
print 'Ringing!'
def _NH_SIPSessionDidStart(self, notification):
print 'Session started! at: %s' %
(datetime.now().strftime("%Y-%m-%d_-_%H-%M-%S"))
session = notification.sender
audio_stream = session.streams[0]
audio_stream.bridge.add(self.player)
print 'Audio session established using "%s" codec at %sHz' %
(audio_stream.codec, audio_stream.sample_rate)
self.player.play()
def _NH_SIPSessionDidFail(self, notification):
print 'Failed to connect! %s' %
(datetime.now().strftime("%Y-%m-%d_-_%H-%M-%S"))
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 at: %s' %
(datetime.now().strftime("%Y-%m-%d_-_%H-%M-%S"))
self.stop()
def _NH_SIPApplicationDidEnd(self, notification):
self.ended.set()
if __name__ == '__main__':
parser = OptionParser()
parser.add_option('-t', '--target', help='Target URI')
parser.add_option('-f', '--file', dest='filename', help='File to play',
metavar='FILE')
options, args = parser.parse_args()
if not options.filename or not options.target:
print 'Target and filename need to be specified, try --help'
sys.exit(1)
if not os.path.isfile(options.filename):
print "The specified file doesn't exist"
sys.exit(1)
application = SimpleCallApplication()
application.call(options)
timeout = 30
print "Placing call, wait %d seconds for call to end automatically or
press Enter to quit the program %s" % (timeout,
datetime.now().strftime("%Y-%m-%d_-_%H-%M-%S"))
rlist, _, _ = select([sys.stdin], [], [], timeout)
if rlist:
s = sys.stdin.readline()
print s
else:
print "No input from the console. Moving on... %s " %
(datetime.now().strftime("%Y-%m-%d_-_%H-%M-%S"))
if application.session:
application.session.end()
application.ended.wait()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20130625/06a704ce/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: caller.pcap
Type: application/octet-stream
Size: 367768 bytes
Desc: not available
URL: <http://lists.ag-projects.com/pipermail/sipbeyondvoip/attachments/20130625/06a704ce/attachment-0001.obj>
More information about the SIPBeyondVoIP
mailing list