Set up WebRTC streaming with Wowza Streaming Engine

Want To Try Us Out?

Our trial plan is free, with no obligation or credit card required. Start your free trial and you'll be streaming in minutes!

Start your trial!

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:

1. Configure SSL/TLS encryption for WebRTC


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 need to 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.

You must enable WebRTC signaling for the SSL/TLS host port you configured with your SSL/TLS certificate to support an SDP exchange for the WebRTC session.

The next two tabs describe how to enable WebRTC signaling using either Wowza Streaming Engine Manager or via XML. Select the method that works best for you by toggling the corresponding tab to view the steps.

Wowza Streaming Engine Manager

  1. Click the Server tab, and then click Virtual Host Setup in the contents panel.
  2. On the Virtual Host Setup page, click Edit
  3. Under Host Ports, locate the port you configured for SSL/TLS and click the edit icon.
  4. Ensure that Use WebRTC is selected.

    VHost configuration dialog

  5. Click Apply and then click Save.
  6. Restart the virtual host.

XML

  1. Navigate to [install-dir]/conf/ and open VHost.xml in a text editor.
  2. 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>
  3. Save your changes to VHost.xml.
  4. 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 need to enable WebRTC publishing and playback for your live application. You can accomplish this task using either Wowza Streaming Engine or via XML. Select the method that works best for you by toggling the corresponding tab to view the steps.

Wowza Streaming Engine Manager

  1. Click the Applications tab at the top of the page and then select your live application in the contents panel.
  2. In the contents panel, click WebRTC.
  3. On the Setup tab, click Edit to configure WebRTC.

    WebRTC configuration page
     
  4. Under WebRTC Enabled Features, select the appropriate settings:
    1. Select Publish WebRTC to Wowza Streaming Engine to ingest WebRTC source streams to this application.
    2. Select Play WebRTC from Wowza Streaming Engine to deliver WebRTC content for playback from this application.
    3. Select Query published stream names to enable querying names of published WebRTC streams for this application.
  5. Under ICE Candidate Setup, specify the network connections over which WebRTC communication can occur by clicking Add ICE Candidate and completing the following steps:
    1. Select either 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.
    2. Change the IP address to the publicly-accessible Wowza Streaming Engine server IP address.
       
      Note: IPv6 addresses are not supported for WebRTC ICE candidates.
    3. 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.
    4. Click OK to save your ICE Candidate.
    5. If needed, add additional ICE Candidates, and adjust their preferred order using the Priority up and down arrows.
  6. If you have Publish WebRTC to Wowza Streaming Engine enabled, specify one or more Publish Video Codecs in the preferred order of use:
    1. Click Add Codec, and then select the codec from the drop down list.
    2. If necessary, adjust the order of the video codecs using the Priority up and down arrows.
    3. Click OK to save your Publish Video Codecs priority list.
  7. Click Save and then restart the application.

XML

  1. Open the Application.xml file for your live application ([install-dir]/conf/[application-name]) in a text editor.
  2. 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 vp8vp9, 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.
  3. 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

4a. Publish a test stream over WebRTC

To test publishing a WebRTC stream, you can publish a basic stream, a stream with two composited video inputs with different layouts, or a meeting stream that others can join.

  1. Go to the hosted WebRTC publish test page. From the Publish page, you can publish a basic WebRTC stream.
    • If you want to test compositing two video inputs for your stream, click Composite.
    • If you want to test creating and sharing a meeting stream, click Meeting.
  2. 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 are 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.

  3. Enter an Application Name that matches the WebRTC live application you configured.
  4. For Stream Name, enter a unique name for the stream.
  5. Configure the remaining settings selections as needed and then click Publish or Join to publish a stream to Wowza Streaming Engine:
     
    • Publish page – 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.
       
      Note: After publishing, to share your screen, click the arrow next to the video camera icon, select Screen Share, and then select which content to share. To toggle back to video, click Stop sharing or select a different option under Input Camera.
    • Composite page – To share your screen, under Video Input 1, select Screen Share, and then select which content to share. After selecting your video and audio sources, select a video layout for the test stream.
    • Meeting page – When you are ready to publish, you will click Join. Then, to add additional participants, click Copy config (copy config icon) to copy the configuration settings and share them. Participants must specify a unique Stream Name before joining the meeting.

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.

4b. Play a test stream over WebRTC

  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. Click Play.

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.

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


More resources