From 0d6b91039d408328caab31a1077d56a809b6bebc Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 16 Dec 2014 09:26:22 +0800 Subject: [PATCH] fix #257, refine latency, send when got one+ msgs, 2.0.72 --- trunk/src/app/srs_app_rtmp_conn.cpp | 9 ++++++++- trunk/src/app/srs_app_source.cpp | 15 ++++++--------- trunk/src/app/srs_app_source.hpp | 3 +-- trunk/src/core/srs_core.hpp | 2 +- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index a5666f64e5..230bb851c8 100644 --- a/trunk/src/app/srs_app_rtmp_conn.cpp +++ b/trunk/src/app/srs_app_rtmp_conn.cpp @@ -629,7 +629,14 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsQueueRecvThread* trd) // wait for message to incoming. // @see https://github.com/winlinvip/simple-rtmp-server/issues/251 - consumer->wait(SRS_PERF_MW_MIN_MSGS, mw_sleep, realtime); + // @see https://github.com/winlinvip/simple-rtmp-server/issues/257 + if (realtime) { + // for realtime, min required msgs is 0, send when got one+ msgs. + consumer->wait(0, mw_sleep); + } else { + // for no-realtime, got some msgs then send. + consumer->wait(SRS_PERF_MW_MIN_MSGS, mw_sleep); + } // for send wait time debug srs_verbose("send thread now=%"PRId64"us wakeup", srs_update_system_time_ms()); diff --git a/trunk/src/app/srs_app_source.cpp b/trunk/src/app/srs_app_source.cpp index 753feafec5..efece45160 100644 --- a/trunk/src/app/srs_app_source.cpp +++ b/trunk/src/app/srs_app_source.cpp @@ -452,6 +452,9 @@ int SrsConsumer::enqueue(SrsSharedPtrMessage* __msg, bool atc, int tba, int tbv, } #ifdef SRS_PERF_QUEUE_COND_WAIT + srs_verbose("enqueue msg, time=%"PRId64", size=%d, duration=%d, waiting=%d, min_msg=%d", + msg->timestamp, msg->size, queue->duration(), mw_waiting, mw_min_msgs); + // fire the mw when msgs is enough. if (mw_waiting) { int duration_ms = queue->duration(); @@ -493,7 +496,7 @@ int SrsConsumer::dump_packets(SrsMessageArray* msgs, int& count) } #ifdef SRS_PERF_QUEUE_COND_WAIT -void SrsConsumer::wait(int nb_msgs, int duration, bool realtime) +void SrsConsumer::wait(int nb_msgs, int duration) { mw_min_msgs = nb_msgs; mw_duration = duration; @@ -509,14 +512,8 @@ void SrsConsumer::wait(int nb_msgs, int duration, bool realtime) // the enqueue will notify this cond. mw_waiting = true; - // use timeout wait for realtime mode. - // @see https://github.com/winlinvip/simple-rtmp-server/issues/257 - if (realtime) { - st_cond_timedwait(mw_wait, duration * 1000); - } else { - // use cond block wait for high performance mode. - st_cond_wait(mw_wait); - } + // use cond block wait for high performance mode. + st_cond_wait(mw_wait); } #endif diff --git a/trunk/src/app/srs_app_source.hpp b/trunk/src/app/srs_app_source.hpp index 83af0ac603..ad7a060a49 100644 --- a/trunk/src/app/srs_app_source.hpp +++ b/trunk/src/app/srs_app_source.hpp @@ -244,9 +244,8 @@ class SrsConsumer * wait for messages incomming, atleast nb_msgs and in duration. * @param nb_msgs the messages count to wait. * @param duration the messgae duration to wait. - * @param realtime whether use realtime mode. */ - virtual void wait(int nb_msgs, int duration, bool realtime); + virtual void wait(int nb_msgs, int duration); #endif /** * when client send the pause message. diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 0ea93eda53..134db9bc4c 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -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 71 +#define VERSION_REVISION 72 // server info. #define RTMP_SIG_SRS_KEY "SRS" #define RTMP_SIG_SRS_ROLE "origin/edge server"