Compare commits
38 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a7cb0dc2a | ||
|
|
8e036283a9 | ||
|
|
36111eec76 | ||
|
|
76c5dbc421 | ||
|
|
62b4a8ceac | ||
|
|
fe1d9f9cee | ||
|
|
f7938b4567 | ||
|
|
cf06fe6ed1 | ||
|
|
bec9609f70 | ||
|
|
04ce7d238b | ||
|
|
b40d4a3c8c | ||
|
|
23407cea60 | ||
|
|
23efbb8501 | ||
|
|
ed0e4913a6 | ||
|
|
c3e77b11dd | ||
|
|
03fd1f7f37 | ||
|
|
9e9a6bddce | ||
|
|
79fb0548c5 | ||
|
|
05d3cf5dd1 | ||
|
|
3a90057bc5 | ||
|
|
be273dd94e | ||
|
|
69b41ac787 | ||
|
|
3928186d2a | ||
|
|
3dbe737fdc | ||
|
|
3ecb83ba6b | ||
|
|
d9fd701dd9 | ||
|
|
c98529f3ae | ||
|
|
64c0d06541 | ||
|
|
e8dfa3ac44 | ||
|
|
a18d038172 | ||
|
|
2dc4dc28f0 | ||
|
|
c4e80fe6d7 | ||
|
|
f63ee34132 | ||
|
|
155f4405ae | ||
|
|
050635e78c | ||
|
|
a71c2f37b3 | ||
|
|
12d3894096 | ||
|
|
ed280c120c |
12 changed files with 1543 additions and 1684 deletions
6
.github/workflows/nodejs.yml
vendored
6
.github/workflows/nodejs.yml
vendored
|
|
@ -7,12 +7,12 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [12.x, 14.x]
|
||||
node-version: [18.x, 20.x, 22.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/checkout@v3
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- name: npm install, build, and test
|
||||
|
|
|
|||
10
README.md
10
README.md
|
|
@ -176,6 +176,16 @@ 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.
|
||||
|
|
|
|||
2997
package-lock.json
generated
2997
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@eyevinn/srt",
|
||||
"version": "0.6.0",
|
||||
"version": "0.8.3",
|
||||
"description": "Nodejs bindings for Secure Reliable Transport SDK",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
|
@ -43,9 +43,10 @@
|
|||
"dependencies": {
|
||||
"debug": "^4.1.1",
|
||||
"del": "^5.1.0",
|
||||
"diff": "^5.1.0",
|
||||
"git-clone": "^0.1.0",
|
||||
"node-addon-api": "^3.0.0",
|
||||
"node-gyp": "^7.0.0"
|
||||
"node-addon-api": "^5.0.0",
|
||||
"node-gyp": "^9.3.0"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Eyevinn/node-srt/issues"
|
||||
|
|
|
|||
|
|
@ -4,15 +4,16 @@
|
|||
|
||||
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 } = require('child_process');
|
||||
const { spawnSync, execSync } = 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.4.2";
|
||||
const SRT_CHECKOUT = "v1.5.4";
|
||||
|
||||
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;
|
||||
|
|
@ -23,7 +24,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);
|
||||
}
|
||||
|
||||
|
|
@ -36,6 +37,21 @@ 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();
|
||||
});
|
||||
|
|
@ -45,10 +61,16 @@ 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();
|
||||
}
|
||||
|
|
@ -86,7 +108,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) {
|
||||
|
|
@ -95,7 +117,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) {
|
||||
|
|
|
|||
17
scripts/configure-data.tcl.patch
Normal file
17
scripts/configure-data.tcl.patch
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ 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;
|
||||
|
||||
|
|
@ -15,7 +16,7 @@ const DEBUG = false;
|
|||
const WORK_ID_GEN_MOD = 0xFFF;
|
||||
*/
|
||||
|
||||
class AsyncSRT {
|
||||
class AsyncSRT extends EventEmitter {
|
||||
|
||||
/**
|
||||
* @static
|
||||
|
|
@ -24,7 +25,7 @@ class AsyncSRT {
|
|||
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'));
|
||||
|
|
@ -67,6 +68,7 @@ class AsyncSRT {
|
|||
'\n Binding call:', traceCallToString(data.call.method, data.call.args),
|
||||
//'\n Stacktrace:', data.err.stack
|
||||
);
|
||||
this.emit('error', data.err.message)
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
133
src/srt-enums.h
133
src/srt-enums.h
|
|
@ -1,66 +1,73 @@
|
|||
#define ENUM(E) StaticValue(#E, Napi::Number::New(env, E))
|
||||
|
||||
// egrep '^\s+SRTO' srtcore/srt.h | sed 's/^.*\(SRTO_[^, ]*\)[, ].*$/ ENUM\(\1\), \\/'
|
||||
#define ENUM(E,F) StaticValue(#E,Napi::Number::New(env,F))
|
||||
|
||||
#define SOCKET_OPTIONS \
|
||||
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)
|
||||
|
||||
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)
|
||||
|
||||
#define SOCKET_STATUS \
|
||||
ENUM(SRTS_INIT), \
|
||||
ENUM(SRTS_OPENED), \
|
||||
ENUM(SRTS_LISTENING), \
|
||||
ENUM(SRTS_CONNECTING), \
|
||||
ENUM(SRTS_CONNECTED), \
|
||||
ENUM(SRTS_BROKEN), \
|
||||
ENUM(SRTS_CLOSING), \
|
||||
ENUM(SRTS_CLOSED)
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class SRTConnection extends EventEmitter {
|
|||
this.emit('closing');
|
||||
const result = await asyncSrt.close(this.fd);
|
||||
this.emit('closed', result);
|
||||
this.off();
|
||||
this.removeAllListeners();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -113,6 +113,14 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
4
types/srt-api-async.d.ts
vendored
4
types/srt-api-async.d.ts
vendored
|
|
@ -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 {
|
||||
export class AsyncSRT extends EventEmitter {
|
||||
|
||||
static TimeoutMs: number;
|
||||
|
||||
|
|
|
|||
3
types/srt-server.d.ts
vendored
3
types/srt-server.d.ts
vendored
|
|
@ -30,6 +30,9 @@ 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>*/ {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue