siproc

A primitive SIP client that spawns processes for each call
git clone git://xatko.vsos.ethz.ch/siproc.git
Log | Files | Refs | README

commit 4efa24d03b1cc28bc080d0ff214dadc2c25af490
parent 88e0d385d012eddff7c09a53854190ec1a3d7f75
Author: Dominik Schmidt <dominik@schm1dt.ch>
Date:   Sun, 27 Oct 2019 00:10:04 +0200

Add some examples

Diffstat:
Aexamples/README.md | 9+++++++++
Aexamples/answer_and_hangup/README.md | 1+
Aexamples/answer_and_hangup/handle.sh | 5+++++
Aexamples/answer_and_hangup/start.sh | 8++++++++
Aexamples/dtmf/README.md | 2++
Aexamples/dtmf/handle.py | 15+++++++++++++++
Aexamples/dtmf/start.sh | 8++++++++
Aexamples/play_outgoing_calls/README.md | 5+++++
Aexamples/play_outgoing_calls/handle.d | 15+++++++++++++++
Aexamples/play_outgoing_calls/start.sh | 19+++++++++++++++++++
10 files changed, 87 insertions(+), 0 deletions(-)

diff --git a/examples/README.md b/examples/README.md @@ -0,0 +1,9 @@ +This directory includes examples for the usage of siproc. + +The entrypoint (i.e. the program to execute to run the example) is always `./start.sh`. +Most of the examples can be terminated by entering "QUIT" on the standard input. +A reasonable order to skim through them is: + +* `answer_and_hangup` +* `dtmf` +* `play_outgoing_calls` diff --git a/examples/answer_and_hangup/README.md b/examples/answer_and_hangup/README.md @@ -0,0 +1 @@ +This example program answers every call it receives, and hangs up after 5 seconds. diff --git a/examples/answer_and_hangup/handle.sh b/examples/answer_and_hangup/handle.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +echo "ANSWER" +sleep 5 +echo "HANGUP" diff --git a/examples/answer_and_hangup/start.sh b/examples/answer_and_hangup/start.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +export SIPROC_USERNAME="max" +export SIPROC_PASSWORD="max1234" +export SIPROC_ID_URI='Max Muster <sip:max@sipproxy.com>' +export SIPROC_REGISTRAR_URI='sip:sipproxy.com' + +siproc ./handle.sh diff --git a/examples/dtmf/README.md b/examples/dtmf/README.md @@ -0,0 +1,2 @@ +This example answers all incoming calls, and hangs up if the remote end +writes "1337" as DTMF tone sequence diff --git a/examples/dtmf/handle.py b/examples/dtmf/handle.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +import sys + +print("ANSWER",flush=True) + +dtmf="" + +for line in sys.stdin: + split = line.strip().split(" ") + if split[0] == "DTMF": + dtmf += split[1] + if dtmf == "1337": + break; + +print("HANGUP",flush=True) diff --git a/examples/dtmf/start.sh b/examples/dtmf/start.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +export SIPROC_USERNAME="max" +export SIPROC_PASSWORD="max1234" +export SIPROC_ID_URI='Max Muster <sip:max@sipproxy.com>' +export SIPROC_REGISTRAR_URI='sip:sipproxy.com' + +siproc ./handle.py diff --git a/examples/play_outgoing_calls/README.md b/examples/play_outgoing_calls/README.md @@ -0,0 +1,5 @@ +This example calls a number every 60 seconds and, after the callee picks up +plays a sound file and hangs up once that is done. + +This example requires a D compiler and the +[flite speech synthesis framwork](http://www.speech.cs.cmu.edu/flite/index.html) diff --git a/examples/play_outgoing_calls/handle.d b/examples/play_outgoing_calls/handle.d @@ -0,0 +1,15 @@ +import std.stdio; + +void main(){ + foreach(l; stdin.byLine()){ + if(l == "CONNECTED"){ + writeln("PLAY message.wav"); + stdout.flush(); + } + else if(l == "STOPPED message.wav"){ + writeln("HANGUP"); + stdout.flush(); + break; + } + } +} diff --git a/examples/play_outgoing_calls/start.sh b/examples/play_outgoing_calls/start.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +# Build the handler first +dmd handle.d -of=handle + +# Generate the message wave file +flite -o message.wav -t "I know what you did last summer" + +# Standard boilerplate +export SIPROC_USERNAME="max" +export SIPROC_PASSWORD="max1234" +export SIPROC_ID_URI='Max Muster <sip:max@sipproxy.com>' +export SIPROC_REGISTRAR_URI='sip:sipproxy.com' + +#Call someone +while sleep 60 +do + echo "CALL sip:contact@sipproxy.com" +done | siproc ./handle