SRT Server in NodeJS

birme

Jonas Birmé

Posted on July 10, 2020

SRT Server in NodeJS

Part of a series of videos we go through the necessary building blocks to build an SRT to WebRTC gateway in NodeJS. SRT in terms of the transport protocol called Secure Reliable Transport.

In the first episode we go through how to build an SRT server using the NodeJS native bindings provided by our @eyevinn/srt library.

Install the library

npm install --save @eyevinn/srt
Enter fullscreen mode Exit fullscreen mode

This will download the SRT SDK and compile it on your computer. Example of a very simple SRT receiver (in listener mode) using the Readable stream API included in the library.

const fs = require('fs');
const dest = fs.createWriteStream('./output.ts');

const { SRTReadStream } = require('@eyevinn/srt');
const srt = new SRTReadStream('0.0.0.0', 1234);
srt.listen(readStream => {
  console.log("Client connected");
  readStream.pipe(dest);
});

console.log("Waiting for client to connect");
Enter fullscreen mode Exit fullscreen mode

Above example will setup an SRT socket to listen on port 1234 for a connection. Once a connection is established it will read data from the socket and pipe it to a Writable stream that writes to disk.

💖 💪 🙅 🚩
birme
Jonas Birmé

Posted on July 10, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

SRT Server in NodeJS
node SRT Server in NodeJS

July 10, 2020