mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine config, add comments.
This commit is contained in:
parent
f572531eca
commit
1accd8c790
2 changed files with 233 additions and 211 deletions
|
@ -1431,6 +1431,179 @@ vector<SrsConfDirective*> SrsConfig::get_vhosts()
|
||||||
return vhosts;
|
return vhosts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SrsConfig::get_vhost_enabled(string vhost)
|
||||||
|
{
|
||||||
|
SrsConfDirective* vhost_conf = get_vhost(vhost);
|
||||||
|
|
||||||
|
return get_vhost_enabled(vhost_conf);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SrsConfig::get_vhost_enabled(SrsConfDirective* vhost)
|
||||||
|
{
|
||||||
|
if (!vhost) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
SrsConfDirective* conf = vhost->get("enabled");
|
||||||
|
if (!conf) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (conf->arg0() == "off") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 false;
|
||||||
|
}
|
||||||
|
|
||||||
|
conf = conf->get("atc");
|
||||||
|
if (conf && conf->arg0() == "on") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SrsConfig::get_atc_auto(string vhost)
|
||||||
|
{
|
||||||
|
SrsConfDirective* conf = get_vhost(vhost);
|
||||||
|
|
||||||
|
if (!conf) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
conf = conf->get("atc_auto");
|
||||||
|
if (conf && conf->arg0() == "off") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SrsConfig::get_time_jitter(string vhost)
|
||||||
|
{
|
||||||
|
SrsConfDirective* dvr = get_vhost(vhost);
|
||||||
|
|
||||||
|
std::string time_jitter = SRS_CONF_DEFAULT_TIME_JITTER;
|
||||||
|
|
||||||
|
if (dvr) {
|
||||||
|
SrsConfDirective* conf = dvr->get("time_jitter");
|
||||||
|
|
||||||
|
if (conf) {
|
||||||
|
time_jitter = conf->arg0();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return _srs_time_jitter_string2int(time_jitter);
|
||||||
|
}
|
||||||
|
|
||||||
|
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_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");
|
||||||
|
}
|
||||||
|
|
||||||
|
int SrsConfig::get_chunk_size(const 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());
|
||||||
|
}
|
||||||
|
|
||||||
|
SrsConfDirective* SrsConfig::get_forward(string vhost)
|
||||||
|
{
|
||||||
|
SrsConfDirective* conf = get_vhost(vhost);
|
||||||
|
|
||||||
|
if (!conf) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return conf->get("forward");
|
||||||
|
}
|
||||||
|
|
||||||
SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost)
|
SrsConfDirective* SrsConfig::get_vhost_on_connect(string vhost)
|
||||||
{
|
{
|
||||||
SrsConfDirective* conf = get_vhost(vhost);
|
SrsConfDirective* conf = get_vhost(vhost);
|
||||||
|
@ -1578,179 +1751,6 @@ SrsConfDirective* SrsConfig::get_vhost_on_dvr_hss_reap_flv(string vhost)
|
||||||
return conf->get("on_dvr_hss_reap_flv");
|
return conf->get("on_dvr_hss_reap_flv");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SrsConfig::get_vhost_enabled(string vhost)
|
|
||||||
{
|
|
||||||
SrsConfDirective* vhost_conf = get_vhost(vhost);
|
|
||||||
|
|
||||||
return get_vhost_enabled(vhost_conf);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SrsConfig::get_vhost_enabled(SrsConfDirective* vhost)
|
|
||||||
{
|
|
||||||
if (!vhost) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SrsConfDirective* conf = vhost->get("enabled");
|
|
||||||
if (!conf) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (conf->arg0() == "off") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 false;
|
|
||||||
}
|
|
||||||
|
|
||||||
conf = conf->get("atc");
|
|
||||||
if (conf && conf->arg0() == "on") {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SrsConfig::get_atc_auto(string vhost)
|
|
||||||
{
|
|
||||||
SrsConfDirective* conf = get_vhost(vhost);
|
|
||||||
|
|
||||||
if (!conf) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
conf = conf->get("atc_auto");
|
|
||||||
if (conf && conf->arg0() == "off") {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int SrsConfig::get_time_jitter(string vhost)
|
|
||||||
{
|
|
||||||
SrsConfDirective* dvr = get_vhost(vhost);
|
|
||||||
|
|
||||||
std::string time_jitter = SRS_CONF_DEFAULT_TIME_JITTER;
|
|
||||||
|
|
||||||
if (dvr) {
|
|
||||||
SrsConfDirective* conf = dvr->get("time_jitter");
|
|
||||||
|
|
||||||
if (conf) {
|
|
||||||
time_jitter = conf->arg0();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return _srs_time_jitter_string2int(time_jitter);
|
|
||||||
}
|
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
||||||
|
|
||||||
int SrsConfig::get_chunk_size(const 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());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SrsConfig::get_bw_check_enabled(const string &vhost)
|
bool SrsConfig::get_bw_check_enabled(const string &vhost)
|
||||||
{
|
{
|
||||||
SrsConfDirective* conf = get_vhost(vhost);
|
SrsConfDirective* conf = get_vhost(vhost);
|
||||||
|
|
|
@ -422,55 +422,38 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual std::vector<SrsConfDirective*> get_vhosts();
|
virtual std::vector<SrsConfDirective*> get_vhosts();
|
||||||
/**
|
/**
|
||||||
*
|
* whether vhost is enabled
|
||||||
|
* @param vhost, the vhost name.
|
||||||
|
* @return true when vhost is ok; otherwise, false.
|
||||||
*/
|
*/
|
||||||
virtual bool get_vhost_enabled(std::string vhost);
|
virtual bool get_vhost_enabled(std::string vhost);
|
||||||
/**
|
/**
|
||||||
*
|
* whether vhost is enabled
|
||||||
|
* @param vhost, the vhost directive.
|
||||||
|
* @return true when vhost is ok; otherwise, false.
|
||||||
*/
|
*/
|
||||||
virtual bool get_vhost_enabled(SrsConfDirective* vhost);
|
virtual bool get_vhost_enabled(SrsConfDirective* vhost);
|
||||||
/**
|
/**
|
||||||
*
|
* whether gop_cache is enabled of vhost.
|
||||||
*/
|
* gop_cache used to cache last gop, for client to fast startup.
|
||||||
virtual SrsConfDirective* get_vhost_on_connect(std::string vhost);
|
* @return true when gop_cache is ok; otherwise, false.
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
virtual SrsConfDirective* get_vhost_on_close(std::string vhost);
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
virtual SrsConfDirective* get_vhost_on_publish(std::string vhost);
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
virtual SrsConfDirective* get_vhost_on_unpublish(std::string vhost);
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
virtual SrsConfDirective* get_vhost_on_play(std::string vhost);
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
virtual SrsConfDirective* get_vhost_on_stop(std::string vhost);
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
virtual SrsConfDirective* get_vhost_on_dvr_hss_reap_flv(std::string vhost);
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
virtual bool get_gop_cache(std::string vhost);
|
virtual bool get_gop_cache(std::string vhost);
|
||||||
/**
|
/**
|
||||||
*
|
* whether atc is enabled of vhost.
|
||||||
|
* atc always use encoder timestamp, SRS never adjust the time.
|
||||||
|
* @return true when atc is ok; otherwise, false.
|
||||||
*/
|
*/
|
||||||
virtual bool get_atc(std::string vhost);
|
virtual bool get_atc(std::string vhost);
|
||||||
/**
|
/**
|
||||||
*
|
* whether atc_auto is enabled of vhost.
|
||||||
|
* atc_auto used to auto enable atc, when metadata specified the bravo_atc.
|
||||||
|
* @return true when atc_auto is ok; otherwise, false.
|
||||||
*/
|
*/
|
||||||
virtual bool get_atc_auto(std::string vhost);
|
virtual bool get_atc_auto(std::string vhost);
|
||||||
/**
|
/**
|
||||||
*
|
* get the time_jitter algorithm.
|
||||||
|
* @return the time_jitter algorithm, defined in SrsRtmpJitterAlgorithm.
|
||||||
*/
|
*/
|
||||||
virtual int get_time_jitter(std::string vhost);
|
virtual int get_time_jitter(std::string vhost);
|
||||||
/**
|
/**
|
||||||
|
@ -480,10 +463,6 @@ public:
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
virtual SrsConfDirective* get_forward(std::string vhost);
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
virtual SrsConfDirective* get_refer(std::string vhost);
|
virtual SrsConfDirective* get_refer(std::string vhost);
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -497,6 +476,49 @@ public:
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
virtual int get_chunk_size(const std::string& vhost);
|
virtual int get_chunk_size(const std::string& vhost);
|
||||||
|
// forward section
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
virtual SrsConfDirective* get_forward(std::string vhost);
|
||||||
|
// http_hooks section
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* get the on_connect callbacks of vhost.
|
||||||
|
* @return the on_connect callback directive, the args is the url to callback.
|
||||||
|
*/
|
||||||
|
virtual SrsConfDirective* get_vhost_on_connect(std::string vhost);
|
||||||
|
/**
|
||||||
|
* get the on_close callbacks of vhost.
|
||||||
|
* @return the on_close callback directive, the args is the url to callback.
|
||||||
|
*/
|
||||||
|
virtual SrsConfDirective* get_vhost_on_close(std::string vhost);
|
||||||
|
/**
|
||||||
|
* get the on_publish callbacks of vhost.
|
||||||
|
* @return the on_publish callback directive, the args is the url to callback.
|
||||||
|
*/
|
||||||
|
virtual SrsConfDirective* get_vhost_on_publish(std::string vhost);
|
||||||
|
/**
|
||||||
|
* get the on_unpublish callbacks of vhost.
|
||||||
|
* @return the on_unpublish callback directive, the args is the url to callback.
|
||||||
|
*/
|
||||||
|
virtual SrsConfDirective* get_vhost_on_unpublish(std::string vhost);
|
||||||
|
/**
|
||||||
|
* get the on_play callbacks of vhost.
|
||||||
|
* @return the on_play callback directive, the args is the url to callback.
|
||||||
|
*/
|
||||||
|
virtual SrsConfDirective* get_vhost_on_play(std::string vhost);
|
||||||
|
/**
|
||||||
|
* get the on_stop callbacks of vhost.
|
||||||
|
* @return the on_stop callback directive, the args is the url to callback.
|
||||||
|
*/
|
||||||
|
virtual SrsConfDirective* get_vhost_on_stop(std::string vhost);
|
||||||
|
/**
|
||||||
|
* get the on_dvr_hss_reap_flv callbacks of vhost.
|
||||||
|
* @return the on_dvr_hss_reap_flv callback directive, the args is the url to callback.
|
||||||
|
*/
|
||||||
|
virtual SrsConfDirective* get_vhost_on_dvr_hss_reap_flv(std::string vhost);
|
||||||
// bwct(bandwidth check tool) section
|
// bwct(bandwidth check tool) section
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue