* 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
127 lines
2.3 KiB
TypeScript
127 lines
2.3 KiB
TypeScript
import { SRTLoggingLevel, SRTResult, SRTSockOpt, SRTSockStatus } from "../src/srt-api-enums";
|
|
|
|
export interface SRTEpollEvent {
|
|
socket: SRTFileDescriptor
|
|
events: number
|
|
}
|
|
|
|
export type SRTReadReturn = Uint8Array | null | SRTResult.SRT_ERROR;
|
|
|
|
export type SRTFileDescriptor = number;
|
|
|
|
export type SRTSockOptValue = boolean | number | string
|
|
|
|
export class SRT {
|
|
|
|
static OK: SRTResult.SRT_OK;
|
|
static ERROR: SRTResult.SRT_ERROR;
|
|
static INVALID_SOCK: SRTResult.SRT_ERROR;
|
|
|
|
// TODO: add SOCKET_OPTIONS, SOCKET_STATUS enums
|
|
// and EPOLL_OPTS
|
|
|
|
/**
|
|
*
|
|
* @param sender
|
|
* @returns SRTSOCKET identifier (integer value)
|
|
*/
|
|
createSocket(sender?: boolean): number
|
|
|
|
/**
|
|
*
|
|
* @param socket
|
|
* @param address
|
|
* @param port
|
|
*/
|
|
bind(socket: number, address: string, port: number): SRTResult
|
|
|
|
/**
|
|
*
|
|
* @param socket
|
|
* @param backlog
|
|
*/
|
|
listen(socket: number, backlog: number): SRTResult
|
|
|
|
/**
|
|
*
|
|
* @param socket
|
|
* @param host
|
|
* @param port
|
|
*/
|
|
connect(socket: number, host: string, port: number): SRTResult
|
|
|
|
/**
|
|
*
|
|
* @param socket
|
|
* @returns File descriptor of incoming connection pipe
|
|
*/
|
|
accept(socket: number): SRTFileDescriptor
|
|
|
|
/**
|
|
*
|
|
* @param socket
|
|
*/
|
|
close(socket: number): SRTResult
|
|
|
|
/**
|
|
*
|
|
* @param socket
|
|
* @param chunkSize
|
|
*/
|
|
read(socket: number, chunkSize: number): SRTReadReturn
|
|
|
|
/**
|
|
*
|
|
* @param socket
|
|
* @param chunk
|
|
*/
|
|
write(socket: number, chunk: Buffer): SRTResult
|
|
|
|
/**
|
|
*
|
|
* @param socket
|
|
* @param option
|
|
* @param value
|
|
*/
|
|
setSockOpt(socket: number, option: SRTSockOpt, value: SRTSockOptValue): SRTResult
|
|
|
|
/**
|
|
*
|
|
* @param socket
|
|
* @param option
|
|
*/
|
|
getSockOpt(socket: number, option: SRTSockOpt): SRTSockOptValue
|
|
|
|
/**
|
|
*
|
|
* @param socket
|
|
*/
|
|
getSockState(socket: number): SRTSockStatus
|
|
|
|
/**
|
|
* @returns epid
|
|
*/
|
|
epollCreate(): number
|
|
|
|
/**
|
|
*
|
|
* @param epid
|
|
* @param socket
|
|
* @param events
|
|
*/
|
|
epollAddUsock(epid: number, socket: number, events: number): SRTResult
|
|
|
|
/**
|
|
*
|
|
* @param epid
|
|
* @param msTimeOut
|
|
*/
|
|
epollUWait(epid: number, msTimeOut: number): SRTEpollEvent[]
|
|
|
|
/**
|
|
*
|
|
* @param logLevel Or 0 - 7 integer (not all values present in enum)
|
|
*/
|
|
setLogLevel(logLevel: SRTLoggingLevel): SRTResult;
|
|
}
|
|
|