SDPMIN or session description protocol minifier is a tool that compresses the SDP WebRTC offer to a tiny string that can be stored in a signaling server or even shared over any messaging platform for a server-less approach.
The demo includes a simple playground to showcase the compressing and uncompressing of the SDP offer object.
Just install the sdpmin like this:
npm i sdpmin -D
import { pack, unpack } from "sdpmin";
const packedStr = pack(SDP_STRING); // output: SKk12k3kdDk2Dj21jk31jk23j....
const sdp = unpack(SDP_COMPRESSED_STRING); // output: -o:123123123....
The default version that is exported is v1
. This outputs a safe lossless compression, other version are available can can be imported with VX
prefix e.g:
import { packV0, unpackV0 } from 'sdpmin';
const packedStr = packV0(...);
const sdp = unpakcV0(...)
- v0 - full output without compression.
- v1 - default lossless compression.
- v2* - (TODO) Smaller bundle size & lossless compression.
- v3* - (TODO) Aggressive compression that is lossy.
Check the Demo above for examples outputs.
To start the playground locally install dependencies and run start.
npm ci && npm run start
If you have a suggestion that would make this better, please create an issues first. Upon discussed you can fork the repo and create a pull request. Don't forget to give the project a star! Thanks again!
- NodeJS 12
const sdpmin = require('sdpmin');
const str = sdpmin.pack(...);
- React / Angular / Vue / etc.
import { pack, unpack } from "sdpmin";
The MIT License (MIT)
Copyright (c) 2014 Shane Tully
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.