Red5 Pro WebRTC

As of release 2.0.0, Red5 Pro Server includes WebRTC support and front-end integration of the Red5 Pro HTML5 SDK.

WebRTC (Web Real-Time Communication) is supported by the Chrome, Firefox and Opera browsers on desktop. In addition, the Chrome browser on Android supports WebRTC. Safari and Internet Explorer do not support WebRTC (but reportedly, Microsoft Edge does).

Broadcasting/subscribing of WebRTC to WebRTC, WebRTC to HLS, WebRTC to Flash, and Flash to WebRTC are all supported.

Subscribing to a WebRTC publisher using the Red5 Pro Android or iOS SDK client is supported. In addition, subscribing with WebRTC to a stream published with Red5 Pro Android or iOS SDK client is supported.

WebRTC Broadcaster/Subscriber combinations supported, in a nutshell:

  • WebRTC <==> WebRTC
  • WebRTC <==> Flash
  • WebRTC <==> Red5 Pro iOS SDK
  • WebRTC <==> Red5 Pro Android SDK
  • WebRTC ==> HLS

Overview

WebRTC runs on the standard HTTPS port (443). To run Red5 Pro WebRTC server you need to have a valid SSL Certificate for a registered URL. Red5 Pro with SSL walks you through setting up the certificate on your server. Additionally, as with other Red5 Pro server distributions, you will need to install Java (minimum version 8.0).

If you are running the server, without an SSL cert, on your local machine or on a server:

  1. You will be able to publish/subscribe locally (between browsers).
  2. You will be able to subscribe to a stream that is being published from localhost (e.g.: http://localhost:5080/live/broadcast.jsp) from a device within the same network (pointing to the IP address of your machine, not to localhost). To subscribe from a mobile device, either via browser on Android, or via SDK client on iOS or Android, the device must be on the same Wifi network as the desktop.
  3. You will not be able to publish via a WebRTC client that is not local to the machine.

Installing Red5 Pro With WebRTC

We recommend running WebRTC on linux, due to CPU and memory requirements. Please see Installing Red5 Pro on an Ubuntu Linux Server

If you want to run Red5 Pro WebRTC on your windows desktop for development purposes, you will need to install Microsoft Visual Studio redistributables if you don't have Visual Studio on your machine.

Red5 Pro WebRTC Ports

The following Inbound ports need to be open on your server/firewall for Red5 Pro features to work on a WebRTC server using SSL:

Port Description Protocol
22 SSH TCP
80 modified web access of Red5 Pro TCP
443 standard HTTPS port TCP
1935 default Red5 Pro RTMP port TCP
8554 default RTSP port TCP
6262 websockets for HLS TCP
8081 websockets for WebRTC TCP
8083 secure websockets for WebRTC TCP
40000-60000 TURN/STUN/ICE port range UDP

Cloud Hosted Server Settings

Most hosted Virtual Machines will have a private and public IP address assigned to the instance. ICE negotiation can run into problems if the server doesn't know which is which.

Modify red5pro/conf/webrtc-plugin.properties, replacing yourpublic.ip.address.here and local.private.ip.address.here with the server's public and private IP addresses, respectively.

 # Forcing a public IP address
 #force.public.ip=yourpublic.ip.address.here

 # Forcing a private IP address
 #force.local.ip=local.private.ip.address.here

 # Configure port availability checking
 #check.port.availability=true

Amazon Web Services

Because of the specific way that AWS treats private/public IP addresses of its virtual instances, it is sometimes necessary to use a special ICE process for AWS servers.

Modify red5pro/conf/webrtc-plugin.properties, under the # ICE section:

Change the default

org.ice4j.ice.harvest.DISABLE_AWS_HARVESTER=true
org.ice4j.ice.harvest.FORCE_AWS_HARVESTER=false

to:

org.ice4j.ice.harvest.DISABLE_AWS_HARVESTER=false
org.ice4j.ice.harvest.FORCE_AWS_HARVESTER=true

Red5 Pro HTML5 SDK and Examples

You can use the Red5 Pro HTML5 SDK to develop your browser-based application. The Red5 Pro HTML5 Streaming Example App contains a simple project with a number of examples that can be used for testing and reference with the Red5 Pro HTML SDK.

The app is also included as a webapp with the server release for developer testing, and can be accessed at https://<your_server_ip>/webrtcexamples/ (or http://localhost:5080/webrtcexamples/ if you are running the server locally).

You will find some more details on the Red5 Pro HTML5 SDK here.

Failover for Publish and Subscribe

The Red5 Pro broadcaster (https://yourserverurl/live/broadcast.jsp) and subscriber (https://yourserverurl/live/subscribe.jsp) use the Red5 Pro HTML5 SDK which allows for fallback player support. Our examples are programmed with the following default fallback order:

  1. WebRTC
  2. Flash
  3. HLS

You can force the broadcaster to publish with Flash by appending the broadcaster.jsp url with &view=rtmp (e.g.: http://localhost:5080/live/localhost?host=webrtc.red5.org&view=rtmp). You can do the same with the subscriber, but you must use the individual stream's url (e.g.: http://localhost:5080/live/viewer.jsp?host=localhoststream=stream&view=rtmp). If you want to force HLS playback you can do that for the subscriber with &view=hls (e.g.: http://localhost:5080/live/viewer.jsp?host=localhoststream=stream&view=hls).


Troubleshooting

Test Supported Resolutions for your WebCam

Here's a very handly link to test what resolutions your webcam supports: webrtchacks.github.io/WebRTC-Camera-Resolution/

WebRTC Internals - browser diagnostics

This will show you more details on your WebRTC connection, and can help to troubleshoot any issues.

STUN/TURN/ICE

Here's a pretty good explanation of STUN, TURN and ICE.

How to Select WebCam in WebRTC (Chrome)

Firefox will prompt you for permissions to access the camera/microphone - at which time you can select your preferred webcam. In Chrome, you will need to select which camera to use via the camera icon in the address bar.

chromecamera

Cloud Hosted Server Settings (see above)