mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
for bug #235, pass timeout to recv thread.
This commit is contained in:
parent
31eb9bf1c1
commit
0b631ee80d
3 changed files with 10 additions and 8 deletions
|
@ -34,8 +34,9 @@ ISrsMessageHandler::~ISrsMessageHandler()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsRecvThread::SrsRecvThread(ISrsMessageHandler* msg_handler, SrsRtmpServer* rtmp_sdk)
|
SrsRecvThread::SrsRecvThread(ISrsMessageHandler* msg_handler, SrsRtmpServer* rtmp_sdk, int timeout_ms)
|
||||||
{
|
{
|
||||||
|
timeout = timeout_ms;
|
||||||
handler = msg_handler;
|
handler = msg_handler;
|
||||||
rtmp = rtmp_sdk;
|
rtmp = rtmp_sdk;
|
||||||
trd = new SrsThread(this, 0, true);
|
trd = new SrsThread(this, 0, true);
|
||||||
|
@ -65,7 +66,7 @@ int SrsRecvThread::cycle()
|
||||||
int ret = ERROR_SUCCESS;
|
int ret = ERROR_SUCCESS;
|
||||||
|
|
||||||
if (!handler->can_handle()) {
|
if (!handler->can_handle()) {
|
||||||
st_usleep(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
|
st_usleep(timeout * 1000);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,11 +110,11 @@ void SrsRecvThread::on_thread_stop()
|
||||||
rtmp->set_auto_response(true);
|
rtmp->set_auto_response(true);
|
||||||
|
|
||||||
// reset the timeout to pulse mode.
|
// reset the timeout to pulse mode.
|
||||||
rtmp->set_recv_timeout(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
|
rtmp->set_recv_timeout(timeout * 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsQueueRecvThread::SrsQueueRecvThread(SrsRtmpServer* rtmp_sdk)
|
SrsQueueRecvThread::SrsQueueRecvThread(SrsRtmpServer* rtmp_sdk, int timeout_ms)
|
||||||
: SrsRecvThread(this, rtmp_sdk)
|
: SrsRecvThread(this, rtmp_sdk, timeout_ms)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,9 @@ protected:
|
||||||
SrsThread* trd;
|
SrsThread* trd;
|
||||||
ISrsMessageHandler* handler;
|
ISrsMessageHandler* handler;
|
||||||
SrsRtmpServer* rtmp;
|
SrsRtmpServer* rtmp;
|
||||||
|
int timeout;
|
||||||
public:
|
public:
|
||||||
SrsRecvThread(ISrsMessageHandler* msg_handler, SrsRtmpServer* rtmp_sdk);
|
SrsRecvThread(ISrsMessageHandler* msg_handler, SrsRtmpServer* rtmp_sdk, int timeout_ms);
|
||||||
virtual ~SrsRecvThread();
|
virtual ~SrsRecvThread();
|
||||||
public:
|
public:
|
||||||
virtual int start();
|
virtual int start();
|
||||||
|
@ -91,7 +92,7 @@ class SrsQueueRecvThread : virtual public ISrsMessageHandler, virtual public Srs
|
||||||
private:
|
private:
|
||||||
std::vector<SrsMessage*> queue;
|
std::vector<SrsMessage*> queue;
|
||||||
public:
|
public:
|
||||||
SrsQueueRecvThread(SrsRtmpServer* rtmp_sdk);
|
SrsQueueRecvThread(SrsRtmpServer* rtmp_sdk, int timeout_ms);
|
||||||
virtual ~SrsQueueRecvThread();
|
virtual ~SrsQueueRecvThread();
|
||||||
public:
|
public:
|
||||||
virtual bool empty();
|
virtual bool empty();
|
||||||
|
|
|
@ -500,7 +500,7 @@ int SrsRtmpConn::playing(SrsSource* source)
|
||||||
|
|
||||||
// use isolate thread to recv,
|
// use isolate thread to recv,
|
||||||
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/217
|
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/217
|
||||||
SrsQueueRecvThread trd(rtmp);
|
SrsQueueRecvThread trd(rtmp, SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
|
||||||
|
|
||||||
// start isolate recv thread.
|
// start isolate recv thread.
|
||||||
if ((ret = trd.start()) != ERROR_SUCCESS) {
|
if ((ret = trd.start()) != ERROR_SUCCESS) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue