diff --git a/trunk/conf/ffmpeg.conf b/trunk/conf/ffmpeg.transcode.conf similarity index 100% rename from trunk/conf/ffmpeg.conf rename to trunk/conf/ffmpeg.transcode.conf diff --git a/trunk/conf/http.hooks.callback.conf b/trunk/conf/http.hooks.callback.conf new file mode 100644 index 000000000..12d165d6c --- /dev/null +++ b/trunk/conf/http.hooks.callback.conf @@ -0,0 +1,18 @@ +# http-hooks or http-callbacks config for srs. +# @see full.conf for detail config. + +listen 1935; +srs_log_tank file; +srs_log_file ./objs/srs.log; +vhost __defaultVhost__ { + http_hooks { + enabled on; + on_connect http://127.0.0.1:8085/api/v1/clients http://localhost:8085/api/v1/clients; + on_close http://127.0.0.1:8085/api/v1/clients http://localhost:8085/api/v1/clients; + on_publish http://127.0.0.1:8085/api/v1/streams http://localhost:8085/api/v1/streams; + on_unpublish http://127.0.0.1:8085/api/v1/streams http://localhost:8085/api/v1/streams; + on_play http://127.0.0.1:8085/api/v1/sessions http://localhost:8085/api/v1/sessions; + on_stop http://127.0.0.1:8085/api/v1/sessions http://localhost:8085/api/v1/sessions; + on_dvr_hss_reap_flv http://127.0.0.1:8085/api/v1/dvrs http://localhost:8085/api/v1/dvrs; + } +} diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index 747ddb7dd..dfe334a59 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -44,6 +44,8 @@ using namespace std; #include #include +using namespace _srs_internal; + #define SRS_WIKI_URL_LOG "https://github.com/winlinvip/simple-rtmp-server/wiki/SrsLog" #define FILE_OFFSET(fd) lseek(fd, 0, SEEK_CUR) @@ -145,13 +147,13 @@ bool SrsConfDirective::is_vhost() return name == "vhost"; } -int SrsConfDirective::parse(_srs_internal::SrsConfigBuffer* buffer) +int SrsConfDirective::parse(SrsConfigBuffer* buffer) { return parse_conf(buffer, parse_file); } // see: ngx_conf_parse -int SrsConfDirective::parse_conf(_srs_internal::SrsConfigBuffer* buffer, SrsDirectiveType type) +int SrsConfDirective::parse_conf(SrsConfigBuffer* buffer, SrsDirectiveType type) { int ret = ERROR_SUCCESS; @@ -213,7 +215,7 @@ int SrsConfDirective::parse_conf(_srs_internal::SrsConfigBuffer* buffer, SrsDire } // see: ngx_conf_read_token -int SrsConfDirective::read_token(_srs_internal::SrsConfigBuffer* buffer, vector& args, int& line_start) +int SrsConfDirective::read_token(SrsConfigBuffer* buffer, vector& args, int& line_start) { int ret = ERROR_SUCCESS; @@ -1166,7 +1168,7 @@ int SrsConfig::parse_file(const char* filename) return ERROR_SYSTEM_CONFIG_INVALID; } - _srs_internal::SrsConfigBuffer buffer; + SrsConfigBuffer buffer; if ((ret = buffer.fullfill(config_file.c_str())) != ERROR_SUCCESS) { return ret; @@ -1175,13 +1177,9 @@ int SrsConfig::parse_file(const char* filename) return parse_buffer(&buffer); } -int SrsConfig::parse_buffer(_srs_internal::SrsConfigBuffer* buffer) +int SrsConfig::check_config() { int ret = ERROR_SUCCESS; - - if ((ret = root->parse(buffer)) != ERROR_SUCCESS) { - return ret; - } // check empty if (root->directives.size() == 0) { @@ -1230,9 +1228,67 @@ int SrsConfig::parse_buffer(_srs_internal::SrsConfigBuffer* buffer) srs_trace("write log to console"); } + // check features +#ifndef SRS_AUTO_HTTP_SERVER + if (get_http_stream_enabled()) { + srs_warn("http_stream is disabled by configure"); + } +#endif +#ifndef SRS_AUTO_HTTP_API + if (get_http_api_enabled()) { + srs_warn("http_api is disabled by configure"); + } +#endif + vector vhosts = get_vhosts(); + for (int i = 0; i < (int)vhosts.size(); i++) { + SrsConfDirective* vhost = vhosts[i]; +#ifndef SRS_AUTO_DVR + if (get_dvr_enabled(vhost->arg0())) { + srs_warn("dvr of vhost %s is disabled by configure", vhost->arg0().c_str()); + } +#endif +#ifndef SRS_AUTO_HLS + if (get_hls_enabled(vhost->arg0())) { + srs_warn("hls of vhost %s is disabled by configure", vhost->arg0().c_str()); + } +#endif +#ifndef SRS_AUTO_HTTP_CALLBACK + if (get_vhost_http_hooks_enabled(vhost->arg0())) { + srs_warn("http_hooks of vhost %s is disabled by configure", vhost->arg0().c_str()); + } +#endif +#ifndef SRS_AUTO_TRANSCODE + if (get_transcode_enabled(get_transcode(vhost->arg0(), ""))) { + srs_warn("transcode of vhost %s is disabled by configure", vhost->arg0().c_str()); + } +#endif +#ifndef SRS_AUTO_INGEST + vector ingesters = get_ingesters(vhost->arg0()); + for (int j = 0; j < (int)ingesters.size(); j++) { + SrsConfDirective* ingest = ingesters[j]; + if (get_ingest_enabled(ingest)) { + srs_warn("ingest %s of vhost %s is disabled by configure", + ingest->arg0().c_str(), vhost->arg0().c_str() + ); + } + } +#endif + } + return ret; } +int SrsConfig::parse_buffer(SrsConfigBuffer* buffer) +{ + int ret = ERROR_SUCCESS; + + if ((ret = root->parse(buffer)) != ERROR_SUCCESS) { + return ret; + } + + return check_config(); +} + string SrsConfig::cwd() { return _cwd; diff --git a/trunk/src/app/srs_app_config.hpp b/trunk/src/app/srs_app_config.hpp index 384dc76ee..4b2b2db11 100644 --- a/trunk/src/app/srs_app_config.hpp +++ b/trunk/src/app/srs_app_config.hpp @@ -338,6 +338,11 @@ protected: * @remark, protected for the utest to override with mock. */ virtual int parse_buffer(_srs_internal::SrsConfigBuffer* buffer); +private: + /** + * check the parsed config. + */ + virtual int check_config(); // global env public: /**