mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine recv thread, donot set auto response for publish recv thread. 2.0.46
This commit is contained in:
parent
5905e5c050
commit
e9712cc627
3 changed files with 47 additions and 9 deletions
|
@ -107,24 +107,21 @@ void SrsRecvThread::on_thread_start()
|
|||
// @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.
|
||||
}
|
||||
|
|
|
@ -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<SrsMessage*> 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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue