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)
// 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());
... ...
... ... @@ -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);
}
}
#endif
... ...
... ... @@ -244,9 +244,8 @@ public:
* 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.
... ...
... ... @@ -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"
... ...