正在显示
7 个修改的文件
包含
86 行增加
和
6 行删除
| @@ -184,6 +184,7 @@ Please select your language: | @@ -184,6 +184,7 @@ Please select your language: | ||
| 184 | 184 | ||
| 185 | ### V3 changes | 185 | ### V3 changes |
| 186 | 186 | ||
| 187 | +* v3.0, 2017-01-06, for [#730][bug #730] support config in/out ack size. 3.0.13 | ||
| 187 | * v3.0, 2017-01-06, for [#711][bug #711] support perfile for transcode. 3.0.12 | 188 | * v3.0, 2017-01-06, for [#711][bug #711] support perfile for transcode. 3.0.12 |
| 188 | * v3.0, 2017-01-05, patch ST for valgrind and ARM. 3.0.11 | 189 | * v3.0, 2017-01-05, patch ST for valgrind and ARM. 3.0.11 |
| 189 | * v3.0, 2017-01-05, for [#324][bug #324], always enable hstrs. 3.0.10 | 190 | * v3.0, 2017-01-05, for [#324][bug #324], always enable hstrs. 3.0.10 |
| @@ -1355,6 +1356,7 @@ Winlin | @@ -1355,6 +1356,7 @@ Winlin | ||
| 1355 | [bug #717]: https://github.com/ossrs/srs/issues/717 | 1356 | [bug #717]: https://github.com/ossrs/srs/issues/717 |
| 1356 | [bug #691]: https://github.com/ossrs/srs/issues/691 | 1357 | [bug #691]: https://github.com/ossrs/srs/issues/691 |
| 1357 | [bug #711]: https://github.com/ossrs/srs/issues/711 | 1358 | [bug #711]: https://github.com/ossrs/srs/issues/711 |
| 1359 | +[bug #730]: https://github.com/ossrs/srs/issues/730 | ||
| 1358 | [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx | 1360 | [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx |
| 1359 | 1361 | ||
| 1360 | [exo #828]: https://github.com/google/ExoPlayer/pull/828 | 1362 | [exo #828]: https://github.com/google/ExoPlayer/pull/828 |
| @@ -300,6 +300,19 @@ vhost scope.vhost.srs.com { | @@ -300,6 +300,19 @@ vhost scope.vhost.srs.com { | ||
| 300 | # vhost chunk size will override the global value. | 300 | # vhost chunk size will override the global value. |
| 301 | # default: global chunk size. | 301 | # default: global chunk size. |
| 302 | chunk_size 128; | 302 | chunk_size 128; |
| 303 | + | ||
| 304 | + # The input ack size, 0 to not set. | ||
| 305 | + # Generally, it's set by the message from peer, | ||
| 306 | + # but for some peer(encoder), it never send message but use a different ack size. | ||
| 307 | + # We can chnage the default ack size in server-side, to send acknowledge message, | ||
| 308 | + # or the encoder maybe blocked after publishing for some time. | ||
| 309 | + # Default: 0 | ||
| 310 | + in_ack_size 0; | ||
| 311 | + | ||
| 312 | + # The output ack size, 0 to not set. | ||
| 313 | + # This is used to notify the peer(player) to send acknowledge to server. | ||
| 314 | + # Default: 2500000 | ||
| 315 | + out_ack_size 2500000; | ||
| 303 | } | 316 | } |
| 304 | 317 | ||
| 305 | # set the chunk size of vhost. | 318 | # set the chunk size of vhost. |
| @@ -3826,6 +3826,7 @@ int SrsConfig::check_config() | @@ -3826,6 +3826,7 @@ int SrsConfig::check_config() | ||
| 3826 | && n != "play" && n != "publish" && n != "cluster" | 3826 | && n != "play" && n != "publish" && n != "cluster" |
| 3827 | && n != "security" && n != "http_remux" | 3827 | && n != "security" && n != "http_remux" |
| 3828 | && n != "http_static" && n != "hds" && n != "exec" | 3828 | && n != "http_static" && n != "hds" && n != "exec" |
| 3829 | + && n != "in_ack_size" && n != "out_ack_size" | ||
| 3829 | ) { | 3830 | ) { |
| 3830 | ret = ERROR_SYSTEM_CONFIG_INVALID; | 3831 | ret = ERROR_SYSTEM_CONFIG_INVALID; |
| 3831 | srs_error("unsupported vhost directive %s, ret=%d", n.c_str(), ret); | 3832 | srs_error("unsupported vhost directive %s, ret=%d", n.c_str(), ret); |
| @@ -4694,6 +4695,40 @@ SrsConfDirective* SrsConfig::get_refer_publish(string vhost) | @@ -4694,6 +4695,40 @@ SrsConfDirective* SrsConfig::get_refer_publish(string vhost) | ||
| 4694 | return conf->get("publish"); | 4695 | return conf->get("publish"); |
| 4695 | } | 4696 | } |
| 4696 | 4697 | ||
| 4698 | +int SrsConfig::get_in_ack_size(string vhost) | ||
| 4699 | +{ | ||
| 4700 | + static int DEFAULT = 0; | ||
| 4701 | + | ||
| 4702 | + SrsConfDirective* conf = get_vhost(vhost); | ||
| 4703 | + if (!conf) { | ||
| 4704 | + return DEFAULT; | ||
| 4705 | + } | ||
| 4706 | + | ||
| 4707 | + conf = conf->get("in_ack_size"); | ||
| 4708 | + if (!conf || conf->arg0().empty()) { | ||
| 4709 | + return DEFAULT; | ||
| 4710 | + } | ||
| 4711 | + | ||
| 4712 | + return ::atoi(conf->arg0().c_str()); | ||
| 4713 | +} | ||
| 4714 | + | ||
| 4715 | +int SrsConfig::get_out_ack_size(string vhost) | ||
| 4716 | +{ | ||
| 4717 | + static int DEFAULT = 2500000; | ||
| 4718 | + | ||
| 4719 | + SrsConfDirective* conf = get_vhost(vhost); | ||
| 4720 | + if (!conf) { | ||
| 4721 | + return DEFAULT; | ||
| 4722 | + } | ||
| 4723 | + | ||
| 4724 | + conf = conf->get("out_ack_size"); | ||
| 4725 | + if (!conf || conf->arg0().empty()) { | ||
| 4726 | + return DEFAULT; | ||
| 4727 | + } | ||
| 4728 | + | ||
| 4729 | + return ::atoi(conf->arg0().c_str()); | ||
| 4730 | +} | ||
| 4731 | + | ||
| 4697 | int SrsConfig::get_chunk_size(string vhost) | 4732 | int SrsConfig::get_chunk_size(string vhost) |
| 4698 | { | 4733 | { |
| 4699 | if (vhost.empty()) { | 4734 | if (vhost.empty()) { |
| @@ -754,6 +754,10 @@ public: | @@ -754,6 +754,10 @@ public: | ||
| 754 | * @return the refer, NULL for not configed. | 754 | * @return the refer, NULL for not configed. |
| 755 | */ | 755 | */ |
| 756 | virtual SrsConfDirective* get_refer_publish(std::string vhost); | 756 | virtual SrsConfDirective* get_refer_publish(std::string vhost); |
| 757 | + // Get the input default ack size, which is generally set by message from peer. | ||
| 758 | + virtual int get_in_ack_size(std::string vhost); | ||
| 759 | + // Get the output default ack size, to notify the peer to send acknowledge to server. | ||
| 760 | + virtual int get_out_ack_size(std::string vhost); | ||
| 757 | /** | 761 | /** |
| 758 | * get the chunk size of vhost. | 762 | * get the chunk size of vhost. |
| 759 | * @param vhost, the vhost to get the chunk size. use global if not specified. | 763 | * @param vhost, the vhost to get the chunk size. use global if not specified. |
| @@ -578,11 +578,17 @@ int SrsRtmpConn::service_cycle() | @@ -578,11 +578,17 @@ int SrsRtmpConn::service_cycle() | ||
| 578 | { | 578 | { |
| 579 | int ret = ERROR_SUCCESS; | 579 | int ret = ERROR_SUCCESS; |
| 580 | 580 | ||
| 581 | - if ((ret = rtmp->set_window_ack_size((int)(2.5 * 1000 * 1000))) != ERROR_SUCCESS) { | ||
| 582 | - srs_error("set window acknowledgement size failed. ret=%d", ret); | 581 | + int out_ack_size = _srs_config->get_out_ack_size(req->vhost); |
| 582 | + if (out_ack_size && (ret = rtmp->set_window_ack_size(out_ack_size)) != ERROR_SUCCESS) { | ||
| 583 | + srs_error("set output window acknowledgement size failed. ret=%d", ret); | ||
| 584 | + return ret; | ||
| 585 | + } | ||
| 586 | + | ||
| 587 | + int in_ack_size = _srs_config->get_in_ack_size(req->vhost); | ||
| 588 | + if (in_ack_size && (ret = rtmp->set_in_window_ack_size(in_ack_size)) != ERROR_SUCCESS) { | ||
| 589 | + srs_error("set input window acknowledgement size failed. ret=%d", ret); | ||
| 583 | return ret; | 590 | return ret; |
| 584 | } | 591 | } |
| 585 | - srs_verbose("set window acknowledgement size success"); | ||
| 586 | 592 | ||
| 587 | if ((ret = rtmp->set_peer_bandwidth((int)(2.5 * 1000 * 1000), 2)) != ERROR_SUCCESS) { | 593 | if ((ret = rtmp->set_peer_bandwidth((int)(2.5 * 1000 * 1000), 2)) != ERROR_SUCCESS) { |
| 588 | srs_error("set peer bandwidth failed. ret=%d", ret); | 594 | srs_error("set peer bandwidth failed. ret=%d", ret); |
| @@ -355,6 +355,12 @@ int64_t SrsProtocol::get_send_bytes() | @@ -355,6 +355,12 @@ int64_t SrsProtocol::get_send_bytes() | ||
| 355 | return skt->get_send_bytes(); | 355 | return skt->get_send_bytes(); |
| 356 | } | 356 | } |
| 357 | 357 | ||
| 358 | +int SrsProtocol::set_in_window_ack_size(int ack_size) | ||
| 359 | +{ | ||
| 360 | + in_ack_size.window = ack_size; | ||
| 361 | + return ERROR_SUCCESS; | ||
| 362 | +} | ||
| 363 | + | ||
| 358 | int SrsProtocol::recv_message(SrsCommonMessage** pmsg) | 364 | int SrsProtocol::recv_message(SrsCommonMessage** pmsg) |
| 359 | { | 365 | { |
| 360 | *pmsg = NULL; | 366 | *pmsg = NULL; |
| @@ -1620,7 +1626,7 @@ int SrsProtocol::response_acknowledgement_message() | @@ -1620,7 +1626,7 @@ int SrsProtocol::response_acknowledgement_message() | ||
| 1620 | } | 1626 | } |
| 1621 | 1627 | ||
| 1622 | // ignore when delta bytes not exceed half of window(ack size). | 1628 | // ignore when delta bytes not exceed half of window(ack size). |
| 1623 | - uint32_t delta = (uint32_t)(skt->get_recv_bytes() - in_ack_size.nb_recv_bytes); | 1629 | + uint32_t delta = (uint32_t)(skt->get_recv_bytes() - in_ack_size.nb_recv_bytes)*100; |
| 1624 | if (delta < in_ack_size.window / 2) { | 1630 | if (delta < in_ack_size.window / 2) { |
| 1625 | return ret; | 1631 | return ret; |
| 1626 | } | 1632 | } |
| @@ -1635,7 +1641,6 @@ int SrsProtocol::response_acknowledgement_message() | @@ -1635,7 +1641,6 @@ int SrsProtocol::response_acknowledgement_message() | ||
| 1635 | 1641 | ||
| 1636 | SrsAcknowledgementPacket* pkt = new SrsAcknowledgementPacket(); | 1642 | SrsAcknowledgementPacket* pkt = new SrsAcknowledgementPacket(); |
| 1637 | pkt->sequence_number = sequence_number; | 1643 | pkt->sequence_number = sequence_number; |
| 1638 | - srs_warn("ack sequence=%#x", sequence_number); | ||
| 1639 | 1644 | ||
| 1640 | // cache the message and use flush to send. | 1645 | // cache the message and use flush to send. |
| 1641 | if (!auto_response_when_recv) { | 1646 | if (!auto_response_when_recv) { |
| @@ -2548,6 +2553,11 @@ int SrsRtmpServer::set_window_ack_size(int ack_size) | @@ -2548,6 +2553,11 @@ int SrsRtmpServer::set_window_ack_size(int ack_size) | ||
| 2548 | return ret; | 2553 | return ret; |
| 2549 | } | 2554 | } |
| 2550 | 2555 | ||
| 2556 | +int SrsRtmpServer::set_in_window_ack_size(int ack_size) | ||
| 2557 | +{ | ||
| 2558 | + return protocol->set_in_window_ack_size(ack_size); | ||
| 2559 | +} | ||
| 2560 | + | ||
| 2551 | int SrsRtmpServer::set_peer_bandwidth(int bandwidth, int type) | 2561 | int SrsRtmpServer::set_peer_bandwidth(int bandwidth, int type) |
| 2552 | { | 2562 | { |
| 2553 | int ret = ERROR_SUCCESS; | 2563 | int ret = ERROR_SUCCESS; |
| @@ -330,6 +330,14 @@ public: | @@ -330,6 +330,14 @@ public: | ||
| 330 | virtual int64_t get_recv_bytes(); | 330 | virtual int64_t get_recv_bytes(); |
| 331 | virtual int64_t get_send_bytes(); | 331 | virtual int64_t get_send_bytes(); |
| 332 | public: | 332 | public: |
| 333 | + // Set the input default ack size. This is generally set by the message from peer, | ||
| 334 | + // but for some encoder, it never send the ack message while it default to a none zone size. | ||
| 335 | + // This will cause the encoder to block after publishing some messages to server, | ||
| 336 | + // because it wait for server to send acknowledge, but server default to 0 which means no need | ||
| 337 | + // to ack encoder. We can change the default input ack size. We will always response the | ||
| 338 | + // ack size whatever the encoder set or not. | ||
| 339 | + virtual int set_in_window_ack_size(int ack_size); | ||
| 340 | +public: | ||
| 333 | /** | 341 | /** |
| 334 | * recv a RTMP message, which is bytes oriented. | 342 | * recv a RTMP message, which is bytes oriented. |
| 335 | * user can use decode_message to get the decoded RTMP packet. | 343 | * user can use decode_message to get the decoded RTMP packet. |
| @@ -928,9 +936,11 @@ public: | @@ -928,9 +936,11 @@ public: | ||
| 928 | */ | 936 | */ |
| 929 | virtual int connect_app(SrsRequest* req); | 937 | virtual int connect_app(SrsRequest* req); |
| 930 | /** | 938 | /** |
| 931 | - * set ack size to client, client will send ack-size for each ack window | 939 | + * set output ack size to client, client will send ack-size for each ack window |
| 932 | */ | 940 | */ |
| 933 | virtual int set_window_ack_size(int ack_size); | 941 | virtual int set_window_ack_size(int ack_size); |
| 942 | + // Set the default input ack size value. | ||
| 943 | + virtual int set_in_window_ack_size(int ack_size); | ||
| 934 | /** | 944 | /** |
| 935 | * @type: The sender can mark this message hard (0), soft (1), or dynamic (2) | 945 | * @type: The sender can mark this message hard (0), soft (1), or dynamic (2) |
| 936 | * using the Limit type field. | 946 | * using the Limit type field. |
-
请 注册 或 登录 后发表评论