Skip to content

Commit

Permalink
For #307, padding to next packet or GSO size
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Apr 15, 2020
1 parent bbdd2d7 commit c95a851
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions trunk/src/app/srs_app_rtc_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,15 +882,25 @@ srs_error_t SrsRtcSenderThread::send_packets_gso(SrsUdpMuxSocket* skt, SrsRtcPac
nn_next_packet = next_packet? next_packet->nb_bytes() : 0;
}

// Padding the first packet if size is similar to the next one.
if (i == 0 && max_padding > 0 && next_packet && nn_packet < nn_next_packet && nn_next_packet - nn_packet < max_padding) {
// Padding the packet to next or GSO size.
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)
srs_trace("Padding %d bytes %d=>%d, packets %d, max_padding %d", nn_next_packet - nn_packet,
nn_packet, nn_next_packet, nn_packets, max_padding);
srs_trace("Padding %d bytes %d=>%d, packets %d, max_padding %d", padding, nn_packet + padding,
nn_next_packet, nn_packets, max_padding);
#endif
packet->set_padding(nn_next_packet - nn_packet);
nn_packet = nn_next_packet;
packets.nn_paddings++;
packet->set_padding(padding);
nn_packet += padding;
packets.nn_paddings++;
}
}

// Check whether we can use GSO to send it.
Expand Down

1 comment on commit c95a851

@winlinvip
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Padding到GSO size,或者下一个包的size,比如:

257 256 257

会将中间的256,padding 1到257。

Please sign in to comment.