Build vs Buy: A Guide To Developers On Video and WebRTC

build vs buy video

Video calling apps have been in a boom since the advent of social distancing, lockdowns and work-from-home policies in the pandemic era. Behind this rise is the technology that has made it possible to implement video calls across any browsers and platforms, 

To help you make a quick and informed decision, this article will discuss the benefits, challenges and key considerations to be taken into account when deciding between both the options.

WebRTC: A Brief Introduction 

WebRTC is an open-source project set up by Google in 2011, to enable real-time video calling capabilities across browsers, without the need for third-party servers, native apps or support plugins. 

You can use WebRTC to build video calls in 2 different ways:

  1. Build and deploy the WebRTC video call app on your own server/ solution
  2. Integrate a cloud-based video solution like MirrorFly

Most video call apps built in recent times use cloud-based APIs for flexible integration, cost and deployment. However, if you face issues with industry regulations and global compliances, a custom-solution might be your go-to-choice. 

💡Did You Know?
Almost 97% of video calls made by global users on a daily basis is WebRTC-enabled

Through our analysis, we found that cloud-based APIs are both cost-effective and easy to integrate when building WebRTC-enabled Video Calls. Apart from these, you will also benefits from other advantages when using SaaS APIs like MirrorFly, as listed below:

  • Ease of use
  • High reliability
  • Reduced upfront and ongoing expenses
  • Enhanced security encryptions
  • Super-quick deployment
  • Flexibility to scale as needed
  • Seamless updates to the most current standards
  • Built-in redundancies
  • Performance Analytics

In order to obtain a full-fledged clarity on choosing between the Build or Buy Decision, we’ve covered a full-fledged analysis of both custom and cloud APIs. 

Hosting The WebRTC Video Calls On Your Own Server

When you build a video call with WebRTC technology from scratch, there are several concerns you may face with adding the calling capabilities, maintenance and deployment. Let us look at each of them, assuming that you are using an open-source software (OSS) for custom hosting of your video call apps.

Challenge 1: Deployment And Maintenance of a WebRTC Media Server

Firstly, you’ll need an internet-accessible IP address to host your app on an open-source WebRTC media streaming server. You can either use an EC2 instance or a virtual machine to deploy the on-prem hardware. This is quite a complex set up to establish, when considering the efforts, cost and time. 

Challenge 2: Deployment And Maintenance of a STUN/ TURN Servers

Once you’ve deployed the app on a server, and has set it running, your app will need 2 separate servers: 

  • Session Traversal Utilities for NAT (STUN)
  • Traversal Using Relay around NAT (TURN) 

For peers that are protected with NAT or a Firewall, it becomes a huge challenge to discover the public IP address to establish the connection. This is where a STUN server is used to find the specific addresses of the client.

Similarly, a TURN server lets the connection happen by acting as a proxy between the NAT/firewall-protected peers.

In the above image, you’ll find how WebRTC is enabled in an app with both STUN and TURN servers on the play. 

  • The peers connect to the WebRTC server to reach the signaling layer
  • In this layer, the audio/video of both the peers are exchanged
  • Next, both the clients connect to the TURN relay for continuous transmission of audio/video streams

Challenge 3: Performance & Scalability 

Database engines like SQLite that are usually used as rich containers to exchange audio/ video may work well with simple instances while exhibit discrepancies at complex situations. Apart from this, you may also need to consider issues that arise with scaling your servers, network topology and audio or video codecs, when using a custom solution. 

Challenge 4: Developing & Using A Custom Library For Users

Next on the list is the threat posed by a client library that uses built-in APIs. In case if you need to use frameworks than the ones covered by your server, you may need to use a WebRTC client that will have to manually manage all the STUN/TURN functions. This may immensely require investment and development resources. 

Now that we’ve made a closer look into developing WebRTC video calls with the help of a custom solution, we will now quickly explore how a cloud-based solution like MirrorFly can help you with the development process. 

Integrating Cloud-Based Video Calls SDKs From MirrorFly

