Data processing method and device, electronic equipment and medium

By receiving heartbeat commands from network devices, storing information, and establishing a direct point-to-point connection when the target device is online, the problem of high server load in security audio and video transmission using P2P hole punching technology is solved, achieving low-cost and high-efficiency audio and video transmission.

CN121509401APending Publication Date: 2026-02-10SHENZHEN STARCAM TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511451939.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-11
Publication Date
2026-02-10

AI Technical Summary

Technical Problem

Existing P2P hole punching technology has problems in security audio and video transmission, such as low hole punching success rate, difficulty in success under symmetric NAT environment, poor multi-platform compatibility, incomplete support for low-power devices, and reliance on dedicated forwarding servers after hole punching failure, resulting in high server load, high cost and low transmission efficiency.

Method used

By receiving heartbeat commands from network devices and storing network and device information, the target network device is determined based on the query request, and a point-to-point direct connection is established through the Session Description Protocol when the target device is online, reducing dependence on servers.

Benefits of technology

It significantly reduces server bandwidth consumption and load, lowers costs, and improves audio and video transmission speed, solving the problems of high server costs, heavy load, and low transmission efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121509401A_ABST
    Figure CN121509401A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a data processing method and device, electronic equipment and a storage medium, and the method comprises the steps: storing the network information and equipment information of network equipment when a heartbeat instruction sent by the network equipment through a user datagram protocol is received; when a query request sent by a client is received, determining a target network device corresponding to the query request; and if the target network device is in the online state, scheduling the target network device to interact a session description protocol with the client, so as to establish point-to-point direct connection between the target network device and the client through the interacted session description protocol. And the requirements of multiple platforms and low-power-consumption equipment are met, and the dependence of the server is reduced through one step.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data processing technology, specifically to a data processing method, apparatus, electronic device, and storage medium. Background Technology

[0002] In the security industry, audio and video data transmission is one of the core business requirements. This is especially true when the number of cameras online simultaneously reaches hundreds of thousands or even millions, with a large number of users concurrently viewing camera feeds, consuming massive amounts of network bandwidth to ensure transmission quality. Currently, traditional audio and video transmission solutions in the industry mostly rely on a server-wide forwarding mode. In this mode, all audio and video data must pass through the server, which not only incurs high server bandwidth and maintenance costs but also leads to excessive server load due to the massive number of devices connected, easily causing problems such as response delays, transmission stutters, and even service interruptions. This makes it difficult to meet the dual requirements of security scenarios for transmission stability and cost control.

[0003] To address the aforementioned server cost and pressure issues, P2P hole punching technology has been gradually applied to the field of security audio and video transmission, aiming to reduce reliance on servers by establishing direct connections between clients and devices. However, existing P2P hole punching technology still has significant drawbacks: First, the success rate of hole punching is significantly affected by the NAT type of the device's network exit; hole punching is extremely difficult in complex network environments such as symmetric NAT, and there is a lack of optimization strategies for different NAT types. Second, it lacks adaptability to multi-platform access; platforms such as web clients require additional development of adaptation modules to access the P2P system, resulting in poor compatibility. Third, support for low-power security devices (such as low-power cameras) is incomplete; devices are difficult to wake up quickly from sleep mode, and the heartbeat maintenance mechanism consumes a lot of power, affecting device battery life. Fourth, after a hole punching failure, it relies excessively on dedicated forwarding servers, failing to effectively reduce server resource consumption. Summary of the Invention

[0004] This application provides a data processing method, electronic device, apparatus, and storage medium that can improve the success rate of hole punching, adapt to the needs of multiple platforms and low-power devices, and reduce server dependence.

[0005] In a first aspect, embodiments of this application provide a data processing method, including: When a heartbeat command is received from a network device via User Datagram Protocol, the network information and device information of the network device are stored. When a query request is received from a client, the target network device corresponding to the query request is determined; If the target network device is online, the target network device is scheduled to interact with the client using the Session Description Protocol (STP) to establish a point-to-point direct connection between the target network device and the client.

[0006] Optionally, in some embodiments of this application, determining the target network device corresponding to the query request when a query request is received from a client includes: When a query request is received from a client, the device identifier is extracted from the query request; Based on the device identifier and the pre-stored device information, the target network device corresponding to the query request is determined.

[0007] Optionally, in some embodiments of this application, determining the target network device corresponding to the query request based on the device identifier and pre-stored device information includes: Parse the serial number from the device identifier; The validity of the digital serial number is verified; When the validity of the digital serial number is verified, the target device information is obtained from the pre-stored device information using the digital serial number. The network device corresponding to the target device information is determined as the target network device corresponding to the query request.

[0008] Optionally, in some embodiments of this application, the step of scheduling the target network device to interact with the client using a Session Description Protocol (SMAP) if the target network device is online, in order to establish a point-to-point direct connection between the target network device and the client through the interacting SMAP, includes: If the target network device is online, then verify the client's access permissions and the interaction status of the target network device; If the client's access permissions and the target network device's interaction status are both verified, the first session description signaling generated by the client is forwarded to the target network device; and the second session description signaling generated by the target network device based on the first session description signaling is forwarded to the client, so as to establish a point-to-point direct connection between the target network device and the client through the interactive session description protocol.

[0009] Optionally, in some embodiments of this application, it further includes: The client creates a first User Datagram Protocol (UDP) interface and determines a first target port based on the second session description signaling. The target network device creates a second User Datagram Protocol (UDP) interface and determines a second target port based on the first session description signaling; A point-to-point direct connection is established between the target network device and the client based on the first User Datagram Protocol (UDP) interface, the second UDP interface, the first target port, and the second target port.

[0010] Optionally, in some embodiments of this application, it further includes: If the point-to-point direct connection between the target network device and the client fails to be established within a preset time, the target data is transmitted through a forwarding node, and a point-to-point direct connection between the target network device and the client is established according to a preset time interval and the session description protocol of the interaction. When a direct point-to-point connection is established between the target network device and the client, the connection is switched to a direct point-to-point connection.

[0011] Optionally, in some embodiments of this application, it further includes: If the target network device is offline, then obtain the device type of the target network device; If the device type is the first type, then output a message indicating that the device is offline; If the device type is the second type, then the target network device is woken up; if a wake-up signal is received from the target network device within a preset time period, then the step of scheduling the target network device to interact with the client using the session description protocol is executed.

[0012] Secondly, embodiments of this application provide a data processing apparatus, including: The storage module is used to store the network information and device information of the network device when it receives a heartbeat command sent by the network device via the User Datagram Protocol. The determination module is used to determine the target network device corresponding to the query request when a query request is received from a client. The processing module is configured to, if the target network device is online, schedule the target network device to interact with the client using the Session Description Protocol (SMAP) to establish a point-to-point direct connection between the target network device and the client through the interactive SMAP.

[0013] Accordingly, this application also provides an electronic device, including a memory, a processor, and a processor program stored in the memory and executable on the processor, wherein the processor executes the program as described in any of the methods above.

[0014] This application also provides a storage medium storing a processor program that, when executed by a processor, implements any of the methods described above.

[0015] This application provides a data processing method, apparatus, electronic device, and storage medium. When a heartbeat command sent by a network device via User Datagram Protocol (UDP) is received, the network information and device information of the network device are stored. When a query request sent by a client is received, the target network device corresponding to the query request is determined. If the target network device is online, the target network device is scheduled to interact with the client using a Session Description Protocol (SMAP) to establish a point-to-point direct connection between the target network device and the client. In the data processing scheme provided in this application, a heartbeat command sent by a network device via UDP is first received, and its network information and device information are stored to lay the foundation for subsequent connections. Upon receiving a client query request, the target network device is determined. If the target device is online, both parties are scheduled to interact using a SMAP to establish a point-to-point direct connection. This process eliminates the need for full server forwarding, significantly reducing server bandwidth consumption and load, lowering costs, and shortening the transmission link, improving audio and video transmission speed, thereby solving the problems of high server costs, high pressure, and low transmission efficiency in the prior art. Attached Figure Description

[0016] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0017] Figure 1 This is a flowchart illustrating the data processing method provided in an embodiment of this application; Figure 2 This is a schematic diagram of the architecture of the data processing system provided in the embodiments of this application; Figure 3 This is a schematic diagram of the structure of the data processing apparatus provided in the embodiments of this application; Figure 4 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0018] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0019] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, components, features, and elements with the same names in different embodiments of this application may have the same meaning or different meanings, the specific meaning of which must be determined by its interpretation in that specific embodiment or further in conjunction with the context of that specific embodiment.

[0020] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.

[0021] In the following description, the use of suffixes such as "module," "part," or "unit" to denote elements is solely for the purpose of illustrative purposes and has no specific meaning in itself. Therefore, "module," "part," or "unit" may be used interchangeably.

[0022] The following describes in detail the embodiments involved in this application. It should be noted that the order of description of the embodiments in this application is not intended to limit the priority of the embodiments.

[0023] This application provides a data processing method, apparatus, storage medium, and smart terminal. Specifically, the data processing method of this application can be executed by a smart terminal or a server, wherein the smart terminal can be a terminal. The terminal can be a smartphone, tablet computer, laptop computer, touch screen, game console, personal computer (PC), personal digital assistant (PDA), or other smart terminal. The terminal may also include a client, which can be a media playback client or an instant messaging client, etc.

[0024] This application provides a data processing method that can be executed by an electronic device or a server. This application describes the data processing method executed by an electronic device as an example. The electronic device includes a touch screen and a processor. The touch screen is used to display a graphical user interface (GUI) and receive operation commands generated by the user interacting with the GUI. When the user operates the GUI through the touch screen, the GUI can control the local content of the electronic device in response to the received operation commands, or it can control the content on the server side in response to the received operation commands.

[0025] The data processing solution provided in this application first receives heartbeat commands sent by network devices via the User Datagram Protocol (UDP), stores their network and device information, and lays the foundation for subsequent connections. Upon receiving a client query request, it identifies the target network device. If the target device is online, it schedules the interaction of the Session Description Protocol (STP) between the two parties to establish a point-to-point direct connection. This process eliminates the need for full forwarding by the server, significantly reducing server bandwidth consumption and load, lowering costs, and shortening the transmission link through point-to-point direct connection, thereby improving audio and video transmission speed and solving the problems of high server costs, high pressure, and low transmission efficiency in the background technology.

[0026] The following sections provide detailed descriptions of each example. It should be noted that the order in which the embodiments are described is not intended to limit the priority of the embodiments.

[0027] A data processing method includes: when receiving a heartbeat command sent by a network device via User Datagram Protocol (UDP), storing network information and device information of the network device; when receiving a query request sent by a client, determining the target network device corresponding to the query request; if the target network device is online, scheduling the target network device to interact with the client using a Session Description Protocol (STP) to establish a point-to-point direct connection between the target network device and the client through the interactive STP.

[0028] Please see Figure 1 , Figure 1 This application provides a schematic flowchart of a data processing method. The specific flow of this data processing method is as follows: 101. When a heartbeat command is received from a network device via the User Datagram Protocol, the network information and device information of the network device are stored.

[0029] Network devices: These refer to terminal devices (such as security cameras) in a peer-to-peer (P2P) system. They are passive devices in the system and need to actively listen for client connections and initiate heartbeats.

[0030] User Datagram Protocol (UDP) is a connectionless, low-latency network transport protocol used for heartbeat transmission between devices and P2P servers, and for Network Address Translation (NAT) hole punching between clients and devices. NAT hole punching refers to the process where the client and the target network device first exchange SDP signaling containing their respective external IP addresses and NAT-mapped ports through a P2P server. Then, both parties use UDP as the transport protocol to send request packets to each other's external IP addresses and NAT-mapped ports (including ports after port floating up and down), establishing a temporary data transmission channel on their respective NAT devices, thereby breaking through NAT restrictions and achieving direct connection.

[0031] Heartbeat commands refer to status notification data packets that network devices periodically send after startup. Their purpose is to maintain the device's online status, update the device's real-time status, and prevent the server from mistakenly judging the device as offline. The documentation clearly states that the device sends heartbeats via UDP / TCP to stay online.

[0032] Network information: Public network access parameters of network devices, mainly including the NAT type of the network where the device is located (full cone, IP restricted, etc.), external IP address, and NAT mapping port (including the port used for hole punching).

[0033] For example, specifically, the system listens for heartbeat commands sent by network devices through a preset UDP port. These heartbeat commands are proactively sent by the device at fixed intervals (e.g., every 30 seconds) after startup, using the User Datagram Protocol (UDP) to ensure low-latency transmission and real-time updates to the device status. Then, the received UDP heartbeat commands are parsed to extract the device's NAT type (e.g., full cone, symmetric), external IP address, and the port number mapped by NAT. This information is autonomously detected by the device before sending the heartbeat command and encapsulated within it. The system also extracts the device's unique ID (containing a 4-letter prefix, an 8-digit serial number, and a 5-letter checksum). Optionally, in some embodiments of this application, the parsed network information (NAT type, external IP address, mapped port) is associated with the device information (unique ID, low-power attributes) and stored at corresponding index positions.

[0034] 102. When a query request is received from a client, determine the target network device corresponding to the query request.

[0035] A query request is a request made by the client after it starts to confirm whether the network device to be connected is online. The request must carry the unique identifier of the target network device.

[0036] For example, a query request sent by a client can be received through a preset port. This request must contain the device identifier (unique device ID) of the target network device. Then, based on the device identifier and the pre-stored device information (i.e., the device information stored in step 101), the target network device corresponding to the query request is determined. That is, optionally, in some embodiments of this application, the step "when a query request is received from a client, determine the target network device corresponding to the query request" may specifically include: When a query request is received from a client, the device identifier is extracted from the query request; Based on the device identifier and pre-stored device information, determine the target network device corresponding to the query request.

[0037] For example, specifically, the query request is parsed to extract the device identifier. Then, the device identifier is parsed to obtain the core location field (such as an 8-digit serial number). Next, using the serial number as the array index, the pre-stored device information is accessed and compared with the device identifier stored in the array storage unit. If they are completely consistent, it means that the device corresponding to the storage unit is the target network device of the query request. After the target device is located and determined, the key information of the device is extracted from the array storage unit.

[0038] Optionally, in some embodiments of this application, the step "determining the target network device corresponding to the query request based on the device identifier and pre-stored device information" may specifically include: Parse the serial number from the device identifier; Verify the validity of the digital serial number; When the validity of the digital serial number is verified, the target device information is obtained from the pre-stored device information using the digital serial number. The network device corresponding to the target device information is identified as the target network device corresponding to the query request.

[0039] In this context, validity refers to the serial number's ability to correctly link to a pre-stored array of device information. The core purpose is to prevent device location failures or access to invalid array cells due to abnormal serial numbers. The criteria for validity can be based on the server's device information storage mechanism: first, the serial number format must conform to the 8-digit pure numeric requirement, ensuring it can be recognized as a valid index; second, the serial number value must be within the range of 0-99999999, ensuring it can match a valid storage unit in the array (for example, if the array capacity corresponds to 10 million devices, the index range is 0-99999999). Only when both requirements are met simultaneously is the serial number valid.

[0040] It should be noted that the device identifier is a unique ID for each device. Its fixed structure can be a 4-letter prefix + an 8-digit serial number + a 5-letter check digit. Therefore, during parsing, the device identifier can be split according to this structure, the 8-digit serial number can be extracted, and then the serial number can be validated for format and range. Format validation: confirms that the parsed serial number is a pure 8-digit number without any letters, symbols, or mismatched digits; range validation: confirms that the serial number value is within a preset range, such as 0-99999999.

[0041] After successful verification, the target device information is retrieved using the serial number. Each device, upon startup and sending a heartbeat, uses its unique 8-digit serial number as an array index to store complete device information (including network information, online status, device attributes, etc.) at the corresponding index location. Once the serial number verification is successful, the corresponding storage unit in the array is accessed directly using that serial number as the array index to retrieve the complete target device information, thus identifying the target network device.

[0042] 103. If the target network device is online, the target network device and the client interact with the Session Description Protocol (STP) to establish a point-to-point direct connection between the target network device and the client through the interactive STP.

[0043] The Session Description Protocol (SDP) is a signaling protocol used to describe the parameters required for network connection between the target network device and the client. Its core function is to exchange key network information between the two parties (such as external IP addresses, NAT-mapped ports, etc.). A point-to-point direct connection between the target network device and the client refers to a data transmission channel established directly between the two parties after successful UDP hole punching, without relying on a server as an intermediary. This channel can directly transmit audio and video data without going through a third-party server, significantly reducing server bandwidth consumption and load, while shortening the data transmission link and improving audio and video transmission speed.

[0044] After confirming that the target network device is online, the client generates a first SDP signaling message containing its own network parameters (such as external IP address, NAT mapping port, etc.) and sends it to the server. Upon receiving this message, the server forwards it to the target network device based on the target device's identifier, allowing the device to obtain the client's critical network information. The target network device, upon receiving the first SDP signaling message, generates a second SDP signaling message containing its own network parameters (external IP address, NAT mapping port, etc.) and sends it to the server. The server then forwards this second SDP signaling message to the client, enabling the client to obtain the device's critical network information, thus completing the exchange of network information between the two parties.

[0045] The target network device and the client initiate a UDP hole punching request based on SDP. The client and the target network device respectively parse the received SDP signaling, obtain the other party's external IP and NAT mapping port, and then simultaneously initiate a hole punching request to the corresponding port of the other party via UDP.

[0046] After successful hole punching, a direct point-to-point connection is established. If the UDP hole punching requests from both parties can successfully penetrate the NAT and be received by the other party, then the hole punching is successful. At this time, the target network device and the client no longer need to go through a server or forwarding server. They can directly establish a stable data transmission channel based on the network parameters in the previously exchanged SDP signaling, thus realizing a direct point-to-point connection.

[0047] Optionally, in some embodiments of this application, the step "if the target network device is online, then schedule the target network device to interact with the client using the Session Description Protocol to establish a point-to-point direct connection between the target network device and the client through the interactive Session Description Protocol" may specifically include: If the target network device is online, verify the client's access permissions and the interaction status of the target network device; If the client's access permissions and the target network device's interaction status are both verified, the first session description signaling generated by the client is forwarded to the target network device; and the second session description signaling generated by the target network device based on the first session description signaling is forwarded to the client, so as to establish a point-to-point direct connection between the target network device and the client through the interactive session description protocol.

[0048] Access permissions refer to whether a client has the legal right to connect to and access the target network device. The client must provide a valid identifier associated with the target device, or be able to generate an encryption key matching the device through a key generator, in order to pass the access verification. Interaction status refers to whether the target network device currently has the conditions to establish a connection with the client and exchange data. Its core purpose is to ensure that the connection can be established stably without affecting the device's existing functions.

[0049] Specifically, the client's identity identifier can be matched with pre-stored target device authorization information (such as client identifiers allowed to access the device and encrypted verification information). When the target network device is still online and there are no connection conflicts (e.g., the target network device is not acting as a forwarding device to provide services for other connections, and no other clients are establishing connections or transmitting data with the device), if the client's access permissions and the target device's interaction status are verified, the P2P server receives the first SDP signaling generated by the client (containing network parameters such as the client's external IP address and NAT mapping port), locates the device based on the target device's unique ID, and forwards the first SDP signaling to the target network device. After receiving the first SDP signaling, the target network device generates a second SDP signaling containing its own external IP address, NAT mapping port, and other parameters, and sends it to the server. After receiving it, the server forwards the second SDP signaling to the client, enabling the client to obtain the device's network parameters and complete the exchange of network information between the two parties.

[0050] Finally, the client and the target network device parse the received SDP signaling to obtain each other's external IP and NAT mapping port. Then, they initiate hole punching on the corresponding port of the other party via UDP (the client sends UDP packets to the device's port, and the device sends UDP packets to the client's port). If the hole punching is successful, the two parties do not need a server relay and directly establish a stable data transmission channel based on the parameters in the SDP signaling to achieve point-to-point direct connection. Subsequent audio and video data can be directly transmitted through this channel.

[0051] Optionally, in some embodiments of this application, it may further include: The client creates a first User Datagram Protocol (UDP) interface and determines the first target port based on the second session description signaling. The target network device creates a second User Datagram Protocol (UDP) interface and determines the second target port based on the first session description signaling; A point-to-point direct connection is established between the target network device and the client based on the first User Datagram Protocol (UDP) interface, the second UDP interface, the first target port, and the second target port.

[0052] In this P2P system, the client, as the active end, needs to create a first UDP interface (i.e., a UDP socket) to initiate UDP hole punching. This interface is the basic carrier for data transmission between the client and the target network device. Subsequently, the client receives and parses the second session description signaling (SDP) relayed by the target network device through the P2P server. This second session description signaling contains key network parameters such as the target network device's external IP address and NAT mapping port. The client extracts the target network device's NAT mapping port from it and identifies it as the first target port (i.e., the client needs to send a UDP hole punching request to this port to penetrate the NAT).

[0053] After receiving the first Session Description Signaling (SDP) relayed by the client through the P2P server, the target network device (i.e., the P2P device, which is the passive end of the system) first creates a second UDP interface to enable communication by initiating UDP hole punching to the client. Then, the device parses the first Session Description Signaling, extracts the client's NAT-mapped port, and determines it as the second target port (i.e., the device needs to send a UDP hole punching request to this port to penetrate its own NAT).

[0054] The client continuously sends UDP hole-punching packets to the first target port (the NAT-mapped port of the target network device) through the first UDP interface; simultaneously, the target network device continuously sends UDP hole-punching packets to the second target port (the client's NAT-mapped port) through the second UDP interface. When both parties' UDP packets can penetrate their respective NATs and be successfully received by the other (i.e., UDP hole punching is successful), a stable data transmission channel is established based on the first and second UDP interfaces, and the corresponding first and second target ports, enabling a direct point-to-point connection between the target network device and the client. Subsequent audio and video data can be transmitted directly through this channel without relying on a P2P server or forwarding server.

[0055] Optionally, in some embodiments of this application, it may further include: If the point-to-point direct connection between the target network device and the client fails to be established within the preset time, the target data is transmitted through the forwarding node, and the point-to-point direct connection between the target network device and the client is established according to the preset time interval and the session description protocol of the interaction. When a direct point-to-point connection is established between the target network device and the client, it switches to a direct point-to-point connection.

[0056] In this process, after the client and the target network device (P2P device) initiate UDP hole punching based on the previously exchanged Session Description Protocol (SDP) signaling, the system monitors the direct connection creation progress in real time. If a direct connection is not successfully established within a preset time (e.g., 30 seconds) (i.e., the UDP hole punching packets from both parties fail to penetrate each other's NATs and reach each other), it is determined that the point-to-point direct connection creation has failed. After the direct connection creation fails, the system automatically activates a P2P forwarding server (i.e., a forwarding node) as a data relay carrier: the client sends the target data (e.g., security audio and video data) to the forwarding server, and the forwarding server then forwards the data to the target network device, and vice versa. The forwarding server provides UDP / TCP forwarding services according to its own type (e.g., a general forwarding server, a dedicated forwarding server for specific prefix devices) to ensure uninterrupted audio and video communication. At this time, data transmission relies on the forwarding server, rather than a direct connection.

[0057] While transmitting data through forwarding nodes, the system re-initiates point-to-point direct connection establishment attempts at preset time intervals (such as every 20 seconds). During the retry, the SDP signaling of the previous interaction between the client and the target network device is still used. The client and the target network device initiate UDP hole punching again, and a port floating strategy is adopted during the hole punching process (such as ±1 or ±2 based on the mapped port recorded in SDP) to improve the success rate of NAT traversal.

[0058] The system continuously monitors the direct connection creation status during the retry process. If a UDP hole punching is successful (both parties successfully receive each other's UDP packets, penetrating NAT restrictions), the point-to-point direct connection is determined to be successfully created. At this time, the system automatically shuts down the relay service of the forwarding node and seamlessly switches the data transmission link to a point-to-point direct connection between the client and the target network device. This switching process is completely imperceptible to upper-layer applications (such as users viewing camera footage) and does not affect the continuity of audio and video transmission.

[0059] Optionally, in some embodiments of this application, it may further include: If the target network device is offline, obtain the device type of the target network device; If the device type is Type 1, output a message indicating that the device is offline; If the device type is type 2, then wake up the target network device; if a wake-up signal is received from the target network device within a preset time, then execute the steps of scheduling the target network device and the client to interact with the session description protocol.

[0060] For example, specifically, offline status of a target network device is determined by monitoring its heartbeat status. If no heartbeat is received from the device within a preset heartbeat timeout period, the device is determined to be offline. Subsequently, the device type attribute is extracted from the pre-stored device information (stored in association with the device's unique ID, the ID structure being a 4-letter prefix + an 8-digit serial number + a 5-letter checksum).

[0061] If the device type is Type 1 (ordinary device), the device will be offline. If the obtained device type is Type 1 (i.e., a non-low-power ordinary device, such as a regular security camera), since such devices do not have a special wake-up mechanism, the terminal will directly output a device offline message to the client that initiated the query, informing the user that it is currently unable to establish a connection with the target device, and terminating the subsequent connection process to avoid invalid operations.

[0062] If the device type is Type 2 (low-power device), a wake-up command is sent directly to the target network device.

[0063] Within a preset time period (e.g., 30-60 seconds), monitor whether a wake-up signal is received from the target network device (after the device is woken up, it will resume sending TCP low-power heartbeats to the server, or actively send back a confirmation signal that the wake-up was successful); if the wake-up signal is successfully received within the preset time period, it means that the target device is online, and at this time, the steps of scheduling the target network device to interact with the client using the Session Description Protocol (SDP) are executed.

[0064] To further understand the data processing scheme of the embodiments of this application, please refer to Figure 2 The following description uses a data processing system as an example. In some embodiments of this application, the data processing system is also referred to as a P2P system. The P2P system includes a P2P server (also called a master control server or signaling server), a forwarding server, a client, and a device, as detailed below: The server is the core of the entire P2P system, responsible for scheduling communication between the device, the client, and the forwarding server. Its specific functions are as follows: 1) Generally, three P2P servers are collectively referred to as a P2P server. 2) After the device is powered on, it maintains a heartbeat with the server via UDP / TCP. 3) When a client wants to connect to a device, it first checks with the P2P server to see if the device is online. If it is online, both parties exchange SDP hole punching information through the P2P server, and then perform hole punching. 4) The forwarding server will actively report to the P2P server to keep track of its online status. When the client and device fail to connect via UDP hole punching, they will connect through the forwarding server to achieve audio and video communication.

[0065] Forwarding servers are also crucial in P2P systems. When UDP hole punching fails, the connection between the device and the client relies entirely on the forwarding server for communication. Its specific functions are as follows: 1) One forwarding server can provide forwarding services for multiple P2P servers. 2) Forwarding servers are divided into 3 types: a) Provide forwarding only for devices with a specific prefix. b) Prioritize forwarding among all forwarding servers. Ordinary forwarding server 3) Provide UDP / TCP forwarding functionality The device is a passive end in the P2P system, actively listening for client connections. Its specific functions are as follows: 1) After the device starts up, it first sends a heartbeat to the P2P server. 2) Actively listen for client connections 3) After receiving the SDP signaling from the client, initiate hole punching to the client via UDP. 4) If hole punching fails, the request will be forwarded through the server. 5) If hole punching is successful or server forwarding is successful, the connection is successful. The client is the active end in the P2P system, initiating connections to specific devices. Its specific functions are as follows: 1) After the client starts, it queries the P2P server to see if the device it needs to connect to is online. 2) When online, a connection is initiated to the device through a P2P server, and SDP signaling is exchanged between them. 3) Perform UDP hole punching on the device side 4) If hole punching fails, the request will be forwarded through the server. 5) If the hole punching is successful or the server forwarding is successful, the connection is successful.

[0066] The data processing method provided in this application, when receiving a heartbeat command sent by a network device via the User Datagram Protocol (UDP), stores the network information and device information of the network device. When receiving a query request sent by a client, it determines the target network device corresponding to the query request. If the target network device is online, it schedules the target network device to interact with the client using the Session Description Protocol (SMAP) to establish a point-to-point direct connection between the target network device and the client. In the data processing scheme provided in this application, the heartbeat command sent by the network device via UDP is first received, and its network information and device information are stored to lay the foundation for subsequent connections. When a client query request is received, the target network device is determined. If the target device is online, the two parties are scheduled to interact using the SMAP to establish a point-to-point direct connection. This process does not require full forwarding by the server, significantly reducing server bandwidth consumption and load, lowering costs, and the point-to-point direct connection shortens the transmission link, improving audio and video transmission speed, thereby solving the problems of high server costs, high pressure, and low transmission efficiency in the background art.

[0067] To facilitate better implementation of the data processing method of this application embodiment, this application embodiment also provides a data processing apparatus. The meanings of the terms used are the same as in the data processing system described above, and specific implementation details can be found in the description of the system embodiment.

[0068] Please see Figure 3 , Figure 3 This is a schematic diagram of the structure of a data processing device provided in an embodiment of this application. The data processing device may specifically include a storage module 201, a determination module 202, and a processing module 203, as follows: Storage module 201 is used to store network information and device information of the network device when it receives a heartbeat command sent by the network device via User Datagram Protocol. The determination module 202 is used to determine the target network device corresponding to the query request when a query request is received from the client; The processing module 203 is configured to, if the target network device is online, schedule the target network device to interact with the client using the session description protocol, so as to establish a point-to-point direct connection between the target network device and the client through the interactive session description protocol.

[0069] Optionally, in some embodiments of this application, the determining module 202 may specifically include: The extraction unit is used to extract the device identifier from the query request when a query request is received from the client; The determining unit is used to determine the target network device corresponding to the query request based on the device identifier and the pre-stored device information.

[0070] Optionally, in some embodiments of this application, the determining unit is specifically used for: Parse the serial number from the device identifier; The validity of the digital serial number is verified; When the validity of the digital serial number is verified, the target device information is obtained from the pre-stored device information using the digital serial number. The network device corresponding to the target device information is determined as the target network device corresponding to the query request.

[0071] Optionally, in some embodiments of this application, the processing module 203 may specifically be used for: If the target network device is online, then verify the client's access permissions and the interaction status of the target network device; If the client's access permissions and the target network device's interaction status are both verified, the first session description signaling generated by the client is forwarded to the target network device; and the second session description signaling generated by the target network device based on the first session description signaling is forwarded to the client, so as to establish a point-to-point direct connection between the target network device and the client through the interactive session description protocol.

[0072] Optionally, in some embodiments of this application, the processing module 203 may specifically be used for: If the point-to-point direct connection between the target network device and the client fails to be established within a preset time, the target data is transmitted through a forwarding node, and a point-to-point direct connection between the target network device and the client is established according to a preset time interval and the session description protocol of the interaction. When a direct point-to-point connection is established between the target network device and the client, the connection is switched to a direct point-to-point connection.

[0073] This application provides a data processing apparatus. A storage module 201, upon receiving a heartbeat command from a network device via the User Datagram Protocol (UDP), stores the network information and device information of the network device. A determination module 202, upon receiving a query request from a client, determines the target network device corresponding to the query request. A processing module 203, if the target network device is online, schedules the target network device to interact with the client using a Session Description Protocol (SMAP) to establish a direct point-to-point connection between the target network device and the client. In the data processing scheme provided in this application, a heartbeat command from a network device via UDP is first received, and its network information and device information are stored to lay the foundation for subsequent connections. Upon receiving a client query request, the target network device is determined. If the target device is online, both parties interact using the SMAP to establish a direct point-to-point connection. This process eliminates the need for full server forwarding, significantly reducing server bandwidth consumption and load, lowering costs, and shortening the transmission link, improving audio and video transmission speed, thereby solving the problems of high server costs, high pressure, and low transmission efficiency in the prior art.

[0074] Furthermore, embodiments of this application also provide an electronic device, such as... Figure 4 As shown, it illustrates a structural schematic diagram of the electronic device involved in the embodiments of this application, specifically: The electronic device may include components such as a processor 301 with one or more processing cores, a memory 302 with one or more processor-readable storage media, a power supply 303, and an input unit 304. Those skilled in the art will understand that... Figure 3 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein: The processor 301 is the control center of the electronic device. It connects various parts of the electronic device via various interfaces and lines. By running or executing software programs and / or modules stored in the memory 302, and by calling data stored in the memory 302, it performs various functions and processes data, thereby providing overall monitoring of the electronic device. Optionally, the processor 301 may include one or more processing cores; preferably, the processor 301 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 301.

[0075] The memory 302 can be used to store software programs and modules. The processor 301 executes various functional applications and data processing methods by running the software programs and modules stored in the memory 302. The memory 302 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 302 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 302 may also include a memory controller to provide the processor 301 with access to the memory 302.

[0076] The electronic device also includes a power supply 303 that supplies power to various components. Preferably, the power supply 303 can be logically connected to the processor 301 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 303 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.

[0077] The electronic device may also include an input unit 304, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0078] Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 301 in the electronic device loads the executable files corresponding to the processes of one or more applications into the memory 302 according to the following instructions, and the processor 301 runs the applications stored in the memory 302 to realize various functions, as follows: When a heartbeat command is received from a network device via the User Datagram Protocol (UDP), the network information and device information of the network device are stored. When a query request is received from a client, the target network device corresponding to the query request is determined. If the target network device is online, the target network device is scheduled to interact with the client using the Session Description Protocol (STP) to establish a point-to-point direct connection between the target network device and the client.

[0079] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0080] In this embodiment, when a heartbeat command sent by a network device via the User Datagram Protocol (UDP) is received, the network information and device information of the network device are stored. When a query request is received from a client, the target network device corresponding to the query request is determined. If the target network device is online, the target network device is scheduled to interact with the client using the Session Description Protocol (SMAP) to establish a point-to-point direct connection between the target network device and the client. In the data processing scheme provided in this application, a heartbeat command sent by a network device via UDP is first received, and its network information and device information are stored to lay the foundation for subsequent connections. When a client query request is received, the target network device is determined. If the target device is online, both parties are scheduled to interact using the SMAP to establish a point-to-point direct connection. This process does not require full forwarding by the server, significantly reducing server bandwidth consumption and load, lowering costs, and the point-to-point direct connection shortens the transmission link, improving audio and video transmission speed, thereby solving the problems of high server costs, high pressure, and low transmission efficiency in the background art.

[0081] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a processor-readable storage medium and loaded and executed by a processor.

[0082] Therefore, embodiments of this application provide a storage medium storing a plurality of instructions that can be loaded by a processor to execute steps in any of the data processing methods provided in embodiments of this application. For example, the instructions can execute the following steps: When a heartbeat command is received from a network device via the User Datagram Protocol (UDP), the network information and device information of the network device are stored. When a query request is received from a client, the target network device corresponding to the query request is determined. If the target network device is online, the target network device is scheduled to interact with the client using the Session Description Protocol (STP) to establish a point-to-point direct connection between the target network device and the client.

[0083] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.

[0084] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0085] Since the instructions stored in the storage medium can execute the steps of any of the data processing methods provided in the embodiments of this application, the beneficial effects that any of the data processing methods provided in the embodiments of this application can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.

[0086] The data processing method, apparatus, electronic device, and storage medium provided in the embodiments of this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A data processing method, characterized in that, include: When a heartbeat command is received from a network device via User Datagram Protocol, the network information and device information of the network device are stored. When a query request is received from a client, the target network device corresponding to the query request is determined; If the target network device is online, the target network device is scheduled to interact with the client using the Session Description Protocol (STP) to establish a point-to-point direct connection between the target network device and the client.

2. The data processing method according to claim 1, characterized in that, When a query request is received from a client, determining the target network device corresponding to the query request includes: When a query request is received from a client, the device identifier is extracted from the query request; Based on the device identifier and the pre-stored device information, the target network device corresponding to the query request is determined.

3. The data processing method according to claim 2, characterized in that, The step of determining the target network device corresponding to the query request based on the device identifier and pre-stored device information includes: Parse the serial number from the device identifier; The validity of the digital serial number is verified; When the validity of the digital serial number is verified, the target device information is obtained from the pre-stored device information using the digital serial number. The network device corresponding to the target device information is determined as the target network device corresponding to the query request.

4. The data processing method according to claim 1, characterized in that, If the target network device is online, the step of scheduling the target network device to interact with the client using the Session Description Protocol (STP) to establish a point-to-point direct connection between the target network device and the client through the interacting STP includes: If the target network device is online, then verify the client's access permissions and the interaction status of the target network device; If the client's access permissions and the target network device's interaction status are both verified, the first session description signaling generated by the client is forwarded to the target network device; and the second session description signaling generated by the target network device based on the first session description signaling is forwarded to the client, so as to establish a point-to-point direct connection between the target network device and the client through the interactive session description protocol.

5. The data processing method according to claim 4, characterized in that, Also includes: The client creates a first User Datagram Protocol (UDP) interface and determines a first target port based on the second session description signaling. The target network device creates a second User Datagram Protocol (UDP) interface and determines a second target port based on the first session description signaling; A point-to-point direct connection is established between the target network device and the client based on the first User Datagram Protocol (UDP) interface, the second UDP interface, the first target port, and the second target port.

6. The data processing method according to claim 4, characterized in that, Also includes: If the point-to-point direct connection between the target network device and the client fails to be established within a preset time, the target data is transmitted through a forwarding node, and a point-to-point direct connection between the target network device and the client is established according to a preset time interval and the session description protocol of the interaction. When a direct point-to-point connection is established between the target network device and the client, the connection is switched to a direct point-to-point connection.

7. The data processing method according to claim 1, characterized in that, Also includes: If the target network device is offline, then obtain the device type of the target network device; If the device type is the first type, then output a message indicating that the device is offline; If the device type is the second type, then wake up the target network device; If a wake-up signal is received from the target network device within a preset time period, then the step of scheduling the target network device to interact with the client using the session description protocol is executed.

8. A data processing apparatus, characterized in that, include: The storage module is used to store the network information and device information of the network device when it receives a heartbeat command sent by the network device via the User Datagram Protocol. The determination module is used to determine the target network device corresponding to the query request when a query request is received from a client. The processing module is configured to, if the target network device is online, schedule the target network device to interact with the client using the Session Description Protocol (SMAP) to establish a point-to-point direct connection between the target network device and the client through the interactive SMAP.

9. An electronic device, characterized in that, include: A memory, a processor, and a processor program stored in the memory and executable on the processor, wherein the processor executes the program as steps of the data processing method as described in any one of claims 1 to 7.

10. A storage medium, characterized in that, The computer processing program is stored and can be loaded by a processor and executed as described in any one of claims 1 to 7.