diff --git a/trunk/src/app/srs_app_recv_thread.cpp b/trunk/src/app/srs_app_recv_thread.cpp index 16ef3bc1e..30939194b 100644 --- a/trunk/src/app/srs_app_recv_thread.cpp +++ b/trunk/src/app/srs_app_recv_thread.cpp @@ -37,14 +37,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define SRS_MR_AVERAGE_BITRATE_KBPS 1000 #define SRS_MR_MIN_BITRATE_KBPS 32 // the max sleep time in ms -#define SRS_MR_MAX_SLEEP_MS 3000 +#define SRS_MR_MAX_SLEEP_MS 2500 // the max small bytes to group -#define SRS_MR_SMALL_BYTES 64 +#define SRS_MR_SMALL_BYTES 4096 // the percent of buffer to set as small bytes #define SRS_MR_SMALL_PERCENT 100 -// set the socket buffer to specified KB. -// the underlayer api will set to 2*SRS_MR_SOCKET_BUFFER KB. -#define SRS_MR_SOCKET_BUFFER 32 +// set the socket buffer to specified bytes. +// the underlayer api will set to SRS_MR_SOCKET_BUFFER bytes. +#define SRS_MR_SOCKET_BUFFER SOCKET_READ_SIZE ISrsMessageHandler::ISrsMessageHandler() { @@ -299,15 +299,15 @@ void SrsPublishRecvThread::on_thread_start() // we donot set the auto response to false, // for the main thread never send message. - // socket recv buffer. - int nb_rbuf = SRS_MR_SOCKET_BUFFER * 1024; + // socket recv buffer, system will double it. + int nb_rbuf = SRS_MR_SOCKET_BUFFER / 2; socklen_t sock_buf_size = sizeof(int); if (setsockopt(mr_fd, SOL_SOCKET, SO_RCVBUF, &nb_rbuf, sock_buf_size) < 0) { srs_warn("set sock SO_RCVBUF=%d failed.", nb_rbuf); } getsockopt(mr_fd, SOL_SOCKET, SO_RCVBUF, &nb_rbuf, &sock_buf_size); - srs_trace("set socket buffer to %d, actual %d KB", SRS_MR_SOCKET_BUFFER, nb_rbuf / 1024); + srs_trace("set socket buffer to %d, actual %d KB", SRS_MR_SOCKET_BUFFER / 1024, nb_rbuf / 1024); // enable the merge read // @see https://github.com/winlinvip/simple-rtmp-server/issues/241 @@ -381,7 +381,7 @@ void SrsPublishRecvThread::on_buffer_change(int nb_buffer) // set percent. mr_small_bytes = (int)(nb_buffer / SRS_MR_SMALL_PERCENT); // select the smaller - mr_small_bytes = srs_min(mr_small_bytes, SRS_MR_SMALL_BYTES); + mr_small_bytes = srs_max(mr_small_bytes, SRS_MR_SMALL_BYTES); // the recv sleep is [buffer / max_kbps, buffer / min_kbps] // for example, buffer is 256KB, max kbps is 10Mbps, min kbps is 10Kbps, diff --git a/trunk/src/qt/srs/srs-qt.pro.user b/trunk/src/qt/srs/srs-qt.pro.user old mode 100644 new mode 100755 diff --git a/trunk/src/rtmp/srs_protocol_buffer.cpp b/trunk/src/rtmp/srs_protocol_buffer.cpp index da0b1e639..68122c24a 100644 --- a/trunk/src/rtmp/srs_protocol_buffer.cpp +++ b/trunk/src/rtmp/srs_protocol_buffer.cpp @@ -27,16 +27,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include -// 4KB=4096 -// 8KB=8192 -// 16KB=16384 -// 32KB=32768 -// 64KB=65536 -// @see https://github.com/winlinvip/simple-rtmp-server/issues/241 -#define SOCKET_READ_SIZE 65536 -// the max buffer for user space socket buffer. -#define SOCKET_MAX_BUF 65536 - IMergeReadHandler::IMergeReadHandler() { } diff --git a/trunk/src/rtmp/srs_protocol_buffer.hpp b/trunk/src/rtmp/srs_protocol_buffer.hpp index be087f3da..7ef91299f 100644 --- a/trunk/src/rtmp/srs_protocol_buffer.hpp +++ b/trunk/src/rtmp/srs_protocol_buffer.hpp @@ -34,6 +34,16 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include +// 4KB=4096 +// 8KB=8192 +// 16KB=16384 +// 32KB=32768 +// 64KB=65536 +// @see https://github.com/winlinvip/simple-rtmp-server/issues/241 +#define SOCKET_READ_SIZE 65536 +// the max buffer for user space socket buffer. +#define SOCKET_MAX_BUF SOCKET_READ_SIZE + /** * to improve read performance, merge some packets then read, * when it on and read small bytes, we sleep to wait more data.,