mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine code for bug #194, add comments to macros.
This commit is contained in:
parent
cc6aca9ad5
commit
4af2e78c59
5 changed files with 34 additions and 8 deletions
|
@ -69,9 +69,6 @@ using namespace std;
|
||||||
// when edge timeout, retry next.
|
// when edge timeout, retry next.
|
||||||
#define SRS_EDGE_TOKEN_TRAVERSE_TIMEOUT_US (int64_t)(3*1000*1000LL)
|
#define SRS_EDGE_TOKEN_TRAVERSE_TIMEOUT_US (int64_t)(3*1000*1000LL)
|
||||||
|
|
||||||
// to get msgs then totally send out.
|
|
||||||
#define SYS_MAX_PLAY_SEND_MSGS 128
|
|
||||||
|
|
||||||
SrsRtmpConn::SrsRtmpConn(SrsServer* srs_server, st_netfd_t client_stfd)
|
SrsRtmpConn::SrsRtmpConn(SrsServer* srs_server, st_netfd_t client_stfd)
|
||||||
: SrsConnection(srs_server, client_stfd)
|
: SrsConnection(srs_server, client_stfd)
|
||||||
{
|
{
|
||||||
|
@ -520,7 +517,7 @@ int SrsRtmpConn::playing(SrsSource* source)
|
||||||
|
|
||||||
// initialize other components
|
// initialize other components
|
||||||
SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_PLAY_USER);
|
SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_PLAY_USER);
|
||||||
SrsSharedPtrMessageArray msgs(SYS_MAX_PLAY_SEND_MSGS);
|
SrsSharedPtrMessageArray msgs(SYS_CONSTS_MAX_PLAY_SEND_MSGS);
|
||||||
bool user_specified_duration_to_stop = (req->duration > 0);
|
bool user_specified_duration_to_stop = (req->duration > 0);
|
||||||
int64_t starttime = -1;
|
int64_t starttime = -1;
|
||||||
|
|
||||||
|
|
|
@ -50,12 +50,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
#define SERVER_LISTEN_BACKLOG 512
|
#define SERVER_LISTEN_BACKLOG 512
|
||||||
|
|
||||||
// system interval
|
// system interval in ms,
|
||||||
// all resolution times should be times togother,
|
// all resolution times should be times togother,
|
||||||
// for example, system-time is 3(300ms),
|
// for example, system-time is 3(300ms),
|
||||||
// then rusage can be 3*x, for instance, 3*10=30(3s),
|
// then rusage can be 3*x, for instance, 3*10=30(3s),
|
||||||
// the meminfo canbe 30*x, for instance, 30*2=60(6s)
|
// the meminfo canbe 30*x, for instance, 30*2=60(6s)
|
||||||
// for performance refine, @see: https://github.com/winlinvip/simple-rtmp-server/issues/194
|
// for performance refine, @see: https://github.com/winlinvip/simple-rtmp-server/issues/194
|
||||||
|
// @remark, recomment to 1000ms.
|
||||||
#define SRS_SYS_CYCLE_INTERVAL 1000
|
#define SRS_SYS_CYCLE_INTERVAL 1000
|
||||||
|
|
||||||
// update time interval:
|
// update time interval:
|
||||||
|
|
|
@ -216,7 +216,7 @@ int SrsMessageQueue::dump_packets(int max_count, SrsSharedPtrMessage** pmsgs, in
|
||||||
} else {
|
} else {
|
||||||
// erase some vector elements may cause memory copy,
|
// erase some vector elements may cause memory copy,
|
||||||
// maybe can use more efficient vector.swap to avoid copy.
|
// maybe can use more efficient vector.swap to avoid copy.
|
||||||
// @remark for the pmsgs is big enough, for instance, SYS_MAX_PLAY_SEND_MSGS 128,
|
// @remark for the pmsgs is big enough, for instance, SYS_CONSTS_MAX_PLAY_SEND_MSGS 128,
|
||||||
// the rtmp play client will get 128msgs once, so this branch rarely execute.
|
// the rtmp play client will get 128msgs once, so this branch rarely execute.
|
||||||
msgs.erase(msgs.begin(), msgs.begin() + count);
|
msgs.erase(msgs.begin(), msgs.begin() + count);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// the timeout to wait for client control message,
|
// the timeout to wait for client control message,
|
||||||
// if timeout, we generally ignore and send the data to client,
|
// if timeout, we generally ignore and send the data to client,
|
||||||
// generally, it's the pulse time for data seding.
|
// generally, it's the pulse time for data seding.
|
||||||
|
// @remark, recomment to 500ms.
|
||||||
#define SRS_CONSTS_RTMP_PULSE_TIMEOUT_US (int64_t)(500*1000LL)
|
#define SRS_CONSTS_RTMP_PULSE_TIMEOUT_US (int64_t)(500*1000LL)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,18 +98,42 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
// always use fmt0 as cache.
|
// always use fmt0 as cache.
|
||||||
//#define SRS_CONSTS_RTMP_MAX_FMT3_HEADER_SIZE 5
|
//#define SRS_CONSTS_RTMP_MAX_FMT3_HEADER_SIZE 5
|
||||||
|
|
||||||
|
/**
|
||||||
|
* how many msgs can be send entirely.
|
||||||
|
* for play clients to get msgs then totally send out.
|
||||||
|
* for example, 25fps video, 40ms per video packet,
|
||||||
|
* while audio is 20ms per audio packet where 2/3 is audios,
|
||||||
|
* when SYS_CONSTS_MAX_PLAY_SEND_MSGS is 128, then
|
||||||
|
* we will send all 128*40ms/3=1706ms packets in a time,
|
||||||
|
* which should greater than the SRS_CONSTS_RTMP_PULSE_TIMEOUT_US
|
||||||
|
* (for example, 500ms), that is, we should:
|
||||||
|
* SYS_CONSTS_MAX_PLAY_SEND_MSGS * 40 / 3 >= SRS_CONSTS_RTMP_PULSE_TIMEOUT_US
|
||||||
|
* @remark, recomment to 128.
|
||||||
|
*/
|
||||||
|
#define SYS_CONSTS_MAX_PLAY_SEND_MSGS 128
|
||||||
/**
|
/**
|
||||||
* for performance issue,
|
* for performance issue,
|
||||||
* the iovs cache, @see https://github.com/winlinvip/simple-rtmp-server/issues/194
|
* the iovs cache, @see https://github.com/winlinvip/simple-rtmp-server/issues/194
|
||||||
* iovs cache for multiple messages for each connections.
|
* iovs cache for multiple messages for each connections.
|
||||||
|
* each iovc is 16bytes, sizeof(iovec)=16, suppose the chunk size is 64k,
|
||||||
|
* each message send in a chunk which needs only 2 iovec,
|
||||||
|
* so the iovs max should be (SYS_CONSTS_MAX_PLAY_SEND_MSGS * 16 * 2)
|
||||||
|
*
|
||||||
|
* @remark, SRS will realloc when the iovs not enough.
|
||||||
*/
|
*/
|
||||||
#define SRS_CONSTS_IOVS_MAX 1024
|
#define SRS_CONSTS_IOVS_MAX (SYS_CONSTS_MAX_PLAY_SEND_MSGS * 32)
|
||||||
/**
|
/**
|
||||||
* for performance issue,
|
* for performance issue,
|
||||||
* the c0c3 cache, @see https://github.com/winlinvip/simple-rtmp-server/issues/194
|
* the c0c3 cache, @see https://github.com/winlinvip/simple-rtmp-server/issues/194
|
||||||
* c0c3 cache for multiple messages for each connections.
|
* c0c3 cache for multiple messages for each connections.
|
||||||
|
* each c0 <= 16byes, suppose the chunk size is 64k,
|
||||||
|
* each message send in a chunk which needs only a c0 header,
|
||||||
|
* so the c0c3 cache should be (SYS_CONSTS_MAX_PLAY_SEND_MSGS * 16)
|
||||||
|
*
|
||||||
|
* @remark, SRS will try another loop when c0c3 cache dry, for we cannot realloc it.
|
||||||
|
* so we use larger c0c3 cache, that is (SYS_CONSTS_MAX_PLAY_SEND_MSGS * 32)
|
||||||
*/
|
*/
|
||||||
#define SRS_CONSTS_C0C3_HEADERS_MAX 4096
|
#define SRS_CONSTS_C0C3_HEADERS_MAX (SYS_CONSTS_MAX_PLAY_SEND_MSGS * 32)
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
///////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -374,6 +374,9 @@ public:
|
||||||
* @param msgs, the msgs to send out, never be NULL.
|
* @param msgs, the msgs to send out, never be NULL.
|
||||||
* @param nb_msgs, the size of msgs to send out.
|
* @param nb_msgs, the size of msgs to send out.
|
||||||
* @param stream_id, the stream id of packet to send over, 0 for control message.
|
* @param stream_id, the stream id of packet to send over, 0 for control message.
|
||||||
|
*
|
||||||
|
* @remark performance issue, to support 6k+ 250kbps client,
|
||||||
|
* @see https://github.com/winlinvip/simple-rtmp-server/issues/194
|
||||||
*/
|
*/
|
||||||
virtual int send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs, int stream_id);
|
virtual int send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs, int stream_id);
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue