1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #307, refine GSO padding algorithm

This commit is contained in:
winlin 2020-04-16 11:57:11 +08:00
parent 34fec09bc0
commit 92419f9836

View file

@ -952,20 +952,24 @@ srs_error_t SrsRtcSenderThread::send_packets_gso(SrsUdpMuxSocket* skt, SrsRtcPac
// Padding the packet to next or GSO size. // Padding the packet to next or GSO size.
if (max_padding > 0 && next_packet) { if (max_padding > 0 && next_packet) {
// Padding to the next packet to merge with it. if (!use_gso) {
padding = nn_next_packet - nn_packet; // Padding to the next packet to merge with it.
if (nn_next_packet > nn_packet) {
if (use_gso) { padding = nn_next_packet - nn_packet;
// If the next one could merge to this GSO stage, padding current to GSO size. }
} else {
// Padding to GSO size for next one to merge with us.
if (nn_next_packet < gso_size) { if (nn_next_packet < gso_size) {
padding = gso_size - nn_packet; padding = gso_size - nn_packet;
} else {
// If the next one could not merge to this GSO stage, never padding.
padding = 0;
} }
} }
if (padding > 0 && padding < max_padding) { // Reset padding if exceed max.
if (padding > max_padding) {
padding = 0;
}
if (padding > 0) {
#if defined(SRS_DEBUG) #if defined(SRS_DEBUG)
srs_trace("#%d, Padding %d bytes %d=>%d, packets %d, max_padding %d", packets.debug_id, srs_trace("#%d, Padding %d bytes %d=>%d, packets %d, max_padding %d", packets.debug_id,
padding, nn_packet, nn_packet + padding, nn_packets, max_padding); padding, nn_packet, nn_packet + padding, nn_packets, max_padding);