|
|
|
@ -765,6 +765,91 @@ void SrsConfig::print_help(char** argv)
|
|
|
|
|
argv[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SrsConfig::get_deamon()
|
|
|
|
|
{
|
|
|
|
|
srs_assert(root);
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = root->get("daemon");
|
|
|
|
|
if (conf && conf->arg0() == "off") {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_max_connections()
|
|
|
|
|
{
|
|
|
|
|
srs_assert(root);
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = root->get("max_connections");
|
|
|
|
|
if (!conf || conf->arg0().empty()) {
|
|
|
|
|
return 2000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(conf->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* SrsConfig::get_listen()
|
|
|
|
|
{
|
|
|
|
|
return root->get("listen");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string SrsConfig::get_pid_file()
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = root->get("pid");
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_PID_FILE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return conf->arg0();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_pithy_print_publish()
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* pithy = root->get("pithy_print");
|
|
|
|
|
if (!pithy) {
|
|
|
|
|
return SRS_STAGE_PUBLISH_USER_INTERVAL_MS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pithy = pithy->get("publish");
|
|
|
|
|
if (!pithy) {
|
|
|
|
|
return SRS_STAGE_PUBLISH_USER_INTERVAL_MS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(pithy->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_pithy_print_forwarder()
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* pithy = root->get("pithy_print");
|
|
|
|
|
if (!pithy) {
|
|
|
|
|
return SRS_STAGE_FORWARDER_INTERVAL_MS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pithy = pithy->get("forwarder");
|
|
|
|
|
if (!pithy) {
|
|
|
|
|
return SRS_STAGE_FORWARDER_INTERVAL_MS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(pithy->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_pithy_print_hls()
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* pithy = root->get("pithy_print");
|
|
|
|
|
if (!pithy) {
|
|
|
|
|
return SRS_STAGE_HLS_INTERVAL_MS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pithy = pithy->get("hls");
|
|
|
|
|
if (!pithy) {
|
|
|
|
|
return SRS_STAGE_HLS_INTERVAL_MS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(pithy->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* SrsConfig::get_vhost(string vhost)
|
|
|
|
|
{
|
|
|
|
|
srs_assert(root);
|
|
|
|
@ -939,167 +1024,366 @@ bool SrsConfig::get_vhost_enabled(SrsConfDirective* vhost)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* SrsConfig::get_transcode(string vhost, string scope)
|
|
|
|
|
bool SrsConfig::get_gop_cache(string vhost)
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* transcode = conf->get("transcode");
|
|
|
|
|
if (!transcode) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (transcode->arg0() == scope) {
|
|
|
|
|
return transcode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SrsConfig::get_transcode_enabled(SrsConfDirective* transcode)
|
|
|
|
|
{
|
|
|
|
|
if (!transcode) {
|
|
|
|
|
return false;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = transcode->get("enabled");
|
|
|
|
|
if (!conf || conf->arg0() != "on") {
|
|
|
|
|
conf = conf->get("gop_cache");
|
|
|
|
|
if (conf && conf->arg0() == "off") {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string SrsConfig::get_transcode_ffmpeg(SrsConfDirective* transcode)
|
|
|
|
|
bool SrsConfig::get_atc(string vhost)
|
|
|
|
|
{
|
|
|
|
|
if (!transcode) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = transcode->get("ffmpeg");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return conf->arg0();
|
|
|
|
|
}
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
void SrsConfig::get_transcode_engines(SrsConfDirective* transcode, std::vector<SrsConfDirective*>& engines)
|
|
|
|
|
{
|
|
|
|
|
if (!transcode) {
|
|
|
|
|
return;
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < (int)transcode->directives.size(); i++) {
|
|
|
|
|
SrsConfDirective* conf = transcode->directives[i];
|
|
|
|
|
|
|
|
|
|
if (conf->name == "engine") {
|
|
|
|
|
engines.push_back(conf);
|
|
|
|
|
}
|
|
|
|
|
conf = conf->get("atc");
|
|
|
|
|
if (conf && conf->arg0() == "on") {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SrsConfig::get_engine_enabled(SrsConfDirective* engine)
|
|
|
|
|
double SrsConfig::get_queue_length(string vhost)
|
|
|
|
|
{
|
|
|
|
|
if (!engine) {
|
|
|
|
|
return false;
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_QUEUE_LENGTH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = engine->get("enabled");
|
|
|
|
|
if (!conf || conf->arg0() != "on") {
|
|
|
|
|
return false;
|
|
|
|
|
conf = conf->get("queue_length");
|
|
|
|
|
if (!conf || conf->arg0().empty()) {
|
|
|
|
|
return SRS_CONF_DEFAULT_QUEUE_LENGTH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
return ::atoi(conf->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string SrsConfig::get_engine_vcodec(SrsConfDirective* engine)
|
|
|
|
|
SrsConfDirective* SrsConfig::get_forward(string vhost)
|
|
|
|
|
{
|
|
|
|
|
if (!engine) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = engine->get("vcodec");
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return "";
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return conf->arg0();
|
|
|
|
|
return conf->get("forward");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_engine_vbitrate(SrsConfDirective* engine)
|
|
|
|
|
SrsConfDirective* SrsConfig::get_refer(string vhost)
|
|
|
|
|
{
|
|
|
|
|
if (!engine) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = engine->get("vbitrate");
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return 0;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(conf->arg0().c_str());
|
|
|
|
|
return conf->get("refer");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double SrsConfig::get_engine_vfps(SrsConfDirective* engine)
|
|
|
|
|
SrsConfDirective* SrsConfig::get_refer_play(string vhost)
|
|
|
|
|
{
|
|
|
|
|
if (!engine) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = engine->get("vfps");
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return 0;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atof(conf->arg0().c_str());
|
|
|
|
|
return conf->get("refer_play");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_engine_vwidth(SrsConfDirective* engine)
|
|
|
|
|
SrsConfDirective* SrsConfig::get_refer_publish(string vhost)
|
|
|
|
|
{
|
|
|
|
|
if (!engine) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = engine->get("vwidth");
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return 0;
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(conf->arg0().c_str());
|
|
|
|
|
return conf->get("refer_publish");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_engine_vheight(SrsConfDirective* engine)
|
|
|
|
|
int SrsConfig::get_chunk_size(const std::string &vhost)
|
|
|
|
|
{
|
|
|
|
|
if (!engine) {
|
|
|
|
|
return 0;
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_CHUNK_SIZE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = engine->get("vheight");
|
|
|
|
|
|
|
|
|
|
conf = conf->get("chunk_size");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return 0;
|
|
|
|
|
// vhost does not specify the chunk size,
|
|
|
|
|
// use the global instead.
|
|
|
|
|
conf = root->get("chunk_size");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_CHUNK_SIZE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(conf->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ::atoi(conf->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_engine_vthreads(SrsConfDirective* engine)
|
|
|
|
|
bool SrsConfig::get_bw_check_enabled(const string &vhost)
|
|
|
|
|
{
|
|
|
|
|
if (!engine) {
|
|
|
|
|
return 0;
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = engine->get("vthreads");
|
|
|
|
|
|
|
|
|
|
conf = conf->get("bandcheck");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return 0;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(conf->arg0().c_str());
|
|
|
|
|
|
|
|
|
|
conf = conf->get("enabled");
|
|
|
|
|
if (!conf || conf->arg0() != "on") {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string SrsConfig::get_bw_check_key(const string &vhost)
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf = conf->get("bandcheck");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf = conf->get("key");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return conf->arg0();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_bw_check_interval_ms(const string &vhost)
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf = conf->get("bandcheck");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf = conf->get("interval_ms");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(conf->arg0().c_str()) * 1000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_bw_check_limit_kbps(const string &vhost)
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf = conf->get("bandcheck");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf = conf->get("limit_kbps");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(conf->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* SrsConfig::get_transcode(string vhost, string scope)
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* transcode = conf->get("transcode");
|
|
|
|
|
if (!transcode) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (transcode->arg0() == scope) {
|
|
|
|
|
return transcode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SrsConfig::get_transcode_enabled(SrsConfDirective* transcode)
|
|
|
|
|
{
|
|
|
|
|
if (!transcode) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = transcode->get("enabled");
|
|
|
|
|
if (!conf || conf->arg0() != "on") {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string SrsConfig::get_transcode_ffmpeg(SrsConfDirective* transcode)
|
|
|
|
|
{
|
|
|
|
|
if (!transcode) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = transcode->get("ffmpeg");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return conf->arg0();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SrsConfig::get_transcode_engines(SrsConfDirective* transcode, std::vector<SrsConfDirective*>& engines)
|
|
|
|
|
{
|
|
|
|
|
if (!transcode) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < (int)transcode->directives.size(); i++) {
|
|
|
|
|
SrsConfDirective* conf = transcode->directives[i];
|
|
|
|
|
|
|
|
|
|
if (conf->name == "engine") {
|
|
|
|
|
engines.push_back(conf);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SrsConfig::get_engine_enabled(SrsConfDirective* engine)
|
|
|
|
|
{
|
|
|
|
|
if (!engine) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = engine->get("enabled");
|
|
|
|
|
if (!conf || conf->arg0() != "on") {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string SrsConfig::get_engine_vcodec(SrsConfDirective* engine)
|
|
|
|
|
{
|
|
|
|
|
if (!engine) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = engine->get("vcodec");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return conf->arg0();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_engine_vbitrate(SrsConfDirective* engine)
|
|
|
|
|
{
|
|
|
|
|
if (!engine) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = engine->get("vbitrate");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(conf->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double SrsConfig::get_engine_vfps(SrsConfDirective* engine)
|
|
|
|
|
{
|
|
|
|
|
if (!engine) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = engine->get("vfps");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atof(conf->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_engine_vwidth(SrsConfDirective* engine)
|
|
|
|
|
{
|
|
|
|
|
if (!engine) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = engine->get("vwidth");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(conf->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_engine_vheight(SrsConfDirective* engine)
|
|
|
|
|
{
|
|
|
|
|
if (!engine) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = engine->get("vheight");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(conf->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_engine_vthreads(SrsConfDirective* engine)
|
|
|
|
|
{
|
|
|
|
|
if (!engine) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = engine->get("vthreads");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(conf->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string SrsConfig::get_engine_vprofile(SrsConfDirective* engine)
|
|
|
|
@ -1266,89 +1550,6 @@ string SrsConfig::get_engine_output(SrsConfDirective* engine)
|
|
|
|
|
return conf->arg0();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SrsConfig::get_deamon()
|
|
|
|
|
{
|
|
|
|
|
srs_assert(root);
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = root->get("daemon");
|
|
|
|
|
if (conf && conf->arg0() == "off") {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_max_connections()
|
|
|
|
|
{
|
|
|
|
|
srs_assert(root);
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* conf = root->get("max_connections");
|
|
|
|
|
if (!conf || conf->arg0().empty()) {
|
|
|
|
|
return 2000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(conf->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SrsConfig::get_gop_cache(string vhost)
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf = conf->get("gop_cache");
|
|
|
|
|
if (conf && conf->arg0() == "off") {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SrsConfig::get_atc(string vhost)
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf = conf->get("atc");
|
|
|
|
|
if (conf && conf->arg0() == "on") {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double SrsConfig::get_queue_length(string vhost)
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_QUEUE_LENGTH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf = conf->get("queue_length");
|
|
|
|
|
if (!conf || conf->arg0().empty()) {
|
|
|
|
|
return SRS_CONF_DEFAULT_QUEUE_LENGTH;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(conf->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* SrsConfig::get_forward(string vhost)
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return conf->get("forward");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string SrsConfig::get_srs_log_file()
|
|
|
|
|
{
|
|
|
|
|
srs_assert(root);
|
|
|
|
@ -1553,207 +1754,6 @@ int SrsConfig::get_http_stream_listen()
|
|
|
|
|
return 8080;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* SrsConfig::get_refer(string vhost)
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return conf->get("refer");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* SrsConfig::get_refer_play(string vhost)
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return conf->get("refer_play");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* SrsConfig::get_refer_publish(string vhost)
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return conf->get("refer_publish");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SrsConfDirective* SrsConfig::get_listen()
|
|
|
|
|
{
|
|
|
|
|
return root->get("listen");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string SrsConfig::get_pid_file()
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = root->get("pid");
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_PID_FILE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return conf->arg0();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_chunk_size(const std::string &vhost)
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_CHUNK_SIZE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf = conf->get("chunk_size");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
// vhost does not specify the chunk size,
|
|
|
|
|
// use the global instead.
|
|
|
|
|
conf = root->get("chunk_size");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_CHUNK_SIZE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(conf->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(conf->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_pithy_print_publish()
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* pithy = root->get("pithy_print");
|
|
|
|
|
if (!pithy) {
|
|
|
|
|
return SRS_STAGE_PUBLISH_USER_INTERVAL_MS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pithy = pithy->get("publish");
|
|
|
|
|
if (!pithy) {
|
|
|
|
|
return SRS_STAGE_PUBLISH_USER_INTERVAL_MS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(pithy->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_pithy_print_forwarder()
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* pithy = root->get("pithy_print");
|
|
|
|
|
if (!pithy) {
|
|
|
|
|
return SRS_STAGE_FORWARDER_INTERVAL_MS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pithy = pithy->get("forwarder");
|
|
|
|
|
if (!pithy) {
|
|
|
|
|
return SRS_STAGE_FORWARDER_INTERVAL_MS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(pithy->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_pithy_print_hls()
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* pithy = root->get("pithy_print");
|
|
|
|
|
if (!pithy) {
|
|
|
|
|
return SRS_STAGE_HLS_INTERVAL_MS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pithy = pithy->get("hls");
|
|
|
|
|
if (!pithy) {
|
|
|
|
|
return SRS_STAGE_HLS_INTERVAL_MS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(pithy->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SrsConfig::get_bw_check_enabled(const string &vhost)
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf = conf->get("bandcheck");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf = conf->get("enabled");
|
|
|
|
|
if (!conf || conf->arg0() != "on") {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string SrsConfig::get_bw_check_key(const string &vhost)
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf = conf->get("bandcheck");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf = conf->get("key");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return conf->arg0();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_bw_check_interval_ms(const string &vhost)
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf = conf->get("bandcheck");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf = conf->get("interval_ms");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_BANDWIDTH_INTERVAL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(conf->arg0().c_str()) * 1000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_bw_check_limit_kbps(const string &vhost)
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* conf = get_vhost(vhost);
|
|
|
|
|
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf = conf->get("bandcheck");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf = conf->get("limit_kbps");
|
|
|
|
|
if (!conf) {
|
|
|
|
|
return SRS_CONF_DEFAULT_BANDWIDTH_LIMIT_KBPS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::atoi(conf->arg0().c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int SrsConfig::get_pithy_print_encoder()
|
|
|
|
|
{
|
|
|
|
|
SrsConfDirective* pithy = root->get("encoder");
|
|
|
|
|