Online Claw Machine Solution Architecture: Comprehensive Guide to Building an Interactive Game Console
Introduction
In the ever-evolving online gaming landscape, online claw machines have become a fascinating blend of nostalgia and modern technology. With live video streaming and remote control capabilities, users can participate in remotely controlling physical claw machines anytime, anywhere, running on iOS, Android, iOS, and Web. This comprehensive guide delves into the technical architecture behind online claw machines, exploring key functional modules such as media services, signaling services, and cloud recording. By the end of this article, you will have a thorough understanding of how to build and optimize an online claw machine platform using TRTC technology.
Implementation plan
Usually, a complete online claw machine scenario is implemented, involving multiple functional modules such as media services and signaling services. The key actions and functional points under each functional module are shown in the following table:
Functional modules | Key actions and functional points |
Media services | Audio and video streaming push, audio and video streaming pull |
Signaling services | Remote control |
The overall business architecture of the online claw machine is shown below. The claw machine control terminal is equipped with two camera positions for video capture and streaming of the claw machine. When the player enters the game interface, the player will enter the TRTC room corresponding to the claw machine, so that the player can see the video stream collected by the claw machine camera. After inserting coins or recharging the game, the player can start to control the claw machine's claws to grab the dolls. The audience can also join the game and watch the player's grabbing process.
Media Service
Audio and Video Push Streaming
RTMP Streaming Uplink
Most webcams or streaming boxes on the market have the RTMP streaming function. Using the RTMP streaming into the room function of Tencent Cloud Real-time Audio and Video TRTC, you can push the video stream pushed by the webcam or streaming box directly to the TRTC room.
The specific process is as follows:
1. Use TRTC's RTMP generation rules to generate the corresponding RTMP streaming address.
2. Manually configure the RTMP streaming address to the webcam or streaming box on your claw machine.
3. Start the RTMP webcam or streaming box to push the video stream to the TRTC room.
TRTC push streaming uplink
There are also hardware manufacturers on the market that cooperate with Tencent Cloud real-time audio and video. They will integrate Tencent Cloud real-time audio and video SDK on webcams or push streaming boxes, so that they can directly capture videos and push them to the TRTC room.The general process is as follows:
1. Manually configure SDKAppID, UserId, RoomId, and Usersig to the TRTC webcam or streaming box on your claw machine.
2. Start the TRTC webcam or streaming box to push the video stream to the TRTC room.
Audio and video Pull Streaming
When the claw machine successfully pushes the audio and video stream to the Tencent Cloud Real-time Audio and Video (TRTC) room, whether the user is a player or a spectator, they can watch the claw machine screen in real time by entering the corresponding TRTC room.The general process is as follows:
1. The business app integrates Tencent Cloud real-time audio and video SDK.
2. The business server is responsible for sending the necessary SDK parameters, including SDKAppID, UserId, RoomId, and Usersig, to the business application.
3. The user enters the TRTC room corresponding to the claw machine through the business application and calls the pull stream interface provided by the TRTC SDK to receive and watch the real-time audio and video stream.
Signaling service
The signaling service is responsible for controlling signaling synchronization. Usually, there are ready-made control hardware modules on the market, which are configured with a variety of network communication modes, without the corresponding development workload, only configuration and debugging.The communication process of the signaling service is as follows:
1. The application App calls the command interface of the business background.
2. The business background constructs a hexadecimal serial port message and then sends it to the hardware network module through the Netty service.
3. The hardware network module processes the serial port message and controls the claw machine by operating the hardware serial port.
Recording service
The wonderful playback function can significantly improve the user's viewing experience and interactive effect. Users can review the wonderful moments of grabbing dolls at any time, especially the moment when they successfully grab the dolls. This not only allows users to experience the joy of success again, but also helps them analyze and improve their skills in grabbing dolls. For this reason, with the help of Tencent Cloud Audio and Video's TRTC cloud recording capabilities, playback recording can be easily achieved.
TRTC cloud recording
TRTC's cloud recording function does not rely on the ability of cloud live broadcast. It uses TRTC's internal real-time recording background to record audio and video, and has a more complete and unified recording experience.
With TRTC's cloud recording function, you can record the audio and video streams of each user in the room into independent files (single stream recording):Or you can combine the audio and video media streams in the same room and record them into one file (combined recording):
Low latency optimization solution
In the online claw machine solution, the tolerance for latency is very low, because the remote machine needs to be controlled with signaling, and the signaling transmission time is relatively short. However, in general scenarios, the TRTC delay is between 300-500ms, which cannot meet business needs. Therefore, the TRTC delay needs to be reduced to 100-200ms or even lower. The following will optimize the delay at each point in the entire transmission link.
Use TRTC SDK to collect and push streams
Use webcams or streaming boxes that integrate Tencent Cloud TRTC SDK to collect and push streams directly to the TRTC room, eliminating the need to use ordinary webcams and distribute them to the TRTC room through the RTMP streaming protocol. In this way, the end-to-end latency can be further optimized from 300-500ms to 100-300ms.
Set the frame rate of the collection
By setting the frame rate of the collection to 30fps and combining it with the policy issued by the cloud control to decode one frame after receiving one frame, the latency can be minimized. The higher the frame rate, the smaller the latency, and the frame rate can be set to 60fps at most.
Set the chorus mode
When the chorus mode is enabled, the background QoS policy will be blocked, and the latency can be further reduced by configuring it separately on the client.
// (lower buffer space)
mTRTCCloud.callExperimentalAPI("{\"api\":\"enableChorus\",\"params\":{\"enable\":1}}");
Conclusion
The online claw machine represents a perfect fusion of entertainment and technology, offering users an engaging and interactive experience that transcends physical boundaries. By understanding the intricacies of its technical architecture—from media streaming and signaling to low-latency optimization and cloud recording—you can create a robust and seamless platform that captivates users and keeps them coming back for more.
If you have any questions or need assistance online, our support team is always ready to help. Please feel free to Contact us or join us on Telegram or Discord. For technical problems, you can also get help directly from developers on Stack Overflow.