rtp.js
v0.15.6
Published
RTP stack for Node.js and browser written in TypeScript
Readme
rtp.js
RTP stack for Node.js and browser written in TypeScript. rtp.js provides with an API to parse, generate and modify RTP and RTCP packets.
Installation
npm install rtp.jsUsage
All RTP and RTCP classes, types and packet related helpers are exported by the
packetsmodule:import { isRtp, isRtcp, RtpPacket, CompoundPacket, ReceiverReportPacket, SenderReportPacket, ReceptionReport, ByePacket, SdesPacket, NackPacket, SrReqPacket, EcnPacket, PliPacket, SliPacket, RpsiPacket, XrPacket, ExtendedJitterReportsPacket, GenericPacket, // etc. } from 'rtp.js/packets'; const rtpPacket = new RtpPacket();The
utilsmodule exports some generic helpers and utilities:import { padTo4Bytes, nodeBufferToDataView, dataViewToNodeBuffer, nodeBufferToArrayBuffer, arrayBufferToNodeBuffer, numericArrayToDataView, numberToDataView, dataViewToString, arrayBufferToString, stringToDataView, getStringByteLength, // etc. } from 'rtp.js/utils'; const view = stringToDataView('fooœæ€ñ#¢∞Ω©bar');CommonJS is also supported:
const { RtpPacket /* etc. */ } = require('rtp.js/packets'); const { padTo4Bytes /* etc. */ } = require('rtp.js/utils');Single entry point ("main" or "module" entries in
package.json) is also supported for backwards compatibility:// Using ESM: import { packets as rtpJsPackets, utils as rtpJsUtils } from 'rtp.js'; // Using CommonJS: const { packets: rtpJsPackets, utils: rtpJsUtils } = require('rtp.js'); const { RtpPacket /* etc. */ } = rtpJsPackets; const { padTo4Bytes /* etc. */ } = rtpJsUtils;
Note about TypeScript
rtp.js is written in TypeScript with module: NodeNext, meaning that TypeScript projects that want to import rtp.js using its exposed entry points ("rtp.js/packets" and "rtp.js/utils") must have moduleResolution set to "node16", 'NodeNext" or "bundler" in their tsconfig.json file.
