WebRTC was designed to be a peer to peer communication system. However, it gives rise to a complicated mesh system when the number of participants increases. A Selective Forwarding Unit (SFU) is an alternate topology for connecting through a centralized server to route outgoing media streams from one to many users.
The multi-party peer to peer party configuration leads to enormous strain on a user machine to send and receive multiple streams from multiple peers and keep them in sync even in heterogeneous network conditions. Also it creates network congestion.
A useful, innovative approach
An SFU becomes very useful to manage medium sized conferences. In this architecture, every participant sends their outgoing stream to a centralized server that decides which other participants will receive the stream. It has the significant advantage of reducing the uplink strain on a client’s machine as well as being suited for heterogeneous networks.
SFU is an innovative approach to designing scalable conferences even for asymmetric networks and endpoints.
- SFU is more comparable to a media proxy than a media server
- SFU is suitable only when all the endpoints are using the same codec. SFU is usually the preferred setup for WebRTC conferences up to 20 participants.
Drawbacks of SFU
- Even though both SFU and MCU can be thought of as centralized RTP topologies, when compared to MCU which mixes (re-encodes and rescales) the media suited for all endpoints, SFU has a higher carbon footprint.
- Additionally the quality of stream delivered by SFU is dependent on the quality of the media stream each participant sends towards the SFU.
- Since the number of incoming streams is still proportional to the number of participants in the confern, a single SFU is not a good approach for large active speaker based conferences.
Installation and Setup of Asterisk for Video SFU
Docker File for this experiment is available at https://github.com/agilityfeat/Energyefficient_WebRTC_Asterisk_systems
Manual Setup involves getting source code from Asterisk Repo and following the instructions below.
sudo Make && make install
Asterisk also provides a utility script, ast_tls_cert in its contrib/scripts source directory to make own self signed certs.
> sudo contrib/scripts/ast_tls_cert -C telcopoc.com -O "telcopoc" -d /etc/asterisk/keys
Add tls support:
Check status on console:
*CLI> http show status HTTP Server Status: Prefix: Server: Asterisk Server Enabled and Bound to 0.0.0.0:8088 HTTPS Server Enabled and Bound to 0.0.0.0:8089 Enabled URI's: /httpstatus => Asterisk HTTP General Status /phoneprov/... => Asterisk HTTP Phone Provisioning Tool /metrics/... => Prometheus Metrics URI /ari/... => Asterisk RESTful API /ws => Asterisk HTTP WebSocket Enabled Redirects: None.
Check status on web:
Don’t forget to allow access is using self signed certs for secure web socket transport! Screenshot below.
Secure Websocket support
[transport-wss] type=transport protocol=wss bind=0.0.0.0
endpoint for Webrtc Clients
[webrtc_client] type=aor max_contacts=5 remove_existing=yes [webrtc_client] type=auth auth_type=userpass username=webrtc_client password=password [webrtc_client] type=endpoint aors=webrtc_client auth=webrtc_client dtls_auto_generate_cert=yes webrtc=yes ; Setting webrtc=yes is a shortcut for setting the following options: ; use_avpf=yes ; media_encryption=dtls ; dtls_verify=fingerprint ; dtls_setup=actpass ; ice_support=yes ; media_use_received_transport=yes ; rtcp_mux=yes context=public disallow=all ; vp8, vp9 and h264 are video pass-through codecs. allow=opus,g722,ulaw,vp9,vp8,h264 max_audio_streams = 1 max_video_streams = 15
Conf with SFU Video Mode
[default_bridge] type=bridge video_mode = sfu
exten => 7000,1,Answer() same => n,ConfBridge(sfuconfbridge) same => n,Hangup()
Using jssip for 2 clients (https://tryit.jssip.net/)
For Multiparty conference trials, one can use Cyber Mega Phone 2K Ultimate Dynamic Edition browser side client application by Digium.
Latencies and Delays
About the Author
Stay tuned for the next part in the series, “Analyzing compute and energy consumption of the most popular video conferencing topologies”. We will walk through a detailed analysis of RTP topologies for SIP telephony systems.
WebRTC.ventures can help build awesome custom video solutions for business, emergency preparedness or to revolutionize work for remote and distributed teams. Get it touch at https://webrtc.ventures/contact/.