WebRTC based distribution with WHIP and WHPP running on AWS Fargate

Eyevinn Technology
5 min readSep 1, 2022

We have in a previous blog post described our proof-of-concept of a standardized WebRTC based streaming for broadcast. Using WebRTC HTTP Ingest Protocol (WHIP) as ingest protocol and the proposed WebRTC HTTP Playback Protocol (WHPP) as consumption protocol. In this blog post we will walk through how you can setup WebRTC based distribution based on the open source components made available from the proof-of-concept. We will be hosting the solution on Amazon Web Services using a combination of ECS on Fargate and AWS EC2 (or on prem).

A WebRTC based client will initiate a handshake using the HTTP based protocol WHIP. The WHIP endpoint will allocate a session on a Selective Forwarding Unit (SFU) and the actual media is transported from the client to the SFU using UDP/SRTP. The WHIP endpoint is responsible for the signaling and no media traffic is sent through this endpoint. Similar when a player wants to start consuming a channel it will initiate a handshake using the HTTP based protocol WHPP. The WHPP endpoint then provides the player with the information needed to establish a connection with the SFU. And here the media is transported from the SFU to the player using UDP/SRTP.

As both the WHIP endpoint and the WHPP endpoint only serves HTTP traffic we can run this on a container based serverless infrastructure. In this example we will be using Amazon ECS with Fargate but nothing prevents us from having the same setup on another cloud platform provider. Nothing is really AWS specific here as it all is container based.

The SFU will be running on an EC2 instance or on a dedicated hardware in a server hall. The SFU instance will need to be accessible on UDP for all ports.

Install and setup SFU

As SFU we will be using Symphony Media Bridge and we have prepared a Docker container that can be used[1]. Important here is that the container needs to be run in host-mode and thus necessary to run it on a Linux server where host-mode is supported by the Docker engine. The following docker-compose template can be used to get it up and running:

version: "3.7"services:
sfu:
image: eyevinntechnology/wrtc-sfu:latest
restart: always
network_mode: "host"
cap_add:
- SYS_NICE
ulimits:
rtprio: 99
environment:
- HTTP_PORT=8180
- UDP_PORT=0
logging:
driver: "local"
options:
max-size: 10m

Once up and running it will with the above configuration provide a management API on port 8180. This will be used by the WHIP and WHPP endpoints that we will setup.

Setup WHIP endpoint task

Next step is to setup the WHIP endpoint task on ECS. Based on the NodeJS library @eyevinn/whip-endpoint we have a container image[2] that can be used. Setup an ECS task that will be running the container image eyevinntechnology/wrtc-origin:latest and we also need to set the following environment variables:

  • PORT=8000 : the HTTP port exposed for the service
  • EXT_PORT=443 : the announced HTTP port and as we will use HTTPS termination with AWS Elastic Loadbalancer we will set this to 443
  • SMB_URL=http://<sfu>:8180/conferences/ : The URL to the management API for the SFU
  • HOSTNAME=<whip-host> : The announced hostname for the WHIP endpoint
  • WHPP_API_URL=https://<whpp-host>/api : The URL for the management API for the WHPP endpoint
  • WHPP_EGRESS_URL=https://<whpp-host>/whpp : The URL for which the player will access to initiate the playback

To setup the AWS ELB to expose this task to the Internet is left as an exercise to the reader.

Setup WHPP endpoint task

Next step is to setup the WHPP endpoint. As WHPP is not yet an established egress protocol and there are other initiatives and proposals recently published we have developed and made available a generic egress endpoint library[3]. It currently supports WHPP but can easily be extended to other HTTP egress signaling protocols. In this example we will be using WHPP though as we can use the WHPP based player available already[4].

For this we also have a container image[5] ready that you can use. Setup the task to be running the container eyevinntechnology/wrtc-whpp:latest and set the following environment variables:

  • PORT=8000 : the HTTP port exposed for the service
  • EXT_PORT=443 : the announced HTTP port and as we will use HTTPS termination with AWS Elastic Loadbalancer we will set this to 443
  • HOSTNAME=<whpp-host> : The announced hostname for the WHPP endpoint
  • SMB_URL=http://<sfu>:8180/conferences/ : The URL to the management API for the SFU

Then setup the AWS ELB to expose this task to the Internet with HTTPS.

Testing end-to-end

To test this end to end you can use the web-based WHIP client available at https://web.whip.eyevinn.technology and point to the endpoint at https://<your-whip-endpoint>/api/v1/whip/sfu-broadcaster?channelId=test

Then go to https://webrtc.player.eyevinn.technology and use the playback URL https://<your-whpp-endpoint>/whpp/channel/test

Regarding WHEP vs WHPP: When we started looking into dividing a WebRTC based broadcast streaming (1 to many) pipeline into ingest, distribution and playback we quickly identified that there was no standard protocol on the playback side available. To fill this gap, we developed and proposed a standard we called WebRTC HTTP Playback Protocol (WHPP). We made it available for comments this spring and presented it at Streaming Tech Sweden 2022 in the beginning of June.

As some of you might have seen a standard called WebRTC HTTP Egress Protocol (WHEP) was drafted and made available in the beginning of August, and that confirms our belief that there is a need to fill this gap.

From Eyevinn’s perspective the name of this standard is not important, and we have provided the WHEP authors with our feedback based on our experiences from our proof-of-concepts and WHPP. Whether it will be on WHEP or WHPP, we will continue our work with our proof-of-concepts and contributing back to the community with knowledge and open-source tools in this area.

Eyevinn Technology is vendor independent specialists in video technology, video development and sustainable streaming. Proud organizer of the yearly nordic conference Streaming Tech Sweden.

--

--

Eyevinn Technology

We are consultants sharing the passion for the technology for a media consumer of the future.