Peer-to-Peer Video Calls Using Ruby on Rails

Peer-to-Peer Video Calls Using Ruby on Rails

 

Modern means of communication have changed the world forever. Now, with only a connection to the Internet, we can speak to somebody on the other side of the Earth. Video calls enabled people not only to hear but see the person they’re talking to. The applications for video calls are numerous. In fact, they have already evolved from just a means of communication to a new method of business interaction. People know how to derive benefits from tools such as video calls and may need to create and/or modify them for personal needs. That’s why, we think, the Ruby on Rails video chat app building tutorial may be of interest to you.

In this post, we would like to delve deep into video chat app development, including the steps to implement it, technologies, ways to apply such an app, examples and existing solutions. For instance, you’ll get to know about WebRTC for Rails and how to set it up.

The information outlined in this post can be useful for webmasters, developers, inventors, business people looking for opportunities to enhance their businesses, and technology fans. Are you ready to plunge into the video calls universe? Enjoy the ride.

 

Introduction to Video Chats

Let’s start with what video chat systems can deliver to you. They can be both personal and professional depending on your goals, needs, and ways of usage. These three types are the most frequently used nowadays:

Daily Interaction

We all enjoy communicating with friends and family. Today is the age of globalization and there is an increasing number of cases where these people live far away from us and we need to interact with each other online. Peer-to-peer video calls give us an opportunity to interact freely and discuss daily problems just like we are standing face-to-face. There’s no need to formulate thoughts into words, which can lose so much of the meaning of a conversation. The video transmits in small data packages fast, so people see the emotions and actions in real time. That’s amazing for maintaining long-distance relationships.

In addition, you can utilize it for work. There are some times when you might need to stay home and work remotely. Such tools eliminate the necessity to be at work in person, as you can delegate tasks, and arrange and hold meetings by video bridge.

 

Online Transmitting

Sometimes you need to reach not just one or two people, but a whole audience. Video-chatting programs allow you to call distant distributed audiences from all over the globe. This can be useful for webinars, corporate events, attracting customers, and generating leads. Online video calls are a great source of opportunities businesses should appreciate.

Real-Time Surveillance

Peer video surveillance can be used in both commercial and state organizations. It can enhance the technologies we used for surveillance before. As it’s needed for security purposes, this new way to approach the problem can save someone’s life. Deep online integration enables building video-call streams into software systems and running real-time observations, processing the images, and detecting dangers.

 

Video Calls Software Examples: Skype vs ooVoo

There are already some examples of software people use to see each other using just an Internet connection. The most popular among them is Skype. Being part of the Microsoft ecosystem, it’s embedded into the modern operating systems of the company. It allows users to create profiles and connect to each other by searching for the right account and establishing a connection with them. The software allows not only makes peer-to-peer video calls but also enables chats and the exchange of files and photos. Importantly, you can also arrange group calls and conferences, and maintain the connection with multiple users simultaneously. The user can share an image from a camera or the screen and comment on the actions with their voice. To use Skype, a person needs to have an account. The users can access functionality both via a desktop application or its web browser version.

Basically, the same functionality is offered by ooVoo, Skype’s main competitor. The big difference is that ooVoo users can make a call to a person who doesn’t have an account or the app installed. For this, ooVoo sends a link to the call recipient, which enables them to answer the call from their browser. In addition, one may embed the ooVoo video chat into the webpage of a site and use it for real-time chat with customers, for example.

If you feel like these options won’t completely satisfy your needs, let’s discover how to build video conferencing with Ruby on Rails and make the most of the opportunities it gives you.

 

 

WebRTC For Building Your Video Conferencing App

WebRTC is a collection of useful JavaScript APIs, which can be used just by calling a constructor. You don’t need to install any libraries to start using it. You can use it straight from the browser and save lots of time on setting the configuration environment. It isn’t connected to any web development framework, and developers can embed it in a project without much hassle.

Note:

In this post we are describing the WebRTC usage in Ruby on Rails, and above we said that it’s fueled by JavaScript. This is the tricky part, because we know how to combine the advantages of Ruby and the legacy of WebRTC in one system.

What’s good about WebRTC?

  • As we have already mentioned, it doesn’t need any installations before it can be used.
  • WebRTC APIs allow sharing not only video stream, but also text, media files, and audio. This means that, like in Skype, users of your Rails website will be able to share files via WebRTC and also do texting. It’s very common for webinars, conferences, online meetings, etc. Here are some examples of how to implement WebRTC file and text sharing.
  • WebRTC supports almost all modern browsers. For example, some time ago Safari didn’t have support for WebRTC. Now this flaw has been eliminated; four versions of Safari support this API collection. This means the technology has great support and a robust community, so by choosing it you won’t have to risk dealing with an obsolete tool. The picture below describes which browser versions support the technology (bear in mind this not a complete list).

 

webrtc

Source: Caniuse.com

 

How to Develop a Ruby on Rails Video Chat App with WebRTC

WebRTC has both JavaScript libraries with access to video and audio devices on the user’s side and open-source codecs for metadata. Web browsers with WebRTC support all have a getUserMedia function to gain access to remote devices. This function has three parameters, which include device type, and the function to accept control in case of both successful and unsuccessful operation.

When you start searching the Internet in search of advice on how to utilize it in a project, you may become a bit confused about the complex abbreviations that are commonly used to describe the issue. However, the biggest problem for newcomers is the complexity of WebRTC integration with projects not developed in Node.js.

Let’s look at an example. If two peers need to connect with each other, they should share information about themselves with other peers. This is a problem for WebRTC, as it doesn’t have any opinions on signaling. The only way to overcome this issue is to build such signaling for your specific project from scratch. And the key to solving the problem of how Rails can integrate with WebRTC is in ActionCable.

Essentially, these are the steps:

  • First of all, you should connect the first user to the server establishing the local and remote video streams.
  • The data with session description transmitted from the computer of this user should become visible to this user and, as a result, for the other clients.
  • Another user should connect to the first one via server by accepting the offer from the first user. For this, you need to apply ActionCable.
  • When both clients have local and remote descriptions and invitations accepted, they can start exchanging files, texts, and maintain an audio and video bridge.

For a more detailed explanation, here is an extensive tutorial with examples of such an approach with code samples in a repository.

As you may have noticed, there is a lot of programming to do. Nevertheless, WebRTC use isn’t so widespread yet, and there are not enough substantial tools to simplify the development process. However, you can use this inconvenience as an advantage. If companies and startups using the technology aren’t numerous, you can outperform them by offering brand-new features and stand out from competitors.

 

Summary: How to Build WebRTC App with Ruby on Rails

Ruby on Rails is a great tool to create an extensive website with state-of-the-art features. Combining great features and remarkable development speed, it remains one of the wisest choices for building your Internet startup. As you can see, it’s compatible with the more outstanding technologies to let your project maintain leadership in a chosen area. In this post, we described how to make good use of WebRTC and integrate a cool video-streaming service into your web app. If you have any questions about how your business can benefit from the peer-to-peer video chat implementation, please feel free to contact us. We have significant expertise in the implementation of similar web solutions and can support your business endeavors with sharp minds and skills.

Alex Morgunov

Alex Morgunov

Project Lead

Join our Newsletter