Red5 Pro WebRTC
As of Red5 Pro 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. With iOS 11 and Mac High Sierra, Safari also supports WebRTC (older versions of MacOS and iOS will fall back to HLS). Microsoft Edge support was added with Red5 Pro Release 5.4.0.
Internet Explorer does not support WebRTC.
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:
- You will be able to publish/subscribe locally (between browsers).
- 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 a browser on Android or via SDK client on iOS or Android, the device must be on the same Wifi network as the desktop.
- You will not be able to publish via a WebRTC client that is not local to the machine.
- Note that some browsers have become more strict and will no longer allow insecure WebRTC publishing or subscribing, even on localhost.
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.
If you want to run Red5 Pro WebRTC on your MacOS desktop for development purposes, you may need to install sdl_image. From a terminal window: brew install sdl_image
.
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 |
5080 | default web access of Red5 Pro; Websockets for WebRTC | TCP |
443 | modified https access of Red5 Pro; secure websockets for WebRTC | TCP |
1935 | default Red5 Pro RTMP port | TCP |
8554 | default RTSP port | TCP |
6262 | websockets for HLS | TCP |
8081 | websockets for WebRTC (severs earlier than 5.4.0) | TCP |
8083 | secure websockets for WebRTC (severs earlier than 5.4.0) | TCP |
40000-65535 | TURN/STUN/ICE port range for WebRTC | 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
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:
- WebRTC
- Flash (RTMP)
- 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.