tencent cloud

All product documents
Video Viewing and Stream Switching
Last updated: 2025-02-11 16:47:37
Video Viewing and Stream Switching
Last updated: 2025-02-11 16:47:37
Note:
Video viewing and stream switching are used for the remote device to control the display of video streams of field device. Currently, it supports viewing and switching multiple video streams from multiple field devices. The remote device SDK initiates this without requiring any operations on the field device SDK.

Usage Introduction

Receiving Video Stream

When the remote device receives video streams, calling the TRRO_connect interface will receive the video stream through the video stream receiver and associate it with the video display window set through the TRRO_setWindows interface. The following diagram illustrates the association relationship between a set of video streams and display windows:



field device video stream:Uniquely identified by fieldDeviceID + Stream ID. Stream ID numbers range from 0 to N, corresponding to the element numbers in the video stream array in the streams_config configuration.
Video Display Window:Uniquely identified by the video window handle, such as HWND in win32. In internal rendering mode, the SDK can render and display the video on the specified window according to the video window handle. In external rendering mode, the developer maintains the video display window and video rendering display.
Remote Device Video Stream Receiver:Uniquely identified by the receive handle (conn_fd). The receive handle numbers increment from 0 and can be customized by the developer, usually set to the window number.
Note:
At the same time, a video stream receiver can only receive one video stream. When the video stream receiver connects to a new video stream, the previously connected video stream will automatically disconnect.
It can be seen that for internal rendering, the remote device video stream receiver bridges the field device video stream and the video window, allowing the SDK to automatically complete video stream display. For external rendering, the remote device video stream receiver handle assists the developer in identifying which receiver the video stream data is from and which windows should be rendered on.

Video Stream Switching

When the remote device switches video streams, it can be done through the TRRO_connect interface. Depending on whether the newly switched video stream needs to be displayed in a new window, there are two scenarios:
1. Switching video streams to display in an existing window:
Use the receive handle corresponding to the existing window, and receive the video stream to be switched to the window through the TRRO_connect interface. In this case, the new video stream will switch to the corresponding window, and the previous video stream on the window will be disconnected.
2. Switching video streams to display in a new window:
Use the receive handle corresponding to the new window, receive the switched video stream through the TRRO_connect interface, and disconnect the pre-switch video stream through the TRRO_disconnect interface.

Video Window Switching

In the internal rendering mode, when the remote device switches video windows, it can be done through the TRRO_setWindows interface. Generally, during the SDK startup phase, the receive handle of the video stream receiver will be associated with the video window. When window layout adjustments are needed (e.g., swapping two video streams' windows without switching the video streams themselves), the TRRO_setWindows interface can be used to update the corresponding relationship between the receive handle of the video stream receiver and the video window, completing the video stream window switch without disconnecting the video stream.

Relevant APIs

Connecting Video Stream

Instructions: This interface can be used to connect and switch the video streams of field device.
/*
* @name : TRRO_connect
* @brief : Initiates a video connection. Multiple calls can be made to connect different streams. Asynchronous mode, confirms successful video connection based on the onState status callback
* @input : gwid ID of the target on-site equipment to connect
* record_config:
* Default is to use global recording configuration. When the default naming rules cannot meet the needs, use a JSON string to configure each stream. e.g.: "{\\"file_names\\": [{\\"file\\":\\"test\\", \\"duration\\":15}, {\\"file\\":\\"test01\\", \\"duration\\":15}]}" ps: file - filename, duration - chunk duration in seconds
* streams_num is the number of live device video streams to be pulled, matching the length of the conn_fds and streams_num arrays, with values ranging from 1 to the number of device_streams supported by the live device
* streams_id Array of field device video stream IDs. The field device video stream ID starts from 0, with a maximum value of the number of device_streams supported by the on-site equipment - 1
* conn_fds is the array of conn_fd, where conn_fd represents the handle identifier for receiving video streams. It is numbered by the user, starting from 0, with the maximum value being max_streams - 1. max_streams is configured in the remote device configuration file
* @return : 1 for success; <= 0 for failure
*/
int TRRO_connect(const char* gwid, const char* record_config, int streams_num, int* streams_id, int* conn_fds);
Parameter
Meaning
gwid
field device ID
record_config
video recording configuration.json string, each video stream to be connected needs to be configured. It is recommended to use the global recording configuration by default, and use this method when it cannot be satisfied.
{
"file_names": [{
"file": "test",
"duration": 15
},
{
"file": "test01",
"duration": 15
}]
}
The parameters are described as follows:
file: File Name
duration: slice duration (unit: seconds)
streams_num
number of video streams to be connected
streams_id
Array of video stream IDs of field device to be connected
conn_fds
Array of handles used to receive video streams
Returned values
Success 1
Failed <= 0

Set video stream rendering window

Instructions: You can set the rendering window through this interface. It is used for internal rendering. If rendering externally, set it to a null pointer.
/*
* @name : TRRO_setWindows
* @brief : Set the display window handle corresponding to the receiving stream handle
* @input : conn_fds Array of handles used to receive video streams
* windows Array of display window handles. The display window handle is the handle/pointer of the display form, such as HWND on the Windows platform;
* When rendering externally, configure the display window handles in the array as nullptr
* num Set the number of display windows to match the length of conn_fds and Windows arrays
* @return :void
*/
void TRRO_setWindows(int* conn_fds, WindowIdType * windows, int num);
Parameter
Meaning
conn_fds
Array of handles used to receive video streams
windows
Array of display window handles, can be set to a null pointer array for external rendering
num
Consistent length with conn_fds and windows arrays

Close video connections

Instructions: This interface can be used to disconnect video connections.

Close specified video connection

/*
* @name : TRRO_disconnect
* @brief : Close the video connection corresponding to conn_fds
* @input : conn_fds Array of handles for the video connections to be closed
* fd_num Length of the conn_fd array
* @return : 1 for success; <= 0 for failure
*/
int TRRO_disconnect(int* conn_fds, int fd_num);
Parameter
Meaning
conn_fd
Array of video receiving handles
fd_num
Array length
Returned values
Success 1
Failed <= 0

Close all video connections

/*
* @name : TRRO_disconnectAll
* @brief : Close all video connections
* @input : void
* @return : 1 for success; <= 0 for failure
*/
int TRRO_disconnectAll();

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

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon