diff --git a/trunk/src/app/srs_app_recv_thread.cpp b/trunk/src/app/srs_app_recv_thread.cpp index 008ffe964..5a6a49807 100644 --- a/trunk/src/app/srs_app_recv_thread.cpp +++ b/trunk/src/app/srs_app_recv_thread.cpp @@ -106,25 +106,22 @@ void SrsRecvThread::on_thread_start() // @see https://github.com/winlinvip/simple-rtmp-server/issues/194 // @see: https://github.com/winlinvip/simple-rtmp-server/issues/217 rtmp->set_recv_timeout(ST_UTIME_NO_TIMEOUT); - - // disable the protocol auto response, - // for the isolate recv thread should never send any messages. - rtmp->set_auto_response(false); + + handler->on_thread_start(); } void SrsRecvThread::on_thread_stop() { - // enable the protocol auto response, - // for the isolate recv thread terminated. - rtmp->set_auto_response(true); - // reset the timeout to pulse mode. rtmp->set_recv_timeout(timeout * 1000); + + handler->on_thread_stop(); } SrsQueueRecvThread::SrsQueueRecvThread(SrsRtmpServer* rtmp_sdk, int timeout_ms) : trd(this, rtmp_sdk, timeout_ms) { + rtmp = rtmp_sdk; recv_error_code = ERROR_SUCCESS; } @@ -200,11 +197,26 @@ void SrsQueueRecvThread::on_recv_error(int ret) recv_error_code = ret; } +void SrsQueueRecvThread::on_thread_start() +{ + // disable the protocol auto response, + // for the isolate recv thread should never send any messages. + rtmp->set_auto_response(false); +} + +void SrsQueueRecvThread::on_thread_stop() +{ + // enable the protocol auto response, + // for the isolate recv thread terminated. + rtmp->set_auto_response(true); +} + SrsPublishRecvThread::SrsPublishRecvThread( SrsRtmpServer* rtmp_sdk, int timeout_ms, SrsRtmpConn* conn, SrsSource* source, bool is_fmle, bool is_edge ): trd(this, rtmp_sdk, timeout_ms) { + rtmp = rtmp_sdk; _conn = conn; _source = source; _is_fmle = is_fmle; @@ -273,3 +285,15 @@ void SrsPublishRecvThread::on_recv_error(int ret) { recv_error_code = ret; } + +void SrsPublishRecvThread::on_thread_start() +{ + // we donot set the auto response to false, + // for the main thread never send message. +} + +void SrsPublishRecvThread::on_thread_stop() +{ + // we donot set the auto response to true, + // for we donot set to false yet. +} diff --git a/trunk/src/app/srs_app_recv_thread.hpp b/trunk/src/app/srs_app_recv_thread.hpp index df9ac8ef3..88e020bc1 100644 --- a/trunk/src/app/srs_app_recv_thread.hpp +++ b/trunk/src/app/srs_app_recv_thread.hpp @@ -63,6 +63,12 @@ public: * when recv message error. */ virtual void on_recv_error(int ret) = 0; + /** + * when thread start or stop, + * for example, the message handler can set whether auto response. + */ + virtual void on_thread_start() = 0; + virtual void on_thread_stop() = 0; }; /** @@ -99,6 +105,7 @@ class SrsQueueRecvThread : public ISrsMessageHandler private: std::vector queue; SrsRecvThread trd; + SrsRtmpServer* rtmp; // the recv thread error code. int recv_error_code; public: @@ -116,6 +123,9 @@ public: virtual bool can_handle(); virtual int handle(SrsMessage* msg); virtual void on_recv_error(int ret); +public: + virtual void on_thread_start(); + virtual void on_thread_stop(); }; /** @@ -126,6 +136,7 @@ class SrsPublishRecvThread : public ISrsMessageHandler { private: SrsRecvThread trd; + SrsRtmpServer* rtmp; // the msgs already got. int64_t _nb_msgs; // the recv thread error code. @@ -148,6 +159,9 @@ public: virtual bool can_handle(); virtual int handle(SrsMessage* msg); virtual void on_recv_error(int ret); +public: + virtual void on_thread_start(); + virtual void on_thread_stop(); }; #endif diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 44a134866..6fa3d0f00 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 45 +#define VERSION_REVISION 46 // server info. #define RTMP_SIG_SRS_KEY "SRS" #define RTMP_SIG_SRS_ROLE "origin/edge server"