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

For #307, padding to next packet or GSO size

This commit is contained in:
winlin 2020-04-15 17:48:52 +08:00
parent bbdd2d7eed
commit c95a8517e7

View file

@ -882,15 +882,25 @@ srs_error_t SrsRtcSenderThread::send_packets_gso(SrsUdpMuxSocket* skt, SrsRtcPac
nn_next_packet = next_packet? next_packet->nb_bytes() : 0; nn_next_packet = next_packet? next_packet->nb_bytes() : 0;
} }
// Padding the first packet if size is similar to the next one. // Padding the packet to next or GSO size.
if (i == 0 && max_padding > 0 && next_packet && nn_packet < nn_next_packet && nn_next_packet - nn_packet < max_padding) { if (max_padding > 0 && next_packet) {
// Padding to the next packet to merge with it.
int padding = nn_next_packet - nn_packet;
// If the next one could merge to this GSO stage, padding current to GSO size.
if (use_gso && nn_next_packet < gso_size) {
padding = gso_size - nn_packet;
}
if (padding > 0 && padding < max_padding) {
#if defined(SRS_DEBUG) #if defined(SRS_DEBUG)
srs_trace("Padding %d bytes %d=>%d, packets %d, max_padding %d", nn_next_packet - nn_packet, srs_trace("Padding %d bytes %d=>%d, packets %d, max_padding %d", padding, nn_packet + padding,
nn_packet, nn_next_packet, nn_packets, max_padding); nn_next_packet, nn_packets, max_padding);
#endif #endif
packet->set_padding(nn_next_packet - nn_packet); packet->set_padding(padding);
nn_packet = nn_next_packet; nn_packet += padding;
packets.nn_paddings++; packets.nn_paddings++;
}
} }
// Check whether we can use GSO to send it. // Check whether we can use GSO to send it.