1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-15 04:42:04 +00:00

Merge branch '4.0release' into merge/develop

This commit is contained in:
winlin 2021-10-07 21:07:08 +08:00
commit f8360781d3
3 changed files with 13 additions and 5 deletions

View file

@ -264,7 +264,7 @@ srs_error_t SrsBandwidth::play_checking(SrsBandwidthSample* sample, SrsKbpsLimit
limit->send_limit();
}
srs_update_system_time();
sample->calc_kbps((int)_rtmp->get_send_bytes(), srsu2msi(srs_get_system_time() - starttime));
sample->calc_kbps((int)_rtmp->get_send_bytes(), srs_get_system_time() - starttime);
return err;
}
@ -342,7 +342,7 @@ srs_error_t SrsBandwidth::publish_checking(SrsBandwidthSample* sample, SrsKbpsLi
limit->recv_limit();
}
srs_update_system_time();
sample->calc_kbps((int)_rtmp->get_recv_bytes(), srsu2msi(srs_get_system_time() - starttime));
sample->calc_kbps((int)_rtmp->get_recv_bytes(), srs_get_system_time() - starttime);
return err;
}

View file

@ -25,6 +25,10 @@ using namespace std;
#include <openssl/ssl.h>
#include <openssl/err.h>
// to avoid dtls negotiate failed, set max fragment size 1200.
// @see https://github.com/ossrs/srs/issues/2415
const int DTLS_FRAGMENT_MAX_SIZE = 1200;
// Defined in HTTP/HTTPS client.
extern int srs_verify_callback(int preverify_ok, X509_STORE_CTX *ctx);
@ -439,7 +443,7 @@ srs_error_t SrsDtlsImpl::initialize(std::string version, std::string role)
// set dtls fragment
// @see https://stackoverflow.com/questions/62413602/openssl-server-packets-get-fragmented-into-270-bytes-per-packet
SSL_set_options(dtls, SSL_OP_NO_QUERY_MTU);
SSL_set_mtu(dtls, kRtpPacketSize);
SSL_set_mtu(dtls, DTLS_FRAGMENT_MAX_SIZE);
// @see https://linux.die.net/man/3/openssl_version_number
// MM NN FF PP S
@ -699,7 +703,7 @@ srs_error_t SrsDtlsClientImpl::initialize(std::string version, std::string role)
// Dtls setup active, as client role.
SSL_set_connect_state(dtls);
SSL_set_max_send_fragment(dtls, kRtpPacketSize);
SSL_set_max_send_fragment(dtls, DTLS_FRAGMENT_MAX_SIZE);
return err;
}

View file

@ -64,7 +64,11 @@ const int kVideoSamplerate = 90000;
// 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 - 200;
// otherwise, the kRtpPacketSize must less than MTU, in webrtc source code,
// the rtp max size is assigned by kVideoMtu = 1200.
// so we set kRtpMaxPayloadSize = 1200.
// see @doc https://groups.google.com/g/discuss-webrtc/c/gH5ysR3SoZI
const int kRtpMaxPayloadSize = kRtpPacketSize - 300;
using namespace std;