npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wtfsdp

v1.0.0-pre.1

Published

SDP parser, high level helpers, and explainer

Downloads

9

Readme

WTF SDP

Build Status Code Climate Test Coverage

Motivation

SDP is painful to work with. Really painful, but there are three things that can make it a pleasant experience

  1. A decent, standards compliant parser
  2. An API that allows you to work quicker and at a higher level of abstraction. This should include the ability to search, filter, and serialise the parsed SDP
  3. Some way to understand what those obscure, undocumented, or proprietary lines actually mean. Some way to say WTF SDP?

This module intends to provide all three.

Current status

Parser

It has excellent support for the core RFCs and pretty decent support for various extensions. For example Source-Specific Media Attributes, RTP Header Extensions, and extended RTP Profiles .

Unit tests are in place and coverage is good. We could use more tests covering specific scenarios such as multple streams (Unified Plan and Plan B) and Simulcast.

Currently the parser will only parse a complete, fully-formed SDP. It would be nice if the parser could also parse smaller chunks. E.g. just parse text that represents a Media section.

API

It provides easy access to the common fields (candidates, crypto, direction, ice, etc). Information about each payload is also aggregated together. Extensions, candidates, ssrcs are easily accessible.

See the usage section for examples.

Explain SDP

I haven't begun work on this yet.

Installation

git clone https://github.com/luma/wtfsdp.git
cd wtfsdp
npm link

Usage

Using the high-level API

import { Sdp } from '../src';
const rawSdp = '...';

Sdp.parse(rawSdp).then((sdp) => {
  console.log('Origin:')
  console.log('\tnetType', sdp.origin.netType);             // e.g. 'IN'
  console.log('\taddressType', sdp.origin.addressType);     // e.g. 'IP4'
  console.log('\taddress', sdp.origin.address);             // e.g. '127.0.0.1'

  // Log out the session-level ICE info: ice-pwd, ice-ufrag, ice-lite, ice-mismatch, ice-options
  console.log('ICE:', sdp.ice);

  const bundle sdp.groups.find((group) => group.semantics === 'BUNDLE');
  if (bundle) {
    console.log('Bundled media:', bundle.ids.join(', '));
  } else {
    console.log('Media is not bundled');
  }

  for (const media of sdp.media) {
    console.log(media.type, 'media. Id:', media.id);
    console.log('Port:', media.port, '. Protocol:', media.protocol);

    // Log out the media-level ICE info: ice-pwd, ice-ufrag, ice-options
    // These override any options also defined at the session level.
    console.log('ICE:', sdp.ice);

    for (const [id, payload] of sdp.payloads) {
      console.log('Payload', payload.encodingName);       // e.g. 'opus'
      console.log('Feedback', payload.feedback);          // e.g. [{type: 'transport-cc' }]
      console.log('Params', payload.params);              // e.g. ['minptime=10']
    }
  }
}).catch((err) => {
  if (err.stack) {
    console.error(err.stack);
  } else {
    console.error(err);
  }
});

Using the low-level API

import { parse } from '../src';
const rawSdp = '...';

parse(rawSdp).then((sdp) => {
  // sdp is just a JSON representation of the parsed SDP.
  console.log(JSON.stringify(sdp, null, 2));
}).catch((err) => {
  if (err.stack) {
    console.error(err.stack);
  } else {
    console.error(err);
  }
});

Examples

See the example dir.

You can run the two examples with npm run example and npm run example2.

Common Tasks

  • npm test: run the tests
  • npm run build: build the release library into the lib/ dir
  • npm run doc: generate the docs. They will be placed in the doc/gen/ folder
  • npm run todo: Creates a TODO.md file that lists all the TODOs/FIXMEs/etc in the project

Contributing

See CONTRIBUTING.md

TODO