Set up WebRTC streaming with Wowza Streaming Engine

Wowza Streaming Engine™ media server software version 4.7.7 and later supports WebRTC streaming, however, we recommend that you update to version 4.8.5 and later to capitalize on expanded functionality and enhancements to publisher reliability. WebRTC is a free, open-source project that enables real-time communication of audio, video, and data in web browsers and mobile applications. Wowza Streaming Engine can ingest source WebRTC audio and video content and deliver it to supporting players. It can also transmux or transcode WebRTC to other streaming protocols, including HLS, HDS, RTMP, RTSP, and Microsoft Smooth Streaming. In addition, Wowza Streaming Engine can ingest a non-WebRTC source stream and play it back with WebRTC or WebRTC plus other scalable HTTP-based streaming protocols like HLS. In this article, learn how to set up WebRTC streaming using Wowza Streaming Engine XML configuration files.

Note: This article assumes a new installation of Wowza Streaming Engine 4.7.7 or later. If you've updated from an earlier version, you must copy and paste content from the sample WebRTC Application.xml file into your Application.xml file.

About WebRTC in Wowza Streaming Engine


Wowza Streaming Engine can ingest WebRTC content from mobile and desktop browsers that support the WebRTC APIs. Supported browsers include the latest versions of Chrome, Firefox, and Safari, as well as Edge version 79 and later. SSL/TLS encryption is required for the WebRTC workflow.

When ingesting source content as WebRTC, Wowza Streaming Engine uses a WebSocket connection to the browser to retrieve the Session Description Protocol (SDP) information. This signaling exchange requires that you set up a Wowza Streaming Engine HTTP provider for the connection. 

Once it's in Wowza Streaming Engine, the WebRTC content can be delivered to viewers as is, or it can be transcoded or transmuxed to other formats for delivery. 

Configure SSL/TLS encryption for Wowza Streaming Engine


Encryption is required for all components of the WebRTC workflow. You must have a secure HTTP (HTTPS) connection to a web camera for WebRTC publishing and playback. As a result, due to cross-domain issues, you'll need to configure an SSL certificate to secure the connection between the browser and Wowza Streaming Engine for the SDP data exchange.

We recommend the free Wowza StreamLock certificate to secure this connection. The instructions in this article assume you've configured port 443 with an SSL certificate.

If you plan to use your own SSL certificate, the following resources may help you convert your SSL certificate to the Java KeyStore (JKS) format that's required by Wowza Streaming Engine. Although it's possible to use self-signed certificates with WebRTC, note that you must ensure the browser you're using to test accepts traffic encrypted with any self-signed certificates in use.

Configure WebRTC in Wowza Streaming Engine


You can configure WebRTC streaming in XML files at the VHost and application level. For instructions using Wowza Streaming Engine Manager to configure WebRTC instead, see Set up WebRTC streaming with Wowza Streaming Engine Manager.

Configure the HTTP provider

You must configure the HTTPWebRTCExchangeSessionInfo HTTP provider to support an SDP exchange for the WebRTC session.

Configure a live application

After the HTTP provider is added to your VHost.xml file, configure a live application for WebRTC streaming. This example uses the live application that's included in the default Wowza Streaming Engine installation.

Test the WebRTC workflow


In production environments, WebRTC playback and publishing pages must be hosted on a web server utilizing SSL/TLS encryption. For testing and learning purposes, Wowza provides hosted WebRTC test pages for publish and playback so you can see WebRTC in action more quickly. 

Notes:
  • Wowza Streaming Engine 4.8.5 or later is required for the hosted WebRTC publish and playback test pages.
  • You can use the the Wowza hosted WebRTC test pages with the latest version of Chrome, Firefox, Safari, and Microsoft Edge version 79 and later.

Publish a test stream to Wowza Streaming Engine

  1. Go to the hosted WebRTC publish test page.
  2. In the Signaling URL field, enter the secure WebSocket URL to connect to the Wowza Streaming Engine WebRTC sessions listener: 
    wss://[ssl-certificate-domain-name]/webrtc-session.json
    where ssl-certificate-domain-name is the secure domain name for your Wowza Streaming Engine instance.

    If using Wowza StreamLock, for example, the Signaling URL looks something like this:
    wss://5ab4321c0d123.streamlock.net/webrtc-session.json

    If you are connecting WebRTC sessions using a port other than the standard SSL/TLS port 443, you must include that non-standard port in the Signaling URL:
    wss://5ab4321c0d123.streamlock.net:[SSL-port-number]/webrtc-session.json
  3. Enter an Application Name that matches the WebRTC live application you configured.
  4. For Stream Name, enter a name for the stream, such as myStream.
  5. Configure the remaining settings selections, as needed.
     
    Note: The frame rate and frame size settings constrain the camera and microphone input and aren't included in the SDP provided to Wowza Streaming Engine. The browser may adjust the frame rate to accommodate changes in network conditions.
  6. To publish an example WebRTC stream from this page into Wowza Streaming Engine, click Publish.
  7. To test publishing from a different browser or with a different device, click Copy config (copy config icon) to copy the configuration settings and share them.

Play a test stream from Wowza Streaming Engine

  1. In a new browser tab, go to the hosted WebRTC play test page.
  2. Enter the same Signaling URL, Application Name, and Stream Name that you entered on the Publish page.
  3. To play the example WebRTC stream from Wowza Streaming Engine, click Play.
  4. To test playback in a different browser or with a different device, click Copy config (copy config icon) to copy the configuration settings and share them.

For more advanced learning and testing, Wowza Media Systems provides WebRTC examples on GitHub that demonstrate how to publish and play WebRTC streams with Wowza Streaming Engine. See Use WebRTC example pages with Wowza Streaming Engine.

About port configuration for WebRTC


When configuring Wowza Streaming Engine to ingest or play streams with WebRTC, you must ensure that certain ports are accessible for client connections. 

Note: Publishing or playing WebRTC streams on a device with an endpoint security platform enabled may result in decreased video performance. During a deep packet inspection (DPI) process, the endpoint protection platform de-encrypts and then re-encrypts each AES-encrypted packet, which can cause packet delays and stuttering. To address this issue, configure your endpoint security platform to ensure that traffic over the following ports is available without deep packet inspection.

See Troubleshoot network errors for information about troubleshooting port configurations.

Port Type Description
443 TCP During the WebRTC signaling process, Wowza Streaming Engine uses a secure WebSocket connection to establish a connection between peers. This requires a port for encrypted connections using SSL/TLS. By default, port 443 is used. The SSL/TLS port is defined in a HostPort entry in [install-dir]/conf/VHost.xml.
6970 to 9999 UDP For WebRTC over UDP, Wowza Streaming Engine uses a default port range of 6970 to 9999. UDP ports are assigned dynamically, and each additional peer WebRTC connection increments the port number used. The starting port number is controlled by the DatagramStartingPort value specified in [install-dir]/conf/Server.xml.
1935 TCP For WebRTC over TCP, Wowza Streaming Engine uses a non-SSL-protected streaming port for TCP-level connections. The TCP port is defined in a HostPort entry in [install-dir]/conf/VHost.xml. By default, port 1935 is used. TCP ports are referenced in the IceCandidateIpAddresses property in [install-dir]/conf/[applicationName]/Application.xml.
9443 (optional) TCP If you choose to use Wowza Streaming Engine to host WebRTC example pages, you must define port 9443 in a HostPort entry in [install-dir]/conf/Vhost.xml. Alternatively, you can host WebRTC example pages via HTTPS on any web server with SSL/TLS encryption.

More resources