rtp.js
TypeScript icon, indicating that this package has built-in type declarations

0.15.2 • Public • Published

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.js

Usage

  • API documentation

  • All RTP and RTCP classes, types and packet related helpers are exported by the packets module:

    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 utils module 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.

Authors

License

ISC

Readme

Keywords

Package Sidebar

Install

npm i rtp.js

Weekly Downloads

177

Version

0.15.2

License

ISC

Unpacked Size

470 kB

Total Files

121

Last publish

Collaborators

  • ibc