Hey! I’m creating a simple demo for my work and I’m struggling with sending audio stream to rtc udp server.
I’ve got working example of creating a snoopChannel and playing back audio, but externalMedia is not sending any data to server.
extension.conf
:
[from-internal]
exten = 100,1,NoOp()
same = n,Stasis(bun-app)
same = n,Hangup()
Node app with ari-client
:
ari.on("StasisStart", async (ev, ch) => {
if (ev.channel.caller.number === "") return;
console.log("Channel entered Stasis application");
try {
await ch.answer();
await play(ch, "sound:hello-world");
const mixingBridge = await createMixingBridge();
mixingBridge.addChannel({ channel: ch.id });
const snoopingChannel = await ch.snoopChannelWithId({
app: "bun-app",
appArgs: "snooping",
snoopId: `snoop-${ch.id}`,
spy: "in",
whisper: "out",
});
await mixingBridge.addChannel({
channel: snoopingChannel.id,
});
const externalMedia = await snoopingChannel.externalMedia({
app: "bun-app",
external_host: "localhost:9999",
format: "ulaw",
});
} catch (e) {
console.log("An error occured:", e);
}
});
What happens here is:
- When we receive call we answer it and play
hello-world
- We create a mixing bridge and we add initial channel to it (createMixingBridge function creates a bridge and destroys it when every channel has left)
- We create snooping channel from initial channel (spy = in, whisper = out)
- Snooping channel is added to mixing bridge
- External media session is started
With provided example I get my voice played back as I speak into the mic.
For rtp udp server I’m using the one provided in external media example with console log on message event.
I don’t know what I’m missing, but rtp udp server is not getting any messages.
I’ve looked at bunch of examples and I can’t wrap my head around it.