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

@eyevinn/whip-endpoint

v1.6.1

Published

WebRTC HTTP ingestion protocol endpoint

Downloads

96

Readme

WHIP Endpoint

An NPM library containing a WebRTC ingest server that implements the WebRTC HTTP Ingestion Protocol (WHIP).

The library includes the following WHIP destinations:

  • A dummy receiver
  • An SFU broadcaster
  • An RTSP restreaming output

Setup

npm install --save @eyevinn/whip-endpoint

Options

Available WHIP endpoint options are:

{
  port: number, // port to bind to
  extPort: number, // port that is exposed in public (default same as port)
  interfaceIp: string, // ip to bind and listen on
  hostname: string, // hostname or public IP
  https: boolean, // use https
  tls: { key: string, cert: string }, // key and cert for TLS termination (optional),
  iceServers: [ { urls: string, username?: string, credential?: string }], // list of STUN/TURN servers
  enabledWrtcPlugins: string[], // list of plugins to enabled. Available are "sfu-broadcaster", "rtsp", "rtmp"
  resourceManager: {uri: string, territoryCode: string}, // Uri to Resource Manager & territory code, e.g "SE". Both must be set to use a resource manager. (optional)
}

The included plugins then provides the following endpoints:

  • sfu-broadcaster: http://<whiphost>:8000/api/v2/whip/sfu-broadcaster?channelId=<channelId>
  • rtsp: http://<whiphost>:8000/api/v2/whip/rtsp
  • rtmp: http://<whiphost>:8000/api/v2/whip/rtmp

Server Reference Implementation

Start a refererence implementation built on this WHIP endpoint library.

npm run build
npm run server

Environment variables

The following environment variables are read to override default values:

  • ICE_GATHERING_TIMEOUT: (default: 4000 ms): Timeout for gathering all ICE candidates
  • API_KEY: Authorization key that clients must use to get ICE server config on OPTIONS request
  • SFU_CONFIG_FILE: Used to configure the path to the local json file. Default value is ../../sfu-config.json.
  • RESOURCE_MANAGER_URL: URI to resource manager API. If not set, application will import sfu config data from local json.
  • WHIP_SERVER_TERRITORY: The territory of the application, using two-lettered country codes. E.g SE or DK.

Usage (WebRTC Broadcasting)

Start a WHIP endpoint on port 8000 and register a WebRTC SFU broadcaster client that creates the channels on the egress endpoint. Example using @eyevinn/wrtc-egress library as Egress endpoint and Symphony Media Bridge as origin and edge media server (SFU).

import { WhipEndpoint } from "@eyevinn/whip-endpoint";

const endpoint = new WhipEndpoint({ 
  port: 8000, 
  hostname: "<whiphost>",
  https: false,
  iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
  enabledWrtcPlugins: [ "sfu-broadcaster" ], 
});

endpoint.setOriginSfuUrl("http://<sfu-origin>/conferences/");
endpoint.registerBroadcasterClient({
  client: new BroadcasterClient("http://<wrtc-egress-endpoint>/api"), 
  sfuUrl: "http://<sfu-edge>/conferences/"
});
endpoint.setSfuApiKey(string | undefined);
endpoint.listen();

The WHIP endpoint for the sfu-broadcaster is then available on http://<whiphost>:8000/api/v2/whip/sfu-broadcaster?channelId=<channelId> and this is where you will point your WHIP compatible producer to this endpoint. Then you can access the channel using the provided protocol that the Egress endpoint provides.

For example using the WebRTC HTTP Egress Protocol (WEPP) and the channel url http://<wrtc-egress-endpoint>/whep/channel/<channelId>. The Eyevinn WebRTC Player has built-in support for WHEP and can be used to try this out.

TLS Termination example

If you want to use TLS termination you provide the tls object containing key and cert. The https option must be set to true.

const endpoint = new WhipEndpoint({ 
  port: 443, 
  hostname: "whip.lab.eyevinn",
  https: true,
  tls: {
    key: fs.readFileSync("./server-key.pem"),
    cert: fs.readFileSync("./server-cert.pem"),
  },
  iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
  enabledWrtcPlugins: [ "sfu-broadcaster" ], 
});

// ...

Resource Manager example

If you want to use a Resource Manager; Provide a uri and a two lettered territoryCode to resourceManager.

const endpoint = new WhipEndpoint({ 
  port: 8000
  hostname: "whip.lab.eyevinn",
  iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
  enabledWrtcPlugins: [ "rtsp", "rtmp", "sfu-broadcaster" ], 
  resourceManager: {uri: "http://127.0.0.1:8080", territoryCode: "SE"}
});

// ...

RTSP output

By default it will restream a WHIP stream to an RTSP server (TCP) running on localhost. If you want to change this you can override this setting by setting the environment variable RTSP_SERVER to for example RTSP_SERVER=rtsp://lab.eyevinn:8554. If you want to run an RTSP server locally you can use the provided docker-compose file rtsp-server.yml.

docker-compose -f rtsp-server.yml up -d

To play the RTSP stream you can for example use ffplay:

ffplay rtsp://lab.eyevinn:8554/<uuid4>

Default output resolution is 960x540 but this can be overriden by setting the environment variable RTSP_RESOLUTION to for example RTSP_RESOLUTION=1920x1080.

About Eyevinn Technology

Eyevinn Technology is an independent consultant firm specialized in video and streaming. Independent in a way that we are not commercially tied to any platform or technology vendor.

At Eyevinn, every software developer consultant has a dedicated budget reserved for open source development and contribution to the open source community. This give us room for innovation, team building and personal competence development. And also gives us as a company a way to contribute back to the open source community.

Want to know more about Eyevinn and how it is to work here. Contact us at [email protected]!