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

support http heartbeat, 0.9.107

This commit is contained in:
winlin 2014-05-19 17:39:01 +08:00
parent cb95b5909c
commit ef0f7f4da8
14 changed files with 459 additions and 185 deletions

View file

@ -1422,17 +1422,6 @@ string SrsConfig::get_pid_file()
return conf->arg0();
}
string SrsConfig::get_heartbeat_url()
{
SrsConfDirective* conf = root->get("heartbeat");
if (!conf) {
return "";
}
return conf->arg0();
}
int SrsConfig::get_pithy_print_publish()
{
SrsConfDirective* pithy = root->get("pithy_print");
@ -2787,6 +2776,74 @@ string SrsConfig::get_vhost_http_dir(string vhost)
return conf->arg0();
}
SrsConfDirective* SrsConfig::get_heartbeart()
{
return root->get("heartbeat");
}
bool SrsConfig::get_heartbeat_enabled()
{
SrsConfDirective* conf = get_heartbeart();
if (!conf) {
return SRS_CONF_DEFAULT_HTTP_HEAETBEAT_ENABLED;
}
conf = conf->get("enabled");
if (!conf || conf->arg0() != "on") {
return SRS_CONF_DEFAULT_HTTP_HEAETBEAT_ENABLED;
}
return true;
}
int64_t SrsConfig::get_heartbeat_interval()
{
SrsConfDirective* conf = get_heartbeart();
if (!conf) {
return (int64_t)(SRS_CONF_DEFAULT_HTTP_HEAETBEAT_INTERVAL * 1000);
}
conf = conf->get("interval");
if (!conf || conf->arg0().empty()) {
return (int64_t)(SRS_CONF_DEFAULT_HTTP_HEAETBEAT_INTERVAL * 1000);
}
return (int64_t)(::atof(conf->arg0().c_str()) * 1000);
}
string SrsConfig::get_heartbeat_url()
{
SrsConfDirective* conf = get_heartbeart();
if (!conf) {
return SRS_CONF_DEFAULT_HTTP_HEAETBEAT_URL;
}
conf = conf->get("url");
if (!conf || conf->arg0().empty()) {
return SRS_CONF_DEFAULT_HTTP_HEAETBEAT_URL;
}
return conf->arg0();
}
string SrsConfig::get_heartbeat_device_id()
{
SrsConfDirective* conf = get_heartbeart();
if (!conf) {
return "";
}
conf = conf->get("device_id");
if (!conf || conf->arg0().empty()) {
return "";
}
return conf->arg0();
}
bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b)
{
// both NULL, equal.