Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of a forward error correction method for streaming media transmission according to an embodiment of the present invention, where the embodiment is applicable to data recovery during streaming media transmission, and the method can be executed by a forward error correction system for streaming media transmission. The method specifically comprises the following steps:
step 110, the sending end obtains the current network quality data during streaming media transmission.
In the embodiment of the present invention, the streaming media is also called streaming media, which refers to media transmitted and played in a streaming transmission manner, that is, media that is transmitted and played simultaneously, such as live broadcast, instant audio or video communication. A receiver receiving streaming media continuously receives and views or listens to the transmitted streaming media while a provider providing the streaming media transmits the media over a network or within a short delay time. The current network Quality data may be a current network Quality of Service (QoS), and parameters in the QoS include, but are not limited to: bandwidth, communication delay, delay jitter, packet loss rate, or hop count. The QoS parameters may be fed back by the receiving end or by the network node to the transmitting end.
According to the transmission condition of the streaming media, when the transmission condition is not good or the requirement of the receiving end cannot be met, the forward error correction function needs to be started at this time, so as to improve the transmission quality of the streaming media. Therefore, the repeated opening and closing of the forward error correction function are controlled by dynamically setting the forward error correction redundancy parameters of the transmitting end.
And step 120, the sending end dynamically sets the forward error correction redundancy parameter of the sending end according to the current network quality data and the preset rule, and performs redundancy coding on the streaming media according to the forward error correction redundancy parameter of the sending end.
In an embodiment of the present invention, the fec redundancy parameter is a basis for performing redundancy coding. Forward error correction redundancy parameters include, but are not limited to: redundancy level, redundancy ratio of each layer of redundancy, redundancy rate of each layer of redundancy and the like. The more redundancy levels, the higher the protection performance for data transmission, but the more complex the corresponding encoding and decoding algorithms. The redundancy ratio represents the ratio of the data packets to be encoded to the redundant data packets generated. For example, a layer redundancy ratio of 10 indicates that 1 redundant data packet is generated from 10 media data packets; the second-layer redundancy ratio is 3, which means that 1 second-layer redundancy data packet is generated by 3 first-layer redundancy data packets; and so on. In this embodiment, a layer of redundancy ratio is set to range from 2 to 25, that is, the minimum value of the redundancy ratio of one layer is set to be 2, and the maximum value is set to be 25; the range of the two-layer redundancy ratio is set to be 2 to 8, namely the minimum value of the two-layer redundancy ratio is set to be 2, and the maximum value is set to be 8. This embodiment does not take into account the complexity of the multi-layer redundancy of more than two layers.
Redundancy represents the proportion of redundant data packets to all data packets. Assuming that the first-layer redundancy ratio is n and the second-layer redundancy ratio is m, when only one redundancy layer is provided, the redundancy is
When two redundancy levels are provided, the redundancy is
For example, assuming that the one-layer redundancy ratio is 5 and the two-layer redundancy ratio is 3, when only one redundancy level is set, the redundancy is about 16.67%; when two levels of redundancy are provided, the redundancy is about 21.05%. It can be understood that the higher the redundancy ratio, the lower the redundancy, and further the lower the packet loss compensation capability, i.e., the data recovery capability, the smaller the network bandwidth occupied additionally, and the longer the delay time.
According to the embodiment, a certain parameter setting rule can be preset according to the requirement of the receiving end and the actual network quality, and the forward error correction redundancy parameter of the sending end is dynamically set according to the corresponding relation between the current network quality data and the preset rule. When the network quality is better or the streaming media transmission effect is better, the redundancy ratio is closed or properly increased, so that the redundancy rate of data transmission is reduced, and the occupation of network bandwidth is saved; when the network quality is poor or the streaming media transmission effect is poor, the redundancy ratio is opened or properly reduced, so that the redundancy rate of data transmission is improved, and the data recovery capability is enhanced, so that the data transmission effect is improved.
Illustratively, the audio data occupies a bandwidth of about 5-6KB per second, the data stream includes overhead of Real-time Transport Protocol (RTP), User Datagram Protocol (UDP) and Internet Protocol (IP) headers for interconnection between networks, the frame length of each frame is 42.67ms, and the frame rate is 23.4, i.e. about 23.4 packets per second. The following two cases are proposed for the setting of the forward error correction redundancy parameter at audio transmission: the first is to set a layer of redundancy with a redundancy ratio of 2, and the second is to set a layer of redundancy with a redundancy ratio of 5. Specifically, the first setting has a low redundancy ratio and a high redundancy, which reaches 33.33%. If the redundancy is increased to 50.00% based on the media packet, the network bandwidth occupied additionally is increased more, the total occupied bandwidth reaches 8-9KB, one forward error correction redundancy data packet is redundant in every 2 frames of audio data, and the theoretical delay time is 85.3 ms. The scheme has high requirement on the redundancy of the audio data, and is suitable for scenes with high requirements on audio delay and continuity. Since the overall occupied bandwidth of the audio data is not high, increasing to 50% also falls within the acceptable range. The redundancy ratio is high in the second setting case, and the redundancy is generally 16.67%. If the redundancy is improved to 20.00 percent based on the media packet, the occupied bandwidth reaches 6-7KB, one forward error correction redundant data packet is redundant in every 5 frames of audio data, and the theoretical delay time is 213 ms. The redundancy requirement of the scheme on the audio data is general, the increase by 20 percent also belongs to a better range, the bandwidth consumption is increased, the audio effect is improved, and the scheme is suitable for scenes which have low requirement on audio delay and high requirement on continuity.
Illustratively, the setting of redundancy parameters for video data is much more complex than for audio data. According to the parameters such as video resolution, quality parameters, frame rate and compression algorithm, the live broadcast application occupies different bandwidths in each scene, the range of the live broadcast application approximately comprises 20KB/s, 40KB/s, 80KB/s, 150KB/s and the like, and the data stream comprises the overhead of RTP, UDP and IP headers. The video frame rate ranges from 10 to 25 frames, and the video coding generally requires packet transmission due to large data volume, so just as the setting of the audio data redundancy parameter, the configuration of the forward error correction redundancy parameter of the video data is not significant according to the frame rate setting. Since video encoding transmission occupies a relatively high bandwidth, and the occupied bandwidth is related to video resolution, frame rate, quality parameters and compression algorithm, the configuration of the redundancy parameters is performed according to the occupied bandwidth. Because the video data occupies a higher bandwidth, the redundancy should be set to be lower, so as to achieve the purpose of avoiding the extra bandwidth from occupying too high. Table 1 shows the preset rules for setting the redundancy parameters according to the video data bandwidth occupation amount.
TABLE 1 Preset rules for setting redundancy parameters based on video data bandwidth occupancy
Video data occupies bandwidth
|
Redundancy hierarchy
|
Redundancy ratio
|
Redundancy
|
Increasing bandwidth
|
20KB/S
|
One layer of redundancy
|
A layer 3
|
25.0%
|
33.3%
|
40KB/S
|
Two-layer redundancy
|
One layer 5, two layers 2
|
23.1%
|
30.0%
|
80KB/S
|
Two-layer redundancy
|
One layer 5, two layers 3
|
21.1%
|
26.7%
|
150KB/S
|
Two-layer redundancy
|
One layer 8 and two layers 3
|
14.3%
|
16.7%
|
300KB/S
|
Two-layer redundancy
|
One layer 10 and two layers 5
|
10.7%
|
12.0% |
The increased bandwidth is the bandwidth ratio additionally occupied by the redundant data packet in the redundant coding. For example, for a redundancy parameter with a redundancy ratio of 3 for one layer of redundancy, after redundancy encoding, the bandwidth additionally occupied by the redundant data packet is 1/3 ≈ 33.33%. It is noted that the video data stream in real environment occupies a large bandwidth fluctuation range, such as a video stream of 40KB/S, and the fluctuation range may be between 30KB/S and 60 KB/S. Therefore, when actually setting the redundancy parameters, the redundancy parameters need to be specifically determined by combining the actual situation and the preset rules.
If the forward error correction redundancy parameter is set only by considering the condition that the video data occupies the bandwidth, the parameter is irrelevant to the actual service application. However, the main purpose of introducing the forward error correction function is to optimize the user experience, so that the redundancy parameters are also optimized according to the actual service needs, and the design is performed based on the redundancy time range. When the redundant time unit is too large, packet loss recovery of forward error correction is not as good as packet loss compensation of backward error correction, and the redundant time unit which is too small increases the occupation of extra bandwidth and has lower cost performance. The embodiment proposes two setting conditions of the redundancy parameters during video data transmission: the first is low delay, which takes about 200ms as a redundant time unit, thereby achieving better delay effect; the second is slightly higher latency, with about 400ms as a redundant time unit, which reduces the extra bandwidth occupied by redundant data while ensuring smooth video transmission. Considering that the amount of data carried by each video data packet is not equal, the present embodiment performs calculation with an average value, and it is set that each packet carries 800Byte data. Taking a video code stream with an occupied bandwidth of 150KB/S as an example, about 40 video data packets are calculated to be transmitted within 200ms, so that the redundancy parameter is suggested to be configured into two layers of redundancy, wherein the redundancy ratio of one layer is 8, and the redundancy ratio of the two layers is 5. The preset rule for setting the redundancy parameter when the redundancy time unit is 200ms is calculated based on the above idea is shown in table 2.
TABLE 2 Preset rules for setting redundancy parameters when the redundancy time unit is 200ms
In summary, the setting of the redundancy parameter is related to both the bandwidth occupied by the video data and the expected redundancy level and recovery effect. In a specific case, the redundancy parameter setting value does not affect the normal use of the forward error correction function, but affects the recovery of individual media packets.
The sending end finally opens a forward error correction encoder according to the forward error correction redundancy parameter set for the sending end, and after the sending end generates a media data packet according to the streaming media, the media data packet is firstly encapsulated by using an RTP protocol, so that the media data packet decoded in the later period comprises the RTP protocol encapsulation for being used in the subsequent media processing of the receiving end; and secondly, inserting the media data packet into a forward error correction encoder so that the forward error correction encoder performs redundancy encoding according to the media data packet to generate a redundancy data packet, and encapsulating the redundancy data packet by using an RTP protocol, wherein the packet head of each packet can mark the channel ID of the packet. The sending end and the receiving end correspond to each other one by one and are identified by the channel ID. And the sending end sends the encapsulated media data packet and the encapsulated redundant data packet to the receiving end based on the UDP protocol.
Step 130, the receiving end receives the redundancy code and dynamically adjusts the forward error correction redundancy parameter of the receiving end according to the redundancy code.
In the embodiment of the invention, the receiving end starts a forward error correction decoder, inserts a media data packet corresponding to the streaming media and a redundant data packet after redundant coding into the forward error correction decoder, and then the forward error correction decoder acquires and dynamically adjusts forward error correction redundant parameters from the inserted data packet, so that the forward error correction redundant parameters in the forward error correction decoder are adaptive to be matched with the dynamically adjusted forward error correction redundant parameters of the sending end.
Illustratively, the forward error correction decoder adapts the redundancy parameters based on the reception of the redundant data packet. First, when only one layer of redundant data packets is inserted into the fec decoder, no matter whether the fec encoder at the transmitting end has two layers of redundancy, the fec decoder is set to only one layer of redundancy level, and a layer of redundancy ratio is obtained according to one layer of redundant data packets. Secondly, when only two layers of redundant data packets are inserted into the forward error correction decoder, the forward error correction decoder is set to be two layers of redundant levels, and meanwhile, the redundant proportion of the two layers is obtained according to the two layers of redundant data packets; but one layer of redundancy ratio is not available, keeping the default value of 0. Thirdly, when a first layer of redundant data packets is inserted into the current error correction decoder and then a second layer of redundant data packets is inserted into the current error correction decoder, a redundancy level is set as a first layer, and a first layer of redundancy proportion is obtained according to the first layer of redundant data packets; and then setting a redundancy level as a second layer, and obtaining a second-layer redundancy proportion according to the second-layer redundancy data packet. Fourthly, when the forward error correction decoder receives two layers of redundant data packets firstly and then receives one layer of redundant data packet, the redundancy level is set as two layers firstly, and a two-layer redundancy proportion is obtained according to the two layers of redundant data packets; then, the redundancy level is still kept as two layers, and a layer of redundancy proportion is obtained according to a layer of redundancy data packets. Fifth, when no redundant data packet is inserted into the fec decoder, the redundancy level and the redundancy ratio are both default values of 0. It can be understood that the situation that the packet loss occurs in the data packet transmission process is unpredictable, after the receiving end receives the data packet, the receiving end inserts all the received data packets into the fec decoder, and the fec decoder performs adaptive adjustment of the redundancy parameters according to the actual data packet insertion situation.
In this embodiment, before the receiving end recovers the streaming media according to the fec redundancy parameters of the receiving end, the receiving and buffering conditions of the media data packet and the redundancy data packet in the receiving end are checked first to determine whether packet loss occurs. If the packet loss event is detected, the receiving end acquires the packet sequence number of the packet to be lost. Thus, the packet loss recovery of the forward error correction decoder is prepared.
Step 140, the receiving end recovers the data packet of the streaming media according to the receiving end adaptive forward error correction redundancy parameter.
In an embodiment of the present invention, the fec decoder at the receiving end calculates the maximum search length according to the fec redundancy parameter adaptive to the fec decoder. Meanwhile, the receiving end inserts the packet serial number of the lost packet into the forward error correction decoder, so that the forward error correction decoder searches in the maximum search range according to the packet serial number of the lost packet, the search amount is reduced, and the recovery efficiency of the lost data packet is improved. And recovering the lost data packets of the streaming media according to the searched redundant data packets.
Specifically, when the redundancy ratio is increased, the redundancy is reduced, and if too many media data packets are currently cached, a part of the media data packets at the head of the cache queue are appropriately discarded, so that the memory can be saved, and the query efficiency of the data packets can be improved. When the forward error correction encoder dynamically adjusts the forward error correction redundancy parameters, the forward error correction decoder can obtain a new redundancy proportion requirement by analyzing a newly received redundant data packet.
Furthermore, different redundancy ratios may occur in the buffered packet queue, i.e. one being the new redundancy ratio and one being the original redundancy ratio. Accordingly, the maximum search length needs to be re-determined when recovering the media data packets. When the new redundancy ratio is greater than the original redundancy ratio, a redundant data packet corresponding to the media data packet may be found, but the maximum search length is increased due to the increase of the redundancy ratio, and further, an erroneous redundant data packet may be found. However, when the new redundancy ratio is smaller than the original redundancy ratio, the maximum search length is decreased due to the decrease of the redundancy ratio, and the redundant data packet corresponding to the media data packet may not be found. If not, abandoning the recovery of the media packet and returning a decoding failure message; if the media data packet can be found, the original redundancy ratio should be adopted to recover the media data packet, so that the correct media data packet can be recovered.
When the redundancy parameters are changed, the data packet recovery of the forward error correction decoder will have a slight disorder condition in a short time, and at this time, in order to maintain compatibility, protection of various abnormal conditions needs to be performed to avoid recovery errors. As the history buffer of the forward error correction decoder is continuously cleared, the data packets corresponding to the original redundancy ratio are all cleared, and the decoder executes according to the new redundancy ratio.
According to the technical scheme of the embodiment, the current network quality data during streaming media transmission is acquired, the forward error correction redundancy parameters of a sending end are dynamically set according to the transmission condition of the streaming media and the current network quality, and the streaming media are subjected to redundancy coding according to the forward error correction redundancy parameters; after receiving the redundant coding corresponding to the streaming media, the receiving end adapts the forward error correction redundant parameters of the receiving end, and finally recovers the lost data packet by the redundant parameters obtained by adaptation. The invention realizes dynamic adjustment of forward error correction redundancy parameters of the sending end according to the current transmission condition of network quality data and streaming media; meanwhile, the receiving end can self-adapt to the redundancy parameters and recover the lost data packet. The network transmission bandwidth and the labor cost are saved, and the timeliness and the user experience of data transmission are improved.
Example two
This embodiment provides a preferred implementation of the forward error correction method for streaming media transmission on the basis of the first embodiment, and can dynamically set the forward error correction redundancy parameter of the sending end. Fig. 2 is a flowchart of a forward error correction method at a transmitting end according to a second embodiment of the present invention, and as shown in fig. 2, the method includes the following specific steps:
step 210, the sending end obtains the current network quality data during streaming media transmission.
In an embodiment of the present invention, the current network quality data may be a current network quality of service QoS, and parameters in the QoS include, but are not limited to: bandwidth, communication delay, delay jitter, packet loss rate, or hop count. The QoS parameters may be fed back by the receiving end or by the network node to the transmitting end.
Step 220, the sending end starts the forward error correction function according to the current network quality data if the current network quality does not meet the transmission requirement of the streaming media.
In the embodiment of the invention, according to the current network quality data, when the transmission condition is not good or the requirement of the receiving end cannot be met, the forward error correction function needs to be started at the moment, so that the transmission quality of the streaming media is improved. Therefore, the repeated opening and closing of the forward error correction function are controlled by dynamically setting the forward error correction redundancy parameters of the transmitting end.
For example, the redundancy level in the fec redundancy parameter may be set to different numbers of levels according to specific situations, and when the redundancy level is set to 0, the fec function may be considered to be turned off; when the redundancy level is set to a positive integer greater than 0, the forward error correction function is turned on. Or, a flag is added in the forward error correction redundancy parameter, and when the flag bit is set to be 0, the forward error correction function can be considered to be closed; when the flag bit is set to 1, it can be regarded as turning on the forward error correction function. The present embodiment does not specifically limit the implementation means of the forward error correction function that is repeatedly turned on and off.
And step 230, the sending end dynamically sets the forward error correction redundancy parameters of the sending end according to the current network quality data and the preset rule.
In the embodiment of the invention, a certain parameter setting rule can be preset according to the requirement of the receiving end and the actual network quality, and the forward error correction redundancy parameter of the sending end is dynamically set according to the corresponding relation between the current network quality data and the preset rule. Therefore, the network quality is better, and when the streaming media transmission effect is better, the redundancy ratio is closed or properly increased, so that the redundancy rate of data transmission is reduced, and the occupation of network bandwidth is saved. When the network quality is poor or the streaming media transmission effect is poor, the redundancy ratio is opened or properly reduced, so that the redundancy rate of data transmission is improved, the data recovery capability is enhanced, and the data transmission effect is improved.
For example, the following two cases are suggested for setting the forward error correction redundancy parameter in audio transmission: the first is to set a layer of redundancy with a redundancy ratio of 2, and the second is to set a layer of redundancy with a redundancy ratio of 5. For setting the redundancy parameters during video data transmission, a preset rule for setting the redundancy parameters can be comprehensively designed according to the occupation condition and the redundancy time of the bandwidth in each scene of live broadcast application.
And step 240, the sending end opens the forward error correction encoder according to the forward error correction redundancy parameter of the sending end.
In the embodiment of the invention, the FEC encoder is opened according to the FEC redundancy parameter of the sending end. For example, the embodiment may set the redundancy level to 0, 1 or 2, and accordingly, the on state of the fec encoder may be controlled according to the redundancy level. When the redundancy level is a positive integer greater than 0, such as 1 or 2, the media data packet needs to be redundantly encoded, and then the fec encoder is turned on according to the redundancy level.
Step 250, the sending end generates a media data packet according to the streaming media, encapsulates the media data packet by using a real-time transmission protocol, and inserts the encapsulated media data packet into the forward error correction encoder, so that the forward error correction encoder performs redundant encoding according to the media data packet to generate a redundant data packet.
In a specific embodiment of the present invention, a forward error correction encoder at a transmitting end is used to implement redundant encoding of a media data packet and generate a corresponding redundant data packet. Specifically, a sending end firstly generates a media data packet according to streaming media, encapsulates the media data packet by using an RTP (real-time transport protocol) protocol, secondly inserts the encapsulated media data packet into a forward error correction encoder for caching, and when a redundancy proportion is reached, the encoder generates a redundant data packet according to the cached data packet and returns the redundant data packet to an upper layer; if the two-layer redundancy is adopted, the media data packet and the one-layer redundancy data packet are inserted into a forward error correction encoder for caching, and when the redundancy proportion is reached, the encoder generates the two-layer redundancy data packet according to the cached data packet, realizes redundancy encoding, and returns the two-layer redundancy data packet to the upper layer. After the redundant data packet is generated, the buffer occupied by the media data packet and the layer of redundant data packet is released immediately. In the embodiment, when the media data packets and the redundant data packets are redundantly encoded, the upper layer can transmit the media data packets and the redundant data packets in any sequence, but the encoder encodes the media data packets and the redundant data packets according to the packet sequence numbers of the data packets, so that the transmission sequence of the upper layer is not limited, and the implementation is more flexible.
For example, assuming that a redundancy level is set as one layer, the redundancy ratio is 5: when performing redundancy coding according to the packet sequence number, the packet sequence number is 1 to 18, wherein the data packet with the packet sequence number 6 is a redundancy data packet of the media data packet with the packet sequence number 1 to 5, similarly, the data packet with the packet sequence number 12 is a redundancy data packet of the media data packet with the packet sequence number 7 to 11, and the data packet with the packet sequence number 18 is a redundancy data packet of the media data packet with the packet sequence number 13 to 17. And assume that the redundancy level is set to two layers, one layer redundancy ratio is 5, and the two layers redundancy ratio is 3: then when performing redundancy coding according to the packet sequence numbers, the packet sequence numbers are 1 to 19, the first layer of redundancy data packets are the same as above, and the data packet with the packet sequence number of 19 is a second layer of redundancy data packet of the first layer of redundancy data packets with the packet sequence numbers of 6, 12 and 18.
And step 260, the sending end encapsulates the redundant data packet by using a real-time transmission protocol.
And 270, the sending end sends the encapsulated media data packet and the encapsulated redundant data packet to the receiving end based on the user datagram protocol.
In the embodiment of the invention, the sending end and the receiving end correspond to each other one by one and are identified by the channel ID. After a sending end generates a media data packet and a redundant data packet of transmitted streaming media, an RTP protocol is utilized to encapsulate the media data packet and the redundant data packet, and the header of each data packet can mark the channel ID of the data packet. Among them, the RTP protocol is a network transport protocol and is widely used in multimedia communication with low delay. And finally, the sending end sends the encapsulated media data packet and the encapsulated redundant data packet to the receiving end based on a UDP protocol.
According to the technical scheme of the embodiment, under the condition that the streaming media transmission condition cannot meet the requirement of a receiving party, a forward error correction function is started; the method comprises the steps of dynamically setting forward error correction redundancy parameters of a sending end according to preset rules by acquiring current network quality data during streaming media transmission and according to the transmission condition of the streaming media and the current network quality data, further opening a forward error correction encoder, and carrying out redundancy encoding, packaging and sending on the streaming media according to the forward error correction redundancy parameters. The invention realizes dynamic adjustment of the forward error correction redundancy parameter of the sending end according to the current transmission condition of the network quality data and the streaming media, thereby saving the network transmission bandwidth and improving the timeliness and the user experience of data transmission.
EXAMPLE III
This embodiment provides a preferred implementation of the forward error correction method for streaming media transmission on the basis of the first embodiment, and can adaptively adjust the forward error correction redundancy parameter of the receiving end according to the forward error correction redundancy parameter dynamically set by the transmitting end. Fig. 3 is a flowchart of a forward error correction method in a receiving end according to a third embodiment of the present invention, and as shown in fig. 3, the method includes the following specific steps:
step 310, the receiving end starts the forward error correction decoder.
Step 320, the receiving end inserts the media data packet and the redundant data packet into the forward error correction decoder, so that the forward error correction decoder dynamically adjusts the forward error correction redundancy parameter of the forward error correction decoder according to the media data packet and the redundant data packet.
In the embodiment of the invention, after the receiving end starts the forward error correction decoder, the receiving end inserts the media data packet corresponding to the streaming media and the redundant data packet after redundant coding into the forward error correction decoder, and then the forward error correction decoder obtains and dynamically adjusts the forward error correction redundant parameter from the inserted data packet, so that the forward error correction redundant parameter in the forward error correction decoder is adaptive to be matched with the forward error correction redundant parameter dynamically adjusted by the sending end.
In this embodiment, to implement the fec decoding function, the receiving end needs to insert the received media data packet and the redundant data packet into the fec decoder, and buffer a certain number of media data packets and redundant data packets in the decoder, including the received first layer redundant data packet and the second layer redundant data packet. Considering that forward error correction decoding mainly processes real-time conditions, only recently received media data packets and redundant data packets are cached, and the number of reserved data packets can be neither too many nor too few; if too much, the memory is wasted and the query efficiency is affected, and if too little is saved, the success rate of forward error correction decoding may be affected. In order to facilitate the query according to the packet sequence number, the present embodiment uses the Map table with the packet sequence number as the primary key to cache a certain number of media data packets and redundant data packets.
Accordingly, a certain range of data is also cleared and released after decoding by the decoder. The present embodiment may also set the maximum time length to implement the cache removal, that is, when the time for caching the packet is longer than the maximum time length, the cache removal is performed. The time range of the time length from inserting data to starting playing is usually between 400ms and 2200ms, the delay is large when the buffering time is long, and the continuity is better when the network condition is worse; otherwise, the buffering time is short, the delay is small, but the frequency of the jamming is higher when the network condition is slightly poor, and the embodiment supports the dynamic adjustment of the buffering time. The method for clearing the cache data by using the maximum time length has the advantages that the time length of the cache packet can be ensured to reach the maximum time length, the phenomenon of too short cache time can not occur, and the decoding requirement of a forward error correction decoder is met. And when the buffering time length is far longer than the maximum time length, the practical significance is not provided, the delay is too large, and the cost for solving the packet loss problem by adopting backward error correction is lower when the timeliness is not considered. It is noted that when the forward error correction decoder buffer is cleared, no check is performed when the buffer data list holds less than 20 data objects. The inspection frequency is in units of time, with intervals of 500ms each.
Step 330, the receiving end checks the receiving and buffering conditions of the media data packet and the redundant data packet in the receiving end; and if the media data packet and/or the redundant data packet are/is detected to be lost, acquiring a packet sequence number of the lost packet.
In the embodiment of the invention, before the receiving end recovers the data packet of the streaming media according to the forward error correction redundancy parameter of the receiving end, the receiving and buffering conditions of the media data packet and the redundancy data packet in the receiving end are firstly checked, and whether the packet loss occurs or not is judged. If the packet loss is detected, the receiving end acquires the packet sequence number of the packet loss.
Specifically, since the encoder performs redundancy coding according to the packet sequence number of each data packet, the receiving end can sequentially search whether there is a lost data packet after receiving the redundancy coding. If no loss exists, operations such as packet loss compensation and the like do not need to be executed; if the packet loss condition exists, determining the packet sequence number of the lost packet, searching a redundant data packet corresponding to the packet of the lost packet backwards within a certain range according to the redundant coding rule, and trying to decode to recover the lost data packet.
Step 340, the fec decoder at the receiving end calculates the maximum search length according to the fec redundancy parameter adaptive to the fec decoder.
In the embodiment of the present invention, when the recovery of the missing data packet is performed to the error correction decoder, the search needs to be performed within a certain range, and there are generally two ways, one is to search all the buffered data packets, and the other is to search only the necessary range. Obviously, by adopting the second mode, the necessary maximum search length is determined, the search amount can be reduced, and the efficiency is improved. Based on the redundancy levels obtained by the receiving end in a self-adaptive manner and the redundancy proportion of each level, the maximum search length can be calculated. Assuming that the redundancy ratio of one layer is n and the redundancy ratio of the two layers is m, when only one layer of redundancy level is set, the maximum search length is n; when two levels of redundancy are set, the maximum search length is (n +1) × m.
Step 350, the receiving end inserts the packet sequence number of the lost packet into the fec decoder, so that the fec decoder recovers the lost data packet of the streaming media according to the maximum search length.
In an embodiment of the present invention, the forward error correction decoder recovers the lost data packet according to the maximum search length. For example, assume that the redundancy ratio of the first layer is 5, the redundancy ratio of the second layer is 3, and the packet sequence number of the packet to be dropped is 2. When only one layer of redundancy level is set, the maximum search length is 5, that is, within the search length of 5 data packets after the packet sequence number of the lost packet, the corresponding redundant data packet 6 can be searched; when two layers of redundancy levels are set, the maximum search length is 18, that is, the corresponding one-layer redundancy data packet 6 and/or two-layer redundancy data packet 19 can be found within the search length of 18 data after the packet sequence number of the lost packet. Finally, the searched redundant data packets are used for decoding the data packets lost by the streaming media, namely the media data packets containing the RTP protocol encapsulation.
In the technical scheme of the embodiment, after receiving a redundant code corresponding to a streaming media, a receiving end inserts a media data packet and a redundant data packet corresponding to the streaming media into a forward error correction decoder, and the forward error correction decoder adaptively adjusts a forward error correction redundant parameter of the forward error correction decoder according to the inserted data packet; when the media data packet and/or the redundant data packet corresponding to the streaming media are/is detected to be lost, the packet sequence number of the lost packet is obtained; finally, the forward error correction decoder determines the maximum search length according to the adaptive redundancy parameters, and recovers the lost data packet within the maximum search length according to the inserted packet sequence number of the lost packet. The invention realizes the self-adaptive adjustment of the forward error correction redundant parameters and the recovery of the lost data packet by the forward error correction decoder by configuring the forward error correction decoder to the receiving end. The network transmission bandwidth and the labor cost are saved, and the timeliness and the user experience of data transmission are improved.
Example four
Fig. 4 is a schematic structural diagram of a forward error correction system for streaming media transmission according to a fourth embodiment of the present invention, where this embodiment is applicable to data recovery during streaming media transmission, and the apparatus can implement the forward error correction method for streaming media transmission according to any embodiment of the present invention. The system specifically comprises: a transmitting end 410 and a receiving end 420, wherein,
the sending end 410 is configured to perform the following operations: acquiring current network quality data during streaming media transmission; dynamically setting forward error correction redundancy parameters of the sending end according to the current network quality data and preset rules, and carrying out redundancy coding on the streaming media according to the forward error correction redundancy parameters of the sending end;
the receiving end 420 is configured to perform the following operations: receiving the redundant code and dynamically adjusting the forward error correction redundancy parameter of the receiving end according to the redundant code; and recovering the data packet of the streaming media according to the self-adaptive forward error correction redundancy parameter of the receiving end.
Further, the transmitting end 410 is configured to:
after the sending end 410 obtains the current network quality data during streaming media transmission, according to the current network quality data, if the current network quality does not meet the transmission requirement of the streaming media, a forward error correction function is started.
Further, the transmitting end 410 is further configured to:
turning on a forward error correction encoder 4101 according to the forward error correction redundancy parameter of the transmitting end 410;
a media data packet is generated according to the streaming media, and the media data packet is inserted into the forward error correction encoder 4101, so that the forward error correction encoder 4101 performs redundancy encoding according to the media data packet to generate a redundancy data packet.
Further, the transmitting end 410 is further configured to:
after the transmitting end 410 performs redundancy coding on the streaming media according to the forward error correction redundancy parameter of the transmitting end 410, the media data packet and the redundancy data packet are encapsulated by using a real-time transmission protocol;
and sending the encapsulated media data packet and the encapsulated redundant data packet to the receiving end 420 based on a user datagram protocol.
Further, the receiving end 420 is configured to:
turn on forward error correction decoder 4201;
the media data packet and the redundancy data packet are inserted into the forward error correction decoder 4201, so that the forward error correction decoder 4201 dynamically adjusts the forward error correction redundancy parameter of the forward error correction decoder 4201 according to the media data packet and the redundancy data packet.
Further, the receiving end 420 is configured to:
before the receiving end 420 recovers the data packet of the streaming media according to the fec redundancy parameter of the receiving end 420, checking the receiving and buffering conditions of the media data packet and the redundancy data packet in the receiving end 420;
and if the media data packet and/or the redundant data packet are/is detected to be lost, acquiring a packet sequence number of the lost packet.
Further, the receiving end 420 is configured to:
after inserting the media data packet and the redundancy data packet into the forward error correction decoder 4201, so that the forward error correction decoder 4201 calculates a maximum search length according to forward error correction redundancy parameters adapted by the forward error correction decoder 4201;
inserting the packet sequence number of the lost packet into the forward error correction decoder 4201, so that the forward error correction decoder 4201 recovers the lost data packet of the streaming media according to the maximum search length.
According to the technical scheme of the embodiment, the current network quality data during streaming media transmission is obtained through a sending end, the forward error correction redundancy parameters of the sending end are dynamically set according to the transmission condition of the streaming media and the current network quality data, and the streaming media is subjected to redundancy coding according to the forward error correction redundancy parameters; after receiving the redundant coding corresponding to the streaming media, the receiving end adapts the forward error correction redundant parameters of the receiving end, and finally recovers the lost data packet by the redundant parameters obtained by adaptation. The invention realizes dynamic adjustment of forward error correction redundancy parameters of the sending end according to the current transmission condition of network quality data and streaming media; meanwhile, the receiving end can self-adapt to the redundancy parameters and recover the lost data packet. The network transmission bandwidth and the labor cost are saved, and the timeliness and the user experience of data transmission are improved.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.