Commit graph

124 commits

Author SHA1 Message Date
Stephan Hesse
bf60795889
Async API server/streams impl & functional tests + Allow to use local SRT source repo instead of remote (#9)
* replace stream module by improved version of readable/writable impl

* rm server.js

* async api improvments:
- better tracing of calls from worker back and forth
- fix transferrable handling to avoid copying buffers for r/w
- optional debug logs
- completed jsdocs annotations
- add dispose method
- add setLogLevel method (analoguous to added binding)

* node-srt C bindings:
- add SetLogLevel to get libSRT log output if desired
- add OK static member
- add #define EPOLL_EVENTS_NUM_MAX 1024
- improve error string thrown in Read (add that it comes from srt_recvmsg)
- improve error string thrown in Write (add that it comes from srt_sendmsg2)
- misc isofunctional improvements (var names) and comments

* add SRT logging related JS-side helper

* rewrite flat TypeScript decl files without "module" keyword

* add ts enum decl for all libSRT enums

* async-worker: enable using transferrable for zero-copy
+ allow better debugging (like in api/dispatcher side)
+ misc improvements on code quality

* add async-helpers: various functions to help dealing with transferrables
+ tracing calls to native bindings in debug output

* add async read/write modes functions + async-reader-writer class
- these will allow for performing high-level r/w operations conveniently
at optimum throughput for larger pieces of payload i.e list of packets.

* add srt-server and srt-connection (can manage multiple clients),
- based on async-api
- can be used with reader/writer (i.e the underlying modes)

* srt-server/connection typings

* async srt spec: add dispose method usage (but commented out as crashing atm)

* async srt spec: rm redundant checks on SRT static members (they are done
in other spec already)

* promises api spec: formal fixes

* stream spec: add dummy test

* package.json:
- put gyp toolchain in runtime deps (since the build happens on install)
- add JEST test runner
- shorten check-tsc script
- rebuild script: check & use all CPU cores available
- run rebuild actually on install, not preinstall (fixes deps not being there)
- remove preinstall and thus "npm install git-clone" in the package scripts

* update package lock

* update typings index not to need triple-slashs anymore

* in srt.ts example: check for read return value type

* build-srt-sdk script:
- allow to use any local libSRT code repo
- when using make: use all amount of cores available for build
- isolate better code running on different platforms

* update package main index with new things

* add enum typings index

* add jest config

* add "use strict" on async-srt-await example

* add integration/smoke testing for client-to-server one-way burst write

* readme: add note on build prerequisites

* readme: add infos on new components SRTServer/Connection & AsyncReaderWriter
2020-10-21 13:09:52 +02:00
Llorx
bf8745b66f
const to fit compiler errors (#11)
const to fit compiler errors
2020-09-14 12:02:38 +02:00
birme
0438ffccfb 0.4.0 2020-08-03 12:14:45 +02:00
birme
de9bab0ba2 Added the async API to the docu 2020-08-03 12:12:25 +02:00
birme
9633c6bff3 Added spec files for async srt library (wip) 2020-08-03 11:50:23 +02:00
Stephan Hesse
0df89c0187
ReadableStream performance improvements (#7)
* various fixes to readable-stream implementation using blocking srt calls.
- refactor reading/pushing routine in order to allow higher througput:
* call srt read() in the same tick/stack as the class _read impl call
* schedule a timer only as needed if no connection yet or socket buffer empty
* blocking loop to push all bytes requested, or until push returns false
or until no more data is in the socket buffer
* generally, handle case properly where no data is yet available from srt-socket read()
* in case no more data, retains the currently requested value remainder
from last _read call
-> this will allow for getting as much data as requested (if socket delivers
it) within the tick where it was requested or any next one in a best effort
manner. it will block the main-thread with "too long" execution frames/ticks
eventually as the data-demand from the _read calls becomes high
in amout/frequency.
but that is simply a consequence of the fact the SRT calls here are
blocking I/O. the previous implementation was also resulting in this
congestion of the main loop queue as read calls would block it, but at best
there was a 100ms lag between a request for read and its actual fulfillment.
one further improvement of this fix could be to split up the requested bytes
amount onto several ticks (executing one partial read directly, and further
ones in further timer scheduled calls, in order to avoid blocking ticks).
- use 50ms timer default for read continuation retry timer
- use 50ms interval for initial connection epoll'ing
- use consts for all timeout values
- implement base class _destroy method & refactor close() in consequence
- trigger Stream base class "readable" event on connection and first packet

* server: add an event for when a client was accepted to pass the fd
2020-08-03 09:58:35 +02:00
Stephan Hesse
074da05097
Worker-based Async API with await/Promise support (or plain callbacks) (#6)
* fix lint errors in eslint config :)

* index.d.s: add /* eslint-disable @typescript-eslint/triple-slash-reference */

* improve eslint calling script

* add async-worker version of the SRT JS API with await/Promise support
+ potentially out-of-order RPC-back/result-dequeuing is possible
with a type of call-ID generator and callback-map that we prototyped
(but not used atm since the worker is only doing sync/blocking internally
with the current SRT lib binding).

* add various examples for async API ("classic" callbacks / Promise / await)

* add .eslintignore (should go with commit where we just call "eslint .")

* index.js: add missing semi

* async.js: fix method name litteral in epollUWait

* async.js: allow for accept method to use a timeout opt (defaults to false),
and a custom timeout value option (default to default timeout),
which can potentially be set differently than the general default timeout.
+ make the timeout value a static class property so that it can be
user-defined module-load wide. defaults to constant in module top scope.

* async.js: fix for a rejected promise, make sure we don't resolve anymore
+ add a custom timeout value argument to _createAsyncWorkPromise

* async.js: rm an experiment

* fix a lint error in example

* add types for async api and fix some details on binding API types

* export async API to index

* async.js: add some missing docs for private methods

* include async types in index
2020-08-03 09:54:26 +02:00
birme
c0846dd7a7 Fixes lint recommendations for Jasmine 2020-07-20 22:10:40 +02:00
birme
b187e048c4 Added eslint plugin for jasmine 2020-07-20 22:09:14 +02:00
birme
87cf3af78f 0.3.1 2020-07-20 12:07:07 +02:00
birme
c6d24dacef Added Stephen Hesse to the list of contributors 2020-07-20 12:06:57 +02:00
birme
34f64cff01 0.3.0 2020-07-20 12:04:11 +02:00
birme
df88ce6cf4 Fixed missing break in switch statements 2020-07-20 11:53:35 +02:00
Stephan Hesse
7973c63f2a
TypeScript support (definition files) + a few small enhancement proposals (#5)
* add typescript definition files for this JS API

* server.js: replace console.log by debug() call

* server.js: set "iface" and "port" properties on SRTServer listen call
+ and init them with null in constructor

* stream.js: SRTReadStream: init fd property with null in constructor

* stream.js: SRTReadStream: add close method (to free the fd aquired with
connect()), likewise the writable stream methods

* example files: add "use strict"; directive on all

* examples/srt.js: correctly state variable fhandle (this would crash in strict mode
otherwise)

* NAPI: NodeSRT::GetSockOpt: fix error handling to really reach ThrowAsJavaScriptException

* add example: srt.ts (TypeScript usage)

* add .editoconfig to project root (helps keeping files free of whitespaces
and maintain indentation etc)

* package.json: improve metadata quality (via npm init call)

* package.json: add dev-deps for tsc/ts-node and node type-defs

* package.json: add check-tsc script to compile typescript example

* gitignore: add tsc-lib (typescript compiler test output)

* add tsconfig.json (typescript compiler config)

* some end-of-file newline and whitespace fixes

* stream.js: add const decls for all the magic numbers in SRTReadStream

* enable eslint static analysis to find possible issues upfront
+ and maintain codestyle

* update package-lock

* stream.js: fix whitespace and eof

* add lint script for src, examples and types modules

* types: lint error fix
2020-07-20 11:41:15 +02:00
birme
25db0b005b 0.2.3 2020-07-03 14:26:47 +02:00
birme
b4f6a98fc5 fix: the readable stream was blocking the entire event queue... 2020-07-03 14:26:40 +02:00
birme
bee98afade 0.2.2 2020-06-30 14:14:08 +02:00
birme
19c8e8bc89 A client server example 2020-06-29 15:24:16 +02:00
birme
2850764451 Handle when client disconnects and ability to close a writeable socket 2020-06-29 15:24:03 +02:00
birme
b958e51ed9 0.2.1 2020-06-25 13:59:26 +02:00
birme
69ac308a82 Check that some socket options are available 2020-06-25 13:59:22 +02:00
birme
79cadfc1eb Merge branch 'master' of github.com:Eyevinn/node-srt 2020-06-25 13:42:57 +02:00
birme
7486df5da1 Added all SRTO and SRTS enums 2020-06-25 13:02:07 +02:00
Jonas Birmé
444bddb977
Create LICENSE (#4) 2020-06-24 22:40:02 +02:00
birme
cb39766bb6 Removed vcpkg submodule 2020-06-24 22:01:22 +02:00
birme
7ad55d7832 Revert attempt to build on windows on push 2020-06-24 21:59:52 +02:00
birme
b3fca6ae00 Do not install any port 2020-06-24 21:40:38 +02:00
birme
05492afb2f Add vcpkg module 2020-06-24 21:35:42 +02:00
birme
4fc9abc457 Another attempt to build on windows 2020-06-24 21:28:32 +02:00
birme
43cb580cb2 Revert attempt to build on windows 2020-06-24 21:19:53 +02:00
birme
068bfbc97e Setup vcpkg for windows build 2020-06-24 21:08:28 +02:00
birme
44a1c05aa6 Github workflow to build on windows 2020-06-24 20:56:57 +02:00
birme
9b72cf29d0 0.2.0 2020-06-24 12:55:33 +02:00
birme
ee2077c896 Async readstream listen 2020-06-24 12:55:23 +02:00
birme
f79e40a4c4 Moved logging to make more clear that it is not blocking 2020-06-24 12:38:05 +02:00
birme
d41259a138 Added example for non blocking polling 2020-06-24 12:36:44 +02:00
birme
5aa37ed66e Updated API doc with the additional bindings 2020-06-24 12:23:04 +02:00
birme
8ff82099b8 Implemented bindings for epoll 2020-06-24 12:18:01 +02:00
birme
08d1eedad8 Can get socket state 2020-06-24 11:34:33 +02:00
birme
62b4e43ebe Can set socket in non-blocking mode 2020-06-24 11:12:02 +02:00
birme
cbf6e2ca87 Ability to set and get sockopt 2020-06-24 10:53:45 +02:00
birme
b0189b20df Misspelling 2020-06-24 09:34:01 +02:00
birme
cf5b16ae87 Build and test on push 2020-06-24 09:32:35 +02:00
birme
7b6ebe9295 Changed name for job 2020-06-24 09:32:26 +02:00
Jonas Birmé
d1ca462bff
Added framework for unit tests (#3) 2020-06-24 09:29:24 +02:00
birme
9a646c84bc 0.1.4 2020-06-24 08:48:38 +02:00
birme
0e650a07b9 Compile on mac os 2020-06-24 08:46:21 +02:00
Dillon Pentz
5b3fc5cdc5
Add Windows build support (#2)
This commit adds Windows build support by utilizing vcpkg to build
dependencies, and CMake for the build system.

These changes rely on vcpkg to be built and located in the VCPKG_ROOT
environment variable, along with having Visual Studio 2019 installed.
2020-06-24 08:44:52 +02:00
birme
937c1a2322 0.1.3 2020-06-22 13:46:31 +02:00
birme
ef94263b8a Implemented writable streams interface 2020-06-22 13:45:43 +02:00