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

for #319, move smi and rsh to play

This commit is contained in:
winlin 2015-08-30 07:36:06 +08:00
parent f7c893d907
commit bc24c0407b
7 changed files with 43 additions and 63 deletions

View file

@ -437,6 +437,21 @@ vhost play.srs.com {
# the value recomment is [300, 1800]
# default: 350
mw_latency 350;
# the minimal packets send interval in ms,
# used to control the ndiff of stream by srs_rtmp_dump,
# for example, some device can only accept some stream which
# delivery packets in constant interval(not cbr).
# @remark 0 to disable the minimal interval.
# @remark >0 to make the srs to send message one by one.
# @remark user can get the right packets interval in ms by srs_rtmp_dump.
# default: 0
send_min_interval 10.0;
# whether reduce the sequence header,
# for some client which cannot got duplicated sequence header,
# while the sequence header is not changed yet.
# default: off
reduce_sequence_header on;
}
}
@ -501,25 +516,12 @@ vhost stream.control.com {
# @see scope.vhost.srs.com
tcp_nodelay on;
# the minimal packets send interval in ms,
# used to control the ndiff of stream by srs_rtmp_dump,
# for example, some device can only accept some stream which
# delivery packets in constant interval(not cbr).
# @remark 0 to disable the minimal interval.
# @remark >0 to make the srs to send message one by one.
# @remark user can get the right packets interval in ms by srs_rtmp_dump.
# default: 0
send_min_interval 10.0;
# whether reduce the sequence header,
# for some client which cannot got duplicated sequence header,
# while the sequence header is not changed yet.
# default: off
reduce_sequence_header on;
# @see play.srs.com
play {
mw_latency 100;
queue_length 10;
send_min_interval 10.0;
reduce_sequence_header on;
}
# @see publish.srs.com

View file

@ -79,7 +79,6 @@ vhost vhost.srs.com {
gop_cache off;
queue_length 10;
# TODO
send_min_interval 10.0;
reduce_sequence_header on;
}

View file

@ -817,18 +817,6 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root)
srs_trace("vhost %s reload publish success.", vhost.c_str());
}
// smi(send_min_interval), only one per vhost
if (!srs_directive_equals(new_vhost->get("send_min_interval"), old_vhost->get("send_min_interval"))) {
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
ISrsReloadHandler* subscribe = *it;
if ((ret = subscribe->on_reload_vhost_smi(vhost)) != ERROR_SUCCESS) {
srs_error("vhost %s notify subscribes smi failed. ret=%d", vhost.c_str(), ret);
return ret;
}
}
srs_trace("vhost %s reload smi success.", vhost.c_str());
}
// http_static, only one per vhost.
if (!srs_directive_equals(new_vhost->get("http_static"), old_vhost->get("http_static"))) {
for (it = subscribes.begin(); it != subscribes.end(); ++it) {
@ -1699,14 +1687,6 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj)
obj->set("debug_srs_upnode", dir->dumps_arg0_to_boolean());
}
// stream control
if ((dir = vhost->get("send_min_interval")) != NULL) {
obj->set("send_min_interval", dir->dumps_arg0_to_number());
}
if ((dir = vhost->get("reduce_sequence_header")) != NULL) {
obj->set("reduce_sequence_header", dir->dumps_arg0_to_boolean());
}
// play
if ((dir = vhost->get("play")) != NULL) {
SrsAmf0Object* play = SrsAmf0Any::object();
@ -1729,6 +1709,10 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj)
play->set("gop_cache", sdir->dumps_arg0_to_boolean());
} else if (sdir->name == "queue_length") {
play->set("queue_length", sdir->dumps_arg0_to_number());
} else if (sdir->name == "reduce_sequence_header") {
play->set("reduce_sequence_header", sdir->dumps_arg0_to_boolean());
} else if (sdir->name == "send_min_interval") {
play->set("send_min_interval", sdir->dumps_arg0_to_number());
}
}
}
@ -2611,7 +2595,6 @@ int SrsConfig::check_config()
&& n != "dvr" && n != "ingest" && n != "hls" && n != "http_hooks"
&& n != "refer" && n != "forward" && n != "transcode" && n != "bandcheck"
&& n != "debug_srs_upnode" && n != "play" && n != "publish"
&& n != "send_min_interval" && n != "reduce_sequence_header"
&& n != "security" && n != "http_remux"
&& n != "http_static" && n != "hds" && n != "exec"
) {
@ -2652,8 +2635,8 @@ int SrsConfig::check_config()
} else if (n == "play") {
for (int j = 0; j < (int)conf->directives.size(); j++) {
string m = conf->at(j)->name.c_str();
if (m != "time_jitter" && m != "mix_correct" && m != "atc" && m != "atc_auto"
&& m != "mw_latency" && m != "gop_cache" && m != "queue_length"
if (m != "time_jitter" && m != "mix_correct" && m != "atc" && m != "atc_auto" && m != "mw_latency"
&& m != "gop_cache" && m != "queue_length" && m != "send_min_interval" && m != "reduce_sequence_header"
) {
ret = ERROR_SYSTEM_CONFIG_INVALID;
srs_error("unsupported vhost play directive %s, ret=%d", m.c_str(), ret);
@ -3505,6 +3488,11 @@ double SrsConfig::get_send_min_interval(string vhost)
return DEFAULT;
}
conf = conf->get("play");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
conf = conf->get("send_min_interval");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
@ -3522,6 +3510,11 @@ bool SrsConfig::get_reduce_sequence_header(string vhost)
return DEFAULT;
}
conf = conf->get("play");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
conf = conf->get("reduce_sequence_header");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
@ -5768,7 +5761,8 @@ int srs_config_transform_vhost(SrsConfDirective* root)
// SRS3+:
// vhost { play { shadow; } }
if (n == "time_jitter" || n == "mix_correct" || n == "atc" || n == "atc_auto"
|| n == "mw_latency" || n == "gop_cache" || n == "queue_length"
|| n == "mw_latency" || n == "gop_cache" || n == "queue_length" || n == "send_min_interval"
|| n == "reduce_sequence_header"
) {
it = dir->directives.erase(it);

View file

@ -155,11 +155,6 @@ int ISrsReloadHandler::on_reload_vhost_publish(string /*vhost*/)
return ERROR_SUCCESS;
}
int ISrsReloadHandler::on_reload_vhost_smi(string /*vhost*/)
{
return ERROR_SUCCESS;
}
int ISrsReloadHandler::on_reload_vhost_tcp_nodelay(string /*vhost*/)
{
return ERROR_SUCCESS;

View file

@ -70,7 +70,6 @@ public:
virtual int on_reload_vhost_hds(std::string vhost);
virtual int on_reload_vhost_dvr(std::string vhost);
virtual int on_reload_vhost_publish(std::string vhost);
virtual int on_reload_vhost_smi(std::string vhost);
virtual int on_reload_vhost_tcp_nodelay(std::string vhost);
virtual int on_reload_vhost_realtime(std::string vhost);
virtual int on_reload_vhost_chunk_size(std::string vhost);

View file

@ -239,21 +239,13 @@ int SrsRtmpConn::on_reload_vhost_play(string vhost)
return ret;
}
return ret;
}
int SrsRtmpConn::on_reload_vhost_smi(string vhost)
{
int ret = ERROR_SUCCESS;
if (req->vhost != vhost) {
return ret;
// send_min_interval
if (true) {
double v = _srs_config->get_send_min_interval(vhost);
if (v != send_min_interval) {
srs_trace("apply smi %.2f=>%.2f", send_min_interval, v);
send_min_interval = v;
}
double smi = _srs_config->get_send_min_interval(vhost);
if (smi != send_min_interval) {
srs_trace("apply smi %.2f=>%.2f", send_min_interval, smi);
send_min_interval = smi;
}
return ret;

View file

@ -104,7 +104,6 @@ protected:
public:
virtual int on_reload_vhost_removed(std::string vhost);
virtual int on_reload_vhost_play(std::string vhost);
virtual int on_reload_vhost_smi(std::string vhost);
virtual int on_reload_vhost_tcp_nodelay(std::string vhost);
virtual int on_reload_vhost_realtime(std::string vhost);
virtual int on_reload_vhost_publish(std::string vhost);