From ab53c34945a1b9f00d236a761339ab03a7992486 Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 15 Apr 2020 10:44:26 +0800 Subject: [PATCH] For #307: Change the RTP payload to 1400 --- trunk/src/app/srs_app_rtc_conn.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/trunk/src/app/srs_app_rtc_conn.cpp b/trunk/src/app/srs_app_rtc_conn.cpp index a01e6305c..973270204 100644 --- a/trunk/src/app/srs_app_rtc_conn.cpp +++ b/trunk/src/app/srs_app_rtc_conn.cpp @@ -60,6 +60,12 @@ using namespace std; #include #include +// The RTP payload max size, reserved some paddings for SRTP as such: +// kRtpPacketSize = kRtpMaxPayloadSize + paddings +// For example, if kRtpPacketSize is 1500, recommend to set kRtpMaxPayloadSize to 1400, +// which reserves 100 bytes for SRTP or paddings. +const int kRtpMaxPayloadSize = kRtpPacketSize - 100; + static bool is_stun(const uint8_t* data, const int size) { return data != NULL && size > 0 && (data[0] == 0 || data[0] == 1); @@ -767,7 +773,6 @@ srs_error_t SrsRtcSenderThread::messages_to_packets( continue; } - const int kRtpMaxPayloadSize = 1200; if (sample->size <= kRtpMaxPayloadSize) { if ((err = packet_single_nalu(msg, sample, &packet)) != srs_success) { return srs_error_wrap(err, "packet single nalu"); @@ -1052,7 +1057,6 @@ srs_error_t SrsRtcSenderThread::packet_nalus(SrsSharedPtrMessage* msg, SrsRtcPac return err; } - const int kRtpMaxPayloadSize = 1200; if (nn_bytes < kRtpMaxPayloadSize) { // Package NALUs in a single RTP packet. SrsRtpPacket2* packet = new SrsRtpPacket2();