Wowza Streaming Engine™ media server software version 4.7.7 and later supports WebRTC streaming. 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 Apple HLS, Adobe HDS, RTMP, RTSP, and Microsoft Smooth Streaming.
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 example WebRTC Application.xml file into your Application.xml file. Optionally, you can also download the WebRTC publish and play examples.
About WebRTC in Wowza Streaming Engine
Wowza Streaming Engine can ingest WebRTC content from desktop browsers that support the WebRTC APIs. These browsers include Mozilla Firefox and Google Chrome.
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 SDP information is formatted as JSON data. The exchange requires that you set up a Wowza Streaming Engine HTTP provider for the connection.
Encryption is required for all components of your 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. You can use a 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:
- Request an SSL certificate for Wowza Streaming Engine from a certificate authority
- Troubleshoot SSL certificate configuration for Wowza Streaming Engine
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.
Note: While Wowza Streaming Engine Transcoder can transcode from WebRTC into other formats, it can't transcode non-WebRTC streams into WebRTC.
Configure WebRTC in Wowza Streaming Engine
WebRTC streaming can't be configured in Wowza Streaming Engine Manager. You must configure it in XML at the VHost and application level.
Configure the HTTP provider
First, configure the HTTP provider to support an SDP exchange for the WebRTC session.
- Navigate to [install-dir]/conf/ and open VHost.xml in a text editor.
- Locate the <HostPort> container for port 443 with SSL and add the following XML snippet as the second-to-last entry in the container of <HTTPProviders>. The new HTTP provider must be the second-to-last provider in the section.
<HTTPProvider> <BaseClass>com.wowza.wms.webrtc.http.HTTPWebRTCExchangeSessionInfo</BaseClass> <RequestFilters>*webrtc-session.json</RequestFilters> <AuthenticationMethod>none</AuthenticationMethod> </HTTPProvider>
- Save your changes to VHost.xml.
Note: The 443 host port with SSL is commented out by default in VHost.xml. When you're ready to stream over WebRTC, comment it back in by removing the lines <!-- 443 with SSL -->, <!--, and --> from around the <HostPort> container.
Configure a live application for WebRTC streaming
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.
Note: These instructions assume a new installation of Wowza Streaming Engine 4.7.7 or later. If you've updated from an earlier version, you must to copy and paste the <WebRTC> container from the example WebRTC Application.xml file into your [install-dir]/conf/[applicationName]/Application.xml file.
- Open [install-dir]/conf/live/Application.xml in a text editor, and configure the following properties in the <WebRTC> container.
Name Type Description EnablePublish Boolean Enables WebRTC publishing to this application. EnablePlay Boolean Enables WebRTC playback from this application. EnableQuery Boolean Enables query of published stream names for this application. IceCandidateIpAddresses String The IP address, transport, and port to use for WebRTC streaming.
For Transmission Control Protocol (TCP), the value should be set to [wowza-streaming-engine-external-ip-address],tcp,[port] where [wowza-streaming-engine-external-ip-address] is the external IP address of the Wowza Streaming Engine instance and [port] is one of the non-SSL-protected streaming HostPort entries defined in [install-dir]/conf/VHost.xml. For example, to stream over port 1935, the entry would be 18.104.22.168,tcp,1935.
For the user datagram protocol (UDP), the value should be [wowza-streaming-engine-external-ip-address],udp where [wowza-streaming-engine-external-ip-address] is the external IP address of the Wowza Streaming Engine instance. The port is dynamically assigned for UDP delivery.
For multiple IP addresses, use a pipe character to separate the lists.
UDPBindAddress String The local IP address of the network card you want to use for WebRTC UDP traffic. (This value is not used if streaming WebRTC over TCP.) For UDP delivery in general, it's OK to leave this property blank. The property is only needed if the server has multiple network interfaces. For some network situations, like running on a cloud instance, a value of 0.0.0.0 would be best instead of the local IP address of the network card to prevent connection problems. PreferredCodecsAudio String A comma-separated list of audio codecs, in order of preference, for stream ingestion. The default is opus,vorbis,pcmu,pcma. PreferredCodecsVideo String A comma-separated list of video codecs, in order of preference, for stream ingestion. The default is vp8,h264. Valid values are vp8, vp9, and h264. If you want to stream in Chrome using VP9, use vp9,vp8,h264. If no value is specified, the WebRTC stream will not be ingested. DebugLog Boolean Enable WebRTC debug logging.
- Optionally, in the [install-dir]/conf/[applicationName]/Application.xml file, add the following property to the <WebRTC> container. Specify the property name, type, and value inside a <Property> element within the <Properties> container.
|webrtcCodecUpdates||Boolean||Set to true to allow codec updates for WebRTC connections to pass through the system. The default value is true. Enabling this property can lead to frequent calls to the onCodecInfoVideo method of the IMediaStreamActionNotify3 interface, depending on the publishing client's source encoder. See Listen for stream events and codec information with the Wowza Streaming Engine Java API.|
Finally, configure the live application's RTP properties.
- Add the following properties to the <RTP> container in the [install-dir]/conf/[applicationName]/Application.xml file.
|rtpForceH264Constraint||Boolean||Set to true to allow the SDP file that is returned to contain different H.264 constraints than the stream contains. In most cases, setting rtpForceH264Constraint to true enables WebRTC to play without issue. The default value is false. Note that Mozilla Firefox and Google Chrome require additional constraint fields to be set.|
|rtpForceH264ConstraintValue||Integer||Use to set the constraint fields. The default value, 192, works in most circumstances. Other valid values are 128, 224, and 240.|
|rtpUseLowestH264Constraint||Boolean||Set to true to compare the initial codec data and the first video unit to the profile data and use the lowest value. Use this or rtpUseHighestH264Constraint to help play the stream when an encoder doesn't send consistent codec information for the stream.|
|rtpUseHighestH264Constraint||Boolean||Set to true to compare the initial codec data and the first video unit to the profile data and use the highest value. Use this or rtpUseLowestH264Constraint to help play the stream when an encoder doesn't send consistent codec information for the stream.|
Note: The rtpUseLowestH264Constraint and rtpUseHighestH264Constraint properties can't be used simultaneously. If both are set to true, rtpUseHighestH264Constraint is used.
Try the WebRTC HTML examples
Note: If you updated to Wowza Streaming Engine 4.7.7 or later, you can download the WebRTC publish and play examples. These files are only included on new installations. Unzip the archive and copy the contents to the [install-dir]/examples/ directory.
Wowza Streaming Engine includes two examples that demonstrate how to use WebRTC with the software:
- Publish example – Shows how to publish a stream to Wowza Streaming Engine using WebRTC. To use this example, the WebRTC application property EnablePublish must be set to true. Change the SDP URL to reflect the domain name of your StreamLock or SSL certificate. This URL is used to exchange SDP information. You can also change the video bitrate, audio bitrate, and frame rate. The frame rate option only works for VP9 and H.264 video codecs when using Chrome version 55.0.1 or later.
- Play example – Shows how to play a stream from Wowza Streaming Engine using WebRTC. To use this example, the WebRTC application property EnablePlay must be set to true. Change the SDP URL to reflect the domain name of your StreamLock or SSL certificate. This URL is used to exchange SDP information.
WebRTC playback and publishing pages must be hosted on a webserver utilizing SSL encryption. If you need to host the HTML examples over HTTPS, you have two options.
First, you can host the HTML examples on your own web server that's secured using HTTPS. To install the examples, copy the contents of the [install-dir]/examples/WebRTC/htdocs/html folder to your web server.
Or, you can host the HTML examples on Wowza Streaming Engine. To do so, follow these steps.
- Navigate to [install-dir]/examples/WebRTC/ and run install.sh (macOS or Linux) or install.bat (Windows).
- Follow the prompts, being sure to replace [streamlock-filename] and [streamlock-password] with your StreamLock file name and password, respectively.
When using Wowza Streaming Engine to host the example files, use the following URL to access them:
For example, if the StreamLock domain name is 123456.streamlock.net, the URL for the publish HTML example would be: