tencent cloud

Scenario Solution
Last updated: 2025-06-06 17:03:09
Scenario Solution
Last updated: 2025-06-06 17:03:09

Scenario Introduction

The online claw machine leverages video streaming and remote control technology, enabling users to remotely control the claw of a physical machine in real time through smartphones, tablets, or computers to grab toys or other prizes. It delivers an experience comparable to in-person claw machines while attracting online audiences for interaction and engagement. Tencent Cloud’s Tencent Real-Time Communication (TRTC) ensures end-to-end audio and video latency below 300ms and supports cross-platform compatibility, allowing users to play anytime, anywhere on WeChat Mini Programs, iOS, Android, or Web. The on-cloud recording feature captures exciting gameplay moments for marketing and boosting application influence.



Implementation Scheme

To implement a complete online claw machine scenario, multiple functional modules, such as Media Service and Signaling Service, are typically involved. The key actions and features under each module are outlined in the following table:
Functional Module
Key Actions and Feature Points
Media service
Audio and video streaming and pulling
Signaling service
Remote control
The overall business architecture of the online claw machine is as follows: The control end of the claw machine is equipped with two camera positions for video capture and streaming. When players enter the game interface, they join the corresponding TRTC room linked to the claw machine, allowing them to view the video stream captured by the claw machine’s cameras. After inserting coins or topping up, players can start controlling the claw machine’s claw to grab toys. The audience can also join the game to watch the player’s claw-catching process.




Media service

Audio and Video Push Streaming

RTMP (Real Time Message Protocol) Streaming Upstream
Most network cameras or streaming boxes on the market support RTMP streaming. Using Tencent Cloud TRTC’s rtmp streaming into the room feature, you can directly push video streams from network cameras or streaming boxes to TRTC rooms.



The specific process is as follows:
1. Use Tencent Cloud TRTC’s RTMP generation rules to generate the corresponding RTMP streaming address.
2. Manually configure the RTMP streaming address on the network camera or streaming box of your claw machine.
3. Start the RTMP network camera or streaming box to push the video stream to the TRTC room.
Note:
The related fees are as follows:
Feature unlock: The RTMP streaming into the room feature requires subscribing to the RTC-Engine Packages Basic or Professional Version to unlock.
Usage fees:
Using the streaming feature involves transcoding operations, which generate transcoding fees. For details, see Mixed Stream Transcoding and Bypass Streaming Billing Instructions.
Audio duration fees will be charged for streaming chatbots in the room (note: fees for chatbots in the room generated by the input online media stream feature will be waived until August 15, 2024, and will be charged starting from August 16, 2024).
Audio and video call fees will be incurred when the audience in the room subscribe to the audio and video content streamed into the room. For details, see Audio and Video Duration Billing Instructions.
TRTC Streaming Upstream
Some hardware vendors collaborate with Tencent Cloud TRTC to integrate the Tencent Cloud TRTC SDK into network cameras or streaming boxes, enabling them to directly capture video and push it to TRTC rooms.



The general process is as follows:
1. Manually configure the SDKAppID, UserId, RoomId, and UserSig on the TRTC network camera or streaming box of your claw machine.
2. Start the TRTC network camera or streaming box to push the video stream to the TRTC room.

Audio and Video Pull Streaming

Once the claw machine successfully pushes the audio and video streams to the Tencent Cloud TRTC room, users, whether players or audience members, can enter the corresponding TRTC room to watch the claw machine’s feed in real-time.



The general process is as follows:
1. The business app integrates Tencent Cloud TRTC SDK.
2. The business server is responsible for delivering the necessary SDK parameters, including SDKAppID, UserId, RoomId, and UserSig, to the business application.
3. Users access the TRTC room corresponding to the claw machine through the business application and call the pull-stream API provided by the TRTC SDK to receive and watch the real-time audio and video stream.

Signaling service

The signaling service is responsible for synchronizing control signals. Typically, ready-made hardware control modules are available on the market, equipped with various network communication modes. These modules require no additional development effort, only configuration and debugging.



The communication process of the signaling service is as follows:
1. The application app calls the instruction API of the business backend.
2. The business backend 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’s serial port.

Extended Features

Recording Service

The replay feature can significantly enhance the user experience and interaction. Users can watch the exciting moments of the claw machine game at any time, especially the successful moments of grabbing the toys. This not only allows users to relive the joy of success, but also helps them analyze and improve their clawing skills. With the help of Tencent Cloud’s TRTC on-cloud recording capabilities, the replay feature can be easily implemented.
TRTC On-Cloud Recording
TRTC’s on-cloud recording feature does not rely on cloud streaming services. It uses TRTC’s internal real-time recording backend to record audio and video, offering a more complete and unified recording experience.
With TRTC’s on-cloud recording feature, you can record the audio and video streams of each user in the room as separate individual files (single-stream recording):