While building a custom solution for WebRTC video calls brings with it challenges like performance, infrastructure, devoted servers for authentication and scalability, MirrorFly resolves these concerns in no matter of time. Whether you have an existing app or planning to build a new one, you can avail pre-built SDKs that can directly add the video calling functionality for enabling real-time communication into any browser. 

Here is a quick walkthrough of the steps to add WebRTC-enabled video calling into your apps:

1. You’ll need to add a script file to start with the integration of the video call SDK

<script src="./index.js"></script>
<script src="./socket.io.js"></script>
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>

2. This will start the SDK object that will carry all the meta-data needed to establish the connection

3. Next, you may choose the language with which you need to build the web application

4. Once, you’ve set up the language and added the SDK, you need to initialize the call SDK

5. In this step, you’ll need to provide the license key that you’ve acquired from creating an account with MirrorFly

const incomingCallListener = (res) => {};
const callStatusListener = (res) => {};
const userTrackListener = (res) => {};
const muteStatusListener = (res) => {};
const missedCallListener = (res) => {};
const callSwitchListener = (res) => {};
const inviteUsersListener = (res) => {};
const mediaErrorListener = (res) => {};
const callSpeakingListener = (res) => {};
const callUsersUpdateListener = (res) => {};
const callUserJoinedListener = (res) => {};
const callUserLeftListener = (res) => {};
const helper = {}

6. To test your app, use the below sandbox method

const incomingCallListener = (res) => {};
const callStatusListener = (res) => {};
const userTrackListener = (res) => {};
const muteStatusListener = (res) => {};
const missedCallListener = (res) => {};
const callSwitchListener = (res) => {};
const inviteUsersListener = (res) => {};
const mediaErrorListener = (res) => {};
const callSpeakingListener = (res) => {};
const callUsersUpdateListener = (res) => {};
const callUserJoinedListener = (res) => {};
const callUserLeftListener = (res) => {};
const helper = {}

const initializeObj = {
  apiBaseUrl: "https://api-preprod-sandbox.mirrorfly.com/api/v1",
  licenseKey: "XXXXXXXXXXXXXXXXX",
  isTrialLicenseKey: true,
  callbackListeners: {
    incomingCallListener,
    callStatusListener,
    userTrackListener,
    muteStatusListener,
    missedCallListener,
    callSwitchListener,
    inviteUsersListener,
    mediaErrorListener,
    callSpeakingListener,
    callUsersUpdateListener,
    callUserJoinedListener,
    callUserLeftListener,
    helper
  },
};

await SDK.initializeSDK(initializeObj);

7. You may receive a response as mentioned below

{
  "statusCode": 200,
  "message": "Success"
}

8. Next, add a user (client) using the below line

await SDK.register(`USER_IDENTIFIER`);

You may receive a response as follows:

{
  statusCode: 200,
  message: "Success",
  data: {
    username: "123456789",
    password: "987654321"
  }
}

9. Once you’ve tested the registered user, you’ll now need to connect the SDK to the server using the connect() method

await SDK.connect(`USERNAME`, `PASSWORD`);

Now the connection between the peers will be established.

10. In the next step, we’ll now allow permissions for audio and video, and then enable the video calling functionality.

await SDK.makeVideoCall(['USER1_JID', 'USER2_JID'...]);

Finally, we’ve connected the peers via video call using MirrorFly SDKs built based on the WebRTC technology

Conclusion

To wrap things up, choosing between building a WebRTC app from scratch vs buying cloud-based APIs is undoubtedly challenging. But considering the facts mentioned in the comparison above, it is very clear that choosing the latter makes it easy, cost-effective and scalable to build WebRTC-based video calling apps.

Ready to take your first step with your WebRTC project? Download our Video Call SDKs and start connecting your users face-to-face today!

Want To Build Your Own Custom Video Call App?

Further Article

Krishi Shivasangaran

Krishi is a Digital Marketer by choice & profession. She munches on topics relating to Technology, E-Commerce, Enterprise Mobility, Cloud Solutions and Internet of Things.

Leave a Reply

Your email address will not be published.