mirror of
				https://github.com/ossrs/srs.git
				synced 2025-03-09 15:49:59 +00:00 
			
		
		
		
	Timer: Apply shared FastTimer to RTC server. 4.0.93
This commit is contained in:
		
							parent
							
								
									8747dd6630
								
							
						
					
					
						commit
						00c192ede1
					
				
					 4 changed files with 10 additions and 17 deletions
				
			
		| 
						 | 
				
			
			@ -259,7 +259,6 @@ SrsRtcServer::SrsRtcServer()
 | 
			
		|||
{
 | 
			
		||||
    handler = NULL;
 | 
			
		||||
    hijacker = NULL;
 | 
			
		||||
    timer = new SrsHourGlass("server", this, 1 * SRS_UTIME_SECONDS);
 | 
			
		||||
 | 
			
		||||
    _srs_config->subscribe(this);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -268,8 +267,6 @@ SrsRtcServer::~SrsRtcServer()
 | 
			
		|||
{
 | 
			
		||||
    _srs_config->unsubscribe(this);
 | 
			
		||||
 | 
			
		||||
    srs_freep(timer);
 | 
			
		||||
 | 
			
		||||
    if (true) {
 | 
			
		||||
        vector<SrsUdpMuxListener*>::iterator it;
 | 
			
		||||
        for (it = listeners.begin(); it != listeners.end(); ++it) {
 | 
			
		||||
| 
						 | 
				
			
			@ -283,14 +280,10 @@ srs_error_t SrsRtcServer::initialize()
 | 
			
		|||
{
 | 
			
		||||
    srs_error_t err = srs_success;
 | 
			
		||||
 | 
			
		||||
    if ((err = timer->tick(5 * SRS_UTIME_SECONDS)) != srs_success) {
 | 
			
		||||
        return srs_error_wrap(err, "hourglass tick");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ((err = timer->start()) != srs_success) {
 | 
			
		||||
        return srs_error_wrap(err, "start timer");
 | 
			
		||||
    }
 | 
			
		||||
    // The RTC server start a timer, do routines of RTC server.
 | 
			
		||||
    _srs_hybrid->timer()->subscribe(5 * SRS_UTIME_SECONDS, this);
 | 
			
		||||
 | 
			
		||||
    // Initialize the black hole.
 | 
			
		||||
    if ((err = _srs_blackhole->initialize()) != srs_success) {
 | 
			
		||||
        return srs_error_wrap(err, "black hole");
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -640,7 +633,7 @@ SrsRtcConnection* SrsRtcServer::find_session_by_username(const std::string& user
 | 
			
		|||
    return dynamic_cast<SrsRtcConnection*>(conn);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
srs_error_t SrsRtcServer::notify(int type, srs_utime_t interval, srs_utime_t tick)
 | 
			
		||||
srs_error_t SrsRtcServer::on_timer(srs_utime_t interval, srs_utime_t tick)
 | 
			
		||||
{
 | 
			
		||||
    srs_error_t err = srs_success;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -105,10 +105,9 @@ public:
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
// The RTC server instance, listen UDP port, handle UDP packet, manage RTC connections.
 | 
			
		||||
class SrsRtcServer : virtual public ISrsUdpMuxHandler, virtual public ISrsHourGlass, virtual public ISrsReloadHandler
 | 
			
		||||
class SrsRtcServer : public ISrsUdpMuxHandler, public ISrsFastTimer, public ISrsReloadHandler
 | 
			
		||||
{
 | 
			
		||||
private:
 | 
			
		||||
    SrsHourGlass* timer;
 | 
			
		||||
    std::vector<SrsUdpMuxListener*> listeners;
 | 
			
		||||
    ISrsRtcServerHandler* handler;
 | 
			
		||||
    ISrsRtcServerHijacker* hijacker;
 | 
			
		||||
| 
						 | 
				
			
			@ -137,9 +136,9 @@ private:
 | 
			
		|||
    srs_error_t do_create_session(SrsRtcUserConfig* ruc, SrsSdp& local_sdp, SrsRtcConnection* session);
 | 
			
		||||
public:
 | 
			
		||||
    SrsRtcConnection* find_session_by_username(const std::string& ufrag);
 | 
			
		||||
// interface ISrsHourGlass
 | 
			
		||||
public:
 | 
			
		||||
    virtual srs_error_t notify(int type, srs_utime_t interval, srs_utime_t tick);
 | 
			
		||||
// interface ISrsFastTimer
 | 
			
		||||
private:
 | 
			
		||||
    srs_error_t on_timer(srs_utime_t interval, srs_utime_t tick);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// The RTC server adapter.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,6 +26,6 @@
 | 
			
		|||
 | 
			
		||||
#define VERSION_MAJOR       4
 | 
			
		||||
#define VERSION_MINOR       0
 | 
			
		||||
#define VERSION_REVISION    92
 | 
			
		||||
#define VERSION_REVISION    93
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue