From 5af572ab50b2cd96b4902552f44bcc1e373cf821 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 18 Apr 2019 08:46:42 +0800 Subject: [PATCH] Refine SrsRtmpConn.duration in time unit. --- trunk/src/app/srs_app_recv_thread.hpp | 2 +- trunk/src/app/srs_app_rtmp_conn.cpp | 17 ++++++----------- trunk/src/app/srs_app_rtmp_conn.hpp | 4 ++-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/trunk/src/app/srs_app_recv_thread.hpp b/trunk/src/app/srs_app_recv_thread.hpp index 477b43f29..d11f55dd3 100644 --- a/trunk/src/app/srs_app_recv_thread.hpp +++ b/trunk/src/app/srs_app_recv_thread.hpp @@ -101,7 +101,7 @@ protected: srs_utime_t timeout; public: // Constructor. - // @param tm The receive timeout in ms. + // @param tm The receive timeout in srs_utime_t. SrsRecvThread(ISrsMessagePumper* p, SrsRtmpServer* r, srs_utime_t tm, int parent_cid); virtual ~SrsRecvThread(); public: diff --git a/trunk/src/app/srs_app_rtmp_conn.cpp b/trunk/src/app/srs_app_rtmp_conn.cpp index 5ddc91411..32ce9a257 100644 --- a/trunk/src/app/srs_app_rtmp_conn.cpp +++ b/trunk/src/app/srs_app_rtmp_conn.cpp @@ -57,18 +57,13 @@ using namespace std; #include #include -// when stream is busy, for example, streaming is already -// publishing, when a new client to request to publish, -// sleep a while and close the connection. -#define SRS_STREAM_BUSY_CIMS (3000) - -// the timeout in ms to wait encoder to republish +// the timeout in srs_utime_t to wait encoder to republish // if timeout, close the connection. #define SRS_REPUBLISH_SEND_TIMEOUT (3 * SRS_UTIME_MINUTES) // if timeout, close the connection. #define SRS_REPUBLISH_RECV_TIMEOUT (3 * SRS_UTIME_MINUTES) -// the timeout in ms to wait client data, when client paused +// the timeout in srs_utime_t to wait client data, when client paused // if timeout, close the connection. #define SRS_PAUSED_SEND_TIMEOUT (3 * SRS_UTIME_MINUTES) // if timeout, close the connection. @@ -767,7 +762,7 @@ srs_error_t SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, Sr if (starttime < 0 || starttime > msg->timestamp) { starttime = msg->timestamp; } - duration += msg->timestamp - starttime; + duration += (msg->timestamp - starttime) * SRS_UTIME_MILLISECONDS; starttime = msg->timestamp; } } @@ -781,12 +776,12 @@ srs_error_t SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, Sr // if duration specified, and exceed it, stop play live. // @see: https://github.com/ossrs/srs/issues/45 if (user_specified_duration_to_stop) { - if (duration >= (int64_t)req->duration) { - return srs_error_new(ERROR_RTMP_DURATION_EXCEED, "rtmp: time %d up %d", (int)duration, (int)req->duration); + if (srsu2ms(duration) >= (int64_t)req->duration) { + return srs_error_new(ERROR_RTMP_DURATION_EXCEED, "rtmp: time %d up %d", srsu2msi(duration), (int)req->duration); } } - // apply the minimal interval for delivery stream in ms. + // apply the minimal interval for delivery stream in srs_utime_t. if (send_min_interval > 0) { srs_usleep(send_min_interval); } diff --git a/trunk/src/app/srs_app_rtmp_conn.hpp b/trunk/src/app/srs_app_rtmp_conn.hpp index 458f39b19..5dc3cb35f 100644 --- a/trunk/src/app/srs_app_rtmp_conn.hpp +++ b/trunk/src/app/srs_app_rtmp_conn.hpp @@ -105,10 +105,10 @@ private: // the wakable handler, maybe NULL. // TODO: FIXME: Should refine the state for receiving thread. ISrsWakable* wakable; - // elapse duration in ms + // elapse duration in srs_utime_t // for live play duration, for instance, rtmpdump to record. // @see https://github.com/ossrs/srs/issues/47 - int64_t duration; + srs_utime_t duration; // the MR(merged-write) sleep time in ms. srs_utime_t mw_sleep; // the MR(merged-write) only enabled for play.