Skip to content

Instantly share code, notes, and snippets.

@Dregu
Last active April 1, 2019 09:32
Show Gist options
  • Save Dregu/9595468972d7b2e848b396b17b4a328e to your computer and use it in GitHub Desktop.
Save Dregu/9595468972d7b2e848b396b17b4a328e to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
var gst = require('gstreamer-superficial');
const port = process.env.UDPPORT || 5000
const timeout = process.env.UDPTIMEOUT || 500
var pipeline = new gst.Pipeline('udpsrc name=src port='+port+' timeout='+timeout+'000000 ! application/x-rtp,media=audio,clock-rate=44100,encoding-name=L16,channels=2,payload=96 ! rtpL16depay ! audioconvert ! autoaudiosink');
var src = pipeline.findChild('src');
pipeline.pollBus((msg) => {
if (msg.name == 'GstUDPSrcTimeout') {
console.log(new Date, 'source timeout in port ' + src.port);
pipeline.stop();
}
});
pipeline.play();
console.log(new Date, 'listening on ' + port);
#!/bin/bash
while true; do
UDPPORT=5000 ./index.js
UDPPORT=5001 ./index.js
done
#!/bin/bash
gst-launch-1.0 audiotestsrc ! audio/x-raw,channels=2,rate=44100 ! rtpL16pay ! udpsink host=127.0.0.1 port=5000
#!/bin/bash
gst-launch-1.0 audiotestsrc wave=white-noise ! audio/x-raw,channels=2,rate=44100 ! rtpL16pay ! udpsink host=127.0.0.1 port=5001
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment