Author: sayer
Date: 2008-04-23 21:37:20 +0200 (Wed, 23 Apr 2008)
New Revision: 915
Added:
trunk/apps/examples/ivr_examples/
trunk/apps/examples/ivr_examples/Readme.ivr_examples
trunk/apps/examples/ivr_examples/b2b_out.py
trunk/apps/examples/ivr_examples/b2bua.py
trunk/apps/examples/ivr_examples/rec.py
trunk/apps/examples/ivr_examples/test_mp3.py
trunk/apps/examples/ivr_examples/tmpfile.py
Log:
some ivr example and test scripts
Added: trunk/apps/examples/ivr_examples/Readme.ivr_examples
===================================================================
--- trunk/apps/examples/ivr_examples/Readme.ivr_examples 2008-04-23
19:27:11 UTC (rev 914)
+++ trunk/apps/examples/ivr_examples/Readme.ivr_examples 2008-04-23
19:37:20 UTC (rev 915)
@@ -0,0 +1,2 @@
+Here there are some ivr script examples that illustrate
+certain ivr functionality.
\ No newline at end of file
Added: trunk/apps/examples/ivr_examples/b2b_out.py
===================================================================
--- trunk/apps/examples/ivr_examples/b2b_out.py 2008-04-23 19:27:11 UTC (rev
914)
+++ trunk/apps/examples/ivr_examples/b2b_out.py 2008-04-23 19:37:20 UTC (rev
915)
@@ -0,0 +1,30 @@
+# (outgoing) ivr b2bua example
+#
+#
+from log import *
+from ivr import *
+
+class IvrDialog(IvrDialogBase):
+
+ def onSessionStart(self, hdrs):
+
+ info("starting b2bua app ...")
+ self.setNoRelayonly()
+ self.audio_msg = IvrAudioFile()
+ self.audio_msg.open("/home/stefan/sub_nautilus.wav", AUDIO_READ)
+ self.setTimer(1, 10)
+ self.enqueue(self.audio_msg,None)
+
+ def onEmptyQueue(self):
+ return
+
+ def onTimer(self, timerid):
+ self.disconnectMedia()
+ debug('hello kitty')
+ self.connectCallee(self.dialog.local_party,self.dialog.local_uri, \
+ self.dialog.remote_party,self.dialog.remote_uri,)
+ return
+
+ def onBye(self):
+
+ self.stopSession()
Added: trunk/apps/examples/ivr_examples/b2bua.py
===================================================================
--- trunk/apps/examples/ivr_examples/b2bua.py 2008-04-23 19:27:11 UTC (rev
914)
+++ trunk/apps/examples/ivr_examples/b2bua.py 2008-04-23 19:37:20 UTC (rev
915)
@@ -0,0 +1,36 @@
+#
+# ivr b2bua script example
+#
+from log import *
+from ivr import *
+
+WELLCOME_MSG = "wav/default_en.wav"
+CALLEE_URI = "sip:[EMAIL PROTECTED]"
+
+class IvrDialog(IvrDialogBase):
+
+ def onSessionStart(self, hdrs):
+
+ info("starting b2bua test ...")
+
+ self.setNoRelayonly()
+
+ self.welcome_msg = IvrAudioFile()
+ self.welcome_msg.open(WELLCOME_MSG, AUDIO_READ)
+ self.enqueue(self.welcome_msg,None)
+
+ def onEmptyQueue(self):
+
+ info("connecting to To: " + CALLEE_URI + " R-URI: " + CALLEE_URI)
+ info("\n\n\n original headers are: ---->%s<----\n\n\n" %
self.invite_req.hdrs)
+ self.invite_req.hdrs += "P-SomeMoreFunky: headervalue\r\n"
+
+ self.disconnectMedia()
+ self.mute()
+
+ self.connectCallee(CALLEE_URI, CALLEE_URI)
+
+ return
+
+ def onBye(self):
+ self.stopSession()
Added: trunk/apps/examples/ivr_examples/rec.py
===================================================================
--- trunk/apps/examples/ivr_examples/rec.py 2008-04-23 19:27:11 UTC (rev
914)
+++ trunk/apps/examples/ivr_examples/rec.py 2008-04-23 19:37:20 UTC (rev
915)
@@ -0,0 +1,13 @@
+#
+# just recording to file
+#
+from log import *
+from ivr import *
+
+class IvrDialog(IvrDialogBase) :
+
+ def onSessionStart( self, hdrs ) :
+
+ self.audio_msg = IvrAudioFile()
+ self.audio_msg.open("record.wav", AUDIO_WRITE)
+ self.enqueue(None,self.audio_msg)
Added: trunk/apps/examples/ivr_examples/test_mp3.py
===================================================================
--- trunk/apps/examples/ivr_examples/test_mp3.py 2008-04-23 19:27:11 UTC
(rev 914)
+++ trunk/apps/examples/ivr_examples/test_mp3.py 2008-04-23 19:37:20 UTC
(rev 915)
@@ -0,0 +1,15 @@
+#
+# testing mp3: play play.mp3, then record record.mp3
+#
+
+from log import *
+from ivr import *
+class IvrDialog(IvrDialogBase):
+
+ def onSessionStart(self, hdrs):
+ self.voice_msg = IvrAudioFile()
+ self.voice_msg.open("play.mp3", AUDIO_READ, False)
+ self.enqueue(self.voice_msg, None)
+ self.voice_msg.open("record.mp3", AUDIO_WRITE, False)
+ self.enqueue(None, self.voice_msg)
+
Added: trunk/apps/examples/ivr_examples/tmpfile.py
===================================================================
--- trunk/apps/examples/ivr_examples/tmpfile.py 2008-04-23 19:27:11 UTC (rev
914)
+++ trunk/apps/examples/ivr_examples/tmpfile.py 2008-04-23 19:37:20 UTC (rev
915)
@@ -0,0 +1,18 @@
+#
+# using IvrAudioFile fpopen
+#
+from log import *
+from ivr import *
+import os
+class IvrDialog(IvrDialogBase):
+
+ def onSessionStart(self, hdrs):
+ f = open("wav/default_en.wav")
+ audio = f.read()
+ debug("Found audio file of length " + str(len(audio)))
+ fp = os.tmpfile()
+ fp.write(audio)
+ fp.seek(0)
+ wav = IvrAudioFile()
+ wav.fpopen("tmp.wav", AUDIO_READ, fp)
+ self.enqueue(wav, None)
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev