Node.js Native Addon for Secure Reliable Transport

@eyevinn/srt is a Node.js Native Addon that provides bindings to SRT

Eyevinn joined the SRT Alliance earlier this year and our first contribution back to this community is a Node.js native addon for Secure Reliable Transport (SRT*) based on the open sourced SDK. This addon is also available as open source.

Why would you want SRT support in a Javascript based application one could ask? The use cases where you want to process video in Javascript might be limited but there might be other types of data that you in a secure and reliable way want to transport between two applications.

Node.js provides a mechanism where you can dynamically load C++ Addons as ordinary Node.js modules providing an interface between Javascript and C++ libraries. The SRT Alliance provides an open source SDK for the implementation of SRT that is written in C++. What we have developed is an Node.js library that binds these two things together. This library is written in C++ and based on the N-API framework. By building the Addon on N-API you don’t have to compile the library for a specific Node.js version as this API is Application Binary Interface (ABI) stable across versions of Node.js.

To install the library:

npm install --save @eyevinn/srt

When installing this Node.js library it will download and build the latest version of the SRT SDK before building the Node.js Addon. The build system is based on node-gyp that comes bundled with Node Package Manager (npm). And once installed you can write this “hello world”-example.

const { SRT } = require('@eyevinn/srt');const srt = new SRT();
const socket = srt.createSocket();
srt.bind(socket, "0.0.0.0", 1234);
srt.listen(socket, 2);
const fd = srt.accept(socket);
if (fd) {
const chunk = srt.read(fd, 1316);
}

This example will create an SRT socket that is bound to any interface and port 1234. On this port the application will listen for new connection and when a client connects start to read data.

An alpha-alpha version of this library is available already today here: https://www.npmjs.com/package/@eyevinn/srt and it is not yet fully feature-complete with the SRT SDK. It will be evolved and we will show you some more use cases and examples in blog posts here. So make sure you follow this blog if you are interested in this. We are also happy for contributions so we can evolve this together. The source code is available on Github.

The Node.js community is a large community with many open source initiatives providing building blocks to build awesome applications. Eyevinn is an active contributor to the open source community in video and we believe it is important when building services and applications, where some open source components are used, to also give something back.

If you have any further questions and comments on this blog drop a comment below or tweet the author on Twitter (@JonasBirme).

Eyevinn Technology is leading specialists in video technology and media distribution, and proud organizer of the yearly nordic conference Streaming Tech Sweden.

(*) SRT is an open source video transport protocol and technology stack that optimizes streaming performance across unpredictable networks with secure streams and easy firewall traversal, bringing the best quality live video over the worst networks.

--

--

--

We are consultants sharing the passion for the technology for a media consumer of the future.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

MDN Breakout with Phaser 3 — Part 6

DOM Manipulation — Document Fragments and Stylesheets

Top React Jobs — Week 14, 2021

React.js Jobs

Add a Time Picker to a Vue App with vue-timeselector

Difference between window, screen, and document in JavaScript

Why Would You Implement A Backend For Your React App?

Defining and Using Angular Attribute Directives

How to resize an image in Magento 2 programmatically

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Eyevinn Technology

Eyevinn Technology

We are consultants sharing the passion for the technology for a media consumer of the future.

More from Medium

Configure renovate bot for npm at Homegate

Cross-region RMQ message migration using Shovel Plugin

Cross-region RMQ message migration using Shovel Plugin

Error 524- Timeout Occurred

Amplify GraphQL Transformer V2 vs V1