Skip to content

Commit

Permalink
chore: add a lab for ha ivr with routr and asterisk
Browse files Browse the repository at this point in the history
  • Loading branch information
psanders committed Feb 25, 2024
1 parent c15cd9c commit 09f6e09
Show file tree
Hide file tree
Showing 14 changed files with 229 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ I'm just getting started with this, so there's only one lab at the moment.

I'll be adding more soon.

- [WebRTC Network with SIP.js and Routr](webrtc_network_with_sipjs_and_routr)
- [WebRTC Network with SIP.js and Routr](webrtc_network_with_routr_and_sipjs)

## Support my work

Expand Down
36 changes: 36 additions & 0 deletions calling_a_door_phone_from_sipjs/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: "3.9"

services:
routr:
image: fonoster/routr-one:latest
environment:
EXTERNAL_ADDRS: ${DOCKER_HOST_ADDRESS}
RTPENGINE_HOST: rtpengine
ports:
- 51908:51908
- 5060:5060
- 5060:5060/udp
- 5062:5062
volumes:
- shared:/var/lib/postgresql/data

# RTPEngine requires of network mode "host" to work properly. However, this option doesn't work on
# Windows and MacOs. For development, we are opening a few ports to the host machine.
# For production, you must use the network_mode: host which works on Linux.
rtpengine:
image: fonoster/rtpengine:latest
restart: unless-stopped
# Uncomment the following line for production
# network_mode: host
environment:
# Set DOCKER_HOST_ADDRESS to an IP address that is reachable to the SIP clients
PUBLIC_IP: ${DOCKER_HOST_ADDRESS}
PORT_MIN: 10000
PORT_MAX: 10100
LOG_LEVEL: 6
ports:
- 22222:22222/udp
- 10000-10100:10000-10100/udp

volumes:
shared:
70 changes: 70 additions & 0 deletions calling_a_door_phone_from_sipjs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta charset="utf-8" />
<title>Video Feed</title>
<style>
h1 { font-family: 'Courier New', Courier, monospace; }
</style>
</head>

<body>
<h1>Door Phone Video Feed</h1>
<div style="border: 1px solid black; width: 300px; height: 300px;">
<video id="remoteVideo" autoplay muted style="background-color: black; height: 100%"></video>
</div>

<br />

<button id="callButton">Call Door Phone</button>
<button id="hangupButton">Hangup</button>

<audio style="display: none" id="remoteAudio" controls>
<p>Your browser doesn't support HTML5 audio.</p>
</audio>
<script type="module">
import { Web } from "https://unpkg.com/[email protected]/lib/index.js";

document.addEventListener('DOMContentLoaded', () => {
const remoteVideo = document.getElementById('remoteVideo');
const callButton = document.getElementById('callButton');
const hangupButton = document.getElementById('hangupButton');
const remoteAudio = document.getElementById('remoteAudio');

const config = {
server: "ws://localhost:5062",
aor: "sip:[email protected]",
doorPhoneAor: "sip:[email protected]"
}

const options = {
aor: config.aor,
media: {
constraints: { audio: true, video: true },
remote: {
audio: remoteAudio,
video: remoteVideo
}
},
userAgentOptions: {
authorizationUsername: "admin",
authorizationPassword: "1234",
}
};

const simpleUser = new Web.SimpleUser(config.server, options);

callButton.addEventListener('click', async() => {
await simpleUser.connect();
simpleUser.call(config.doorPhoneAor);
});

hangupButton.addEventListener('click', () => {
simpleUser.hangup();
});
});
</script>
</body>

</html>
4 changes: 4 additions & 0 deletions calling_the_pstn_from_sipjs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Calling the PSTN from SIP.js

This example shows how to use the SIP.js library to make a call from a web page to a phone number.

36 changes: 36 additions & 0 deletions calling_the_pstn_from_sipjs/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
version: "3.9"

services:
routr:
image: fonoster/routr-one:latest
environment:
EXTERNAL_ADDRS: ${DOCKER_HOST_ADDRESS}
RTPENGINE_HOST: rtpengine
ports:
- 51908:51908
- 5060:5060
- 5060:5060/udp
- 5062:5062
volumes:
- shared:/var/lib/postgresql/data

# RTPEngine requires of network mode "host" to work properly. However, this option doesn't work on
# Windows and MacOs. For development, we are opening a few ports to the host machine.
# For production, you must use the network_mode: host which works on Linux.
rtpengine:
image: fonoster/rtpengine:latest
restart: unless-stopped
# Uncomment the following line for production
# network_mode: host
environment:
# Set DOCKER_HOST_ADDRESS to an IP address that is reachable to the SIP clients
PUBLIC_IP: ${DOCKER_HOST_ADDRESS}
PORT_MIN: 10000
PORT_MAX: 10100
LOG_LEVEL: 6
ports:
- 22222:22222/udp
- 10000-10100:10000-10100/udp

volumes:
shared:
20 changes: 20 additions & 0 deletions ha_ivr_with_routr_and_asterisk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Happy hacking!

To start the service, use the following command:

```bash
# Remember to replace the Docker Host Address with your own
DOCKER_HOST_ADDRESS=192.168.1.3 docker compose up
```

> Wait for all the services to be "healthy".
Then, you will need to register with Routr from a softphone like Zoiper.

The access information is as follows:

Domain: sip.local
Username: 1001
Password: 1234

After this, you can make a call to Asterisk using sip:asterisk@routr as the address of record.
58 changes: 58 additions & 0 deletions ha_ivr_with_routr_and_asterisk/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version: "3"

services:
routr:
image: fonoster/routr-one:2.7.0
environment:
EXTERNAL_ADDRS: ${DOCKER_HOST_ADDRESS}
RTPENGINE_HOST: rtpengine
ports:
- 51908:51908
- 5060:5060
- 5062:5062
volumes:
- shared:/var/lib/postgresql/data

rtpengine:
image: fonoster/rtpengine:latest
ports:
- 22222:22222/udp
- 10000-10100:10000-10100/udp
environment:
PUBLIC_IP: ${DOCKER_HOST_ADDRESS}
PORT_MIN: 10000
PORT_MAX: 10100

asterisk-01:
image: fonoster/mediaserver:latest
expose:
- 6060
environment:
EXTERN_ADDR: ${DOCKER_HOST_ADDRESS}
SIPPROXY_HOST: routr
SIPPROXY_USERNAME: asterisk
SIPPROXY_SECRET: asterisk
volumes:
- ./extensions.conf:/etc/asterisk/extensions.conf
- ./sounds/count-1.sln16:/var/lib/asterisk/sounds/count.sln16

asterisk-02:
image: fonoster/mediaserver:latest
expose:
- 6060
environment:
EXTERN_ADDR: ${DOCKER_HOST_ADDRESS}
SIPPROXY_HOST: routr
SIPPROXY_USERNAME: asterisk
SIPPROXY_SECRET: asterisk
volumes:
- ./extensions.conf:/etc/asterisk/extensions.conf
- ./sounds/count-2.sln16:/var/lib/asterisk/sounds/count.sln16

simplephone:
image: psanders/simplephone:latest
ports:
- 8080:8080

volumes:
shared:
4 changes: 4 additions & 0 deletions ha_ivr_with_routr_and_asterisk/extensions.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[local-ctx]
exten => asterisk,1,NoOp()
same => n,Playback(count)
same => n,Hangup()
Binary file not shown.
Binary file not shown.

0 comments on commit 09f6e09

Please sign in to comment.