1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

refine config, warning when feature disabled.

This commit is contained in:
winlin 2014-07-25 09:38:48 +08:00
parent 394cb4b47e
commit 1c27f3b913
4 changed files with 88 additions and 9 deletions

View file

@ -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;
}
}

View file

@ -44,6 +44,8 @@ using namespace std;
#include <srs_app_source.hpp> #include <srs_app_source.hpp>
#include <srs_kernel_file.hpp> #include <srs_kernel_file.hpp>
using namespace _srs_internal;
#define SRS_WIKI_URL_LOG "https://github.com/winlinvip/simple-rtmp-server/wiki/SrsLog" #define SRS_WIKI_URL_LOG "https://github.com/winlinvip/simple-rtmp-server/wiki/SrsLog"
#define FILE_OFFSET(fd) lseek(fd, 0, SEEK_CUR) #define FILE_OFFSET(fd) lseek(fd, 0, SEEK_CUR)
@ -145,13 +147,13 @@ bool SrsConfDirective::is_vhost()
return name == "vhost"; return name == "vhost";
} }
int SrsConfDirective::parse(_srs_internal::SrsConfigBuffer* buffer) int SrsConfDirective::parse(SrsConfigBuffer* buffer)
{ {
return parse_conf(buffer, parse_file); return parse_conf(buffer, parse_file);
} }
// see: ngx_conf_parse // 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; int ret = ERROR_SUCCESS;
@ -213,7 +215,7 @@ int SrsConfDirective::parse_conf(_srs_internal::SrsConfigBuffer* buffer, SrsDire
} }
// see: ngx_conf_read_token // see: ngx_conf_read_token
int SrsConfDirective::read_token(_srs_internal::SrsConfigBuffer* buffer, vector<string>& args, int& line_start) int SrsConfDirective::read_token(SrsConfigBuffer* buffer, vector<string>& args, int& line_start)
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
@ -1166,7 +1168,7 @@ int SrsConfig::parse_file(const char* filename)
return ERROR_SYSTEM_CONFIG_INVALID; return ERROR_SYSTEM_CONFIG_INVALID;
} }
_srs_internal::SrsConfigBuffer buffer; SrsConfigBuffer buffer;
if ((ret = buffer.fullfill(config_file.c_str())) != ERROR_SUCCESS) { if ((ret = buffer.fullfill(config_file.c_str())) != ERROR_SUCCESS) {
return ret; return ret;
@ -1175,13 +1177,9 @@ int SrsConfig::parse_file(const char* filename)
return parse_buffer(&buffer); return parse_buffer(&buffer);
} }
int SrsConfig::parse_buffer(_srs_internal::SrsConfigBuffer* buffer) int SrsConfig::check_config()
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
if ((ret = root->parse(buffer)) != ERROR_SUCCESS) {
return ret;
}
// check empty // check empty
if (root->directives.size() == 0) { if (root->directives.size() == 0) {
@ -1230,9 +1228,67 @@ int SrsConfig::parse_buffer(_srs_internal::SrsConfigBuffer* buffer)
srs_trace("write log to console"); 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<SrsConfDirective*> 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<SrsConfDirective*> 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; 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() string SrsConfig::cwd()
{ {
return _cwd; return _cwd;

View file

@ -338,6 +338,11 @@ protected:
* @remark, protected for the utest to override with mock. * @remark, protected for the utest to override with mock.
*/ */
virtual int parse_buffer(_srs_internal::SrsConfigBuffer* buffer); virtual int parse_buffer(_srs_internal::SrsConfigBuffer* buffer);
private:
/**
* check the parsed config.
*/
virtual int check_config();
// global env // global env
public: public:
/** /**