websocketstreamingchatrtp

Video streaming + real-time chat implementation


We would like to add a real-time chat function to an app that provides video streaming.

Video streaming communicates by modifying the RTP protocol to TCP to provide special video.

Therefore, files are continuously transferred while maintaining the connection.

I would like to ask for advice on how to implement the chat function.

In general, real-time chat is commonly implemented with WebSockets.

The person in charge of my department It is said that maintaining each RTP and WebSocket connection can place a large load on the client smartphone and cause problems such as battery consumption.

Does maintaining two TCP connections really pose a big risk to the client?


Solution

  • Does maintaining two TCP connections really pose a big risk to the client?

    An app can have multiple TCP connections which is totally fine in general and it doesn't pose risk by itself. The risk depends on how it is implemented. That being said, yes, you can have both video streaming (or ingestion) and real-time chat features running concurrently.

    I would like to ask for advice on how to implement the chat function

    There are plenty of ways to do it. You could either do it from scratch or use 3rd party chat apis (TalkJS, CometChat, Sendbird).

    To do it from scratch, you have to choose which real-time communication protocol you are going to use. Yes, WebSockets are commonly used. You can also use libraries like Socket.io, Firebase Realtime Database or even with WebRTC.

    Regarding your concern on battery: No, the WebSocket itself doesnot consume significant amount of battery. It all depends on the frequency of the messages, payload of the message, background or foreground activity, network type (Cellular) and so on. I assume for transmitting the video, you are using some kind of codec too. The kind of codec, resolution, frame-rate and background streaming have some effect on your battery. In simple, higher the processing and bandwidth will lead to increased battery usage.

    My final thought is it is normal to use video streaming + websocket concurrently (Most chatting app are doing it anyway). Just be sure to use proper protocal for video transmission and streaming.