diff --git a/apps/examples/ivr_examples/Readme.ivr_examples b/apps/examples/ivr_examples/Readme.ivr_examples new file mode 100644 index 00000000..06986b06 --- /dev/null +++ b/apps/examples/ivr_examples/Readme.ivr_examples @@ -0,0 +1,2 @@ +Here there are some ivr script examples that illustrate +certain ivr functionality. \ No newline at end of file diff --git a/apps/examples/ivr_examples/b2b_out.py b/apps/examples/ivr_examples/b2b_out.py new file mode 100644 index 00000000..016f1f8a --- /dev/null +++ b/apps/examples/ivr_examples/b2b_out.py @@ -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() diff --git a/apps/examples/ivr_examples/b2bua.py b/apps/examples/ivr_examples/b2bua.py new file mode 100644 index 00000000..8f6cc9b0 --- /dev/null +++ b/apps/examples/ivr_examples/b2bua.py @@ -0,0 +1,36 @@ +# +# ivr b2bua script example +# +from log import * +from ivr import * + +WELLCOME_MSG = "wav/default_en.wav" +CALLEE_URI = "sip:gong@iptel.org" + +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() diff --git a/apps/examples/ivr_examples/rec.py b/apps/examples/ivr_examples/rec.py new file mode 100644 index 00000000..b37a6386 --- /dev/null +++ b/apps/examples/ivr_examples/rec.py @@ -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) diff --git a/apps/examples/ivr_examples/test_mp3.py b/apps/examples/ivr_examples/test_mp3.py new file mode 100644 index 00000000..2572f5af --- /dev/null +++ b/apps/examples/ivr_examples/test_mp3.py @@ -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) + diff --git a/apps/examples/ivr_examples/tmpfile.py b/apps/examples/ivr_examples/tmpfile.py new file mode 100644 index 00000000..e81f5a20 --- /dev/null +++ b/apps/examples/ivr_examples/tmpfile.py @@ -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)