mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
merge from 2.0.153
This commit is contained in:
commit
2d3d628865
9 changed files with 84 additions and 14 deletions
|
@ -457,6 +457,21 @@ SrsJsonAny* SrsJsonObject::ensure_property_string(string name)
|
|||
return prop;
|
||||
}
|
||||
|
||||
SrsJsonAny* SrsJsonObject::ensure_property_integer(string name)
|
||||
{
|
||||
SrsJsonAny* prop = get_property(name);
|
||||
|
||||
if (!prop) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!prop->is_integer()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return prop;
|
||||
}
|
||||
|
||||
SrsJsonAny* SrsJsonObject::ensure_property_boolean(string name)
|
||||
{
|
||||
SrsJsonAny* prop = get_property(name);
|
||||
|
|
|
@ -149,6 +149,7 @@ public:
|
|||
virtual void set(std::string key, SrsJsonAny* value);
|
||||
virtual SrsJsonAny* get_property(std::string name);
|
||||
virtual SrsJsonAny* ensure_property_string(std::string name);
|
||||
virtual SrsJsonAny* ensure_property_integer(std::string name);
|
||||
virtual SrsJsonAny* ensure_property_boolean(std::string name);
|
||||
};
|
||||
|
||||
|
|
|
@ -190,4 +190,8 @@ int ISrsReloadHandler::on_reload_ingest_updated(string /*vhost*/, string /*inges
|
|||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
int ISrsReloadHandler::on_reload_user_info()
|
||||
{
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ public:
|
|||
virtual int on_reload_ingest_removed(std::string vhost, std::string ingest_id);
|
||||
virtual int on_reload_ingest_added(std::string vhost, std::string ingest_id);
|
||||
virtual int on_reload_ingest_updated(std::string vhost, std::string ingest_id);
|
||||
virtual int on_reload_user_info();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -389,6 +389,14 @@ void SrsSignalManager::sig_catcher(int signo)
|
|||
errno = err;
|
||||
}
|
||||
|
||||
ISrsServerCycle::ISrsServerCycle()
|
||||
{
|
||||
}
|
||||
|
||||
ISrsServerCycle::~ISrsServerCycle()
|
||||
{
|
||||
}
|
||||
|
||||
SrsServer::SrsServer()
|
||||
{
|
||||
signal_reload = false;
|
||||
|
@ -397,6 +405,8 @@ SrsServer::SrsServer()
|
|||
|
||||
signal_manager = NULL;
|
||||
|
||||
handler = NULL;
|
||||
|
||||
// donot new object in constructor,
|
||||
// for some global instance is not ready now,
|
||||
// new these objects in initialize instead.
|
||||
|
@ -456,6 +466,8 @@ void SrsServer::destroy()
|
|||
|
||||
srs_freep(signal_manager);
|
||||
|
||||
srs_freep(handler);
|
||||
|
||||
// @remark never destroy the connections,
|
||||
// for it's still alive.
|
||||
|
||||
|
@ -464,7 +476,7 @@ void SrsServer::destroy()
|
|||
// and segment fault.
|
||||
}
|
||||
|
||||
int SrsServer::initialize()
|
||||
int SrsServer::initialize(ISrsServerCycle* cycle_handler)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
|
@ -480,6 +492,11 @@ int SrsServer::initialize()
|
|||
srs_assert(!signal_manager);
|
||||
signal_manager = new SrsSignalManager(this);
|
||||
|
||||
handler = cycle_handler;
|
||||
if(handler && (ret = handler->initialize()) != ERROR_SUCCESS){
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef SRS_AUTO_HTTP_API
|
||||
if ((ret = http_api_mux->initialize()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
|
@ -795,6 +812,11 @@ int SrsServer::do_cycle()
|
|||
|
||||
// the deamon thread, update the time cache
|
||||
while (true) {
|
||||
if(handler && (ret = handler->on_cycle(conns.size())) != ERROR_SUCCESS){
|
||||
srs_error("cycle handle failed. ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
// the interval in config.
|
||||
int heartbeat_max_resolution = (int)(_srs_config->get_heartbeat_interval() / SRS_SYS_CYCLE_INTERVAL);
|
||||
|
||||
|
|
|
@ -170,6 +170,25 @@ private:
|
|||
static void sig_catcher(int signo);
|
||||
};
|
||||
|
||||
/**
|
||||
* the handler to the handle cycle in SRS RTMP server.
|
||||
*/
|
||||
class ISrsServerCycle
|
||||
{
|
||||
public:
|
||||
ISrsServerCycle();
|
||||
virtual ~ISrsServerCycle();
|
||||
public:
|
||||
/**
|
||||
* initialize the cycle handler.
|
||||
*/
|
||||
virtual int initialize() = 0;
|
||||
/**
|
||||
* do on_cycle while server doing cycle.
|
||||
*/
|
||||
virtual int on_cycle(int connections) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* SRS RTMP server, initialize and listen,
|
||||
* start connection service thread, destroy client.
|
||||
|
@ -211,6 +230,10 @@ private:
|
|||
*/
|
||||
SrsSignalManager* signal_manager;
|
||||
/**
|
||||
* handle in server cycle.
|
||||
*/
|
||||
ISrsServerCycle* handler;
|
||||
/**
|
||||
* user send the signal, convert to variable.
|
||||
*/
|
||||
bool signal_reload;
|
||||
|
@ -227,7 +250,7 @@ public:
|
|||
virtual void destroy();
|
||||
// server startup workflow, @see run_master()
|
||||
public:
|
||||
virtual int initialize();
|
||||
virtual int initialize(ISrsServerCycle* cycle_handler);
|
||||
virtual int initialize_signal();
|
||||
virtual int acquire_pid_file();
|
||||
virtual int initialize_st();
|
||||
|
|
|
@ -288,7 +288,7 @@ int main(int argc, char** argv)
|
|||
* and use initialize to create members, set hooks for instance the reload handler,
|
||||
* all initialize will done in this stage.
|
||||
*/
|
||||
if ((ret = _srs_server->initialize()) != ERROR_SUCCESS) {
|
||||
if ((ret = _srs_server->initialize(NULL)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue