1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-15 04:42:04 +00:00

merge from 2.0.153

This commit is contained in:
winlin 2015-03-31 18:09:13 +08:00
commit 2d3d628865
9 changed files with 84 additions and 14 deletions

View file

@ -566,6 +566,7 @@ Supported operating systems and hardware:
### SRS 2.0 history ### SRS 2.0 history
* v2.0, 2015-03-31, support server cycle handler. 2.0.153.
* v2.0, 2015-03-31, support on_hls for http hooks. 2.0.152. * v2.0, 2015-03-31, support on_hls for http hooks. 2.0.152.
* v2.0, 2015-03-31, enhanced hls, support deviation for duration. 2.0.151. * v2.0, 2015-03-31, enhanced hls, support deviation for duration. 2.0.151.
* v2.0, 2015-03-30, for [#351](https://github.com/winlinvip/simple-rtmp-server/issues/351), support config the m3u8/ts path for hls. 2.0.149. * v2.0, 2015-03-30, for [#351](https://github.com/winlinvip/simple-rtmp-server/issues/351), support config the m3u8/ts path for hls. 2.0.149.

25
trunk/configure vendored
View file

@ -61,15 +61,16 @@ if [ $SRS_UTEST = YES ]; then SrsUtestMakeEntry="(cd ${SRS_OBJS_DIR}/utest; \$(M
# where srs module is a dir which contains a config file. # where srs module is a dir which contains a config file.
SRS_MODULES=() SRS_MODULES=()
__mfiles=`find modules -name "config"` && for __mfile in $__mfiles; do __mfiles=`find modules -name "config"` && for __mfile in $__mfiles; do
SRS_MODULES+="`dirname $__mfile`" SRS_MODULES+=("`dirname $__mfile`")
done done
# variables for makefile for all modules. # variables for makefile for all modules.
__mphonys="" && __mdefaults="" && __mcleanups="" __mphonys="" && __mdefaults="" && __mcleanups=""
# add each modules for application # add each modules for application
for SRS_MODULE in $SRS_MODULES; do for SRS_MODULE in ${SRS_MODULES[*]}; do
echo "install module at: $SRS_MODULE" echo "install module at: $SRS_MODULE"
. $SRS_MODULE/config . $SRS_MODULE/config
if [[ 0 -eq ${#SRS_MODULE_MAIN[@]} ]]; then continue; fi
__mphonys="$__mphonys $SRS_MODULE_NAME" __mphonys="$__mphonys $SRS_MODULE_NAME"
__mdefaults="$__mdefaults $SRS_MODULE_NAME" __mdefaults="$__mdefaults $SRS_MODULE_NAME"
__mcleanups="$__mcleanups $SRS_MODULE_NAME" __mcleanups="$__mcleanups $SRS_MODULE_NAME"
@ -177,9 +178,9 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
"srs_app_mpegts_udp" "srs_app_rtsp" "srs_app_listener" "srs_app_async_call") "srs_app_mpegts_udp" "srs_app_rtsp" "srs_app_listener" "srs_app_async_call")
DEFINES="" DEFINES=""
# add each modules for app # add each modules for app
for SRS_MODULE in $SRS_MODULES; do for SRS_MODULE in ${SRS_MODULES[*]}; do
. $SRS_MODULE/config . $SRS_MODULE/config
MODULE_FILES+=($SRS_MODULE_APP) MODULE_FILES+=("${SRS_MODULE_APP[*]}")
DEFINES="${DEFINES} ${SRS_MODULE_DEFINES}" DEFINES="${DEFINES} ${SRS_MODULE_DEFINES}"
done done
APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh
@ -201,9 +202,9 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot} ${LibHttpParserRoot}) ModuleLibIncs=(${LibSTRoot} ${SRS_OBJS_DIR} ${LibGperfRoot} ${LibHttpParserRoot})
MODULE_FILES=("srs_main_server") MODULE_FILES=("srs_main_server")
# add each modules for main # add each modules for main
for SRS_MODULE in $SRS_MODULES; do for SRS_MODULE in ${SRS_MODULES[*]}; do
. $SRS_MODULE/config . $SRS_MODULE/config
MODULE_FILES+=($SRS_MODULE_MAIN) MODULE_FILES+=("${SRS_MODULE_MAIN[*]}")
done done
MAIN_INCS="src/main"; MODULE_DIR=${MAIN_INCS} . auto/modules.sh MAIN_INCS="src/main"; MODULE_DIR=${MAIN_INCS} . auto/modules.sh
MAIN_OBJS="${MODULE_OBJS[@]}" MAIN_OBJS="${MODULE_OBJS[@]}"
@ -218,9 +219,9 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
# all main entrances # all main entrances
MAIN_ENTRANCES=("srs_main_server") MAIN_ENTRANCES=("srs_main_server")
# add each modules for main # add each modules for main
for SRS_MODULE in $SRS_MODULES; do for SRS_MODULE in ${SRS_MODULES[*]}; do
. $SRS_MODULE/config . $SRS_MODULE/config
MAIN_ENTRANCES+=($SRS_MODULE_MAIN) MAIN_ENTRANCES+=("${SRS_MODULE_MAIN[*]}")
done done
# #
# all depends libraries # all depends libraries
@ -232,8 +233,10 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
# srs: srs(simple rtmp server) over st(state-threads) # srs: srs(simple rtmp server) over st(state-threads)
BUILD_KEY="srs" APP_MAIN="srs_main_server" APP_NAME="srs" . auto/apps.sh BUILD_KEY="srs" APP_MAIN="srs_main_server" APP_NAME="srs" . auto/apps.sh
# add each modules for application # add each modules for application
for SRS_MODULE in $SRS_MODULES; do for SRS_MODULE in ${SRS_MODULES[*]}; do
. $SRS_MODULE/config . $SRS_MODULE/config
# no SRS_MODULE_MAIN
if [[ 0 -eq ${#SRS_MODULE_MAIN[@]} ]]; then continue; fi
BUILD_KEY="$SRS_MODULE_NAME" APP_MAIN="$SRS_MODULE_MAIN" APP_NAME="$SRS_MODULE_NAME" . auto/apps.sh BUILD_KEY="$SRS_MODULE_NAME" APP_MAIN="$SRS_MODULE_MAIN" APP_NAME="$SRS_MODULE_NAME" . auto/apps.sh
done done
fi fi
@ -340,7 +343,7 @@ server: _prepare_dir
END END
fi fi
# generate all modules entry # generate all modules entry
for SRS_MODULE in $SRS_MODULES; do for SRS_MODULE in ${SRS_MODULES[*]}; do
. $SRS_MODULE/config . $SRS_MODULE/config
# if export librtmp, donot build the bravo-ingest. # if export librtmp, donot build the bravo-ingest.
if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then if [ $SRS_EXPORT_LIBRTMP_PROJECT != NO ]; then
@ -596,7 +599,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
echo -e "${GREEN}note: mips-ubuntu12 for srs are not builded${BLACK}" echo -e "${GREEN}note: mips-ubuntu12 for srs are not builded${BLACK}"
fi fi
# add each modules for application # add each modules for application
for SRS_MODULE in $SRS_MODULES; do for SRS_MODULE in ${SRS_MODULES[*]}; do
echo -e "${GREEN}module: $SRS_MODULE${BLACK}" echo -e "${GREEN}module: $SRS_MODULE${BLACK}"
done done
fi fi

View file

@ -457,6 +457,21 @@ SrsJsonAny* SrsJsonObject::ensure_property_string(string name)
return prop; 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* SrsJsonObject::ensure_property_boolean(string name)
{ {
SrsJsonAny* prop = get_property(name); SrsJsonAny* prop = get_property(name);

View file

@ -149,6 +149,7 @@ public:
virtual void set(std::string key, SrsJsonAny* value); virtual void set(std::string key, SrsJsonAny* value);
virtual SrsJsonAny* get_property(std::string name); virtual SrsJsonAny* get_property(std::string name);
virtual SrsJsonAny* ensure_property_string(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); virtual SrsJsonAny* ensure_property_boolean(std::string name);
}; };

View file

@ -190,4 +190,8 @@ int ISrsReloadHandler::on_reload_ingest_updated(string /*vhost*/, string /*inges
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
int ISrsReloadHandler::on_reload_user_info()
{
return ERROR_SUCCESS;
}

View file

@ -75,6 +75,7 @@ public:
virtual int on_reload_ingest_removed(std::string vhost, std::string ingest_id); 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_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_ingest_updated(std::string vhost, std::string ingest_id);
virtual int on_reload_user_info();
}; };
#endif #endif

View file

@ -389,6 +389,14 @@ void SrsSignalManager::sig_catcher(int signo)
errno = err; errno = err;
} }
ISrsServerCycle::ISrsServerCycle()
{
}
ISrsServerCycle::~ISrsServerCycle()
{
}
SrsServer::SrsServer() SrsServer::SrsServer()
{ {
signal_reload = false; signal_reload = false;
@ -397,6 +405,8 @@ SrsServer::SrsServer()
signal_manager = NULL; signal_manager = NULL;
handler = NULL;
// donot new object in constructor, // donot new object in constructor,
// for some global instance is not ready now, // for some global instance is not ready now,
// new these objects in initialize instead. // new these objects in initialize instead.
@ -456,6 +466,8 @@ void SrsServer::destroy()
srs_freep(signal_manager); srs_freep(signal_manager);
srs_freep(handler);
// @remark never destroy the connections, // @remark never destroy the connections,
// for it's still alive. // for it's still alive.
@ -464,7 +476,7 @@ void SrsServer::destroy()
// and segment fault. // and segment fault.
} }
int SrsServer::initialize() int SrsServer::initialize(ISrsServerCycle* cycle_handler)
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
@ -480,6 +492,11 @@ int SrsServer::initialize()
srs_assert(!signal_manager); srs_assert(!signal_manager);
signal_manager = new SrsSignalManager(this); signal_manager = new SrsSignalManager(this);
handler = cycle_handler;
if(handler && (ret = handler->initialize()) != ERROR_SUCCESS){
return ret;
}
#ifdef SRS_AUTO_HTTP_API #ifdef SRS_AUTO_HTTP_API
if ((ret = http_api_mux->initialize()) != ERROR_SUCCESS) { if ((ret = http_api_mux->initialize()) != ERROR_SUCCESS) {
return ret; return ret;
@ -795,6 +812,11 @@ int SrsServer::do_cycle()
// the deamon thread, update the time cache // the deamon thread, update the time cache
while (true) { 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. // the interval in config.
int heartbeat_max_resolution = (int)(_srs_config->get_heartbeat_interval() / SRS_SYS_CYCLE_INTERVAL); int heartbeat_max_resolution = (int)(_srs_config->get_heartbeat_interval() / SRS_SYS_CYCLE_INTERVAL);

View file

@ -170,6 +170,25 @@ private:
static void sig_catcher(int signo); 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, * SRS RTMP server, initialize and listen,
* start connection service thread, destroy client. * start connection service thread, destroy client.
@ -211,6 +230,10 @@ private:
*/ */
SrsSignalManager* signal_manager; SrsSignalManager* signal_manager;
/** /**
* handle in server cycle.
*/
ISrsServerCycle* handler;
/**
* user send the signal, convert to variable. * user send the signal, convert to variable.
*/ */
bool signal_reload; bool signal_reload;
@ -227,7 +250,7 @@ public:
virtual void destroy(); virtual void destroy();
// server startup workflow, @see run_master() // server startup workflow, @see run_master()
public: public:
virtual int initialize(); virtual int initialize(ISrsServerCycle* cycle_handler);
virtual int initialize_signal(); virtual int initialize_signal();
virtual int acquire_pid_file(); virtual int acquire_pid_file();
virtual int initialize_st(); virtual int initialize_st();

View file

@ -288,7 +288,7 @@ int main(int argc, char** argv)
* and use initialize to create members, set hooks for instance the reload handler, * and use initialize to create members, set hooks for instance the reload handler,
* all initialize will done in this stage. * all initialize will done in this stage.
*/ */
if ((ret = _srs_server->initialize()) != ERROR_SUCCESS) { if ((ret = _srs_server->initialize(NULL)) != ERROR_SUCCESS) {
return ret; return ret;
} }