Quick launch WebRTC with Infobip

Web Real Time Communication (WebRTC) is fast becoming a de facto framework used to build applications to facilitate audio and video communication on the web. WebRTC connects users through their browsers or on their mobile devices. In this post, we’ll take a closer look at why WebRTC is so widely used for development today. Along the way, we’ll use a set of Infobip SDKs to get started quickly.

Let’s start by delving a little deeper into the details and history of WebRTC.

What is WebRTC?

At the highest level, WebRTC is a peer-to-peer (P2P) data transmission technology. Although it has versatile uses, it is commonly used for delay-sensitive applications, and makes it ideal for P2P video and audio streaming. Many major tech companies — including Zoom, Slack, and Discard استعمال use WebRTC in their implementation to provide their customers with a secure and seamless streaming experience.

How long has WebRTC existed?

According to most accounts, the industry first saw the use of WebRTC for cross-browser video calling in February 2013. That means WebRTC is almost 10 years old! For those who focus on paperwork, WebRTC became an official “candidate recommendation” with the W3C in 2017 and a “proposal” in January 2021. With the support of governing technical bodies and the use of industry, however, the adoption of WebRTC is increasing. This is especially true of companies that want to create audio and video applications.

Why choose WebRTC over another option?

Why would a company choose to build on WebRTC as opposed to other options like RTMP? There are several reasons for this, and we will highlight the most important ones here:

No central server.

Since WebRTC is P2P, clients manage the connection. In other words, there is no client-server architecture with centralized infrastructure broking connections when handling media and static assets. End-user devices manage all connections. Although it puts more resources on the clients, the P2P approach is more secure and flexible.

Significantly, WebRTC needs a way to connect clients. This process is called “signaling”. Therefore, when there is no central server in terms of connection management, you need a signaling server to help clients be aware of each other’s presence and discuss their connections. However, the resources required for this signaling server are significantly less than maintaining the entire client-server architecture.

W3C / IETF standard

Historically, developers have probably not had much stock in technology validation from W3C or IETF. Nevertheless, WebRTC’s support for these institutions means that there has been a lot of thinking, design and discussion in this technology. WebRTC has been building for more than a decade, and its official recommendation has been bolstered by a group of big tech companies that actively use it. You are in good company with WebRTC.

High quality and fast

WebRTC uses UDP packet broadcasts, unlike TCP-based streaming alternatives (eg MPEG-DASH or RTMP). The use of UDP reduces the need for re-encryption and re-transfer of packet surfaces. For video and audio streaming applications, the minimal packet that comes with UDP has an equally negative impact on the end user experience. The final result, though, is WebRTC. fast. It’s one of the only protocols that can permanently achieve sub-second latency, and it does it from the outside!

Local activity

As a formally endorsed technology in HTML5, WebRTC is easy to get started with. You don’t need a plugin. All you need is a WebRTC compatible browser, and you’ll have instant access to device detection, media capture, data transfer, and more. When you create on WebRTC, everything in your application is local. Your users will not need to download or install anything else.

How can Infobip help?

To work with WebRTC, Infobip offers SDKs for Android, iOS, React Native, and JavaScript. It covers all WebRTC applications. Infobip makes it very easy to get started.

Setting up

Suppose you are starting a new project based on JavaScript. Getting started is as easy as installing the Ingobip JavaScript SDK with npm or adding a distribution file to your project:

$ npm install infobip-rtc --save
# main.js 
let InfobipRTC = require('infobip-rtc');

# or as an ES6 Import
import {InfobipRTC} from "infobip-rtc";

Infobip also offers a distribution file that you can add:

<script src="https://rtc.cdn.infobip.com/latest/infobip.rtc.js"></script>

Use it

Infobip adopts a hands-off approach for user management. You have customers. Your Users To enable Infobip services for your users, you just need to create a token for them. Here is an example of what a token request looks like with the answer:

# main.js
var settings = {
    "url": "https://{baseUrl}/webrtc/1/token",
    "method": "POST",
    "timeout": 0,
    "headers": {
        "Authorization": "{authorization}",
        "Content-Type": "application/json",
        "Accept": "application/json"
    },
    "data": JSON.stringify({"identity":"Alice","applicationId":"2277594c-76ea-4b8e-a299-e2b6db41b9dc","displayName":"Alice in Wonderland","capabilities":{"recording":"ALWAYS"},"timeToLive":43200}),
};

$.ajax(settings).done(function (response) {
    console.log(response);
});

# Response
{
  "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZGVudGl0eSI6IkFsaWNlIiwibmFtZSI6IkFsaWNlIGluIFdvbmRlcmxhbmQiLCJleHAiOjE1NzkyOTA2MzgsImNhcHMiOlsyXX0.QyCMqjH8DsftChibW2Rw4EByH-eEviUp3-kHVKuJpKg",
  "expirationTime": "2020-01-17T19:50:38.488589Z"
}

After creating and storing tokens, you’re ready to get started!

Although application usage varies greatly, each SDK’s GitHub repository has excellent resources for getting started. Official documents along with all the goods can be found here with Infobip’s WebRTC offer.

Summarize WebRTC

We’ve covered a lot of land on WebRTC, so let’s take a moment. WebRTC is:

  • A stable, industry-supported framework used primarily for P2P audio and video communication between browsers and mobile devices.
  • Widely adopted by many tech companies and for a variety of uses.
  • TCP-based alternatives are preferred, as its UDP-based approach provides incredible speed while maintaining quality.

And check out Infobip’s platform – a free and quick way to get started with WebRTC.

.

Write a Comment