winlin

for bug #235, pass timeout to recv thread.

@@ -34,8 +34,9 @@ ISrsMessageHandler::~ISrsMessageHandler() @@ -34,8 +34,9 @@ ISrsMessageHandler::~ISrsMessageHandler()
34 { 34 {
35 } 35 }
36 36
37 -SrsRecvThread::SrsRecvThread(ISrsMessageHandler* msg_handler, SrsRtmpServer* rtmp_sdk) 37 +SrsRecvThread::SrsRecvThread(ISrsMessageHandler* msg_handler, SrsRtmpServer* rtmp_sdk, int timeout_ms)
38 { 38 {
  39 + timeout = timeout_ms;
39 handler = msg_handler; 40 handler = msg_handler;
40 rtmp = rtmp_sdk; 41 rtmp = rtmp_sdk;
41 trd = new SrsThread(this, 0, true); 42 trd = new SrsThread(this, 0, true);
@@ -65,7 +66,7 @@ int SrsRecvThread::cycle() @@ -65,7 +66,7 @@ int SrsRecvThread::cycle()
65 int ret = ERROR_SUCCESS; 66 int ret = ERROR_SUCCESS;
66 67
67 if (!handler->can_handle()) { 68 if (!handler->can_handle()) {
68 - st_usleep(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US); 69 + st_usleep(timeout * 1000);
69 return ret; 70 return ret;
70 } 71 }
71 72
@@ -109,11 +110,11 @@ void SrsRecvThread::on_thread_stop() @@ -109,11 +110,11 @@ void SrsRecvThread::on_thread_stop()
109 rtmp->set_auto_response(true); 110 rtmp->set_auto_response(true);
110 111
111 // reset the timeout to pulse mode. 112 // reset the timeout to pulse mode.
112 - rtmp->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US); 113 + rtmp->set_recv_timeout(timeout * 1000);
113 } 114 }
114 115
115 -SrsQueueRecvThread::SrsQueueRecvThread(SrsRtmpServer* rtmp_sdk)  
116 - : SrsRecvThread(this, rtmp_sdk) 116 +SrsQueueRecvThread::SrsQueueRecvThread(SrsRtmpServer* rtmp_sdk, int timeout_ms)
  117 + : SrsRecvThread(this, rtmp_sdk, timeout_ms)
117 { 118 {
118 } 119 }
119 120
@@ -68,8 +68,9 @@ protected: @@ -68,8 +68,9 @@ protected:
68 SrsThread* trd; 68 SrsThread* trd;
69 ISrsMessageHandler* handler; 69 ISrsMessageHandler* handler;
70 SrsRtmpServer* rtmp; 70 SrsRtmpServer* rtmp;
  71 + int timeout;
71 public: 72 public:
72 - SrsRecvThread(ISrsMessageHandler* msg_handler, SrsRtmpServer* rtmp_sdk); 73 + SrsRecvThread(ISrsMessageHandler* msg_handler, SrsRtmpServer* rtmp_sdk, int timeout_ms);
73 virtual ~SrsRecvThread(); 74 virtual ~SrsRecvThread();
74 public: 75 public:
75 virtual int start(); 76 virtual int start();
@@ -91,7 +92,7 @@ class SrsQueueRecvThread : virtual public ISrsMessageHandler, virtual public Srs @@ -91,7 +92,7 @@ class SrsQueueRecvThread : virtual public ISrsMessageHandler, virtual public Srs
91 private: 92 private:
92 std::vector<SrsMessage*> queue; 93 std::vector<SrsMessage*> queue;
93 public: 94 public:
94 - SrsQueueRecvThread(SrsRtmpServer* rtmp_sdk); 95 + SrsQueueRecvThread(SrsRtmpServer* rtmp_sdk, int timeout_ms);
95 virtual ~SrsQueueRecvThread(); 96 virtual ~SrsQueueRecvThread();
96 public: 97 public:
97 virtual bool empty(); 98 virtual bool empty();
@@ -500,7 +500,7 @@ int SrsRtmpConn::playing(SrsSource* source) @@ -500,7 +500,7 @@ int SrsRtmpConn::playing(SrsSource* source)
500 500
501 // use isolate thread to recv, 501 // use isolate thread to recv,
502 // @see: https://github.com/winlinvip/simple-rtmp-server/issues/217 502 // @see: https://github.com/winlinvip/simple-rtmp-server/issues/217
503 - SrsQueueRecvThread trd(rtmp); 503 + SrsQueueRecvThread trd(rtmp, SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
504 504
505 // start isolate recv thread. 505 // start isolate recv thread.
506 if ((ret = trd.start()) != ERROR_SUCCESS) { 506 if ((ret = trd.start()) != ERROR_SUCCESS) {