https://github.com/versatica/rtp.js
RTP stack for Node and browser written in TypeScript
https://github.com/versatica/rtp.js
nodejs rtp typescript
Last synced: 5 months ago
JSON representation
RTP stack for Node and browser written in TypeScript
- Host: GitHub
- URL: https://github.com/versatica/rtp.js
- Owner: versatica
- License: isc
- Created: 2020-07-12T16:54:37.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2025-03-25T20:43:35.000Z (7 months ago)
- Last Synced: 2025-04-25T22:48:34.453Z (6 months ago)
- Topics: nodejs, rtp, typescript
- Language: TypeScript
- Homepage: https://versatica.github.io/rtp.js/
- Size: 3.72 MB
- Stars: 47
- Watchers: 5
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# rtp.js
[![][npm-shield-rtp.js]][npm-rtp.js]
[![][github-actions-shield-rtp.js]][github-actions-rtp.js]
[![][github-actions-shield-docs]][github-actions-docs]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
```text
npm install rtp.js
```## Usage
- [API documentation](https://versatica.github.io/rtp.js)
- All RTP and RTCP classes, types and packet related helpers are exported by the `packets` module:
```ts
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:
```ts
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:
```ts
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:
```ts
// 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
- Iñaki Baz Castillo [[website](https://inakibaz.me)|[github](https://github.com/ibc/)]
- José Luis Millán [[github](https://github.com/jmillan/)]## License
[ISC](./LICENSE)
[npm-shield-rtp.js]: https://img.shields.io/npm/v/rtp.js.svg
[npm-rtp.js]: https://npmjs.org/package/rtp.js
[github-actions-shield-rtp.js]: https://github.com/versatica/rtp.js/actions/workflows/rtp.js.yaml/badge.svg
[github-actions-rtp.js]: https://github.com/versatica/rtp.js/actions/workflows/rtp.js.yaml
[github-actions-shield-docs]: https://github.com/versatica/rtp.js/actions/workflows/docs.yaml/badge.svg
[github-actions-docs]: https://github.com/versatica/rtp.js/actions/workflows/docs.yaml