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

add performance header to control options for performance. 2.0.50

This commit is contained in:
winlin 2014-12-04 13:43:55 +08:00
parent fd5ef89030
commit 60bc9c2aa0
15 changed files with 167 additions and 25 deletions

View file

@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR 2
#define VERSION_MINOR 0
#define VERSION_REVISION 49
#define VERSION_REVISION 50
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
#define RTMP_SIG_SRS_ROLE "origin/edge server"

View file

@ -0,0 +1,25 @@
/*
The MIT License (MIT)
Copyright (c) 2013-2014 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_core_performance.hpp>

View file

@ -0,0 +1,71 @@
/*
The MIT License (MIT)
Copyright (c) 2013-2014 winlin
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef SRS_CORE_PERFORMANCE_HPP
#define SRS_CORE_PERFORMANCE_HPP
/*
#include <srs_core_performance.hpp>
*/
#include <srs_core.hpp>
/**
* this file defines the perfromance options.
*/
/**
* to improve read performance, merge some packets then read,
* when it on and read small bytes, we sleep to wait more data.,
* that is, we merge some data to read together.
* @see https://github.com/winlinvip/simple-rtmp-server/issues/241
* @remark other macros:
* SOCKET_MAX_BUF, the max size of user-space buffer.
* SOCKET_READ_SIZE, the user space buffer for socket.
* SRS_MR_MAX_BITRATE_KBPS, the kbps of stream for system to guess the sleep time.
* SRS_MR_AVERAGE_BITRATE_KBPS, the average kbps of system.
* SRS_MR_MIN_BITRATE_KBPS, the min kbps of system.
* SRS_MR_MAX_SLEEP_MS, the max sleep time, the latency+ when sleep+.
* SRS_MR_SMALL_BYTES, sleep when got small bytes, the latency+ when small+.
* SRS_MR_SMALL_PERCENT, to calc the small bytes = SRS_MR_SOCKET_BUFFER/percent.
* SRS_MR_SOCKET_BUFFER, the socket buffer to set fd.
* @remark the actual socket buffer used to set the buffer user-space size.
* buffer = min(SOCKET_MAX_BUF, SRS_MR_SOCKET_BUFFER, SOCKET_READ_SIZE)
* small bytes = max(buffer/SRS_MR_SMALL_PERCENT, SRS_MR_SMALL_BYTES)
* sleep = calc the sleep by kbps and buffer.
* @remark the main merged-read algorithm:
* while true:
* nread = read from socket.
* sleep if nread < small bytes
* process bytes.
* @example, for the default settings, this algorithm will use:
* socket buffer set to 64KB,
* user space buffer set to 64KB,
* buffer=65536B, small=4096B, sleep=780ms
* that is, when got nread bytes smaller than 4KB, sleep(780ms).
*/
#define SRS_PERF_MERGED_READ
#undef SRS_PERF_MERGED_READ
#endif