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

for #730, support config in/out ack size. 3.0.13

This commit is contained in:
winlin 2017-01-06 14:57:54 +08:00
parent bbbc40f9c2
commit 1b175b1107
7 changed files with 86 additions and 6 deletions

View file

@ -3826,6 +3826,7 @@ int SrsConfig::check_config()
&& n != "play" && n != "publish" && n != "cluster"
&& n != "security" && n != "http_remux"
&& n != "http_static" && n != "hds" && n != "exec"
&& n != "in_ack_size" && n != "out_ack_size"
) {
ret = ERROR_SYSTEM_CONFIG_INVALID;
srs_error("unsupported vhost directive %s, ret=%d", n.c_str(), ret);
@ -4694,6 +4695,40 @@ SrsConfDirective* SrsConfig::get_refer_publish(string vhost)
return conf->get("publish");
}
int SrsConfig::get_in_ack_size(string vhost)
{
static int DEFAULT = 0;
SrsConfDirective* conf = get_vhost(vhost);
if (!conf) {
return DEFAULT;
}
conf = conf->get("in_ack_size");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return ::atoi(conf->arg0().c_str());
}
int SrsConfig::get_out_ack_size(string vhost)
{
static int DEFAULT = 2500000;
SrsConfDirective* conf = get_vhost(vhost);
if (!conf) {
return DEFAULT;
}
conf = conf->get("out_ack_size");
if (!conf || conf->arg0().empty()) {
return DEFAULT;
}
return ::atoi(conf->arg0().c_str());
}
int SrsConfig::get_chunk_size(string vhost)
{
if (vhost.empty()) {

View file

@ -754,6 +754,10 @@ public:
* @return the refer, NULL for not configed.
*/
virtual SrsConfDirective* get_refer_publish(std::string vhost);
// Get the input default ack size, which is generally set by message from peer.
virtual int get_in_ack_size(std::string vhost);
// Get the output default ack size, to notify the peer to send acknowledge to server.
virtual int get_out_ack_size(std::string vhost);
/**
* get the chunk size of vhost.
* @param vhost, the vhost to get the chunk size. use global if not specified.

View file

@ -578,11 +578,17 @@ int SrsRtmpConn::service_cycle()
{
int ret = ERROR_SUCCESS;
if ((ret = rtmp->set_window_ack_size((int)(2.5 * 1000 * 1000))) != ERROR_SUCCESS) {
srs_error("set window acknowledgement size failed. ret=%d", ret);
int out_ack_size = _srs_config->get_out_ack_size(req->vhost);
if (out_ack_size && (ret = rtmp->set_window_ack_size(out_ack_size)) != ERROR_SUCCESS) {
srs_error("set output window acknowledgement size failed. ret=%d", ret);
return ret;
}
int in_ack_size = _srs_config->get_in_ack_size(req->vhost);
if (in_ack_size && (ret = rtmp->set_in_window_ack_size(in_ack_size)) != ERROR_SUCCESS) {
srs_error("set input window acknowledgement size failed. ret=%d", ret);
return ret;
}
srs_verbose("set window acknowledgement size success");
if ((ret = rtmp->set_peer_bandwidth((int)(2.5 * 1000 * 1000), 2)) != ERROR_SUCCESS) {
srs_error("set peer bandwidth failed. ret=%d", ret);