Flussonic Media Server documentation

Contents

Using WebRTC for Video Playback from Flussonic Media Server

WebRTC

WebRTC is a P2P protocol of communication between two clients over an already established connection. For example, to communicate with each other by WebRTC, two browsers need to be connected by opening the same website in the Internet. Connection can also be established by means of a mediator, so called signaling server.

So there are two clients and a signaling server, that connects these clients. Before starting to transmit video data, the clients need to establish the connection. To do so, they exchange data of two types about the connection:

  • Textual descriptions of media streams in the SDP format
  • ICE Candidates as part of an SDP

The signaling server (the mediator) makes it possible to transfer the data about the connection from one client to the other.

About playback via WebRTC from Flussonic

Flussonic Media Server uses WebRTC for playback a media stream from Flussonic (the source) to a client device or app (the recipient). Flussonic also acts as the signaling server during connection establishment to exchange data about the connection.

Why do we use WebRTC to send media data between clients? Because with the WebRTC mechanism we can provide ultra-low latency.

Therefore, the exchange of video via Flussonic cannot be called peer-to-peer; rather, we call it video publication to Flussonic Media Server via WebRTC and video playback via WebRTC.

The diagram shows the process of initiating the connection between Flussonic and a client device, for playback:

WebRTC Playback

How to organize the playback of pubished streams via WebRTC

Parties should exchange SDPs via the mediator (signaling server - Flussonic), and then start the direct data transfer. In the case of video playback, it's the Flussonic server (video source) that initiates the process and sends an SDP offer.

Connection is established via WebSocket, and then video is transferred via RTP.

The code must be run on the client side that plays video from the published stream. To write the code, use the Flussonic WebRTC player library. The description of the library classes and the example code can be found at npm.

On the Flussonic server, a published stream must be configured where clients can publish video and from where we will take it. You will use the URL of this stream in the code (the ws and wss protocols are supported).

stream STREAMNAME {
  url publish://;
}

To play a stream correctly in Safari, you must allow access to the camera and microphone because iOS requires it.