1
0
Fork 0
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:
winlin 2014-12-02 17:16:20 +08:00
parent 5905e5c050
commit e9712cc627
3 changed files with 47 additions and 9 deletions

View file

@ -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/194
// @see: https://github.com/winlinvip/simple-rtmp-server/issues/217 // @see: https://github.com/winlinvip/simple-rtmp-server/issues/217
rtmp->set_recv_timeout(ST_UTIME_NO_TIMEOUT); rtmp->set_recv_timeout(ST_UTIME_NO_TIMEOUT);
// disable the protocol auto response, handler->on_thread_start();
// for the isolate recv thread should never send any messages.
rtmp->set_auto_response(false);
} }
void SrsRecvThread::on_thread_stop() 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. // reset the timeout to pulse mode.
rtmp->set_recv_timeout(timeout * 1000); rtmp->set_recv_timeout(timeout * 1000);
handler->on_thread_stop();
} }
SrsQueueRecvThread::SrsQueueRecvThread(SrsRtmpServer* rtmp_sdk, int timeout_ms) SrsQueueRecvThread::SrsQueueRecvThread(SrsRtmpServer* rtmp_sdk, int timeout_ms)
: trd(this, rtmp_sdk, timeout_ms) : trd(this, rtmp_sdk, timeout_ms)
{ {
rtmp = rtmp_sdk;
recv_error_code = ERROR_SUCCESS; recv_error_code = ERROR_SUCCESS;
} }
@ -200,11 +197,26 @@ void SrsQueueRecvThread::on_recv_error(int ret)
recv_error_code = 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( SrsPublishRecvThread::SrsPublishRecvThread(
SrsRtmpServer* rtmp_sdk, int timeout_ms, SrsRtmpServer* rtmp_sdk, int timeout_ms,
SrsRtmpConn* conn, SrsSource* source, bool is_fmle, bool is_edge SrsRtmpConn* conn, SrsSource* source, bool is_fmle, bool is_edge
): trd(this, rtmp_sdk, timeout_ms) ): trd(this, rtmp_sdk, timeout_ms)
{ {
rtmp = rtmp_sdk;
_conn = conn; _conn = conn;
_source = source; _source = source;
_is_fmle = is_fmle; _is_fmle = is_fmle;
@ -273,3 +285,15 @@ void SrsPublishRecvThread::on_recv_error(int ret)
{ {
recv_error_code = 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.
}

View file

@ -63,6 +63,12 @@ public:
* when recv message error. * when recv message error.
*/ */
virtual void on_recv_error(int ret) = 0; 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: private:
std::vector<SrsMessage*> queue; std::vector<SrsMessage*> queue;
SrsRecvThread trd; SrsRecvThread trd;
SrsRtmpServer* rtmp;
// the recv thread error code. // the recv thread error code.
int recv_error_code; int recv_error_code;
public: public:
@ -116,6 +123,9 @@ public:
virtual bool can_handle(); virtual bool can_handle();
virtual int handle(SrsMessage* msg); virtual int handle(SrsMessage* msg);
virtual void on_recv_error(int ret); 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: private:
SrsRecvThread trd; SrsRecvThread trd;
SrsRtmpServer* rtmp;
// the msgs already got. // the msgs already got.
int64_t _nb_msgs; int64_t _nb_msgs;
// the recv thread error code. // the recv thread error code.
@ -148,6 +159,9 @@ public:
virtual bool can_handle(); virtual bool can_handle();
virtual int handle(SrsMessage* msg); virtual int handle(SrsMessage* msg);
virtual void on_recv_error(int ret); virtual void on_recv_error(int ret);
public:
virtual void on_thread_start();
virtual void on_thread_stop();
}; };
#endif #endif

View file

@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version // current release version
#define VERSION_MAJOR 2 #define VERSION_MAJOR 2
#define VERSION_MINOR 0 #define VERSION_MINOR 0
#define VERSION_REVISION 45 #define VERSION_REVISION 46
// server info. // server info.
#define RTMP_SIG_SRS_KEY "SRS" #define RTMP_SIG_SRS_KEY "SRS"
#define RTMP_SIG_SRS_ROLE "origin/edge server" #define RTMP_SIG_SRS_ROLE "origin/edge server"