Data processing method, device, equipment and computer readable storage medium

文档序号:1925249 发布日期:2021-12-03 浏览:10次 中文

阅读说明:本技术 数据处理方法、装置、设备及计算机可读存储介质 (Data processing method, device, equipment and computer readable storage medium ) 是由 闫威 于 2021-07-30 设计创作,主要内容包括:本发明公开了一种数据处理方法,包括:获取实时消息传输协议RTMP对应的第一程序,并确定所述第一程序的握手协议代码;在所述第一程序中移除所述第一程序的握手协议代码,得到第二程序;获取安全可靠传输协议SRT对应的第三程序;基于所述第三程序的握手协议代码,修改所述第二程序,获得第一目标程序。本发明还公开了一种数据处理装置、设备及计算机可读存储介质。本发明通过将第一程序的握手协议替换为SRT的握手协议,使得第一目标程序可实现SRT的握手协议,在通过第一目标程序建立通信连接时,通过减少基于TCP的多个RTT的时间消以及降低握手流程的时间消耗,从而降低了首次建立连接的时间延迟。(The invention discloses a data processing method, which comprises the following steps: acquiring a first program corresponding to a real-time message transfer protocol (RTMP), and determining a handshake protocol code of the first program; removing the handshake protocol code of the first program in the first program to obtain a second program; acquiring a third program corresponding to a secure and reliable transport protocol (SRT); and modifying the second program based on the handshake protocol code of the third program to obtain a first target program. The invention also discloses a data processing device, equipment and a computer readable storage medium. The invention replaces the handshake protocol of the first program with the handshake protocol of the SRT, so that the first target program can realize the handshake protocol of the SRT, and when the communication connection is established through the first target program, the time delay of establishing the connection for the first time is reduced by reducing the time consumption of a plurality of RTTs based on TCP and reducing the time consumption of a handshake flow.)

1. A data processing method, characterized in that the data processing method comprises the steps of:

acquiring a first program corresponding to a real-time message transfer protocol (RTMP), and determining a handshake protocol code of the first program;

removing the handshake protocol code of the first program in the first program to obtain a second program;

acquiring a third program corresponding to a secure and reliable transport protocol (SRT);

and modifying the second program based on the handshake protocol code of the third program to obtain a first target program.

2. The data processing method of claim 1, wherein the step of modifying the second program based on the handshake protocol code of the third program to obtain the first target program comprises:

and determining a handshake interface corresponding to a handshake protocol code of a third program, modifying the second program based on the handshake interface, and calling the handshake interface through the modified second program to obtain the first target program.

3. The data processing method of claim 1, wherein the step of modifying the second program based on the handshake protocol code of the third program to obtain the first target program is followed by further comprising:

acquiring a TCP socket corresponding to the first program and a UDP socket corresponding to the third program;

replacing a TCP socket in the first target program with a corresponding UDP socket to obtain a second target program, and taking the second target program as the first target program.

4. The data processing method of claim 3, wherein the step of modifying the second program based on the handshake protocol code of the third program to obtain the first target program is followed by further comprising:

acquiring a first function corresponding to the TCP socket and a second function corresponding to the UDP socket;

and replacing the first function in the second target program with the corresponding second function to obtain a third target program, and taking the third target program as the first target program.

5. The data processing method according to any one of claims 1 to 4, wherein the step of modifying the second program based on the handshake protocol code of the third program to obtain the first target program further comprises:

establishing a communication link with a target client based on a handshake protocol code in the first target program;

acquiring RTMP video data corresponding to the target client;

and performing sub-packaging on video data to be sent based on a preset byte threshold value to obtain an SRT data packet, and sending the SRT data packet to the target client, wherein the preset byte threshold value is smaller than the maximum byte number of an SRT message.

6. The data processing method of claim 5, wherein the packetizing the video data to be transmitted based on the predetermined byte threshold to obtain the SRT packet comprises:

sequentially traversing RTMP information in RTMP video data to obtain the currently traversed RTMP information;

sequentially traversing the logic blocks of the RTMP information for the currently traversed RTMP information to obtain the currently traversed logic blocks;

and determining the SRT data packet to which the currently traversed logic partition belongs based on the preset byte threshold until the RTMP video data traversal is completed.

7. The data processing method of claim 6, wherein the step of determining the SRT packet to which the currently traversed logical partition belongs based on the preset byte threshold comprises:

acquiring a first byte number of data in a current SRT cache region, a second byte number of the logic partition and a third byte number of an RTMP header;

calculating the total bytes of the first byte length, the second byte length and the third byte length;

if the total bytes are less than or equal to the preset byte threshold, caching the logic blocks and the data blocks corresponding to the RTMP head into the SRT cache region;

and if the total bytes are larger than the preset byte threshold value, generating an SRT data packet based on the data in the SRT cache region, emptying the SRT cache region, and caching the data block to the SRT cache region.

8. A data processing apparatus, characterized in that the data processing apparatus comprises:

the device comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring a first program corresponding to a real-time message transfer protocol (RTMP) and determining a handshake protocol code of the first program;

a shifting-out module, configured to remove a handshake protocol code of the first program from the first program to obtain a second program;

the second acquisition module is used for acquiring a third program corresponding to the safe and reliable transport protocol SRT;

and the modifying module is used for modifying the second program based on the handshake protocol code of the third program to obtain a first target program.

9. A data processing apparatus, characterized in that the data processing apparatus comprises: memory, processor and data processing program stored on the memory and executable on the processor, which when executed by the processor implements the steps of the data processing method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that a data processing program is stored thereon, which when executed by a processor implements the steps of the data processing method according to any one of claims 1 to 7.

Technical Field

The present invention relates to the field of data processing technologies, and in particular, to a data processing method, apparatus, device, and computer readable storage medium.

Background

The RTMP (Real Time Messaging Protocol) guarantees the reliability of information transmission by an underlying transport layer Protocol (usually TCP). After the link establishment based on the RTMP is completed, the RTMP requires the client and the server to establish an RTMP Connection link over the transport layer link through a "handshake", and some control information, such as SetChunkSize, SetACKWindowSize, etc., will be transmitted over the Connection link. A Stream link is then created via CreateStream command for transmitting specific audio-visual data and command information for controlling the transmission of such information. When the RTMP protocol is used for transmission, the data is formatted, a Message in the format is called as an RTMP Message, when the RTMP protocol is used for transmission, a sending end divides the Message into chunks with Message IDs, each Chunk may be an independent Message or a part of the Message, and a receiving end reduces the chunks into a complete Message according to the length of the data contained in the chunks, the Message IDs and the length of the Message, so that the information is sent and received.

Because the RTMP is a protocol for video transmission based on the TCP, the TCP has three handshakes, and the RTMP itself also has three handshakes, and the flows of connect, CreateStream, and play/publish are added, so that 9 sessions are required to be performed to establish a communication connection through the RTMP, which results in a long delay in establishing the connection.

The above is only for the purpose of assisting understanding of the technical aspects of the present invention, and does not represent an admission that the above is prior art.

Disclosure of Invention

The invention mainly aims to provide a data processing method, a data processing device, data processing equipment and a computer readable storage medium, and aims to solve the technical problem of time delay for establishing connection through RTMP.

In order to achieve the above object, the present invention provides a data processing method, including the steps of:

acquiring a first program corresponding to a real-time message transfer protocol (RTMP), and determining a handshake protocol code of the first program;

removing the handshake protocol code of the first program in the first program to obtain a second program;

acquiring a third program corresponding to a secure and reliable transport protocol (SRT);

and modifying the second program based on the handshake protocol code of the third program to obtain a first target program.

Further, the step of modifying the second program based on the handshake protocol code of the third program to obtain the first target program includes:

and determining a handshake interface corresponding to a handshake protocol code of a third program, modifying the second program based on the handshake interface, and calling the handshake interface through the modified second program to obtain the first target program.

Further, after the step of modifying the second program based on the handshake protocol code of the third program to obtain the first target program, the method further includes:

acquiring a TCP socket corresponding to the first program and a UDP socket corresponding to the third program;

replacing a TCP socket in the first target program with a corresponding UDP socket to obtain a second target program, and taking the second target program as the first target program.

Further, after the step of modifying the second program based on the handshake protocol code of the third program to obtain the first target program, the method further includes:

acquiring a first function corresponding to the TCP socket and a second function corresponding to the UDP socket;

and replacing the first function in the second target program with the corresponding second function to obtain a third target program, and taking the third target program as the first target program.

Further, after the step of modifying the second program based on the handshake protocol code of the third program to obtain the first target program, the method further includes:

establishing a communication link with a target client based on a handshake protocol code in the first target program;

acquiring RTMP video data corresponding to the target client;

and performing sub-packaging on video data to be sent based on a preset byte threshold value to obtain an SRT data packet, and sending the SRT data packet to the target client, wherein the preset byte threshold value is smaller than the maximum byte number of an SRT message.

Further, the packetizing the video data to be transmitted based on the preset byte threshold to obtain the SRT packet includes:

sequentially traversing RTMP information in RTMP video data to obtain the currently traversed RTMP information;

sequentially traversing the logic blocks of the RTMP information for the currently traversed RTMP information to obtain the currently traversed logic blocks;

and determining the SRT data packet to which the currently traversed logic partition belongs based on the preset byte threshold until the RTMP video data traversal is completed.

Further, the step of determining the SRT packet to which the currently traversed logical partition belongs based on the preset byte threshold includes:

acquiring a first byte number of data in a current SRT cache region, a second byte number of the logic partition and a third byte number of an RTMP header;

calculating the total bytes of the first byte length, the second byte length and the third byte length;

if the total bytes are less than or equal to the preset byte threshold, caching the logic blocks and the data blocks corresponding to the RTMP head into the SRT cache region;

and if the total bytes are larger than the preset byte threshold value, generating an SRT data packet based on the data in the SRT cache region, emptying the SRT cache region, and caching the data block to the SRT cache region.

Further, to achieve the above object, the present invention also provides a data processing apparatus comprising:

the device comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring a first program corresponding to a real-time message transfer protocol (RTMP) and determining a handshake protocol code of the first program;

a shifting-out module, configured to remove a handshake protocol code of the first program from the first program to obtain a second program;

the second acquisition module is used for acquiring a third program corresponding to the safe and reliable transport protocol SRT;

and the modifying module is used for modifying the second program based on the handshake protocol code of the third program to obtain a first target program.

Further, to achieve the above object, the present invention also provides a data processing apparatus comprising: a memory, a processor and a data processing program stored on the memory and executable on the processor, the data processing program, when executed by the processor, implementing the steps of the data processing method as described above.

Further, to achieve the above object, the present invention provides a computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a data processing program, which when executed by a processor, implements the steps of the data processing method according to any one of claims 1 to 7.

The method comprises the steps of acquiring a first program corresponding to a real-time message transfer protocol (RTMP) and determining a handshake protocol code of the first program; removing the handshake protocol code of the first program in the first program to obtain a second program; then acquiring a third program corresponding to the safe and reliable transport protocol SRT; and then modifying the second program based on the handshake protocol code of the third program to obtain a first target program, wherein the handshake protocol of the first program is replaced by the handshake protocol of the SRT, so that the first target program can realize the handshake protocol of the SRT, and when the communication connection is established through the first target program, the time delay of establishing the connection for the first time is reduced by reducing the time consumed by a plurality of RTTs based on the TCP and reducing the time consumption of the handshake flow. Meanwhile, the protocol control and the data format of RTMP are multiplexed by the first target program, so that the complexity of transmitting and processing live stream interaction control and a data message structure on the SRT by adopting the first target program is reduced.

Drawings

FIG. 1 is a block diagram of a data processing device in a hardware operating environment according to an embodiment of the present invention;

FIG. 2 is a flowchart illustrating a data processing method according to a first embodiment of the present invention;

FIG. 3 is a functional block diagram of a data processing apparatus according to an embodiment of the present invention.

The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.

Detailed Description

It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

As shown in fig. 1, fig. 1 is a schematic structural diagram of a data processing device in a hardware operating environment according to an embodiment of the present invention.

The data processing device in the embodiment of the present invention may be a PC, or may be a mobile terminal device having a display function, such as a smart phone, a tablet computer, an electronic book reader, an MP3(Moving Picture Experts Group Audio Layer III, motion video Experts compression standard Audio Layer 3) player, an MP4(Moving Picture Experts Group Audio Layer IV, motion video Experts compression standard Audio Layer 4) player, a portable computer, or the like.

As shown in fig. 1, the data processing apparatus may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, a communication bus 1002. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.

Optionally, the data processing device may further include a camera, a Radio Frequency (RF) circuit, a sensor, an audio circuit, a WiFi module, and the like. Such as light sensors, motion sensors, and other sensors. Of course, the data processing device may also be configured with other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, etc., which are not described herein again.

Those skilled in the art will appreciate that the terminal architecture shown in fig. 1 does not constitute a limitation of the data processing apparatus and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.

As shown in fig. 1, a memory 1005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a data processing program.

In the data processing apparatus shown in fig. 1, the network interface 1004 is mainly used for connecting to a backend server and communicating with the backend server; the user interface 1003 is mainly used for connecting a client (user side) and performing data communication with the client; and the processor 1001 may be used to invoke a data processing program stored in the memory 1005.

In this embodiment, the data processing apparatus includes: the system comprises a memory 1005, a processor 1001 and a data processing program which is stored on the memory 1005 and can run on the processor 1001, wherein when the processor 1001 calls the data processing program stored in the memory 1005, the steps of the data processing method in each embodiment are executed.

Referring to fig. 2, fig. 2 is a schematic flow chart of a first embodiment of the data processing method according to the present invention.

In this embodiment, the data processing method includes the following steps:

step S101, acquiring a first program corresponding to a real-time message transfer protocol (RTMP), and determining a handshake protocol code of the first program;

step S202, removing the handshake protocol code of the first program in the first program to obtain a second program;

step S103, acquiring a third program corresponding to the safe and reliable transport protocol SRT;

and step S104, modifying the second program based on the handshake protocol code of the third program to obtain a first target program.

It should be noted that, when video data is transmitted by the RTMP, all control command messages and audio/video data messages adopt a unified data transmission format; for example, create connection/create stream/control command/RPC call/audio-only video data stream, etc. all originate from the same Chunk Message structure, except that the Message type id of the Message Header in the Message is different. Although the RTMP has many control and data transmission types, it is based on standard Chunk and Message structures, and the data content of the Message can be actually transmitted no matter on TCP or UDP, so long as the RTMP implements the sending and receiving ends of the program receiving the Message, it can directly analyze and interact using the existing code processing logic, and does not need to do extra private protocol processing and encapsulation, and then it can transplant the RTMP Message from TCP to SRT (Secure Reliable Transport protocol) based on UDP for transmission.

The media handshake of the RTMP includes three interactions of C0C1C2/S0S1S2, which do not belong to the Chunk/Message structure, and the RTMP implementation procedure needs additional processing for the three handshakes in addition to the parsing processing for the standard Chunk and Message, and consumes more round trip RTTs. The handshake logic of SRT is exemplified by the Caller-Listener mode, where one party is the calling party (Caller) and the other party is the listening party (Listener). The SRT exchanges cookie when the first handshake comes and goes; the second round trip will exchange detail parameters such as version, encryption mode, amount of bi-directional delay, StreamID, etc. After transmission is started, the packet header is time-stamped and a lot of control data, such as ACK, NCK, ACKACK (acknowledgement for positive acknowledgement), Keepalive, Shutdown, is exchanged.

In this embodiment, a first program corresponding to the RTMP is obtained, where the first program is an RTMP implementation program, and video data transmission based on the RTMP is implemented by the first program. And determining a handshake protocol code of the first program, i.e., a program code of a three-way handshake processing logic of the first program that implements the RTMP.

After the first program and the handshake protocol code are acquired, the handshake protocol code of the first program is removed from the first program to obtain a second program, namely, the handshake protocol code in the first program is deleted, and the deleted first program is used as the second program, so that the redundancy and the complexity of a handshake flow are reduced.

And then, acquiring a third program corresponding to the SRT, wherein the third program is an implementation program of the SRT, determining a handshake protocol in the third program, modifying the second program based on a handshake protocol code of the third program, and acquiring a first target program, so as to introduce the handshake protocol code of the third program into the second program, and further introduce a handshake logic of the SRT into the second program as a substitute. Specifically, the handshake API of the SRT may be called by the second program, so that the handshake flow of the SRT is realized without re-packaging.

Further, in an embodiment, the step S104 includes:

and determining a handshake interface corresponding to a handshake protocol code of a third program, modifying the second program based on the handshake interface, and calling the handshake interface through the modified second program to obtain the first target program.

In this embodiment, after the third program is obtained, a handshake protocol code of the third program is determined, a corresponding handshake interface (handshake API) is determined according to the handshake protocol code, then the second program is modified, the handshake interface is called by the modified second program, the first target program is obtained, and then the handshake API of the SRT can be called by the first target program, so as to implement a handshake flow of the SRT.

In the data processing method provided in this embodiment, a first program corresponding to a real-time messaging protocol (RTMP) is obtained, and a handshake protocol code of the first program is determined; removing the handshake protocol code of the first program in the first program to obtain a second program; then acquiring a third program corresponding to the safe and reliable transport protocol SRT; and then modifying the second program based on the handshake protocol code of the third program to obtain a first target program, wherein the handshake protocol of the first program is replaced by the handshake protocol of the SRT, so that the first target program can realize the handshake protocol of the SRT, and when the communication connection is established through the first target program, the time delay of establishing the connection for the first time is reduced by reducing the time consumed by a plurality of RTTs based on the TCP and reducing the time consumption of the handshake flow. Meanwhile, the protocol control and the data format of RTMP are multiplexed by the first target program, so that the complexity of transmitting and processing live stream interaction control and a data message structure on the SRT by adopting the first target program is reduced.

Based on the first embodiment, a second embodiment of the data processing method of the present invention is proposed, in this embodiment, after step S104, the data processing method further includes:

step S201, obtaining a TCP socket corresponding to the first program and a UDP socket corresponding to the third program;

step S202, replacing a TCP socket in the first target program with a corresponding UDP socket, obtaining a second target program, and taking the second target program as the first target program.

Note that Socket functions to send and receive recv data on the network. The socket adopted by RTMP is based on TCP, and the socket of SRT is based on UDP. The two establish connection and establish socket in different ways, and the bottom layer receiving and sending mechanisms are also different. Therefore, it is necessary to replace the TCP socket used by the RTMP _ Connect () in the first target program with the UDP socket used by the SRT _ Connect () that calls the SRT, so that the RTMP chunk packet established on top of the socket can be transparently transferred when using send and recv without making more adaptation code changes related to the socket.

In this embodiment, when a first target program is obtained, a TCP socket corresponding to the first program and a UDP socket corresponding to the third program are obtained, the TCP socket in the first target program is replaced with the corresponding UDP socket, a second target program is obtained, the second target program is used as the first target program, and by replacing the sockets, adaptive modification of codes related to the sockets in the first target program is avoided, and applicability of the first target program is improved.

Further, in an embodiment, after step S202, the data processing method further includes:

step S203, acquiring a first function corresponding to the TCP socket and a second function corresponding to the UDP socket;

step S204, replacing the first function in the second target program with the corresponding second function to obtain a third target program, and taking the third target program as the first target program.

In this embodiment, to further reduce adaptive changes to a code related to a socket in a first target program, a first function corresponding to a TCP socket is obtained in the first target program, and a second function corresponding to a UDP socket is obtained in a third program, where the first function is a function related to a TCP socket connection and the second function is a function related to a UDP socket connection.

And then, replacing the first function in the second target program with the corresponding second function to obtain a third target program, taking the third target program as the first target program, and further avoiding the adaptive change of the code related to the socket in the first target program by directly replacing the corresponding function.

In the data processing method provided in this embodiment, a TCP socket corresponding to the first program and a UDP socket corresponding to the third program are obtained; and then replacing the TCP socket in the first target program with a corresponding UDP socket to obtain a second target program, and taking the second target program as the first target program, so that adaptive modification of codes related to the socket in the first target program can be avoided, and the applicability of the first target program is improved.

Based on the foregoing embodiments, a third embodiment of the data processing method according to the present invention is proposed, where in this embodiment, after step S104, the method further includes:

step S301, establishing a communication link with a target client based on a handshake protocol code in the first target program;

step S302, obtaining RTMP video data corresponding to the target client;

step S303, packetizing video data to be sent based on a preset byte threshold to obtain an SRT data packet, and sending the SRT data packet to the target client, wherein the preset byte threshold is smaller than the maximum byte number of an SRT message.

It should be noted that, since the RTMP is based on TCP transmission, the implementation of the TCP protocol layer already includes support for MTU (maximum transmission unit), which is a limitation of the network in the link layer to data frames, and the MTU is 1500 bytes, taking ethernet as an example. An IP datagram is transmitted in ethernet and if its length is greater than the MTU value, it is transmitted in fragments such that the length of each datagram is less than the MTU. The datagram based on the UDP layer can not be segmented, so when the length exceeds the MTU, the IP fragmentation can be carried out on the network layer; because the IP layer itself has no timeout retransmission mechanism, it must be processed by the upper transport layer or even the application layer, but the UDP protocol and the above SRT protocol do not perform corresponding processing, and when transmitting the data packet of the RTMP over the UDP and SRT, it needs to packetize the RTMP data.

In this embodiment, when a connection request is received, the first target program is run, and a communication link with a target client is established through a handshake protocol code in the first target program.

After the communication connection is established, RTMP video data corresponding to a target client is obtained, sub-packaging is carried out on the video data to be sent based on a preset byte threshold value, an SRT data packet is obtained, and the SRT data packet is sent to the target client, wherein the preset byte threshold value is smaller than the maximum byte number of an SRT message, IP fragmentation in the data transmission process is avoided by sub-packaging the data, and the complexity of transmission processing of live stream interaction control and a data message structure on the SRT is reduced.

The Header of the existing SRT has 16 bytes; plus 28 bytes of IP and UDP Header, which are a fixed 44 bytes, to avoid IP fragmentation, it is ensured that the actual transmission content of each SRT message is less than 1500-44-1456 bytes, i.e. the maximum number of bytes of the SRT message is 1456 bytes.

In the data processing method provided in this embodiment, a communication link with a target client is established based on a handshake protocol code in the first target program; then acquiring RTMP video data corresponding to the target client; and then, sub-packaging video data to be sent based on a preset byte threshold value to obtain an SRT data packet, and sending the SRT data packet to the target client, wherein the preset byte threshold value is smaller than the maximum byte number of an SRT message, and the complexity of transmission and processing of live stream interaction control and a data message structure on the SRT is reduced by sub-packaging data to avoid IP fragmentation in the data transmission process. Meanwhile, data transmission is carried out by adopting UDP, high-delay transmission caused by overtime retransmission, congestion control and the like of TCP in the process of live broadcasting audio and video streams is avoided, and the delay of data transmission is reduced.

A fourth embodiment of the data processing method of the present invention is proposed based on the third embodiment, and in this embodiment, step S303 includes:

step S401, sequentially traversing RTMP information in RTMP video data to obtain currently traversed RTMP information;

step S402, sequentially traversing the logic blocks of the RTMP information for the currently traversed RTMP information to obtain the currently traversed logic blocks;

step S403, determining, based on the preset byte threshold, an SRT packet to which the currently traversed logical partition belongs, until the traversal of the RTMP video data is completed.

In this embodiment, when the RTMP video data is acquired, the RTMP information in the RTMP video data is sequentially traversed to acquire the currently traversed RTMP information, that is, the RTMP message, and for the currently traversed RTMP message, the logical partition chunk of the RTMP information is sequentially traversed to acquire the currently traversed chunk.

Next, determining, based on the preset byte threshold, an SRT packet to which the currently traversed logical partition belongs until the traversal of the RTMP video data is completed, specifically, step S403 includes:

step a, acquiring a first byte number of data in a current SRT cache region, a second byte number of the logic partition and a third byte number of an RTMP header;

b, calculating the total bytes of the first byte length, the second byte length and the third byte length;

step c, if the total bytes are less than or equal to the preset byte threshold, caching the logic blocks and the data blocks corresponding to the RTMP head into the SRT cache region;

and d, if the total bytes are larger than the preset byte threshold value, generating an SRT data packet based on the data in the SRT cache region, emptying the SRT cache region, and caching the data block to the SRT cache region.

In this embodiment, each time the currently traversed chunk is obtained, a first byte number of data in the current SRT cache area, a second byte number of the currently traversed chunk, and a third byte number of the RTMP header are obtained, and a total byte of the first byte length, the second byte length, and the third byte length, that is, a sum of the first byte length, the second byte length, and the third byte length is calculated.

Then, it is determined whether the total byte is less than or equal to the preset byte threshold, where the preset byte threshold is less than the maximum byte number of the SRT packet, and since the maximum byte number of the chunk is 128 and the maximum byte number of the RTMP header is 44, in order to leave a certain redundant space in the SRT buffer, a preset byte number may be set according to the chunk and the RTMP header, where the preset byte number is greater than 172(128+44), for example, the preset byte number may be 200, and the preset byte threshold is less than the maximum byte number-the preset byte number of the SRT packet, that is, the preset byte threshold is less than 1256 (1456-.

If the total bytes are smaller than or equal to the preset byte threshold, caching the logic blocks and the data blocks corresponding to the RTMP head into the SRT cache region, and continuously traversing the logic blocks of the RTMP information. If the total bytes are larger than the preset byte threshold value, generating an SRT data packet based on the data in the SRT cache region, emptying the SRT cache region, caching the data block to the SRT cache region, and continuously traversing the logic blocks of the RTMP information.

And when the traversal of the RTMP information which is traversed currently is finished, continuously executing the step of sequentially traversing the RTMP information in the RTMP video data.

According to the data processing method provided by the embodiment, the RTMP information in the RTMP video data is traversed in sequence to obtain the currently traversed RTMP information, then the logic blocks of the RTMP information are traversed in sequence to obtain the currently traversed logic blocks, the SRT data packet to which the currently traversed logic blocks belong is determined based on the preset byte threshold until the RTMP video data is traversed, the RTMP information can be packetized through the preset byte threshold to avoid IP fragmentation in the data transmission process, and the complexity of transmission processing of live stream interaction control and data message structures on the SRT is further reduced.

The present invention also provides a data processing apparatus, referring to fig. 3, the data processing apparatus including:

a first obtaining module 10, configured to obtain a first program corresponding to a real-time message transfer protocol RTMP, and determine a handshake protocol code of the first program;

a removing module 20, configured to remove a handshake protocol code of the first program from the first program to obtain a second program;

a second obtaining module 30, configured to obtain a third program corresponding to a secure and reliable transport protocol SRT;

and a modifying module 40, configured to modify the second program based on the handshake protocol code of the third program, to obtain a first target program.

The methods executed by the program units can refer to the embodiments of the data processing method of the present invention, and are not described herein again.

The invention also provides a computer readable storage medium.

The computer-readable storage medium of the present invention has stored thereon a data processing program which, when executed by a processor, implements the steps of the data processing method as described above.

The method implemented when the data processing program running on the processor is executed may refer to each embodiment of the data processing method of the present invention, and details are not described here.

Furthermore, an embodiment of the present invention further provides a computer program product, which includes a data processing program, and when the data processing program is executed by a processor, the data processing program implements the steps of the data processing method described above.

It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.

The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.

Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present invention.

The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

14页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:流量的控制方法、装置和非易失性计算机可读存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!