正在显示
5 个修改的文件
包含
34 行增加
和
8 行删除
@@ -69,9 +69,6 @@ using namespace std; | @@ -69,9 +69,6 @@ using namespace std; | ||
69 | // when edge timeout, retry next. | 69 | // when edge timeout, retry next. |
70 | #define SRS_EDGE_TOKEN_TRAVERSE_TIMEOUT_US (int64_t)(3*1000*1000LL) | 70 | #define SRS_EDGE_TOKEN_TRAVERSE_TIMEOUT_US (int64_t)(3*1000*1000LL) |
71 | 71 | ||
72 | -// to get msgs then totally send out. | ||
73 | -#define SYS_MAX_PLAY_SEND_MSGS 128 | ||
74 | - | ||
75 | SrsRtmpConn::SrsRtmpConn(SrsServer* srs_server, st_netfd_t client_stfd) | 72 | SrsRtmpConn::SrsRtmpConn(SrsServer* srs_server, st_netfd_t client_stfd) |
76 | : SrsConnection(srs_server, client_stfd) | 73 | : SrsConnection(srs_server, client_stfd) |
77 | { | 74 | { |
@@ -520,7 +517,7 @@ int SrsRtmpConn::playing(SrsSource* source) | @@ -520,7 +517,7 @@ int SrsRtmpConn::playing(SrsSource* source) | ||
520 | 517 | ||
521 | // initialize other components | 518 | // initialize other components |
522 | SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_PLAY_USER); | 519 | SrsPithyPrint pithy_print(SRS_CONSTS_STAGE_PLAY_USER); |
523 | - SrsSharedPtrMessageArray msgs(SYS_MAX_PLAY_SEND_MSGS); | 520 | + SrsSharedPtrMessageArray msgs(SYS_CONSTS_MAX_PLAY_SEND_MSGS); |
524 | bool user_specified_duration_to_stop = (req->duration > 0); | 521 | bool user_specified_duration_to_stop = (req->duration > 0); |
525 | int64_t starttime = -1; | 522 | int64_t starttime = -1; |
526 | 523 |
@@ -50,12 +50,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -50,12 +50,13 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
50 | 50 | ||
51 | #define SERVER_LISTEN_BACKLOG 512 | 51 | #define SERVER_LISTEN_BACKLOG 512 |
52 | 52 | ||
53 | -// system interval | 53 | +// system interval in ms, |
54 | // all resolution times should be times togother, | 54 | // all resolution times should be times togother, |
55 | // for example, system-time is 3(300ms), | 55 | // for example, system-time is 3(300ms), |
56 | // then rusage can be 3*x, for instance, 3*10=30(3s), | 56 | // then rusage can be 3*x, for instance, 3*10=30(3s), |
57 | // the meminfo canbe 30*x, for instance, 30*2=60(6s) | 57 | // the meminfo canbe 30*x, for instance, 30*2=60(6s) |
58 | // for performance refine, @see: https://github.com/winlinvip/simple-rtmp-server/issues/194 | 58 | // for performance refine, @see: https://github.com/winlinvip/simple-rtmp-server/issues/194 |
59 | +// @remark, recomment to 1000ms. | ||
59 | #define SRS_SYS_CYCLE_INTERVAL 1000 | 60 | #define SRS_SYS_CYCLE_INTERVAL 1000 |
60 | 61 | ||
61 | // update time interval: | 62 | // update time interval: |
@@ -216,7 +216,7 @@ int SrsMessageQueue::dump_packets(int max_count, SrsSharedPtrMessage** pmsgs, in | @@ -216,7 +216,7 @@ int SrsMessageQueue::dump_packets(int max_count, SrsSharedPtrMessage** pmsgs, in | ||
216 | } else { | 216 | } else { |
217 | // erase some vector elements may cause memory copy, | 217 | // erase some vector elements may cause memory copy, |
218 | // maybe can use more efficient vector.swap to avoid copy. | 218 | // maybe can use more efficient vector.swap to avoid copy. |
219 | - // @remark for the pmsgs is big enough, for instance, SYS_MAX_PLAY_SEND_MSGS 128, | 219 | + // @remark for the pmsgs is big enough, for instance, SYS_CONSTS_MAX_PLAY_SEND_MSGS 128, |
220 | // the rtmp play client will get 128msgs once, so this branch rarely execute. | 220 | // the rtmp play client will get 128msgs once, so this branch rarely execute. |
221 | msgs.erase(msgs.begin(), msgs.begin() + count); | 221 | msgs.erase(msgs.begin(), msgs.begin() + count); |
222 | } | 222 | } |
@@ -78,6 +78,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -78,6 +78,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
78 | // the timeout to wait for client control message, | 78 | // the timeout to wait for client control message, |
79 | // if timeout, we generally ignore and send the data to client, | 79 | // if timeout, we generally ignore and send the data to client, |
80 | // generally, it's the pulse time for data seding. | 80 | // generally, it's the pulse time for data seding. |
81 | +// @remark, recomment to 500ms. | ||
81 | #define SRS_CONSTS_RTMP_PULSE_TIMEOUT_US (int64_t)(500*1000LL) | 82 | #define SRS_CONSTS_RTMP_PULSE_TIMEOUT_US (int64_t)(500*1000LL) |
82 | 83 | ||
83 | /** | 84 | /** |
@@ -98,17 +99,41 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -98,17 +99,41 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
98 | //#define SRS_CONSTS_RTMP_MAX_FMT3_HEADER_SIZE 5 | 99 | //#define SRS_CONSTS_RTMP_MAX_FMT3_HEADER_SIZE 5 |
99 | 100 | ||
100 | /** | 101 | /** |
102 | +* how many msgs can be send entirely. | ||
103 | +* for play clients to get msgs then totally send out. | ||
104 | +* for example, 25fps video, 40ms per video packet, | ||
105 | +* while audio is 20ms per audio packet where 2/3 is audios, | ||
106 | +* when SYS_CONSTS_MAX_PLAY_SEND_MSGS is 128, then | ||
107 | +* we will send all 128*40ms/3=1706ms packets in a time, | ||
108 | +* which should greater than the SRS_CONSTS_RTMP_PULSE_TIMEOUT_US | ||
109 | +* (for example, 500ms), that is, we should: | ||
110 | +* SYS_CONSTS_MAX_PLAY_SEND_MSGS * 40 / 3 >= SRS_CONSTS_RTMP_PULSE_TIMEOUT_US | ||
111 | +* @remark, recomment to 128. | ||
112 | +*/ | ||
113 | +#define SYS_CONSTS_MAX_PLAY_SEND_MSGS 128 | ||
114 | +/** | ||
101 | * for performance issue, | 115 | * for performance issue, |
102 | * the iovs cache, @see https://github.com/winlinvip/simple-rtmp-server/issues/194 | 116 | * the iovs cache, @see https://github.com/winlinvip/simple-rtmp-server/issues/194 |
103 | * iovs cache for multiple messages for each connections. | 117 | * iovs cache for multiple messages for each connections. |
118 | +* each iovc is 16bytes, sizeof(iovec)=16, suppose the chunk size is 64k, | ||
119 | +* each message send in a chunk which needs only 2 iovec, | ||
120 | +* so the iovs max should be (SYS_CONSTS_MAX_PLAY_SEND_MSGS * 16 * 2) | ||
121 | +* | ||
122 | +* @remark, SRS will realloc when the iovs not enough. | ||
104 | */ | 123 | */ |
105 | -#define SRS_CONSTS_IOVS_MAX 1024 | 124 | +#define SRS_CONSTS_IOVS_MAX (SYS_CONSTS_MAX_PLAY_SEND_MSGS * 32) |
106 | /** | 125 | /** |
107 | * for performance issue, | 126 | * for performance issue, |
108 | * the c0c3 cache, @see https://github.com/winlinvip/simple-rtmp-server/issues/194 | 127 | * the c0c3 cache, @see https://github.com/winlinvip/simple-rtmp-server/issues/194 |
109 | * c0c3 cache for multiple messages for each connections. | 128 | * c0c3 cache for multiple messages for each connections. |
129 | +* each c0 <= 16byes, suppose the chunk size is 64k, | ||
130 | +* each message send in a chunk which needs only a c0 header, | ||
131 | +* so the c0c3 cache should be (SYS_CONSTS_MAX_PLAY_SEND_MSGS * 16) | ||
132 | +* | ||
133 | +* @remark, SRS will try another loop when c0c3 cache dry, for we cannot realloc it. | ||
134 | +* so we use larger c0c3 cache, that is (SYS_CONSTS_MAX_PLAY_SEND_MSGS * 32) | ||
110 | */ | 135 | */ |
111 | -#define SRS_CONSTS_C0C3_HEADERS_MAX 4096 | 136 | +#define SRS_CONSTS_C0C3_HEADERS_MAX (SYS_CONSTS_MAX_PLAY_SEND_MSGS * 32) |
112 | 137 | ||
113 | /////////////////////////////////////////////////////////// | 138 | /////////////////////////////////////////////////////////// |
114 | /////////////////////////////////////////////////////////// | 139 | /////////////////////////////////////////////////////////// |
@@ -374,6 +374,9 @@ public: | @@ -374,6 +374,9 @@ public: | ||
374 | * @param msgs, the msgs to send out, never be NULL. | 374 | * @param msgs, the msgs to send out, never be NULL. |
375 | * @param nb_msgs, the size of msgs to send out. | 375 | * @param nb_msgs, the size of msgs to send out. |
376 | * @param stream_id, the stream id of packet to send over, 0 for control message. | 376 | * @param stream_id, the stream id of packet to send over, 0 for control message. |
377 | + * | ||
378 | + * @remark performance issue, to support 6k+ 250kbps client, | ||
379 | + * @see https://github.com/winlinvip/simple-rtmp-server/issues/194 | ||
377 | */ | 380 | */ |
378 | virtual int send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs, int stream_id); | 381 | virtual int send_and_free_messages(SrsSharedPtrMessage** msgs, int nb_msgs, int stream_id); |
379 | /** | 382 | /** |
-
请 注册 或 登录 后发表评论