WebRTC & Viinex: An Overview of the Protocol’s Use in Video Surveillance

This article delves into the specific details of how WebRTC is integrated and utilized within the Viinex middleware for video surveillance, including its benefits and potential areas of application.

Let’s revisit the past. WebRTC, or Web Real Time Communication, is a standard that has received substantial development investment from Google. First introduced in May 2011, it has since undergone revisions and updates, and remains an open-source project with support from major tech companies such as Apple, Google, Microsoft, and Mozilla. This results in a comprehensive, open web standard that can be used for video surveillance and can be accessed through JavaScript API interfaces on all major browsers, as per webrtc.org.

Why does this matter? In video surveillance field, thick client applications were previously widely used to address questions about Client-Server communication in a network, development, and data exchange standards between the server and client. However, the use of thick clients on user equipment may not be feasible, restricted, or even unwelcome by users. This has become especially apparent with the global trend towards remote work in the post-COVID era.

Web technologies are a staple in many of the software we use daily, often utilized for integration with other systems in the creation of complex solutions. When building a distributed system, it often requires data transfer over the Internet.

However, there is a challenge in using web technologies in video surveillance. Take IP cameras, a fundamental component of video surveillance systems, as an example. They stream video using the RTSP standard and to view the stream and perform actions such as watching video, zooming in, and setting up onboard video detectors, the video must be played back in a browser. To address this, camera manufacturers often resort to using additional browser plugins, which must be installed by the user (often it’s ActiveX with its associated limitations).

But thanks to WebRTC’s capabilities in video streaming to mobile clients and browsers, there is now a solution that solves the issue across all platforms and browsers, eliminating the need for additional plugins and thick clients.

WebRTC was designed to enable video calls over the Internet while maximizing network efficiency and minimizing traffic trough P2P. As a result, it has incorporated many VoIP technology solutions. Some of its key benefits include:

  • Low latency
  • Efficient communication through NAT when neither communicator has a direct IP address in the Internet
  • Secure
  • Comfortable and easy API using.

Let’s examine the first crucial aspect, starting with the fundamental WebRTC scheme and its signaling server.

The replacement of Browser 1 with a video server transforms the structure into a classic example of a video surveillance system deployment. Adding cameras and network environment further emphasizes this illustration.

It’s crucial to understand that the STUN (Session Traversal Utilities for NAT) and TURN (Traversal Using Relays around NAT) servers are special applications in the Internet with a unique IP address.

STUN role is to facilitate communication between routers by tuning their NAT routing tables and allowing them to exchange information about each other and their data needs. This direct communication between the server and the client reduces the cost of maintaining the central service, as there is no need for significant processing power, fail-safe data storage, or wide bandwidth for video traffic. STUN servers can either be independent services in the Internet or integrated with a video management system service, depending on the video solution’s architecture.

Viinex includes a STUN server that offers several benefits:

  • Firstly, Viinex provides a complete software package necessary for WebRTC-based video surveillance system deployment.
  • Secondly, the communication becomes more seamless as data passes through a single application with the same IP address and port, enabling its use in enterprise networks where public STUN and signal servers cannot be utilized.

TURN server is utilized in WebRTC when a direct peer-to-peer connection cannot be established between devices because of the presence of a firewall or multiple NAT that does not permit the use of STUN. The TURN server acts as a relay between the two devices, forwarding the media data between them. In other words, TURN is used as a fallback mechanism when direct communication is not possible, and it adds additional latency and overhead to the communication. The use of TURN is usually a trade-off between ensuring the communication works in all network conditions and the cost of using a centralized relay server. Viinex middleware incorporates support for TURN as well.

Real-time streaming

Latency in the delivery of information from the scene to the screen can be caused by a range of factors, information processing, including data format, encoding and decoding data, and in the case of WebRTC, decrypting as well. The quicker and simpler these steps are at every stage, the sooner the image will appear on the screen. As mentioned earlier, the first step of direct P2P communication leads to a direct exchange of video streams between server and client, which undoubtedly helps to decrease latency.

The second step is to use the UDP transport protocol as the foundation for online video streaming, as it eliminates the need for extra packet exchange control. It’s worth noting that real-time tuning of routing tables and subsequent streaming are possible with UDP, which is based on the fundamental principles of communication network building for broadcasting. It’s a widely supported standard protocol that is compatible with the most routers in the market, including SOHO hardware and professional solutions. Quality of Service (QoS) technology is utilized to guarantee high-quality packet delivery.

Finally, the way information is transferred and received can also make a significant contribution to reducing latency. WebRTC streams video in real-time, eliminating the need for chunk formatting and buffering, which is required in the HLS protocol. Our test results in lower latency, with total latency when streaming from an ordinary USB camera (not a special video conferencing camera) being approximately 230 milliseconds, and 300-400 milliseconds with common IP cameras, which also require time for onboard video coding.

Low latency can be crucial in some video surveillance scenarios, for example, for quick delivery of alarm incidents with online video verification to a remote security officer, as well as quick and convenient manual PTZ operation.

Secure Communication

WebRTC provides end-to-end encryption, ensuring secure communication between the server and client. This helps protect sensitive information from being intercepted and decoded by unauthorized parties. The use of DTLS standard for encryption keys and SRTP for media streaming provides robust protection against Man-in-the-Middle (MitM) attacks, making it impossible to understand the content of the data being streamed. In addition, the encryption in WebRTC not only enhances the security of information, but also improves communication quality by providing checksums that detect damaged data fragments and prevent their decoding. This helps ensure that the received data is accurate and enhances the overall communication quality. By using WebRTC, organizations can securely transmit information with confidence, knowing that their data is protected from potential attacks.

Viinex supports the use of custom certificates, which provide protection against data spoofing attacks. By checking the certificates on the client side, the client can verify that incoming data is authentic and not fake. This adds an extra layer of security to WebRTC real-time streaming and ensures the protection of sensitive information.

Widespread Adoption by Browsers

Browsers are ready for WebRTC with good compatibility. At the moment the situation looks pretty decent as per (WebRTC caniuse.com). For an effective video surveillance system, the ability to display multiple video streams simultaneously is important. To achieve this, the browser should support hardware decoding using the GPU. Currently, only two codecs, H.264 and VP9, are mentioned in the WebRTC specification. H.264 has good support according to (H.264 caniuse.com). However, H.265, which is quite common in video surveillance systems, is not supported by the WebRTC standard or the majority of browsers and is mainly supported by thick client applications (H.265 caniuse.com).

Checking if your browser supports hardware decoding is easy, for example in Chrome, simply enter “chrome://gpu”.

Optimizing WebRTC Connections with Viinex

The speed of video delivery is not the only important aspect, the overall system responsiveness when transmitting commands is crucial as well. As seen in the diagram below, a lot of communication occurs during the handshaking process, which is the establishment of the connection. The blue arrow signifies that secure video streaming has finally started, with everything prior being preparation.

In Viinex, we have optimized this process by reducing the number of handshakes required, making use of already established connections for time-efficient video streaming. Viinex’s API includes a simple command “Stream Switch” for changing the video stream, which replaces the existing stream in a current session with a new one using WebRTC. This reduces the requirement for establishing new connections, resulting in enhanced responsiveness when changing the video stream and providing a better end-user experience through decreased waiting time when switching cameras. It’s worth mentioning that Viinex is not just an online streamer, but also a video recorder. When streaming video archives, time positioning, pause, playback and other commands are executed within the current session.

Third-Party Video Management Systems for Online and Archive Video Streaming

The WebRTC standard doesn’t distinguish between live or archived video streams. Viinex allows working with cameras, its own video archive, and other video sources, like third-party video surveillance systems, by serving as a gateway software to manage VMS video streams in HTML5 format.

The external command signature in Viinex middleware is consistent when working with both Viinex’s video archive and records from other video surveillance systems. This allows for the use of a single API for supporting multiple video surveillance systems at once. This enhances the work of our partners who develop PSIM, as it gives them a unified tool set for video management and the ability to work with multiple video surveillance systems through the single Viinex API. Via its API Viinex enables video archive streaming both in RTSP and WebRTC, including external VMS, which sometimes have no HTML5 compatible streaming feature, and that allows our partners that want to provide their customers web access to video from these VMS, stream video in a HTML5 compatible format.

Comparing WebRTC and HLS, it is challenging to interact with external video archives using HLS as VMS typically provide archive as a continuous video stream, making it difficult to determine how to break the stream into chunks and detect the I-frames to start each chunk. This means HLS cannot provide the ability to instantly stream video from any point in the archive, but Viinex can, as it supports WebRTC and makes video archive streaming accessible for web applications.

Managing video on the Internet with Viinex middleware

The paragraph provides an overview of a solution for organizing P2P functionality for video in applications. This solution provides users with access to their video surveillance system by incorporating WebRTC and Viinex middleware into the existing video surveillance system, and and the ability to enhance existing third-party video surveillance systems with P2P functionality.

The installed video surveillance system remains behind the router and is only accessible to those within the local network, ensuring security and simplicity. WebRTC enables remote access to the system without the need for a dedicated IP address, and the Viinex middleware includes a STUN server and supports a TURN server. The STUN and TURN servers are responsible for establishing communication between the client and the video surveillance system, while the Viinex middleware handles video surveillance and streaming using WebRTC and other popular standards.

Leave a Reply