Solutions ArchitectLuca Pradovera
What is FreeSWITCH?
FreeSWITCH is an open-source telephony platform that can be used to build voice and video applications. It supports a wide range of protocols and codecs, making it a versatile choice for a variety of use cases. Some of the features of FreeSWITCH include multi-tenant support, call routing, and voicemail.
Scaling video can be difficult and expensive due to the high bandwidth and processing power required to transmit and decode video streams. Unlike audio, video requires a large amount of data to be transmitted in real-time, which can cause strain on network infrastructure. Additionally, video codecs are computationally intensive, requiring powerful hardware to encode and decode streams efficiently.
Video conferencing and streaming services also need to handle a large number of concurrent users. This requires a lot of resources to maintain the quality of service for all the users.
Video in FreeSWITCH
FreeSWITCH uses a Multipoint Control Unit (MCU) video model. MCU is a device that connects multiple video streams from different participants in a video conference and combines them into a single stream that is then sent to all participants.
The MCU acts as a central hub for the video conference, managing the video streams of all the participants and making sure that everyone can see and hear each other. The MCU also handles tasks such as adjusting the video resolution, frame rate, and bitrate to ensure that the video streams are transmitted efficiently and with minimal latency.
In the MCU model, each participant sends their video stream to the MCU, which then combines the streams and sends the resulting video to all participants. This eliminates the need for each participant to establish a direct connection with every other participant in the conference, which would result in a high number of connections and high bandwidth usage.
The MCU model results in a great user experience, as it has predictable resource usage on the client side, but it has the drawback of being CPU heavy on the server. As a result, running video on your own FreeSWITCH server can be expensive and hard to manage.
When factoring in the WebRTC configuration and certificate management, and the necessary STUN and TURN setup, it is possible (but very difficult) to scale an on-premise video solution based on FreeSWITCH.
The SignalWire Video SDK
SignalWire provides a variety of services including voice, video, and messaging. The SignalWire Video API is a software development kit that allows developers to easily integrate video functionality into their applications.
The SignalWire Video SDK provides a variety of features such as:
- Real-time video and audio streaming
- Multi-party video conferencing
- Screen sharing
- Video quality optimization
- Support for WebRTC and SIP
The SDK also comes with a variety of pre-built UI components that can be used to quickly and easily add video functionality to an application.
One of the main advantages of the SignalWire Video SDK is its ease of use. The SDK is designed to be simple to integrate and use, allowing developers to quickly add video functionality to their applications without having to spend a lot of time on implementation.
Another advantage is its scalability. The SignalWire Video SDK can handle large numbers of concurrent users, which makes it suitable for use in high-traffic applications such as live streaming and video conferencing.
Additionally, the SDK is built on top of FreeSWITCH which enables developers to leverage the features and capabilities of FreeSWITCH, such as the MCU video model, while enjoying the ease-of-use and scalability of the SignalWire Video SDK.
One great solution to the issue is to use FreeSWITCH for all your user and dialplan management, but call in to the SignalWire Video API to join a scalable video room without resource constraints.
Setting Up the SignalWire Video API
The easiest way to get started is using a Programmable Video Conference, SignalWire’s product that creates a ready-to-use video room without any code. For the sake of this post, we will not go into the details of the Video SDK, but you can find more information on our documentation website.
Give the room a very simple name, and keep the link to join it handy.
Next, we will need to wire up the necessary connectivity. FreeSWITCH can place calls via SIP, so we will use a SignalWire SIP Domain App to connect to our demo room. Domain apps can be used not only for carrier purposes, but also to connect a SIP address to any destination including a LAML Bin, which is the serverless container for simple SignalWire applications.
First, let’s set up the LAML Bin in your SignalWire dashboard with this content:
The <Room> XML noun connects a LAML context to a video room with the same name. Copy the Bin URL and navigate to the SIP Domain App page to create a new one.
Set it up to use a LAML Webhook, and input the URL for the Bin you copied above. Take note of the domain app name - it will be similar to yourspace-yourappname.dapp.signalwire.com.
Starting from a stock FS install, such as the one you can get using my ClueCon lab Docker container, you need to simply add an extension, for example in dialplan/public.xml:
The user portion of the SIP URL you are calling does not matter for the purpose of this demo, so I just used room. The domain portion is your Domain App from above. Also, check that your vars.xml contains the necessary video codecs:
Remember to restart FreeSWITCH if you have changed vars.xml, or run reloadxml in the fs_cli tool if you have changed the dialplan.
Ready for your first call?
Register a SIP phone such as Zoiper to your FreeSWITCH server, then open a browser window with the Programmable Video Conference URL, which you can get from your SignalWire Dashboard.
Now, the moment everyone has been waiting for: in your Zoiper window, after making sure you are registered to your FreeSWITCH server, call fstovideo using a video call, and here you are!
Starting from here, you can easily add more logic and dialplan features, while not having to worry about CPU power and scaling. You can also easily mix WebRTC participants using the SignalWire SDK with your FreeSWITCH users.
Have a question about FreeSWITCH, SignalWire, or both? Join our team for Office Hours and work through any issues you may have when setting up your new video platform.