winlin

fix #257, refine latency, send when got one+ msgs, 2.0.72

@@ -629,7 +629,14 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsQueueRecvThread* trd) @@ -629,7 +629,14 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsQueueRecvThread* trd)
629 629
630 // wait for message to incoming. 630 // wait for message to incoming.
631 // @see https://github.com/winlinvip/simple-rtmp-server/issues/251 631 // @see https://github.com/winlinvip/simple-rtmp-server/issues/251
632 - consumer->wait(SRS_PERF_MW_MIN_MSGS, mw_sleep, realtime); 632 + // @see https://github.com/winlinvip/simple-rtmp-server/issues/257
  633 + if (realtime) {
  634 + // for realtime, min required msgs is 0, send when got one+ msgs.
  635 + consumer->wait(0, mw_sleep);
  636 + } else {
  637 + // for no-realtime, got some msgs then send.
  638 + consumer->wait(SRS_PERF_MW_MIN_MSGS, mw_sleep);
  639 + }
633 640
634 // for send wait time debug 641 // for send wait time debug
635 srs_verbose("send thread now=%"PRId64"us wakeup", srs_update_system_time_ms()); 642 srs_verbose("send thread now=%"PRId64"us wakeup", srs_update_system_time_ms());
@@ -452,6 +452,9 @@ int SrsConsumer::enqueue(SrsSharedPtrMessage* __msg, bool atc, int tba, int tbv, @@ -452,6 +452,9 @@ int SrsConsumer::enqueue(SrsSharedPtrMessage* __msg, bool atc, int tba, int tbv,
452 } 452 }
453 453
454 #ifdef SRS_PERF_QUEUE_COND_WAIT 454 #ifdef SRS_PERF_QUEUE_COND_WAIT
  455 + srs_verbose("enqueue msg, time=%"PRId64", size=%d, duration=%d, waiting=%d, min_msg=%d",
  456 + msg->timestamp, msg->size, queue->duration(), mw_waiting, mw_min_msgs);
  457 +
455 // fire the mw when msgs is enough. 458 // fire the mw when msgs is enough.
456 if (mw_waiting) { 459 if (mw_waiting) {
457 int duration_ms = queue->duration(); 460 int duration_ms = queue->duration();
@@ -493,7 +496,7 @@ int SrsConsumer::dump_packets(SrsMessageArray* msgs, int& count) @@ -493,7 +496,7 @@ int SrsConsumer::dump_packets(SrsMessageArray* msgs, int& count)
493 } 496 }
494 497
495 #ifdef SRS_PERF_QUEUE_COND_WAIT 498 #ifdef SRS_PERF_QUEUE_COND_WAIT
496 -void SrsConsumer::wait(int nb_msgs, int duration, bool realtime) 499 +void SrsConsumer::wait(int nb_msgs, int duration)
497 { 500 {
498 mw_min_msgs = nb_msgs; 501 mw_min_msgs = nb_msgs;
499 mw_duration = duration; 502 mw_duration = duration;
@@ -509,14 +512,8 @@ void SrsConsumer::wait(int nb_msgs, int duration, bool realtime) @@ -509,14 +512,8 @@ void SrsConsumer::wait(int nb_msgs, int duration, bool realtime)
509 // the enqueue will notify this cond. 512 // the enqueue will notify this cond.
510 mw_waiting = true; 513 mw_waiting = true;
511 514
512 - // use timeout wait for realtime mode.  
513 - // @see https://github.com/winlinvip/simple-rtmp-server/issues/257  
514 - if (realtime) {  
515 - st_cond_timedwait(mw_wait, duration * 1000);  
516 - } else {  
517 - // use cond block wait for high performance mode.  
518 - st_cond_wait(mw_wait);  
519 - } 515 + // use cond block wait for high performance mode.
  516 + st_cond_wait(mw_wait);
520 } 517 }
521 #endif 518 #endif
522 519
@@ -244,9 +244,8 @@ public: @@ -244,9 +244,8 @@ public:
244 * wait for messages incomming, atleast nb_msgs and in duration. 244 * wait for messages incomming, atleast nb_msgs and in duration.
245 * @param nb_msgs the messages count to wait. 245 * @param nb_msgs the messages count to wait.
246 * @param duration the messgae duration to wait. 246 * @param duration the messgae duration to wait.
247 - * @param realtime whether use realtime mode.  
248 */ 247 */
249 - virtual void wait(int nb_msgs, int duration, bool realtime); 248 + virtual void wait(int nb_msgs, int duration);
250 #endif 249 #endif
251 /** 250 /**
252 * when client send the pause message. 251 * when client send the pause message.
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 // current release version 31 // current release version
32 #define VERSION_MAJOR 2 32 #define VERSION_MAJOR 2
33 #define VERSION_MINOR 0 33 #define VERSION_MINOR 0
34 -#define VERSION_REVISION 71 34 +#define VERSION_REVISION 72
35 // server info. 35 // server info.
36 #define RTMP_SIG_SRS_KEY "SRS" 36 #define RTMP_SIG_SRS_KEY "SRS"
37 #define RTMP_SIG_SRS_ROLE "origin/edge server" 37 #define RTMP_SIG_SRS_ROLE "origin/edge server"