mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine the config, support directly parse file.
This commit is contained in:
parent
b8e70f8538
commit
fbbe46d272
6 changed files with 66 additions and 48 deletions
13
trunk/configure
vendored
13
trunk/configure
vendored
|
@ -51,9 +51,9 @@ if [ $SRS_UTEST = YES ]; then SrsUtestMakeEntry="(cd ${SRS_OBJS_DIR}/utest; \$(M
|
|||
#####################################################################################
|
||||
# finger out modules to install.
|
||||
# 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
|
||||
SRS_MODULES="$SRS_MODULES `dirname $__mfile`"
|
||||
SRS_MODULES+="`dirname $__mfile`"
|
||||
done
|
||||
|
||||
# variables for makefile for all modules.
|
||||
|
@ -177,6 +177,11 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
|||
"srs_app_kbps" "srs_app_heartbeat" "srs_app_empty" "srs_app_http_client"
|
||||
"srs_app_recv_thread" "srs_app_security" "srs_app_statistic"
|
||||
"srs_app_mpegts_udp" "srs_app_rtsp" "srs_app_listener")
|
||||
# add each modules for app
|
||||
for SRS_MODULE in $SRS_MODULES; do
|
||||
. $SRS_MODULE/config
|
||||
MODULE_FILES+=($SRS_MODULE_APP)
|
||||
done
|
||||
APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh
|
||||
APP_OBJS="${MODULE_OBJS[@]}"
|
||||
fi
|
||||
|
@ -198,7 +203,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
|||
# add each modules for main
|
||||
for SRS_MODULE in $SRS_MODULES; do
|
||||
. $SRS_MODULE/config
|
||||
MODULE_FILES="${MODULE_FILES[@]} $SRS_MODULE_MAIN"
|
||||
MODULE_FILES+=($SRS_MODULE_MAIN)
|
||||
done
|
||||
MAIN_INCS="src/main"; MODULE_DIR=${MAIN_INCS} . auto/modules.sh
|
||||
MAIN_OBJS="${MODULE_OBJS[@]}"
|
||||
|
@ -215,7 +220,7 @@ if [ $SRS_EXPORT_LIBRTMP_PROJECT = NO ]; then
|
|||
# add each modules for main
|
||||
for SRS_MODULE in $SRS_MODULES; do
|
||||
. $SRS_MODULE/config
|
||||
MAIN_ENTRANCES="${MAIN_ENTRANCES[@]} $SRS_MODULE_MAIN"
|
||||
MAIN_ENTRANCES+=($SRS_MODULE_MAIN)
|
||||
done
|
||||
#
|
||||
# all depends libraries
|
||||
|
|
|
@ -6,5 +6,6 @@ SRS模块规则:
|
|||
模块中需要定义变量,例如:
|
||||
1. SRS_MODULE_NAME:模块名称,用来做Makefile的phony以及执行binary文件名。
|
||||
2. SRS_MODULE_MAIN:模块的main函数所在的cpp文件,在src/main目录。
|
||||
3. SRS_MODULE_APP:模块在src/app目录的源文件列表。
|
||||
|
||||
winlin, 2015.3
|
||||
|
|
|
@ -351,11 +351,11 @@ private:
|
|||
* print help and exit.
|
||||
*/
|
||||
virtual void print_help(char** argv);
|
||||
public:
|
||||
/**
|
||||
* parse the config file, which is specified by cli.
|
||||
*/
|
||||
virtual int parse_file(const char* filename);
|
||||
public:
|
||||
/**
|
||||
* check the parsed config.
|
||||
*/
|
||||
|
|
|
@ -488,49 +488,6 @@ int SrsServer::initialize()
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef SRS_AUTO_HTTP_API
|
||||
srs_assert(http_api_mux);
|
||||
if ((ret = http_api_mux->handle("/", new SrsGoApiRoot())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api", new SrsGoApiApi())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1", new SrsGoApiV1())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/versions", new SrsGoApiVersion())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/summaries", new SrsGoApiSummaries())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/rusages", new SrsGoApiRusages())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/self_proc_stats", new SrsGoApiSelfProcStats())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/system_proc_stats", new SrsGoApiSystemProcStats())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/meminfos", new SrsGoApiMemInfos())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/authors", new SrsGoApiAuthors())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/requests", new SrsGoApiRequests())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/vhosts", new SrsGoApiVhosts())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/streams", new SrsGoApiStreams())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SRS_AUTO_HTTP_SERVER
|
||||
srs_assert(http_stream_mux);
|
||||
if ((ret = http_stream_mux->initialize()) != ERROR_SUCCESS) {
|
||||
|
@ -689,6 +646,56 @@ int SrsServer::register_signal()
|
|||
return signal_manager->start();
|
||||
}
|
||||
|
||||
int SrsServer::http_handle()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
#ifdef SRS_AUTO_HTTP_API
|
||||
srs_assert(http_api_mux);
|
||||
if ((ret = http_api_mux->handle("/", new SrsGoApiRoot())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api", new SrsGoApiApi())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1", new SrsGoApiV1())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/versions", new SrsGoApiVersion())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/summaries", new SrsGoApiSummaries())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/rusages", new SrsGoApiRusages())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/self_proc_stats", new SrsGoApiSelfProcStats())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/system_proc_stats", new SrsGoApiSystemProcStats())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/meminfos", new SrsGoApiMemInfos())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/authors", new SrsGoApiAuthors())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/requests", new SrsGoApiRequests())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/vhosts", new SrsGoApiVhosts())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
if ((ret = http_api_mux->handle("/api/v1/streams", new SrsGoApiStreams())) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SrsServer::ingest()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
|
|
@ -236,6 +236,7 @@ public:
|
|||
virtual int initialize_st();
|
||||
virtual int listen();
|
||||
virtual int register_signal();
|
||||
virtual int http_handle();
|
||||
virtual int ingest();
|
||||
virtual int cycle();
|
||||
// server utility
|
||||
|
|
|
@ -336,6 +336,10 @@ int run_master()
|
|||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = _srs_server->http_handle()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = _srs_server->ingest()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue