Audio and video data packet processing method and device, equipment and storage medium
By obtaining the packet sequence number of audio and video packets and performing modulus calculations, and dynamically adjusting the cache area, the problem of audio and video packet disorder caused by UDP transmission is solved, fast reordering and real-time transmission is realized, and the real-time nature of data transmission is improved. and efficiency.
Patent Information
- Application Number
- CN202411238107.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-04
- Publication Date
- 2024-12-20
AI Technical Summary
In the security video surveillance, the prior art has the timing of the packets reaching the destination because UDP transmission does not guarantee the timing of the packets reaching the destination, resulting in packet loss or out of order of audio and video packets. The existing reordering algorithm is complex and has low real-time performance.
By obtaining audio and video data packets and their target packet numbers, comparing packet sequence numbers and performing modulo calculations, dynamically adjusting the cache area, realizing fast reordering and cache area management, ensuring that the data packets are transmitted in the correct order.
It improves the real-time nature of audio and video data transmission, reduces network latency, and optimizes the efficiency of cache space utilization.
Smart Images

Figure CN119172562A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of computer technology, and in particular to a method, device, equipment and storage medium for processing audio and video data packets. Background Art
[0002] In the field of security video surveillance, front-end audio and video acquisition devices such as access cameras usually transmit audio and video data through RTP (Real-time Transport Protocol). In the actual transmission process, in order to ensure the real-time nature of video transmission, the RTP transmission method based on UDP (User Datagram Protocol) is adopted. However, since UDP transmission does not guarantee the timing of data packets arriving at the destination, it may cause packet loss or disorder at the receiving end.
[0003] The prior art reorders data packets according to the SEQ (Sequence Number) field of the RTP packet header and multiple cache linked list queues. These reordering algorithms require the use of various parameters and linked list queues, and their time complexity is generally O(n), where n is the number of out-of-order data packets received. The algorithms are complex and have low real-time performance.
[0004] Therefore, how to achieve fast reordering of audio and video data packets is a problem that needs to be solved at present. Summary of the invention
[0005] In view of the above problems, the present invention proposes a method, device, equipment and storage medium for processing audio and video data packets.
[0006] In a first aspect of the present invention, a method for processing an audio and video data packet is provided, wherein the method comprises:
[0007] Obtain the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet, and determine the current packet sequence number for the audio and video data packet, where the current packet sequence number is a preset value or a packet sequence number corresponding to the n-1th audio and video data packet;
[0008] Subtract 1 from the target packet sequence number to obtain the first target packet sequence number, and compare whether the first target packet sequence number is equal to the current packet sequence number;
[0009] If the first target packet sequence number is equal to the current packet sequence number, the nth audio and video data packet and the audio and video data packets stored in the preset buffer area are transmitted to the preset application layer, and the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet is returned;
[0010] If the first target packet sequence number is not equal to the current packet sequence number, the nth audio and video data packet is sorted, and the sorted nth audio and video data packet is stored in a preset cache area, and the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet is returned.
[0011] Optionally, when the current packet sequence number is a preset value, before comparing whether the first target packet sequence number is equal to the current packet sequence number, the method further includes:
[0012] Update the current packet sequence number to the first target packet sequence number.
[0013] Optionally, the step of transmitting the nth audio and video data packet and the audio and video data packets stored in the preset buffer area to a preset application layer, and returning to obtain the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet includes:
[0014] Transmitting the nth audio and video data packet to a preset application layer;
[0015] Update the current package sequence number to the target package sequence number;
[0016] Add 1 to the current packet sequence number to obtain the current target packet sequence number, and perform a modulo calculation on the current target packet sequence number to obtain a second index value;
[0017] Determine whether there is a second storage audio and video data packet in a second storage unit corresponding to the second index value in a preset cache area;
[0018] If the second storage unit contains a second storage audio and video data packet, the second storage audio and video data packet is processed, and the current target packet sequence number is obtained by adding 1 to the current packet sequence number, and the current target packet sequence number is calculated by modulus to obtain a second index value.
[0019] If the second storage audio and video data packet does not exist in the second storage unit, return to the step of obtaining the nth audio and video data packet and the corresponding target packet sequence number.
[0020] Optionally, processing the second stored audio and video data packet includes:
[0021] Obtain a second stored audio and video data packet and a second stored packet sequence number corresponding to the second stored audio and video data packet;
[0022] Transmitting the second stored audio and video data packet to the application layer;
[0023] The current packet sequence number is updated to the second storage packet sequence number, and the second storage unit is set to empty.
[0024] Optionally, the steps of sorting the nth audio and video data packet, storing the sorted nth audio and video data packet into a preset buffer area, and returning to obtain the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet include:
[0025] The target packet sequence number is calculated by modulus to obtain the first index value;
[0026] Determine whether a first storage audio and video data packet exists in a first storage unit corresponding to a preset cache area of a first index value;
[0027] If the first storage unit contains the first stored audio and video data packet, the first stored audio and video data packet is processed, and the step of returning to obtain the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet is returned;
[0028] If the first storage audio and video data packet does not exist in the first storage unit, the nth audio and video data packet is stored in the first storage unit, and the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet is returned.
[0029] Optionally, processing the first stored audio and video data packet includes:
[0030] Add 1 to the current packet sequence number to obtain the current target packet sequence number, and perform a modulo calculation on the current target packet sequence number to obtain a second index value;
[0031] Determine whether there is a second stored audio and video data packet in the second storage unit corresponding to the second index value in the cache area;
[0032] If the second storage unit contains a second storage audio and video data packet, obtaining the second storage audio and video data packet and a second storage packet sequence number corresponding to the second storage audio and video data packet;
[0033] Transmitting the second stored audio and video data packet to a preset application layer;
[0034] Update the current packet sequence number to the second storage packet sequence number, and empty the second storage unit;
[0035] If the second storage audio and video data packet does not exist in the second storage unit, the current packet sequence number is updated to the current target packet sequence number;
[0036] Compare the first index value and the second index value to see if they are equal;
[0037] If the first index value is not equal to the second index value, return to the step of adding 1 to the current packet sequence number to obtain the current target packet sequence number, and performing a modulo calculation on the current target packet sequence number to obtain the second index value.
[0038] Optionally, the method further comprises:
[0039] If the first index value is equal to the second index value, the target packet sequence number is subtracted by 1 to obtain the first target packet sequence number, and the first target packet sequence number is compared with the current packet sequence number to see whether they are equal;
[0040] If the first target packet sequence number is equal to the current packet sequence number, returning to the step of transmitting the nth audio and video data packet to the preset application layer;
[0041] If the first target packet sequence number is not equal to the current packet sequence number, the nth audio and video data packet is stored in the first storage unit.
[0042] In a second aspect of the present invention, there is also provided an audio and video data packet processing device, characterized in that the device comprises:
[0043] An acquisition module, used to acquire the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet, and determine the current packet sequence number for the audio and video data packet, where the current packet sequence number is a preset value or a packet sequence number corresponding to the n-1th audio and video data packet;
[0044] A comparison module, used for subtracting 1 from the target packet sequence number to obtain a first target packet sequence number, and comparing whether the first target packet sequence number is equal to the current packet sequence number;
[0045] A first processing module is used for transmitting the nth audio and video data packet and the audio and video data packet stored in the preset buffer area to the preset application layer if the target packet sequence number minus 1 is equal to the current packet sequence number, and returning to the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet;
[0046] The second processing module is used to sort the nth audio and video data packet if the target packet number minus 1 is not equal to the current packet number, and store the sorted nth audio and video data packet into a preset cache area, and return to the step of obtaining the nth audio and video data packet and the target packet number corresponding to the nth audio and video data packet.
[0047] Optionally, when the current packet sequence number is a preset value, the device further includes:
[0048] The preset updating module is used to update the current packet sequence number to the first target packet sequence number before comparing whether the first target packet sequence number is equal to the current packet sequence number.
[0049] Optionally, the first processing module includes:
[0050] A transmission module, used for transmitting the nth audio and video data packet to a preset application layer;
[0051] A first updating module, used for updating the current packet sequence number to the target packet sequence number;
[0052] A first acquisition module is used to add 1 to the current packet sequence number to obtain the current target packet sequence number, and perform a modulo calculation on the current target packet sequence number to obtain a second index value;
[0053] A first determination module, used to determine whether a second storage audio and video data packet exists in a second storage unit corresponding to a preset cache area with a second index value;
[0054] The first processing module is used for processing the second stored audio and video data packet if the second storage unit has the second stored audio and video data packet, and returning to the step of adding 1 to the current packet sequence number to obtain the current target packet sequence number, and performing a modulo calculation on the current target packet sequence number to obtain a second index value;
[0055] The second processing module is used to return to the step of obtaining the nth audio and video data packet and the corresponding target packet sequence number if the second stored audio and video data packet does not exist in the second storage unit.
[0056] Optionally, the first treatment module includes:
[0057] A first acquisition unit, used to acquire a second stored audio and video data packet and a second stored packet sequence number corresponding to the second stored audio and video data packet;
[0058] A first transmission unit, configured to transmit the second stored audio and video data packet to the application layer;
[0059] The first updating unit is used to update the current packet sequence number to the second storage packet sequence number and set the second storage unit empty.
[0060] Optionally, the second processing module includes:
[0061] A second acquisition module is used to obtain a first index value by performing a modulo calculation on the target packet sequence number;
[0062] A second determination module is used to determine whether a first storage audio and video data packet exists in a first storage unit corresponding to a preset cache area of a first index value;
[0063] A third processing module is used for processing the first stored audio and video data packet if the first storage unit has the first stored audio and video data packet, and returning to the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet;
[0064] The fourth reset module is used to store the nth audio and video data packet in the first storage unit if the first storage audio and video data packet does not exist in the first storage unit, and return to the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet.
[0065] Optionally, the third processing module includes:
[0066] A first calculation unit is used to add 1 to the current packet sequence number to obtain the current target packet sequence number, and perform a modulo calculation on the current target packet sequence number to obtain a second index value;
[0067] A first determining unit, used to determine whether a second storage audio and video data packet exists in a second storage unit corresponding to a second index value in a cache area;
[0068] The first processing unit is configured to obtain the second stored audio and video data packet and a second storage package sequence number corresponding to the second stored audio and video data packet if the second storage unit has the second stored audio and video data packet;
[0069] A second transmission unit, used for transmitting the second stored audio and video data packet to a preset application layer;
[0070] A second updating unit, used for updating the current packet sequence number to the second storage packet sequence number and setting the second storage unit empty;
[0071] A second processing unit, configured to update the current packet sequence number to the current target packet sequence number if the second stored audio and video data packet does not exist in the second storage unit;
[0072] A first comparison unit, used to compare whether the first index value and the second index value are equal;
[0073] The third processing unit is used to return to the step of adding 1 to the current packet sequence number to obtain the current target packet sequence number, and performing modulo calculation on the current target packet sequence number to obtain the second index value if the first index value is not equal to the second index value.
[0074] Optionally, the third processing module further includes:
[0075] a fourth processing unit, configured to, if the first index value is equal to the second index value, subtract 1 from the target packet sequence number to obtain a first target packet sequence number, and compare whether the first target packet sequence number is equal to the current packet sequence number;
[0076] a fifth processing unit, configured to return to the step of transmitting the nth audio and video data packet to a preset application layer if the first target packet sequence number is equal to the current packet sequence number;
[0077] The sixth processing unit is used to store the nth audio and video data packet into the first storage unit if the first target packet sequence number is not equal to the current packet sequence number.
[0078] In the third aspect of the implementation of the present invention, there is also provided an electronic device, characterized in that it includes a processor, a memory, and a computer program stored in the memory and capable of running on the processor, and when the computer program is executed by the processor, the above-mentioned audio and video data packet processing method is implemented.
[0079] In the fourth aspect of the implementation of the present invention, a computer-readable storage medium is also provided, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the above-mentioned audio and video data packet processing method is implemented.
[0080] The embodiments of the present invention have the following advantages:
[0081] In an embodiment of the present invention, an nth audio and video data packet and a target packet sequence number corresponding to the nth audio and video data packet are obtained, and a current packet sequence number for the audio and video data packet is determined, the current packet sequence number being a preset value or a packet sequence number corresponding to the n-1th audio and video data packet; the target packet sequence number is subtracted by 1 to obtain a first target packet sequence number, and the first target packet sequence number is compared to see whether they are equal to the current packet sequence number; if the first target packet sequence number is equal to the current packet sequence number, the nth audio and video data packet and the audio and video data packet stored in a preset buffer area are transmitted to a preset application layer, and the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet is returned; if the first target packet sequence number is not equal to the current packet sequence number, the nth audio and video data packet is sorted, and the sorted nth audio and video data packet is stored in a preset buffer area, and the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet is returned. The embodiment of the present invention is based on packet sequence number modulo and dynamic caching strategy. When disorder occurs during the transmission of audio and video data packets, fast reordering can be achieved, thereby improving the real-time performance of audio and video data transmission and reducing network delay. BRIEF DESCRIPTION OF THE DRAWINGS
[0082] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art.
[0083] Figure 1 It is a flowchart of a method for processing audio and video data packets provided by one embodiment of the present invention;
[0084] Figure 2 is a flow chart of a method for processing audio and video data packets provided by one embodiment of the present invention;
[0085] Figure 3 It is a structural diagram of an audio and video data packet processing device provided by one embodiment of the present invention. DETAILED DESCRIPTION
[0086] In order to make the purpose, technical scheme and advantages of the embodiments of the present invention clearer, the embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings. However, it can be understood by those skilled in the art that in the embodiments of the present invention, many technical details are proposed in order to enable readers to better understand the present invention. However, even without these technical details and various changes and modifications based on the following embodiments, the technical scheme claimed in the present invention can also be implemented. The division of the following embodiments is for the convenience of description and should not constitute any limitation on the specific implementation of the present invention. The various embodiments can be combined and referenced with each other without contradiction.
[0087] RTP (Real-time Transport Protocol) is a network transmission protocol used to transmit multimedia data such as audio and video over the Internet. It can ensure the order and synchronization of real-time data by dividing the data into small packets and including sequence numbers and timestamps, while supporting multicast transmission to adapt to scenarios such as large conferences and live broadcasts. RTP itself does not provide transmission guarantees, but its flexibility enables it to be used in combination with various underlying transport protocols (such as UDP) to adapt to different network conditions. It is widely used in a variety of real-time communication scenarios such as video conferencing systems, real-time streaming services, and online education platforms.
[0088] UDP (User Datagram Protocol) is a simple, connectionless network transmission protocol that provides an unreliable data transmission service without guaranteeing the order, integrity or repetitiveness of data packets. However, due to its low overhead and low latency, it is suitable for applications with high real-time requirements, such as real-time audio and video transmission, online games, and real-time data analysis. The simplicity and efficiency of UDP make it the preferred protocol for many real-time communication and data transmission scenarios.
[0089] When using the UDP-based RTP transmission method, since UDP transmission does not guarantee the timing of data packets arriving at the destination, it may cause packet loss or disorder at the receiving end. The existing data packet reordering algorithm is complex and has low real-time performance. Therefore, an embodiment of the present invention provides an audio and video data packet processing method to achieve rapid reordering of audio and video data packets.
[0090] Reference Figure 1 , shows a flowchart of a method for processing an audio and video data packet provided by an embodiment of the present invention, and the method may specifically include the following steps:
[0091] Step 101, obtain the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet, and determine the current packet sequence number for the audio and video data packet, where the current packet sequence number is a preset value or a packet sequence number corresponding to the n-1th audio and video data packet.
[0092] It should be noted that the packet number is a unique serial number for each audio and video data packet, which can be used to identify its position in the entire audio and video data stream and is assigned by the RTP sender.
[0093] In the embodiment of the present invention, when transmitting audio or video data, the audio or video data may be received by a receiving end of RTP and the data may be divided into a plurality of audio and video data packets.
[0094] The nth audio and video data packet and the packet sequence number of the data packet can be obtained, and the current packet sequence number for the audio and video data packet can be determined. The current packet sequence number can be a preset value -1, or the packet sequence number of the n-1th audio and video data packet.
[0095] It should be noted that n is a positive integer greater than or equal to 1. When n=1, it can be said that this is the initial state, no audio or video data has been processed, the data packet obtained at this time is the first audio or video data packet, and the current packet number is the preset value minus 1; when n≠1, the current packet number is the packet number of the n-1th audio or video data packet. The target packet number can be defined as a uint16 (unsigned 16-bit integer) type variable; the current packet number can be defined as an int32 (signed 32-bit integer) type variable, indicating the packet number of the latest processed audio or video data packet.
[0096] Step 102, subtract 1 from the target packet sequence number to obtain a first target packet sequence number, and compare whether the first target packet sequence number is equal to the current packet sequence number.
[0097] In the embodiment of the present invention, the target packet sequence number can be reduced by 1 to obtain the packet sequence number of the previous data packet in the non-random order, that is, the first target packet sequence number. The first target packet sequence number is compared with the packet sequence number of the previous data packet in the actual situation (that is, the current packet sequence number) to determine whether the two packet sequence numbers are equal, and then determine whether the nth audio and video data packet is a random order data packet.
[0098] It should be noted that the embodiment of the present invention performs a subtraction operation on the target packet sequence number instead of a plus operation on the current packet sequence number because when the current packet sequence number is equal to 65535, if a plus operation is performed on it, its value becomes 65536, and the target packet sequence number is a variable of type uint16, and its value range can be 0 to 65535. At this time, the value of the target packet sequence number will exceed the value range of the target packet sequence number, and a normal comparison operation cannot be performed. If the target packet sequence number value is 0, it becomes 65535 after a minus operation is performed on it, and a comparison operation can be performed with the current value (65535) of the current packet sequence number to determine whether a data packet disorder occurs.
[0099] In an embodiment of the present invention, by subtracting 1 from the target packet number to obtain the first target packet number and comparing it with the current packet number, it is effectively determined whether the audio and video data packets are out of order, while avoiding comparison errors caused by packet number overflow.
[0100] In an optional embodiment of the present invention, when the current packet sequence number is a preset value, before comparing whether the first target packet sequence number is equal to the current packet sequence number, the following sub-steps are further included:
[0101] Update the current packet sequence number to the first target packet sequence number.
[0102] In an embodiment of the present invention, when the current packet sequence number is a preset value, it may indicate that the first audio and video data packet is received at this time. At this time, the current packet sequence number needs to be updated to the first target packet sequence number before further comparison can be performed to see whether the first target packet sequence number is equal to the current packet sequence number.
[0103] It should be noted that the packet sequence number of the first audio and video data packet may be the smallest packet sequence number among all data packets, and the first audio and video data packet is a non-random sequence data packet.
[0104] Step 103, if the first target packet sequence number is equal to the current packet sequence number, the nth audio and video data packet and the audio and video data packet stored in the preset cache area are transmitted to the preset application layer, and the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet is returned.
[0105] It should be noted that the preset buffer area can be an array of preset specifications, which can be used to store pointers to cached audio and video data. The preset specifications can be 2 to the power of n, where n is a positive integer. All storage unit values of the buffer area are initialized to empty. The application layer can combine the received audio and video data packets into frames of audio and video data.
[0106] In the embodiment of the present invention, if the first target packet sequence number is equal to the current packet sequence number, it can be indicated that the audio and video data packet currently being processed is the next data packet expected to be processed, that is, the data packets are not out of order at this time. At this time, after the audio and video data packet is transmitted to the application layer, the audio and video data packets temporarily stored in the preset buffer area are also transmitted to the application layer. After the transmission of the data packets in the correct order in the buffer area is completed, the step of re-receiving the audio and video data packets can be returned.
[0107] It should be noted that the audio and video data packets that can be transmitted and exist in the buffer area are in a non-disordered relationship with the nth audio and video data packet. For example, if the packet number of the nth audio and video data packet is 1997, the packet number of the audio and video data packet that can be transmitted and exist in the buffer area is 1998. After the transmission of the packet number 1998 is completed, the packet number 1999 can be processed. If there is no packet number 2000 in the buffer area, the process returns to the step of obtaining the nth audio and video data packet.
[0108] In an embodiment of the present invention, a mechanism for dynamically adjusting the size of the buffer can be introduced. When initializing the buffer, in addition to presetting a basic size (such as 16 or 32), a maximum buffer size (such as 64 or 128) can also be set. At the same time, a disorder degree monitor can be introduced to count and evaluate the disorder degree of data packets in real time. The disorder degree monitor can calculate the proportion of disordered packets to the total received data packets regularly (such as every second or every time a certain number of data packets are received), and adjust the size of the buffer according to the disorder ratio. For example, if the proportion of disordered packets exceeds a preset threshold, the size of the buffer is gradually increased; if the proportion of disordered packets is reduced to a lower level, the size of the buffer is gradually reduced. In an embodiment of the present invention, a mechanism for dynamically adjusting the size of the buffer is introduced to adapt to the disorder of data packets under different network environments. Thereby, while ensuring the rapid reordering of data packets, the utilization efficiency of the cache space is optimized.
[0109] In an optional embodiment of the present invention, step 103 includes the following sub-steps:
[0110] S31: Transmitting the nth audio and video data packet to a preset application layer;
[0111] S32: Update the current packet sequence number to the target packet sequence number;
[0112] S33: adding 1 to the current packet sequence number to obtain the current target packet sequence number, and performing a modulo calculation on the current target packet sequence number to obtain a second index value;
[0113] S34: Determine whether there is a second storage audio and video data packet in a second storage unit corresponding to the second index value in a preset cache area;
[0114] S35: If the second storage unit contains the second stored audio and video data packet, process the second stored audio and video data packet, and return to the step of adding 1 to the current packet sequence number to obtain the current target packet sequence number, and performing modulo calculation on the current target packet sequence number to obtain the second index value;
[0115] S36: If the second storage audio and video data packet does not exist in the second storage unit, return to the step of obtaining the nth audio and video data packet and the corresponding target packet sequence number.
[0116] It should be noted that the cache unit can be a storage location or slot in a preset cache area. Each array element can be a cache unit. The cache unit is used to temporarily store audio and video data packets for subsequent processing and transmission; the index value can be a numerical value used to identify the location of the cache unit. In the array structure, the index value is usually an integer starting from 0, which can be used to directly access a specific element in the array. When processing audio and video data packets, the index value can be used to determine the storage location of the data packet in the cache area. Modulo calculation (usually expressed as the "%" operator) is a mathematical operation that can be used to calculate the remainder after one number is divided by another number. In cache management, modulo calculation is often used to cyclically access the cache area. For example, if the size of the cache area is 2 to the power of n (such as 16, 32, etc.), the modulo calculation can ensure that the index value is always within the valid range of the cache area, so that the cache space can be recycled.
[0117] In an embodiment of the present invention, the acquired nth audio and video data packet can be sent to the application layer for further processing, and the current packet sequence number is updated to the target packet sequence number, indicating that the latest processing of the nth audio and video data packet has been completed to ensure that subsequent data packets can be processed in the correct order.
[0118] The current packet number is added by 1 and modulo calculation is performed to obtain the second index value, which is used to indicate the position of the next data packet of the nth audio and video data packet in the buffer area when received in the correct order. For example, if the target packet number is 1977, the second index value represents the position of the data packet with packet number 1978 in the buffer area.
[0119] It can be checked whether the second storage unit corresponding to the second index value in the buffer area has stored the audio and video data packet. If the audio and video data packet does not exist in the second storage unit, it means that the buffer area does not temporarily store a data packet connected to the nth video data packet sequence number, and then return to receive the next data packet again.
[0120] If there is an audio or video data packet in the second storage unit, it is necessary to process the audio or video data packet and then return to calculate the position of the next packet number of the audio or video data packet by modulo until there is no storage data in the storage unit.
[0121] For example, the current packet sequence number is added by 1 to obtain the current target packet sequence number, and the current target packet sequence number is calculated by modulus to obtain the second index value. The calculation expression is:
[0122] index = (lastSeq + 1) % size (1)
[0123] Among them, index is the second index value, lastSeq is the current packet sequence number, and size is the preset specification of the buffer area, which is 2 to the power of n integer.
[0124] In an optional embodiment of the present invention, step S35 further includes the following sub-steps:
[0125] S351: Obtain a second stored audio and video data packet and a second stored packet sequence number corresponding to the second stored audio and video data packet;
[0126] S352: Transmitting the second stored audio and video data packet to the application layer;
[0127] S353: Update the current packet sequence number to the second storage packet sequence number, and clear the second storage unit.
[0128] In an embodiment of the present invention, the audio and video data packets and their corresponding packet sequence numbers can be obtained from the second storage unit and sent to the application layer. The current packet sequence number is updated to the second storage packet sequence number to ensure that subsequent data packets can be processed in the correct order. At the same time, the second storage unit is cleared to facilitate the storage of subsequent data packets.
[0129] In an embodiment of the present invention, for non-out-of-order data packets, on the basis of transmitting them normally to the application layer for processing, the audio and video data packets temporarily stored in the cache area are transmitted to the application layer in sequence based on the packet sequence number modulo and cache area management, thereby ensuring the sequentiality and continuity of the audio and video data packets during real-time transmission.
[0130] Step 104, if the first target packet sequence number is not equal to the current packet sequence number, sort the nth audio and video data packet, and store the sorted nth audio and video data packet into a preset cache area, and return to the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet.
[0131] In the embodiment of the present invention, if the first target packet sequence number is not equal to the current packet sequence number, it means that the nth audio and video data packet is out of order. At this time, the nth audio and video data packet can be sorted to ensure that the data packet can be processed in the correct order. The sorted nth audio and video data packet can be stored in a preset buffer area, waiting for further processing, and then return to receive the next audio and video data.
[0132] In an optional embodiment of the present invention, step 104 includes the following sub-steps:
[0133] S41: performing a modulo calculation on the target packet sequence number to obtain a first index value;
[0134] S42: Determine whether there is a first storage audio and video data packet in a first storage unit corresponding to a preset cache area with a first index value;
[0135] S43: If the first storage unit contains the first stored audio and video data packet, process the first stored audio and video data packet, and return to the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet;
[0136] S44: If the first storage audio and video data packet does not exist in the first storage unit, the nth audio and video data packet is stored in the first storage unit, and the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet is returned.
[0137] In the embodiment of the present invention, a first index value may be obtained by performing a modulo calculation on the target packet sequence number, and the index value may be used to determine the storage position of the nth audio and video data packet in the buffer area.
[0138] It can be checked whether the first storage unit corresponding to the first index value in the buffer area has stored the audio and video data packet. If the audio and video data packet does not exist in the first storage unit, the nth audio and video data packet is stored in the first storage unit, and the next data packet is received again.
[0139] If there is an audio or video data packet in the second storage unit, it is necessary to process the audio or video data packet and then return to receive the next data packet.
[0140] For example, the target packet sequence number is calculated by modulus to obtain the first index value, and the calculation expression is:
[0141] newindex = Seq%size(2)
[0142] Among them, newindex is the second index value, Seq is the target packet sequence number, and size is the preset specification of the buffer area, which is 2 to the power of an integer of n.
[0143] In an optional embodiment of the present invention, step S43 includes the following sub-steps:
[0144] S431: adding 1 to the current packet sequence number to obtain the current target packet sequence number, and performing a modulo calculation on the current target packet sequence number to obtain a second index value;
[0145] S432: Determine whether there is a second stored audio and video data packet in the second storage unit corresponding to the second index value in the cache area;
[0146] S433: If the second storage unit contains a second storage audio and video data packet, obtain the second storage audio and video data packet and a second storage packet sequence number corresponding to the second storage audio and video data packet;
[0147] S434: Transmitting the second stored audio and video data packet to a preset application layer;
[0148] S435: Update the current packet sequence number to the second storage packet sequence number, and clear the second storage unit;
[0149] S436: If the second storage audio and video data packet does not exist in the second storage unit, the current packet sequence number is updated to the current target packet sequence number;
[0150] S437: Compare whether the first index value and the second index value are equal;
[0151] S438: If the first index value is not equal to the second index value, return to the step of adding 1 to the current packet sequence number to obtain the current target packet sequence number, and performing a modulo calculation on the current target packet sequence number to obtain the second index value.
[0152] In an embodiment of the present invention, the current packet sequence number is increased by 1 and a modulo calculation is performed to obtain a second index value, which is used to indicate the position of the next data packet of the nth audio and video data packet in the buffer area when received in the correct order.
[0153] It can be checked whether the second storage unit corresponding to the second index value in the buffer area has stored the audio and video data packet. If the audio and video data packet exists in the second storage unit, the audio and video data packet and its corresponding packet sequence number can be obtained from the second storage unit and sent to the application layer. The current packet sequence number is updated to the second storage packet sequence number to ensure that subsequent data packets can be processed in the correct order. At the same time, the second storage unit is emptied to facilitate the storage of subsequent data packets.
[0154] If there is no audio or video data packet in the second storage unit, it means that there is no data packet connected to the packet sequence number of the nth video data packet temporarily stored in the buffer area, and the current packet sequence number is increased by 1 at this time.
[0155] By comparing the first index value and the second index value, it can be determined whether they point to the same cache unit. If the first index value and the second index value are not equal, it means that the empty storage unit is not a location that can be stored for the nth audio and video data packet. At this time, return to the step of calculating the second index to determine whether the next storage unit is a location that can be stored for the nth audio and video data packet.
[0156] For example, the current packet sequence number is added by 1 to obtain the current target packet sequence number, and the current target packet sequence number is calculated by modulus to obtain the second index value. The calculation expression is:
[0157] index = (lastSeq + 1) % size (3)
[0158] Among them, index is the second index value, lastSeq is the current packet sequence number, and size is the preset specification of the buffer area, which is 2 to the power of n integer.
[0159] In an optional embodiment of the present invention, step S43 further includes the following sub-steps:
[0160] S439: If the first index value is equal to the second index value, subtract 1 from the target packet sequence number to obtain a first target packet sequence number, and compare the first target packet sequence number with the current packet sequence number to see if they are equal;
[0161] S4391: If the first target packet sequence number is equal to the current packet sequence number, return to the step of transmitting the nth audio and video data packet to the preset application layer;
[0162] S4392: If the first target packet sequence number is not equal to the current packet sequence number, the nth audio and video data packet is stored in the first storage unit.
[0163] In the embodiment of the present invention, if the first index value and the second index value are not equal, it indicates that the empty storage unit is the storage location of the nth audio and video data packet. At this time, the target packet sequence number can be reduced by 1 to obtain the first target packet sequence number, and the first target packet sequence number is compared with the current packet sequence number to see if they are equal. If the first target packet sequence number is equal to the current packet sequence number, it indicates that the nth audio and video data packet at this time is the expected next data packet, that is, the nth audio and video data packet at this time is a non-random data packet, and the process of processing non-random data packets can be returned to the step of transmitting the nth audio and video data packet to the preset application layer.
[0164] In the embodiment of the present invention, for out-of-order data packets, rapid reordering of audio and video data packets is achieved based on packet sequence number modulo, rapid index positioning, effective use of cache areas, dynamic update and processing mechanisms, and circular use of cache space.
[0165] In the embodiment of the present invention, different processing methods are used to sort and cache out-of-order and non-out-of-order data packets, so that the audio and video data packets can be sent to the application layer in the correct order for combination, and finally generate frame-by-frame video data. In the case of out-of-order audio and video data packet transmission, the data packets can be quickly reordered, the real-time performance of audio and video data transmission can be improved, and network delay can be reduced.
[0166] Reference Figure 2, shows a flow chart of a method for processing an audio and video data packet provided by an embodiment of the present invention, which may specifically include the following contents:
[0167] In the embodiment of the present invention, an array of preset specifications is used as a buffer area, and the current packet number is preset to -1. The target packet number corresponding to the nth audio and video data packet is obtained, and it is determined whether the current packet number is -1. If so, it means that n is 1, and the current packet number is updated to the target packet number minus 1.
[0168] Compare the target packet sequence number minus 1 with the current packet sequence number. If they are equal, it means that this is a positive sequence data packet. The processing method at this time is as follows:
[0169] The nth audio and video data packet is transmitted to the application layer, and the current packet sequence number is updated to the target packet sequence number. The current packet sequence number is increased by 1 and then modulo calculation is performed to obtain the second index value. It is determined whether there is a second audio storage data packet in the second storage unit corresponding to the second index value in the cache area. If so, the data packet is transmitted to the application layer, the current packet sequence number is updated to the second storage packet sequence number, and the second storage unit is cleared. Finally, the step of calculating the second index value is returned; if not, the step of obtaining the nth audio and video data packet is returned.
[0170] If they are equal, it means that this is a positive sequence data packet. The processing method is as follows:
[0171] Compare the target packet sequence number minus 1 with the current packet sequence number. If they are not equal, it means that the data packet is out of order. The processing method at this time is as follows:
[0172] The first index value is obtained by taking a modulus calculation of the target packet sequence number, and it is determined whether there is a second audio storage data packet in the first storage unit corresponding to the first index value in the cache area. If not, the nth audio and video data packet is stored in the first storage unit, and the step of obtaining the nth audio and video data packet is returned; if so, the following steps are executed:
[0173] Add 1 to the current packet sequence number and then perform a modulo calculation to obtain a second index value. Determine whether there is a second audio storage data packet in the second storage unit corresponding to the second index value in the cache area. If so, transmit the data packet to the application layer, update the current packet sequence number to the second storage packet sequence number, and clear the second storage unit; otherwise, add 1 to the current packet sequence number;
[0174] Determine whether the first index value and the second index value are equal, if not, return to the step of calculating the second index value; if so, subtract 1 from the target packet number and compare it with the current packet number, if the two are equal, return to the step of transmitting the nth audio and video data packet to the application layer, if the two are not equal, store the nth audio and video data packet in the first storage unit, and return to the step of obtaining the nth audio and video data packet.
[0175] In an embodiment of the present invention, an nth audio and video data packet and a target packet sequence number corresponding to the nth audio and video data packet are obtained, and a current packet sequence number for the audio and video data packet is determined, the current packet sequence number being a preset value or a packet sequence number corresponding to the n-1th audio and video data packet; the target packet sequence number is subtracted by 1 to obtain a first target packet sequence number, and the first target packet sequence number is compared to see whether they are equal to the current packet sequence number; if the first target packet sequence number is equal to the current packet sequence number, the nth audio and video data packet and the audio and video data packet stored in a preset buffer area are transmitted to a preset application layer, and the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet is returned; if the first target packet sequence number is not equal to the current packet sequence number, the nth audio and video data packet is sorted, and the sorted nth audio and video data packet is stored in a preset buffer area, and the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet is returned. The embodiment of the present invention is based on packet sequence number modulo and dynamic caching strategy. When disorder occurs during the transmission of audio and video data packets, fast reordering can be achieved, thereby improving the real-time performance of audio and video data transmission and reducing network delay.
[0176] Reference Figure 3 , shows a schematic diagram of the structure of an audio and video data packet processing device provided by an embodiment of the present invention. The device includes:
[0177] The acquisition module 301 is used to acquire the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet, and determine the current packet sequence number for the audio and video data packet, where the current packet sequence number is a preset value or a packet sequence number corresponding to the n-1th audio and video data packet;
[0178] A comparison module 302 is used to reduce the target packet sequence number by 1 to obtain a first target packet sequence number, and compare whether the first target packet sequence number is equal to the current packet sequence number;
[0179] The first processing module 303 is used for transmitting the nth audio and video data packet and the audio and video data packet stored in the preset buffer area to the preset application layer if the target packet sequence number minus 1 is equal to the current packet sequence number, and returning to the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet;
[0180] The second processing module 304 is used to sort the nth audio and video data packet if the target packet number minus 1 is not equal to the current packet number, and store the sorted nth audio and video data packet into a preset cache area, and return to the step of obtaining the nth audio and video data packet and the target packet number corresponding to the nth audio and video data packet.
[0181] Optionally, when the current packet sequence number is a preset value, the device further includes:
[0182] The preset updating module is used to update the current packet sequence number to the first target packet sequence number before comparing whether the first target packet sequence number is equal to the current packet sequence number.
[0183] Optionally, the first processing module 303 includes:
[0184] A transmission module, used for transmitting the nth audio and video data packet to a preset application layer;
[0185] A first updating module, used for updating the current packet sequence number to the target packet sequence number;
[0186] A first acquisition module is used to add 1 to the current packet sequence number to obtain the current target packet sequence number, and perform a modulo calculation on the current target packet sequence number to obtain a second index value;
[0187] A first determination module, used to determine whether a second storage audio and video data packet exists in a second storage unit corresponding to a preset cache area with a second index value;
[0188] The first processing module is used for processing the second stored audio and video data packet if the second storage unit has the second stored audio and video data packet, and returning to the step of adding 1 to the current packet sequence number to obtain the current target packet sequence number, and performing a modulo calculation on the current target packet sequence number to obtain a second index value;
[0189] The second processing module is used to return to the step of obtaining the nth audio and video data packet and the corresponding target packet sequence number if the second stored audio and video data packet does not exist in the second storage unit.
[0190] Optionally, the first treatment module includes:
[0191] A first acquisition unit, used to acquire a second stored audio and video data packet and a second stored packet sequence number corresponding to the second stored audio and video data packet;
[0192] A first transmission unit, configured to transmit the second stored audio and video data packet to the application layer;
[0193] The first updating unit is used to update the current packet sequence number to the second storage packet sequence number and set the second storage unit empty.
[0194] Optionally, the second processing module 304 includes:
[0195] A second acquisition module is used to obtain a first index value by performing a modulo calculation on the target packet sequence number;
[0196] A second determination module is used to determine whether a first storage audio and video data packet exists in a first storage unit corresponding to a preset cache area of a first index value;
[0197] A third processing module is used for processing the first stored audio and video data packet if the first storage unit has the first stored audio and video data packet, and returning to the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet;
[0198] The fourth reset module is used to store the nth audio and video data packet in the first storage unit if the first storage audio and video data packet does not exist in the first storage unit, and return to the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet.
[0199] Optionally, the third processing module includes:
[0200] A first calculation unit is used to add 1 to the current packet sequence number to obtain the current target packet sequence number, and perform a modulo calculation on the current target packet sequence number to obtain a second index value;
[0201] A first determining unit, used to determine whether a second storage audio and video data packet exists in a second storage unit corresponding to a second index value in a cache area;
[0202] The first processing unit is configured to obtain the second stored audio and video data packet and a second storage package sequence number corresponding to the second stored audio and video data packet if the second storage unit has the second stored audio and video data packet;
[0203] A second transmission unit, used for transmitting the second stored audio and video data packet to a preset application layer;
[0204] A second updating unit, used for updating the current packet sequence number to the second storage packet sequence number and setting the second storage unit empty;
[0205] A second processing unit, configured to update the current packet sequence number to the current target packet sequence number if the second stored audio and video data packet does not exist in the second storage unit;
[0206] A first comparison unit, used to compare whether the first index value and the second index value are equal;
[0207] The third processing unit is used to return to the step of adding 1 to the current packet sequence number to obtain the current target packet sequence number, and performing modulo calculation on the current target packet sequence number to obtain the second index value if the first index value is not equal to the second index value.
[0208] Optionally, the third processing module further includes:
[0209] a fourth processing unit, configured to, if the first index value is equal to the second index value, subtract 1 from the target packet sequence number to obtain a first target packet sequence number, and compare whether the first target packet sequence number is equal to the current packet sequence number;
[0210] a fifth processing unit, configured to return to the step of transmitting the nth audio and video data packet to a preset application layer if the first target packet sequence number is equal to the current packet sequence number;
[0211] The sixth processing unit is used to store the nth audio and video data packet into the first storage unit if the first target packet sequence number is not equal to the current packet sequence number.
[0212] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0213] An embodiment of the present invention further provides an electronic device, which may include a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, the above-mentioned audio and video data packet processing method is implemented.
[0214] An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned audio and video data packet processing method is implemented.
[0215] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0216] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0217] Those skilled in the art will appreciate that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the embodiments of the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0218] The embodiments of the present invention are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0219] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0220] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0221] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present invention.
[0222] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the above elements.
[0223] The above is a detailed introduction to the provided audio and video data packet processing method and device. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A method for processing audio and video data packets, characterized in that: The method comprises: Obtaining an nth audio and video data packet and a target packet sequence number corresponding to the nth audio and video data packet, and determining a current packet sequence number for the audio and video data packet, wherein the current packet sequence number is a preset value or a packet sequence number corresponding to the n-1th audio and video data packet; Subtract 1 from the target packet sequence number to obtain a first target packet sequence number, and compare whether the first target packet sequence number is equal to the current packet sequence number; If the first target packet sequence number is equal to the current packet sequence number, the nth audio and video data packet and the audio and video data packet stored in the preset buffer area are transmitted to the preset application layer, and the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet is returned; If the first target packet sequence number is not equal to the current packet sequence number, the nth audio and video data packet is sorted, and the sorted nth audio and video data packet is stored in a preset cache area, and the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet is returned.
2. The method according to claim 1, characterized in that When the current packet sequence number is a preset value, before comparing whether the first target packet sequence number is equal to the current packet sequence number, the method further includes: The current packet sequence number is updated to the first target packet sequence number.
3. The method according to claim 1, characterized in that The step of transmitting the nth audio and video data packet and the audio and video data packet stored in a preset buffer area to a preset application layer, and returning the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet, comprises: Transmitting the nth audio and video data packet to a preset application layer; Updating the current packet sequence number to the target packet sequence number; Add 1 to the current packet sequence number to obtain the current target packet sequence number, and perform a modulo calculation on the current target packet sequence number to obtain a second index value; Determine whether there is a second storage audio and video data packet in a second storage unit corresponding to the second index value in a preset cache area; If the second storage unit contains the second stored audio and video data packet, process the second stored audio and video data packet, and return to the step of adding 1 to the current packet sequence number to obtain the current target packet sequence number, and performing modulo calculation on the current target packet sequence number to obtain the second index value; If the second stored audio and video data packet does not exist in the second storage unit, return to the step of obtaining the nth audio and video data packet and the corresponding target packet sequence number.
4. The method according to claim 3, characterized in that The processing of the second stored audio and video data packet includes: Obtain the second stored audio and video data packet and the second stored packet sequence number corresponding to the second stored audio and video data packet; Transmitting the second stored audio and video data packet to the application layer; The current packet sequence number is updated to the second stored packet sequence number, and the second storage unit is set to empty.
5. The method according to claim 3, characterized in that: The step of sorting the nth audio and video data packet, storing the sorted nth audio and video data packet into a preset buffer area, and returning the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet comprises: Performing a modulo calculation on the target packet sequence number to obtain a first index value; Determine whether there is a first storage audio and video data packet in a first storage unit corresponding to the first index value in a preset cache area; If the first storage unit contains the first stored audio and video data packet, the first stored audio and video data packet is processed, and the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet is returned; If the first stored audio and video data packet does not exist in the first storage unit, the nth audio and video data packet is stored in the first storage unit, and the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet is returned.
6. The method according to claim 5, characterized in that The processing of the first stored audio and video data packet includes: Add 1 to the current packet sequence number to obtain the current target packet sequence number, and perform a modulo calculation on the current target packet sequence number to obtain a second index value; Determine whether there is a second stored audio and video data packet in the second storage unit corresponding to the second index value in the cache area; If the second storage unit contains the second storage audio and video data packet, obtaining the second storage audio and video data packet and a second storage packet sequence number corresponding to the second storage audio and video data packet; Transmitting the second stored audio and video data packet to a preset application layer; Updating the current packet sequence number to the second storage packet sequence number, and setting the second storage unit empty; If the second stored audio and video data packet does not exist in the second storage unit, updating the current packet sequence number to the current target packet sequence number; Comparing whether the first index value and the second index value are equal; If the first index value is not equal to the second index value, return to the step of adding 1 to the current packet sequence number to obtain the current target packet sequence number, and performing modulo calculation on the current target packet sequence number to obtain the second index value.
7. The method according to claim 6, characterized in that The method further comprises: If the first index value is equal to the second index value, subtract 1 from the target packet sequence number to obtain a first target packet sequence number, and compare whether the first target packet sequence number is equal to the current packet sequence number; If the first target packet sequence number is equal to the current packet sequence number, returning to the step of transmitting the nth audio and video data packet to a preset application layer; If the first target packet sequence number is not equal to the current packet sequence number, the nth audio and video data packet is stored in the first storage unit.
8. An audio and video data packet processing device, characterized in that: The device comprises: An acquisition module, used to acquire the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet, and determine the current packet sequence number for the audio and video data packet, where the current packet sequence number is a preset value or a packet sequence number corresponding to the n-1th audio and video data packet; A comparison module, configured to subtract 1 from the target packet sequence number to obtain a first target packet sequence number, and compare whether the first target packet sequence number is equal to the current packet sequence number; A first processing module, configured to transmit the nth audio and video data packet and the audio and video data packet stored in a preset buffer area to a preset application layer if the first target packet sequence number is equal to the current packet sequence number, and return to the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet; The second processing module is used to sort the nth audio and video data packet if the first target packet sequence number is not equal to the current packet sequence number, and store the sorted nth audio and video data packet into a preset cache area, and return to the step of obtaining the nth audio and video data packet and the target packet sequence number corresponding to the nth audio and video data packet.
9. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; The processor is used to implement the audio and video data packet processing method as described in any one of claims 1 to 7 when executing the program stored in the memory.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for processing audio and video data packets according to any one of claims 1 to 7 is implemented.