Alternatively, you can merge the audio and video streams of the same room into a single file (mix-stream recording):


Key Business Logic

Low Latency Optimization Scheme

In the online claw machine solution, the tolerance for latency is very low because it requires synchronizing with signaling to control the remote machine, and the signaling transmission time is also relatively short. However, in general scenarios, TRTC latency ranges from 300 ms-500 ms, which fails to meet business requirements. Therefore, it is necessary to reduce TRTC latency to 100 ms-300 ms or even lower. The following will optimize the latency at every point in the entire transmission link.


Capturing and Streaming with TRTC SDK

Capturing and Streaming with TRTC SDK
By integrating the Tencent Cloud TRTC SDK with network cameras or pulling boxes to collect and pull video directly to TRTC rooms. This eliminates the intermediate step of using standard network cameras and distributing streams via RTMP transfer protocol to TRTC rooms. Consequently, end-to-end latency can be further reduced from 300 ms-500 ms to 100 ms-300 ms.
Using the Latest Camera Firmware
The firmware of network cameras or pulling boxes integrated with the Tencent Cloud TRTC SDK is continuously being optimized and upgraded. In terms of reducing latency, hardware vendors and the TRTC team are collaborating to optimize. Therefore, when a latency issue is detected, it can be optimized by upgrading the camera firmware to the latest version.
Setting the Frame Rate for Capture
By setting the capture frame rate to 30 fps and implementing a cloud control policy to decode each frame as it is received, latency can be minimized to the greatest extent. The higher the frame rate, the lower the latency, with a maximum frame rate of 60 fps.
Optimizing QoS
Enable the QoS low-latency stream pulling policy, reduce jitter buffer cache, and significantly lower push/pull stream latency. You can contact us to activate it.
Setting Low-Latency Stream Pulling
Since QoS release configurations take some time, you can configure low-latency stream pulling on the terminal. The specific code is as follows:
Android
iOS
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("api", "SetAudioCacheParams");
JSONObject params = new JSONObject();
params.put("min_cache_time", 100); // Local minimum audio cache duration.
params.put("max_cache_time", 600); // Local maximum audio cache duration.
jsonObject.put("params", params);
mTRTCCloud.callExperimentalAPI(String.format(Locale.ENGLISH, jsonObject.toString()));
} catch (JSONException e) {
e.printStackTrace();
}
NSDictionary *jsonDic = @{
@"api": @"SetAudioCacheParams",
@"params": @{
@"min_cache_time": @(100),
@"max_cache_time": @(600)
}
};
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonDic options:NSJSONWritingPrettyPrinted error:nil];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
[trtcCloud callExperimentalAPI:jsonString];
Note:
To configure a low-latency API on the client side, you need to use TRTC version 12.4 or later. Using a version earlier than the version 12.4 will cause the local configurations to override the QoS configurations.
If the latency still does not meet your requirements, contact us for further optimization.

Optimization Scheme for First Frame Time

In the online claw machine or coin pusher scenarios, the first frame loading speed directly affects users' experience of entering the live streaming room. First frame time refers to the total duration from when a user clicks the live streaming room to when the visual is first rendered. The bottleneck may exist in the response of business APIs (including the authentication and room information obtaining) or in the competition between the business component loading and stream-pulling network resources. Therefore, it is necessary to perform instrumentation analysis on the key link to locate the bottleneck and perform targeted optimization accordingly, as shown below.

Targeted optimization:
1. API preloading: Requests the authentication and room information asynchronously in advance to reduce dependencies on the critical path.
2. RTC preferential stream pulling: Prioritizes ensuring TRTC's room entry stream pulling. Upon successful TRTC stream pulling, load other services.
3. Dynamic downgrade: Disables optional features (including gift animation) in weak network conditions.

Supporting Products for the Solution

System Level
Product Name
Applicable Scenarios
Access Layer
Provides low-latency, high-quality real-time audio and video interaction solutions, which are the basic infrastructure capabilities for audio/video call scenarios.
Cloud Services
Oriented to audio-video media, it offers an integrated high-quality media service that includes production and upload, storage, transcoding, media processing, media AI, accelerated distribution and playback, and copyright protection.
Data Storage
Provides storage services for audio and video recording files, as well as audio and video slicing files.

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback