HLS and WebRTC

As Requested

HLS

HLS stands for HTTP Live Streaming. It is a media streaming protocol designed to deliver audio-visual content to viewers over the internet. It facilitates content transportation from media servers to viewer screens — mobile, desktop, tablets, smart TVs, etc. Created by Apple, HLS is widely used for distributing live and on-demand media files.

HLS works by dividing the video into smaller segments and encoding them at different quality levels. The segments are stored on a web server and delivered to the viewers using HTTP. The viewers can switch between different quality levels according to their network conditions and device capabilities. This is called adaptive bitrate streaming.

HLS offers some advantages over other streaming protocols, such as:

- It is compatible with most platforms and devices, especially Apple products.

- It is secure and reliable, as it uses HTTPS and encryption to protect the content.

- It is scalable and cost-effective, as it leverages the existing HTTP infrastructure and CDN support.

However, HLS also has some limitations, such as:

- It has a high latency, typically 6-30 seconds, which is not suitable for real-time applications.

- It is proprietary and not standardized, as it is developed by Apple and has some variations across implementations.

As you can see HLS and DASH are similar in many aspects. So why did I focus more on DASH?

First of all, DASH is a standard and HLS is not. DASH is based on the ISO/IEC 23009 standard, which defines a common media presentation format for adaptive streaming over HTTP. HLS, on the other hand, is a proprietary protocol developed by Apple, which has not been submitted to any standardization body.

Moreover, DASH has some technical advantages too. DASH uses a single manifest file that describes all the available media segments and their quality levels, while HLS uses multiple playlist files for each quality level. This reduces the overhead and complexity of DASH compared to HLS. Also,  DASH allows for the use of any media encoding and container format, such as MP4, WebM, or MPEG-2 TS, while HLS is limited to MPEG-2 TS and fragmented MP4. This gives DASH more flexibility and compatibility with different devices and platforms.

WebRTC

WebRTC stands for Web Real-Time Communication. It is a set of APIs and protocols that enable real-time communication between web browsers and mobile applications. It allows for peer-to-peer audio and video communication, as well as data transfer, without the need for any plugins or native apps. WebRTC is an open-source and free project that is standardized by the W3C and the IETF. 

WebRTC works by establishing a direct connection between two peers using a set of protocols, such as:

- ICE (Interactive Connectivity Establishment), which is a framework to find the best way to connect peers across different network environments.

- STUN (Session Traversal Utilities for NAT), which is a protocol to discover the public address and port of the peers behind a NAT (Network Address Translation) device.

- TURN (Traversal Using Relays around NAT), which is a protocol to relay the media traffic through a server when a direct connection is not possible.

- SDP (Session Description Protocol), which is a protocol to describe the media capabilities and preferences of the peers.

- RTP/RTCP (Real-time Transport Protocol/Real-time Control Protocol), which are protocols to deliver and control the media streams that were covered in the course.

WebRTC offers some advantages over other communication technologies, such as:

- Very low latency, typically sub-500 milliseconds, which is ideal for interactive and live applications.

- High quality, as it can adjust the bitrate and resolution according to the network conditions and device capabilities.

However, WebRTC was initially designed for peer-to-peer communication therefore, it is complex and expensive to operate and scale, as it requires signaling and encryption protocols and has no CDN support. Also, it is not fully supported and compatible across all browsers and platforms, as it is still evolving and has some variations across implementations. Moreover, it is vulnerable to leaks and attacks, as it may expose the IP address and location of the peers and be exploited by malicious actors.