Compare commits

..

No commits in common. "master" and "v0.6.0" have entirely different histories.

12 changed files with 1687 additions and 1546 deletions

View file

@ -7,12 +7,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
node-version: [12.x, 14.x]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install, build, and test

View file

@ -176,16 +176,6 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
## Support
Join our [community on Slack](http://slack.streamingtech.se) where you can post any questions regarding any of our open source projects. Eyevinn's consulting business can also offer you:
- Further development of this component
- Customization and integration of this component into your platform
- Support and maintenance agreement
Contact [sales@eyevinn.se](mailto:sales@eyevinn.se) if you are interested.
## About Eyevinn Technology
Eyevinn Technology is an independent consultant firm specialized in video and streaming. Independent in a way that we are not commercially tied to any platform or technology vendor.

3003
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{
"name": "@eyevinn/srt",
"version": "0.8.3",
"version": "0.6.0",
"description": "Nodejs bindings for Secure Reliable Transport SDK",
"main": "index.js",
"scripts": {
@ -43,10 +43,9 @@
"dependencies": {
"debug": "^4.1.1",
"del": "^5.1.0",
"diff": "^5.1.0",
"git-clone": "^0.1.0",
"node-addon-api": "^5.0.0",
"node-gyp": "^9.3.0"
"node-addon-api": "^3.0.0",
"node-gyp": "^7.0.0"
},
"bugs": {
"url": "https://github.com/Eyevinn/node-srt/issues"

View file

@ -4,16 +4,15 @@
const path = require('path');
const fs = require('fs');
const jsdiff = require('diff');
const process = require('process');
const clone = require('git-clone');
const del = require('del');
const { spawnSync, execSync } = require('child_process');
const { spawnSync } = require('child_process');
const os = require('os');
const env = process.env;
const SRT_REPO = env.NODE_SRT_REPO || "https://github.com/Haivision/srt.git";
const SRT_CHECKOUT = "v1.5.4";
const SRT_CHECKOUT = "v1.4.2";
const srtRepoPath = env.NODE_SRT_LOCAL_REPO ? `file://${path.join(__dirname, env.NODE_SRT_LOCAL_REPO)}` : SRT_REPO;
const srtCheckout = env.NODE_SRT_CHECKOUT || SRT_CHECKOUT;
@ -24,7 +23,7 @@ const buildDir = path.join(depsPath, 'build'); // FIXME: name this srt-build (in
const numCpus = os.cpus().length; // NOTE: not the actual physical cores amount btw, see https://www.npmjs.com/package/physical-cpu-count
if (!fs.existsSync(depsPath)) {
console.log('Creating dir:', depsPath);
console.log('Creating dir:', depsPath)
fs.mkdirSync(depsPath);
}
@ -37,21 +36,6 @@ if (!fs.existsSync(srtSourcePath)) {
if (fs.existsSync(srtSourcePath)) del.sync(srtSourcePath);
process.exit(1);
}
console.log("Patch build script");
// Read the source file and the patch file
const sourceFilePath = path.join(srtSourcePath, 'configure-data.tcl');
const patchFilePath = path.join(__dirname, 'configure-data.tcl.patch');
// Read the source file and the patch file
const sourceContent = fs.readFileSync(sourceFilePath, 'utf8');
const patchContent = fs.readFileSync(patchFilePath, 'utf8');
// Apply the patch
const patchedContent = jsdiff.applyPatch(sourceContent, patchContent);
// Write the patched content back to the source file
fs.writeFileSync(sourceFilePath, patchedContent, 'utf8');
build();
});
@ -61,16 +45,10 @@ if (!fs.existsSync(srtSourcePath)) {
function build() {
console.log('Building SRT SDK and prerequisites for current platform:', process.platform);
let opensslRoot;
switch (process.platform) {
case "win32":
buildWin32();
break;
case "darwin":
opensslRoot = execSync('brew --prefix openssl').toString().trim();
process.env.OPENSSL_ROOT_DIR = opensslRoot;
buildNx();
break;
default:
buildNx();
}
@ -108,7 +86,7 @@ function buildWin32() {
}
console.log("Running cmake generator");
const generator = spawnSync('cmake', [ '"'+srtSourcePath+'"', '-DCMAKE_BUILD_TYPE=Release', '-G"Visual Studio 16 2019"', '-A', process.arch, '-DCMAKE_TOOLCHAIN_FILE="%VCPKG_ROOT%\\scripts\\buildsystems\\vcpkg.cmake' ], { cwd: buildDir, shell: true } );
const generator = spawnSync('cmake', [ srtSourcePath, '-DCMAKE_BUILD_TYPE=Release', '-G"Visual Studio 16 2019"', '-A', process.arch, '-DCMAKE_TOOLCHAIN_FILE="%VCPKG_ROOT%\\scripts\\buildsystems\\vcpkg.cmake' ], { cwd: buildDir, shell: true } );
if (generator.stdout)
console.log(generator.stdout.toString());
if (generator.status) {
@ -117,7 +95,7 @@ function buildWin32() {
}
console.log("Running CMake build");
const build = spawnSync('cmake', [ '--build', '"'+buildDir+'"', '--config', 'Release' ], { cwd: buildDir, shell: true } );
const build = spawnSync('cmake', [ '--build', buildDir, '--config', 'Release' ], { cwd: buildDir, shell: true } );
if (build.stdout)
console.log(build.stdout.toString());
if (build.status) {

View file

@ -1,17 +0,0 @@
diff --git a/configure-data.tcl b/configure-data.tcl
index 5c0ee2e..ebca78e 100644
--- a/configure-data.tcl
+++ b/configure-data.tcl
@@ -372,9 +372,10 @@ proc postprocess {} {
if { $er } {
error "You must have OpenSSL installed from 'brew' tool. The standard Mac version is inappropriate."
}
+ set prefix [exec brew --prefix openssl]
- lappend ::cmakeopt "-DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include"
- lappend ::cmakeopt "-DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib/libcrypto.a"
+ lappend ::cmakeopt "-DOPENSSL_INCLUDE_DIR=$prefix/include"
+ lappend ::cmakeopt "-DOPENSSL_LIBRARIES=$prefix/lib/libcrypto.a"
}
}
}

View file

@ -6,7 +6,6 @@ const debug = require('debug')('srt-async');
const { traceCallToString, extractTransferListFromParams } = require('./async-helpers');
const { SRT } = require('../build/Release/node_srt.node');
const EventEmitter = require('events');
const DEFAULT_PROMISE_TIMEOUT_MS = 3000;
@ -16,7 +15,7 @@ const DEBUG = false;
const WORK_ID_GEN_MOD = 0xFFF;
*/
class AsyncSRT extends EventEmitter {
class AsyncSRT {
/**
* @static
@ -25,7 +24,7 @@ class AsyncSRT extends EventEmitter {
static TimeoutMs = DEFAULT_PROMISE_TIMEOUT_MS;
constructor() {
super()
DEBUG && debug('Creating task-runner worker instance');
this._worker = new Worker(path.resolve(__dirname, './async-worker.js'));
@ -68,7 +67,6 @@ class AsyncSRT extends EventEmitter {
'\n Binding call:', traceCallToString(data.call.method, data.call.args),
//'\n Stacktrace:', data.err.stack
);
this.emit('error', data.err.message)
return;
}

View file

@ -177,7 +177,7 @@ Napi::Value NodeSRT::Accept(const Napi::CallbackInfo& info) {
Napi::Error::New(env, srt_getlasterror_str()).ThrowAsJavaScriptException();
return Napi::Number::New(env, SRT_ERROR);
}
srt_close(socketValue);
socketValue = Napi::Number::New(env, SRT_INVALID_SOCK);
return Napi::Number::New(env, their_fd);
}

View file

@ -1,73 +1,66 @@
#define ENUM(E,F) StaticValue(#E,Napi::Number::New(env,F))
#define ENUM(E) StaticValue(#E, Napi::Number::New(env, E))
// egrep '^\s+SRTO' srtcore/srt.h | sed 's/^.*\(SRTO_[^, ]*\)[, ].*$/ ENUM\(\1\), \\/'
#define SOCKET_OPTIONS \
ENUM(SRTO_MSS, 0), \
ENUM(SRTO_SNDSYN, 1), \
ENUM(SRTO_RCVSYN, 2), \
ENUM(SRTO_ISN, 3), \
ENUM(SRTO_FC, 4), \
ENUM(SRTO_SNDBUF, 5), \
ENUM(SRTO_RCVBUF, 6), \
ENUM(SRTO_LINGER, 7), \
ENUM(SRTO_UDP_SNDBUF, 8), \
ENUM(SRTO_UDP_RCVBUF, 9), \
ENUM(SRTO_RENDEZVOUS, 12), \
ENUM(SRTO_SNDTIMEO, 13), \
ENUM(SRTO_RCVTIMEO, 14), \
ENUM(SRTO_REUSEADDR, 15), \
ENUM(SRTO_MAXBW, 16), \
ENUM(SRTO_STATE, 17), \
ENUM(SRTO_EVENT, 18), \
ENUM(SRTO_SNDDATA, 19), \
ENUM(SRTO_RCVDATA, 20), \
ENUM(SRTO_SENDER, 21), \
ENUM(SRTO_TSBPDMODE, 22), \
ENUM(SRTO_LATENCY, 23), \
ENUM(SRTO_INPUTBW, 24), \
ENUM(SRTO_OHEADBW, 25), \
ENUM(SRTO_PASSPHRASE, 26), \
ENUM(SRTO_PBKEYLEN, 27), \
ENUM(SRTO_KMSTATE, 28), \
ENUM(SRTO_IPTTL, 29), \
ENUM(SRTO_IPTOS, 30), \
ENUM(SRTO_TLPKTDROP, 31), \
ENUM(SRTO_SNDDROPDELAY, 32), \
ENUM(SRTO_NAKREPORT, 33), \
ENUM(SRTO_VERSION, 34), \
ENUM(SRTO_PEERVERSION, 35), \
ENUM(SRTO_CONNTIMEO, 36), \
ENUM(SRTO_DRIFTTRACER, 37), \
ENUM(SRTO_MININPUTBW, 38), \
ENUM(SRTO_SNDKMSTATE, 40), \
ENUM(SRTO_RCVKMSTATE, 41), \
ENUM(SRTO_LOSSMAXTTL, 42), \
ENUM(SRTO_RCVLATENCY, 43), \
ENUM(SRTO_PEERLATENCY, 44), \
ENUM(SRTO_MINVERSION, 45), \
ENUM(SRTO_STREAMID, 46), \
ENUM(SRTO_CONGESTION, 47), \
ENUM(SRTO_MESSAGEAPI, 48), \
ENUM(SRTO_PAYLOADSIZE, 49), \
ENUM(SRTO_TRANSTYPE, 50), \
ENUM(SRTO_KMREFRESHRATE, 51), \
ENUM(SRTO_KMPREANNOUNCE, 52), \
ENUM(SRTO_ENFORCEDENCRYPTION, 53), \
ENUM(SRTO_IPV6ONLY, 54), \
ENUM(SRTO_PEERIDLETIMEO, 55), \
ENUM(SRTO_BINDTODEVICE, 56), \
ENUM(SRTO_GROUPCONNECT, 57), \
ENUM(SRTO_GROUPMINSTABLETIMEO, 58), \
ENUM(SRTO_GROUPTYPE, 59), \
ENUM(SRTO_PACKETFILTER, 60), \
ENUM(SRTO_RETRANSMITALGO, 61)
ENUM(SRTO_MSS), \
ENUM(SRTO_SNDSYN), \
ENUM(SRTO_RCVSYN), \
ENUM(SRTO_ISN), \
ENUM(SRTO_FC), \
ENUM(SRTO_SNDBUF), \
ENUM(SRTO_RCVBUF), \
ENUM(SRTO_LINGER), \
ENUM(SRTO_UDP_SNDBUF), \
ENUM(SRTO_UDP_RCVBUF), \
ENUM(SRTO_RENDEZVOUS), \
ENUM(SRTO_SNDTIMEO), \
ENUM(SRTO_RCVTIMEO), \
ENUM(SRTO_REUSEADDR), \
ENUM(SRTO_MAXBW), \
ENUM(SRTO_STATE), \
ENUM(SRTO_EVENT), \
ENUM(SRTO_SNDDATA), \
ENUM(SRTO_RCVDATA), \
ENUM(SRTO_SENDER), \
ENUM(SRTO_TSBPDMODE), \
ENUM(SRTO_INPUTBW), \
ENUM(SRTO_OHEADBW), \
ENUM(SRTO_PASSPHRASE), \
ENUM(SRTO_PBKEYLEN), \
ENUM(SRTO_KMSTATE), \
ENUM(SRTO_IPTTL), \
ENUM(SRTO_IPTOS), \
ENUM(SRTO_TLPKTDROP), \
ENUM(SRTO_SNDDROPDELAY), \
ENUM(SRTO_NAKREPORT), \
ENUM(SRTO_VERSION), \
ENUM(SRTO_PEERVERSION), \
ENUM(SRTO_CONNTIMEO), \
ENUM(SRTO_SNDKMSTATE), \
ENUM(SRTO_RCVKMSTATE), \
ENUM(SRTO_LOSSMAXTTL), \
ENUM(SRTO_RCVLATENCY), \
ENUM(SRTO_PEERLATENCY), \
ENUM(SRTO_MINVERSION), \
ENUM(SRTO_STREAMID), \
ENUM(SRTO_CONGESTION), \
ENUM(SRTO_MESSAGEAPI), \
ENUM(SRTO_PAYLOADSIZE), \
ENUM(SRTO_TRANSTYPE), \
ENUM(SRTO_KMREFRESHRATE), \
ENUM(SRTO_KMPREANNOUNCE), \
ENUM(SRTO_ENFORCEDENCRYPTION), \
ENUM(SRTO_IPV6ONLY), \
ENUM(SRTO_PEERIDLETIMEO), \
ENUM(SRTO_PACKETFILTER)
#define SOCKET_STATUS \
ENUM(SRTS_INIT, 1), \
ENUM(SRTS_OPENED, 2), \
ENUM(SRTS_LISTENING, 3), \
ENUM(SRTS_CONNECTING, 4), \
ENUM(SRTS_CONNECTED, 5), \
ENUM(SRTS_BROKEN, 6), \
ENUM(SRTS_CLOSING, 7), \
ENUM(SRTS_CLOSED, 8), \
ENUM(SRTS_NONEXIST, 9)
ENUM(SRTS_INIT), \
ENUM(SRTS_OPENED), \
ENUM(SRTS_LISTENING), \
ENUM(SRTS_CONNECTING), \
ENUM(SRTS_CONNECTED), \
ENUM(SRTS_BROKEN), \
ENUM(SRTS_CLOSING), \
ENUM(SRTS_CLOSED)

View file

@ -99,7 +99,7 @@ class SRTConnection extends EventEmitter {
this.emit('closing');
const result = await asyncSrt.close(this.fd);
this.emit('closed', result);
this.removeAllListeners();
this.off();
return result;
}
@ -113,14 +113,6 @@ class SRTConnection extends EventEmitter {
this._gotFirstData = true;
}
}
async getSocketOpt(opt) {
return await this._asyncSrt.getSockOpt(this.fd, opt);
}
async setSocketOpt(opt, val) {
return await this._asyncSrt.setSockOpt(this.fd, opt, val);
}
}
/**

View file

@ -1,11 +1,11 @@
import { EventEmitter } from "events";
import { SRTLoggingLevel, SRTResult, SRTSockOpt, SRTSockStatus } from "../src/srt-api-enums";
import { SRTReadReturn, SRTFileDescriptor, SRTEpollEvent, SRTSockOptValue, SRTStats } from "./srt-api"
export type AsyncSRTCallback<T> = (result: T) => void;
export class AsyncSRT extends EventEmitter {
export class AsyncSRT {
static TimeoutMs: number;

View file

@ -30,9 +30,6 @@ export class SRTConnection extends EventEmitter {
onData(): void;
getReaderWriter(): AsyncReaderWriter;
getSocketOpt(opt: number): Promise<number|boolean|string>;
setSocketOpt(opt: number, val: number|boolean|string): Promise<number>;
}
export class SRTServer extends EventEmitter /*<SRTServerEvent>*/ {