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 WebRTC supporting players.
It can also transmux or transcode WebRTC to other streaming protocols, including HLS, MPEG-DASH, RTMP, and RTSP. 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). This article focuses on how to both publish and play a stream over WebRTC.
Note: 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 or later to capitalize on expanded functionality and enhancements to publisher reliability.
Video tutorial: Using WebRTC with Wowza Streaming Engine
See how to configure Wowza Streaming Engine to publish and play streams over WebRTC.
Before you start
You should complete the following tasks:
- Create a live application according to Create applications.
- Review the supported codecs, browsers, and workflows for publishing and playing WebRTC streams in About WebRTC workflows in Wowza Streaming Engine.
- Obtain an SSL/TLS certificate and configure Wowza Streaming Engine to use it. We recommend using the free Wowza StreamLock certificate service described in the Get SSL/TLS certificates from the Wowza Streaming Engine StreamLock service article.
Note: If you plan to use your own SSL/TLS certificate instead, the following resources may help you convert your 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.
1. Configure SSL/TLS encryption for WebRTC
Encryption is required for all components of the WebRTC workflow. For WebRTC publishing and playback, you must have a secure HTTP (HTTPS) connection to a web camera. Due to cross-domain issues, you must configure an SSL/TLS certificate to secure the connection between the browser and Wowza Streaming Engine for the SDP data exchange and enable WebRTC signaling for the SSL/TLS host port.
To support an SDP exchange for the WebRTC session, you must enable WebRTC signaling for the SSL/TLS host port you configured with your SSL/TLS certificate.
The next two tabs describe how to enable WebRTC signaling using either Wowza Streaming Engine Manager or via XML. To view the steps, toggle between the tabs and select the best method for you.
Wowza Streaming Engine Manager
- Click the Server tab, and then click Virtual Host Setup in the contents panel.
- On the Virtual Host Setup page, click Edit.
- Under Host Ports, locate the port you configured for SSL/TLS and click the edit icon.
- Ensure that Use WebRTC is selected.
- Click Apply and then click Save.
- Restart the virtual host.
XML
- Navigate to [install-dir]/conf/ and open VHost.xml in a text editor.
- Locate the <HostPort> container for the port you configured for SSL/TLS and add the following <HTTPProvider> as the second-to-last entry in the <HTTPProviders> container element. 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.
- Restart Wowza Streaming Engine.
Note: The 443 host port with SSL/TLS 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.
2. Configure WebRTC publishing and playback
After enabling SSL/TLS for WebRTC streaming, you must enable WebRTC publishing and playback for your live application. You can accomplish this task using either Wowza Streaming Engine or via XML. To view the steps, toggle between the tabs and select the best method for you.
Wowza Streaming Engine Manager
- Click the Applications tab at the top of the page and then select your live application in the contents panel.
- In the contents panel, click WebRTC.
- On the Setup tab, click Edit to configure WebRTC.
- Under WebRTC Enabled Features, select the appropriate settings:
- Select Publish WebRTC to Wowza Streaming Engine to ingest WebRTC source streams to this application.
- Select Play WebRTC from Wowza Streaming Engine to deliver WebRTC content for playback from this application.
- Select Query published stream names to enable querying names of published WebRTC streams for this application.
- Under ICE Candidate Setup, specify the network connections over which WebRTC communication can occur by clicking Add ICE Candidate and completing the following steps:
- Select UDP (recommended) or TCP as the ICE candidate transport protocol.
Notes:
- Firefox requires UDP. TCP is not supported.
- If you use UDP ICE candidates, enabling NACK messages is recommended to allow for retransmission of lost packets. See the optional RTP properties in Configure custom WebRTC properties for information about how to enable NACK.
- At this time, full session traversal utilities for NAT (STUN) negotiation aren't supported. Currently, Wowza Streaming Engine only supports traversal of symmetric NATs. A single STUN transport configuration (TCP or UDP) must be used. TURN servers are not supported at this time.
- Change the IP address to the publicly accessible Wowza Streaming Engine server IP address.
Note: IPv6 addresses are not supported for WebRTC ICE candidates.
- For TCP candidates, you must specify a port to use for WebRTC streaming. The default streaming port for Wowza Streaming Engine is 1935. For UDP candidates, the port is dynamically assigned.
Note: Port 554 isn't supported for TCP ICE candidates. See WebRTC port configuration for more information about WebRTC ports.
- Click OK to save your ICE Candidate.
- If needed, add additional ICE Candidates, and adjust their preferred order using the Priority up and down arrows.
- Select UDP (recommended) or TCP as the ICE candidate transport protocol.
- If you have Publish WebRTC to Wowza Streaming Engine enabled, specify one or more Publish Video Codecs in the preferred order of use:
- Click Add Codec, and then select the codec from the dropdown list.
- If necessary, adjust the order of the video codecs using the Priority up and down arrows.
- Click OK to save your Publish Video Codecs priority list.
- Click Save and then restart the application.
XML
- Open the Application.xml file for your live application ([install-dir]/conf/[application-name]) in a text editor.
- In the <WebRTC> container element, configure the following properties:
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 copy and paste the <WebRTC> container from the sample WebRTC Application.xml file into your Application.xml file.
Name Type Description EnablePublish Boolean Set to true to enable WebRTC publishing to this application. EnablePlay Boolean Set to true to enable WebRTC playback from this application. EnableQuery Boolean Set to true to enable querying of published stream names for this application. IceCandidateIpAddresses String The IP address, transport, and port to use for WebRTC streaming.
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 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/TLS-protected streaming HostPort entries defined in [install-dir]/conf/VHost.xml. For example, to stream over port 1935, the entry would be 66.175.168.127,tcp,1935.
For multiple IP addresses, use a pipe character to separate the lists.
Notes:
- IPv6 addresses are not supported for WebRTC ICE candidates.
- Firefox requires UDP. TCP is not supported.
- Port 554 isn't supported for TCP ICE candidates. See WebRTC port configuration for more information about WebRTC ports.
- If you use UDP ICE candidates, enabling NACK messages is recommended to allow for retransmission of lost packets. See the optional RTP properties for information about how to enable NACK.
- At this time, full session traversal utilities for NAT (STUN) negotiation aren't supported. Currently, Wowza Streaming Engine only supports traversal of symmetric NATs. A single STUN transport configuration (TCP or UDP) must be supplied using IceCandidateIpAddresses. TURN servers are not supported at this time.
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 okay 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,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 Set to true to enable WebRTC debug logging. - Save your changes and then restart Wowza Streaming Engine.
After setting up WebRTC publishing and playback, you can optionally configure custom WebRTC properties or configure transcoding if needed.
Note: We recommend disabling B-frames for WebRTC streams. With Wowza Streaming Engine 4.8.14 and later, the Transcoder adds B-frames by default. To disable B-frames, see Configure B-frame generation in Wowza Streaming Engine.
3. (Optional) Configure custom WebRTC properties
After enabling WebRTC publishing and playback for your live application, you can optionally configure additional WebRTC functionality around FIR and NACK messages, handling out-of-order and retransmitted packets, packet loss, SDP playback compatibility, and more.
4. 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.
WebRTC test page requirements
- Wowza Streaming Engine – version 4.8.5 or later
- Browsers – latest version of Chrome, Firefox, Safari, and Microsoft Edge version 79 and later. There is a resolved known issue with publishing and playing WebRTC streams using Safari on iOS 15. See WebRTC publishing and playback fails with Safari on iOS 15 for updates.
- Screen share – not supported on mobile devices, Safari, or Firefox
Publish a test stream over WebRTC
To test publishing a WebRTC stream, you can publish a basic stream, a stream with two composite video inputs with different layouts, or a meeting stream that others can join. Switch between the tabs in the following instructions to see the steps for each workflow.
Publish
From the Publish page, you can test and publish a basic WebRTC stream.
- Go to the hosted WebRTC publish test page.
- For Signaling URL, enter the secure WebSocket URL to connect to the Wowza Streaming Engine WebRTC sessions listener in the following format:
wss://[ssl-certificate-domain-name]:[SSL-port-number]/webrtc-session.json
where ssl-certificate-domain-name is the secure domain name for your Wowza Streaming Engine instance. If you're connecting WebRTC sessions using a port other than the default SSL/TLS port 443, you must include that non-standard port in the URL. If using Wowza StreamLock and the default SSL/TLS port (443), for example, the Signaling URL looks something like this: wss://5ab4321c0d123.streamlock.net/webrtc-session.json.
- Enter an Application Name that matches the WebRTC live application you configured.
- For Stream Name, enter a unique name for the stream.
- Configure the remaining settings as needed.
- Then click Publish to publish a stream to Wowza Streaming Engine.
Notes:
- 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.
- After publishing, click the arrow next to the video camera icon to share your screen. Then, select Screen Share and pick which content to share. To toggle back to video, click Stop sharing or select a different option under Input Camera.
- To test publishing from a different browser or with a different device, click Copy config () to copy the configuration settings and share them.
Composite
From the Composite page, you can test and publish two video inputs from your stream. See Use the WebRTC composite example page for a video tutorial and more information.
- Go to the hosted WebRTC composite test page.
- For Signaling URL, enter the secure WebSocket URL to connect to the Wowza Streaming Engine WebRTC sessions listener in the following format:
wss://[ssl-certificate-domain-name]:[SSL-port-number]/webrtc-session.json
where ssl-certificate-domain-name is the secure domain name for your Wowza Streaming Engine instance. If you're connecting WebRTC sessions using a port other than the default SSL/TLS port 443, you must include that non-standard port in the URL. If using Wowza StreamLock and the default SSL/TLS port (443), for example, the Signaling URL looks something like this: wss://5ab4321c0d123.streamlock.net/webrtc-session.json.
- Enter an Application Name that matches the WebRTC live application you configured.
- For Stream Name, enter a unique name for the stream.
- Select video inputs from the Video Input 1 and Video Input 2 dropdowns. To share your screen, you can select the Screen Share option and specify which content to share.
- After selecting your video and audio sources, select a video layout for the test stream.
- Click Publish to publish a stream to Wowza Streaming Engine.
- To test publishing from a different browser or with a different device, click Copy config () to copy the configuration settings and share them.
Meeting
From the Meeting page, you can create and share a meeting stream.
- Go to the hosted WebRTC meeting test page.
- For Signaling URL, enter the secure WebSocket URL to connect to the Wowza Streaming Engine WebRTC sessions listener in the following format:
wss://[ssl-certificate-domain-name]:[SSL-port-number]/webrtc-session.json
where ssl-certificate-domain-name is the secure domain name for your Wowza Streaming Engine instance. If you're connecting WebRTC sessions using a port other than the default SSL/TLS port 443, you must include that non-standard port in the URL. If using Wowza StreamLock and the default SSL/TLS port (443), for example, the Signaling URL looks something like this: wss://5ab4321c0d123.streamlock.net/webrtc-session.json.
- Enter an Application Name that matches the WebRTC live application you configured.
- For Stream Name, enter a unique name for the stream.
- Select options from the Input Camera and Input Microphone dropdowns.
- When you are ready to publish, click Join.
- To add additional participants, click Copy config () to copy the configuration settings and share them. Participants must specify a unique Stream Name before joining the meeting.
Play a test stream over WebRTC
Use these steps after you've completed the directions in the previous section, and you've published a test stream over WebRTC.
- In a new browser tab, go to the hosted WebRTC play test page.
- Enter the same Signaling URL, Application Name, and Stream Name that you entered on the Publish page.
- If you've set up SecureToken playback security protection, add these values in the Secure Token Data section:
- Shared Secret: Required when using a security token to protect content against spoofing threats. This value should match the Shared Secret from the Playback Security page of your live application.
- Token Timeout: This value is optional. It specifies the time in UTC seconds from the current time when SecureToken playback security stops.
- Hash Query Parameter Prefix: Defaults to wowzatoken. This value corresponds to the Hash Query Parameter Prefix value on the Playback Security page of your live application in Wowza Streaming Engine. If you changed this value there, you must update it on the WebRTC play test page.
- Include Client IP Address: This value is optional. It corresponds to the Include client IP address in hash generation checkbox on the Playback Security page of your live application in Wowza Streaming Engine. When this additional security option is enabled, a unique hash is generated for each connecting client.
- Client IP Address: This value is required when the Include Client IP Address checkbox is selected. To get the client's IP address, you can use the What is my IP address site.
- Click Play to view the test WebRTC stream.
- To test playback in a different browser or with a different device, click Copy config () to copy the configuration settings and share them.
Tip: When you're ready to implement WebRTC for production, consider using the Wowza Flowplayer Real-Time Streaming (WebRTC) plugin for playback. You can purchase Wowza Flowplayer and use it with Wowza Streaming Engine for playback.
Note: To test playback over other protocols, enable other playback protocols for the application you configured for WebRTC by clicking the Setup tab for your application and enabling any of the protocols listed under Playback Types. Then, you can use the playback URL for the protocol you want to test with the player of your choice or the Video Test Players webpage.
Next steps
For more advanced WebRTC learning and testing, we provide WebRTC examples on GitHub that demonstrate how to publish and play WebRTC streams with Wowza Streaming Engine. For more information, see Use WebRTC example pages with Wowza Streaming Engine.
More resources
- Ingest RTSP, SRT, or RTMP streams into Wowza Streaming Engine for playback with WebRTC
- Control access to WebRTC publishing and playback
- Record WebRTC streams with Wowza Streaming Engine
- Tune Wowza Streaming Engine for WebRTC optimal performance
- Protect streaming using SecureToken in Wowza Streaming Engine