tencent cloud

Real-time Teleoperation

Product Introduction
Overview
Features
Use Cases
Purchase Guide
Free Trial
Billing Overview
Renewal and discontinuation
Quick Start Demo
Development Guide
Multi-Path Network Transmission
Control data transfer
Operation Permission Management
Voice Interaction
Video Viewing and Stream Switching
Field Device SDK
Basic Introduction
SDK Call Procedure
C Field Device SDK API
Field Device Configuration Instructions
Error Codes
Remote Device SDK
Basic Introduction
SDK Call Procedure
C Remote Device SDK API
Remote Device Configuration Description
Error Codes
API Documentation
History
Introduction
API Category
Making API Requests
Project APIs
Device APIs
Session APIs
Authorization APIs
Other APIs
Data Types
Error Codes
SDK and Demo Download
Field Device Side
Remote Device Side
FAQs
Common Issues
Service Agreement
Privacy Policy Module Real-Time Teleoperation
Data Processing and Security Agreement Module Real-Time Teleoperation
Service Level Agreement

SDK Call Procedure

PDF
Modo Foco
Tamanho da Fonte
Última atualização: 2025-02-11 16:48:24


Recommended Steps

Note:
The signalState signaling callback registration needs to be invoked before the initialization function, other callback functions can be registered after initialization.

Step 1: Initialization

Call the Init interface to initialize the SDK with loading a JSON file or inputting a JSON string. . Before initialization, the signalState signaling callback interface should be registered first.

Step 2: Register the necessary callback functions

Register the required callback functions as needed, such as control message callback, log callback, connection status callback, video link information callback, latency information callback, to handle corresponding status information and events.

Step 3: Start SDK to enter video managed state

Invoke TRRO_start to enter the managed state. At this point, the SDK will listen to various requests, automatically carry out video capture, video streaming, and handle abnormal events such as network disconnection.

Step 4: Call the data send function as needed

When there is a need to input external video data or binary data, call the corresponding sending interface to input the video data or binary control/status data at the required sending time.

Sample Code

#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <thread>
#include "trro_field.h"

// External input video data
void externalVideoInput(int stream_id) {
int data_width = 1280;
int data_height = 720;
char *data = (char*)malloc(data_width*data_height*3/2);
// YUV420 video data, using all-zero simulated data (Green Map) in the sample for illustration
memset(data, 0, data_size);
while(true) {
TRRO_externalVideoData(stream_id, data, data_width, data_height, 0);
usleep(33 * 1000);
}
free(data);
}

// Main thread
int main() {
// Register signal callback
TRRO_registerSignalStateCallback(nullptr, [](void *context, SignalState state) {
if(state == kTrroReady) {
// Server connection successful, register callback function, and start SDK management
printf("init success \\n");
TRRO_registerControlDataCallback(nullptr, [](void * context, const char* controlid, const char* msg, int len, int cmd) {
printf("receive control data from %s: %s\\n", controlid, msg);
});
TRRO_registerOnState(nullptr, [](void* context, int stream_id, int state) {
printf("stream_id: %d, state: %d\\n", stream_id, state);
});
TRRO_registerOnErrorEvent(nullptr, [](void* context, int error_code, const char* error_msg) {
printf("error_code %d, error_msg %s\\n", error_code, error_msg);
});
TRRO_registerVideoCaptureCallback(nullptr, [](void *context, const char* data, int width, int height, int type, int stream_id) {});
TRRO_registerLatencyCallback(nullptr, [](void *context, int stream_id, int vcct){
printf("LatencyCallbac context: %p, stream id %d, vcct %d\\n", context, stream_id, vcct);
});
TRRO_registerMediaState(nullptr, [](void* context, int stream_id, int fps, int bps, int rtt, long long lost, long long packets_send, int stun) {
printf("stream %d, fps %d, bps %d, rtt %d, lost %lld, packets_send %lld, stun %d\\n", stream_id, fps, bps, rtt, lost, packets_send, stun);
});
TRRO_registerOperationPermissionRequest(nullptr, [](void* context, const char* remote_devid, int permission) {
printf("remote devid %s permission %d\\n", remote_devid, permission);
});
int ret = TRRO_start();
// After init successfully connects to the service, TRRO SDK management can be started
if(TRRO_SUCCED == ret) {
printf("start succeed\\n");
} else if (ret == -TRRO_INIT_LICENSE_FILE_ERROR || ret == -TRRO_INIT_LICENSE_CHECK_FAILED) {
printf("start license error, wait for regist or exit error:%d\\n", ret);
} else {
// Pay attention to configuration issues
printf("start config error, please check config it, error:%d\\n", ret);
}
}
if (state == kTrroAuthFailed) {
printf("device_id or password is incorrect\\n");
}
if (state == kTrroKickout) {
printf("the device is kicked by server, may be there is another device using the same device id\\n");
}
});

// It is recommended to use -1 for the last parameter to start in non-blocking mode and wait for the signaling connection success callback
// You can replace it with other initialization functions as needed, such as initializing with a configuration string
int ret = TRRO_initGwPathWithLicense("./config.json", "./license.txt", -1);
if(TRRO_SUCCED != ret) {
if (ret == -TRRO_SIGNAL_CONNECT_OUTTIME) {
printf("init process: wait for connecting\\n");
} else {
printf("init fail ret %d\\n", ret);
}
}

// Start an external input video data thread, input video data to stream 0, stream 0 protocol must be 'outside'
// std::thread t1(externalVideoInput, 0);
// t1.detach();
// Prevent the program from exiting
while(true){
sleep(30000);
}
return 0;
}


Ajuda e Suporte

Esta página foi útil?

comentários