正在显示
10 个修改的文件
包含
96 行增加
和
142 行删除
| @@ -28,7 +28,7 @@ vhost __defaultVhost__ { | @@ -28,7 +28,7 @@ vhost __defaultVhost__ { | ||
| 28 | dir ./objs/nginx/html/hls; | 28 | dir ./objs/nginx/html/hls; |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | - # for SRS2. | 31 | + # for SRS1. |
| 32 | refer github.com github.io; | 32 | refer github.com github.io; |
| 33 | refer_publish github.com github.io; | 33 | refer_publish github.com github.io; |
| 34 | refer_play github.com github.io; | 34 | refer_play github.com github.io; |
| @@ -43,7 +43,7 @@ vhost __defaultVhost__ { | @@ -43,7 +43,7 @@ vhost __defaultVhost__ { | ||
| 43 | latency 350; | 43 | latency 350; |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | - # for SRS2 | 46 | + # for SRS1 |
| 47 | mode remote; | 47 | mode remote; |
| 48 | origin 127.0.0.1:1935 localhost:1935; | 48 | origin 127.0.0.1:1935 localhost:1935; |
| 49 | 49 | ||
| @@ -52,21 +52,27 @@ vhost __defaultVhost__ { | @@ -52,21 +52,27 @@ vhost __defaultVhost__ { | ||
| 52 | 52 | ||
| 53 | debug_srs_upnode off; | 53 | debug_srs_upnode off; |
| 54 | 54 | ||
| 55 | - # for SRS2 | 55 | + # for SRS1 |
| 56 | forward 127.0.0.1:1936 127.0.0.1:1937; | 56 | forward 127.0.0.1:1936 127.0.0.1:1937; |
| 57 | 57 | ||
| 58 | - # for SRS2 | 58 | + # for SRS1 |
| 59 | time_jitter full; | 59 | time_jitter full; |
| 60 | + | ||
| 61 | + # for SRS2 | ||
| 60 | mix_correct off; | 62 | mix_correct off; |
| 61 | 63 | ||
| 64 | + #for SRS1 | ||
| 62 | atc on; | 65 | atc on; |
| 63 | atc_auto on; | 66 | atc_auto on; |
| 64 | 67 | ||
| 68 | + # for SRS2 | ||
| 65 | mw_latency 100; | 69 | mw_latency 100; |
| 66 | 70 | ||
| 71 | + # for SRS1 | ||
| 67 | gop_cache off; | 72 | gop_cache off; |
| 68 | queue_length 10; | 73 | queue_length 10; |
| 69 | 74 | ||
| 75 | + # for SRS2 | ||
| 70 | send_min_interval 10.0; | 76 | send_min_interval 10.0; |
| 71 | reduce_sequence_header on; | 77 | reduce_sequence_header on; |
| 72 | } | 78 | } |
| @@ -378,6 +378,21 @@ vhost play.srs.com { | @@ -378,6 +378,21 @@ vhost play.srs.com { | ||
| 378 | # for play client, both RTMP and other stream clients, | 378 | # for play client, both RTMP and other stream clients, |
| 379 | # for instance, the HTTP FLV stream clients. | 379 | # for instance, the HTTP FLV stream clients. |
| 380 | play { | 380 | play { |
| 381 | + # whether cache the last gop. | ||
| 382 | + # if on, cache the last gop and dispatch to client, | ||
| 383 | + # to enabled fast startup for client, client play immediately. | ||
| 384 | + # if off, send the latest media data to client, | ||
| 385 | + # client need to wait for the next Iframe to decode and show the video. | ||
| 386 | + # set to off if requires min delay; | ||
| 387 | + # set to on if requires client fast startup. | ||
| 388 | + # default: on | ||
| 389 | + gop_cache off; | ||
| 390 | + # the max live queue length in seconds. | ||
| 391 | + # if the messages in the queue exceed the max length, | ||
| 392 | + # drop the old whole gop. | ||
| 393 | + # default: 30 | ||
| 394 | + queue_length 10; | ||
| 395 | + | ||
| 381 | # about the stream monotonically increasing: | 396 | # about the stream monotonically increasing: |
| 382 | # 1. video timestamp is monotonically increasing, | 397 | # 1. video timestamp is monotonically increasing, |
| 383 | # 2. audio timestamp is monotonically increasing, | 398 | # 2. audio timestamp is monotonically increasing, |
| @@ -466,24 +481,11 @@ vhost min.delay.com { | @@ -466,24 +481,11 @@ vhost min.delay.com { | ||
| 466 | # @see scope.vhost.srs.com | 481 | # @see scope.vhost.srs.com |
| 467 | tcp_nodelay on; | 482 | tcp_nodelay on; |
| 468 | 483 | ||
| 469 | - # whether cache the last gop. | ||
| 470 | - # if on, cache the last gop and dispatch to client, | ||
| 471 | - # to enabled fast startup for client, client play immediately. | ||
| 472 | - # if off, send the latest media data to client, | ||
| 473 | - # client need to wait for the next Iframe to decode and show the video. | ||
| 474 | - # set to off if requires min delay; | ||
| 475 | - # set to on if requires client fast startup. | ||
| 476 | - # default: on | ||
| 477 | - gop_cache off; | ||
| 478 | - # the max live queue length in seconds. | ||
| 479 | - # if the messages in the queue exceed the max length, | ||
| 480 | - # drop the old whole gop. | ||
| 481 | - # default: 30 | ||
| 482 | - queue_length 10; | ||
| 483 | - | ||
| 484 | # @see play.srs.com | 484 | # @see play.srs.com |
| 485 | play { | 485 | play { |
| 486 | mw_latency 100; | 486 | mw_latency 100; |
| 487 | + gop_cache off; | ||
| 488 | + queue_length 10; | ||
| 487 | } | 489 | } |
| 488 | 490 | ||
| 489 | # @see publish.srs.com | 491 | # @see publish.srs.com |
| @@ -499,8 +501,6 @@ vhost stream.control.com { | @@ -499,8 +501,6 @@ vhost stream.control.com { | ||
| 499 | # @see scope.vhost.srs.com | 501 | # @see scope.vhost.srs.com |
| 500 | tcp_nodelay on; | 502 | tcp_nodelay on; |
| 501 | 503 | ||
| 502 | - # @see vhost min.delay.com | ||
| 503 | - queue_length 10; | ||
| 504 | # the minimal packets send interval in ms, | 504 | # the minimal packets send interval in ms, |
| 505 | # used to control the ndiff of stream by srs_rtmp_dump, | 505 | # used to control the ndiff of stream by srs_rtmp_dump, |
| 506 | # for example, some device can only accept some stream which | 506 | # for example, some device can only accept some stream which |
| @@ -519,6 +519,7 @@ vhost stream.control.com { | @@ -519,6 +519,7 @@ vhost stream.control.com { | ||
| 519 | # @see play.srs.com | 519 | # @see play.srs.com |
| 520 | play { | 520 | play { |
| 521 | mw_latency 100; | 521 | mw_latency 100; |
| 522 | + queue_length 10; | ||
| 522 | } | 523 | } |
| 523 | 524 | ||
| 524 | # @see publish.srs.com | 525 | # @see publish.srs.com |
| @@ -76,10 +76,10 @@ vhost vhost.srs.com { | @@ -76,10 +76,10 @@ vhost vhost.srs.com { | ||
| 76 | 76 | ||
| 77 | mw_latency 100; | 77 | mw_latency 100; |
| 78 | 78 | ||
| 79 | - # TODO | ||
| 80 | gop_cache off; | 79 | gop_cache off; |
| 81 | queue_length 10; | 80 | queue_length 10; |
| 82 | 81 | ||
| 82 | + # TODO | ||
| 83 | send_min_interval 10.0; | 83 | send_min_interval 10.0; |
| 84 | reduce_sequence_header on; | 84 | reduce_sequence_header on; |
| 85 | } | 85 | } |
| @@ -732,30 +732,6 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root) | @@ -732,30 +732,6 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root) | ||
| 732 | srs_trace("vhost %s reload min_latency success.", vhost.c_str()); | 732 | srs_trace("vhost %s reload min_latency success.", vhost.c_str()); |
| 733 | } | 733 | } |
| 734 | 734 | ||
| 735 | - // gop_cache, only one per vhost | ||
| 736 | - if (!srs_directive_equals(new_vhost->get("gop_cache"), old_vhost->get("gop_cache"))) { | ||
| 737 | - for (it = subscribes.begin(); it != subscribes.end(); ++it) { | ||
| 738 | - ISrsReloadHandler* subscribe = *it; | ||
| 739 | - if ((ret = subscribe->on_reload_vhost_gop_cache(vhost)) != ERROR_SUCCESS) { | ||
| 740 | - srs_error("vhost %s notify subscribes gop_cache failed. ret=%d", vhost.c_str(), ret); | ||
| 741 | - return ret; | ||
| 742 | - } | ||
| 743 | - } | ||
| 744 | - srs_trace("vhost %s reload gop_cache success.", vhost.c_str()); | ||
| 745 | - } | ||
| 746 | - | ||
| 747 | - // queue_length, only one per vhost | ||
| 748 | - if (!srs_directive_equals(new_vhost->get("queue_length"), old_vhost->get("queue_length"))) { | ||
| 749 | - for (it = subscribes.begin(); it != subscribes.end(); ++it) { | ||
| 750 | - ISrsReloadHandler* subscribe = *it; | ||
| 751 | - if ((ret = subscribe->on_reload_vhost_queue_length(vhost)) != ERROR_SUCCESS) { | ||
| 752 | - srs_error("vhost %s notify subscribes queue_length failed. ret=%d", vhost.c_str(), ret); | ||
| 753 | - return ret; | ||
| 754 | - } | ||
| 755 | - } | ||
| 756 | - srs_trace("vhost %s reload queue_length success.", vhost.c_str()); | ||
| 757 | - } | ||
| 758 | - | ||
| 759 | // play, only one per vhost | 735 | // play, only one per vhost |
| 760 | if (!srs_directive_equals(new_vhost->get("play"), old_vhost->get("play"))) { | 736 | if (!srs_directive_equals(new_vhost->get("play"), old_vhost->get("play"))) { |
| 761 | for (it = subscribes.begin(); it != subscribes.end(); ++it) { | 737 | for (it = subscribes.begin(); it != subscribes.end(); ++it) { |
| @@ -1723,14 +1699,6 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj) | @@ -1723,14 +1699,6 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj) | ||
| 1723 | obj->set("debug_srs_upnode", dir->dumps_arg0_to_boolean()); | 1699 | obj->set("debug_srs_upnode", dir->dumps_arg0_to_boolean()); |
| 1724 | } | 1700 | } |
| 1725 | 1701 | ||
| 1726 | - // realtime latency | ||
| 1727 | - if ((dir = vhost->get("gop_cache")) != NULL) { | ||
| 1728 | - obj->set("gop_cache", dir->dumps_arg0_to_boolean()); | ||
| 1729 | - } | ||
| 1730 | - if ((dir = vhost->get("queue_length")) != NULL) { | ||
| 1731 | - obj->set("queue_length", dir->dumps_arg0_to_number()); | ||
| 1732 | - } | ||
| 1733 | - | ||
| 1734 | // stream control | 1702 | // stream control |
| 1735 | if ((dir = vhost->get("send_min_interval")) != NULL) { | 1703 | if ((dir = vhost->get("send_min_interval")) != NULL) { |
| 1736 | obj->set("send_min_interval", dir->dumps_arg0_to_number()); | 1704 | obj->set("send_min_interval", dir->dumps_arg0_to_number()); |
| @@ -1757,6 +1725,10 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj) | @@ -1757,6 +1725,10 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj) | ||
| 1757 | play->set("atc_auto", sdir->dumps_arg0_to_boolean()); | 1725 | play->set("atc_auto", sdir->dumps_arg0_to_boolean()); |
| 1758 | } else if (sdir->name == "mw_latency") { | 1726 | } else if (sdir->name == "mw_latency") { |
| 1759 | play->set("mw_latency", sdir->dumps_arg0_to_number()); | 1727 | play->set("mw_latency", sdir->dumps_arg0_to_number()); |
| 1728 | + } else if (sdir->name == "gop_cache") { | ||
| 1729 | + play->set("gop_cache", sdir->dumps_arg0_to_boolean()); | ||
| 1730 | + } else if (sdir->name == "queue_length") { | ||
| 1731 | + play->set("queue_length", sdir->dumps_arg0_to_number()); | ||
| 1760 | } | 1732 | } |
| 1761 | } | 1733 | } |
| 1762 | } | 1734 | } |
| @@ -2637,7 +2609,6 @@ int SrsConfig::check_config() | @@ -2637,7 +2609,6 @@ int SrsConfig::check_config() | ||
| 2637 | if (n != "enabled" && n != "chunk_size" && n != "min_latency" && n != "tcp_nodelay" | 2609 | if (n != "enabled" && n != "chunk_size" && n != "min_latency" && n != "tcp_nodelay" |
| 2638 | && n != "mode" && n != "origin" && n != "token_traverse" && n != "vhost" | 2610 | && n != "mode" && n != "origin" && n != "token_traverse" && n != "vhost" |
| 2639 | && n != "dvr" && n != "ingest" && n != "hls" && n != "http_hooks" | 2611 | && n != "dvr" && n != "ingest" && n != "hls" && n != "http_hooks" |
| 2640 | - && n != "gop_cache" && n != "queue_length" | ||
| 2641 | && n != "refer" && n != "forward" && n != "transcode" && n != "bandcheck" | 2612 | && n != "refer" && n != "forward" && n != "transcode" && n != "bandcheck" |
| 2642 | && n != "debug_srs_upnode" && n != "play" && n != "publish" | 2613 | && n != "debug_srs_upnode" && n != "play" && n != "publish" |
| 2643 | && n != "send_min_interval" && n != "reduce_sequence_header" | 2614 | && n != "send_min_interval" && n != "reduce_sequence_header" |
| @@ -2681,7 +2652,9 @@ int SrsConfig::check_config() | @@ -2681,7 +2652,9 @@ int SrsConfig::check_config() | ||
| 2681 | } else if (n == "play") { | 2652 | } else if (n == "play") { |
| 2682 | for (int j = 0; j < (int)conf->directives.size(); j++) { | 2653 | for (int j = 0; j < (int)conf->directives.size(); j++) { |
| 2683 | string m = conf->at(j)->name.c_str(); | 2654 | string m = conf->at(j)->name.c_str(); |
| 2684 | - if (m != "time_jitter" && m != "mix_correct" && m != "atc" && m != "atc_auto" && m != "mw_latency") { | 2655 | + if (m != "time_jitter" && m != "mix_correct" && m != "atc" && m != "atc_auto" |
| 2656 | + && m != "mw_latency" && m != "gop_cache" && m != "queue_length" | ||
| 2657 | + ) { | ||
| 2685 | ret = ERROR_SYSTEM_CONFIG_INVALID; | 2658 | ret = ERROR_SYSTEM_CONFIG_INVALID; |
| 2686 | srs_error("unsupported vhost play directive %s, ret=%d", m.c_str(), ret); | 2659 | srs_error("unsupported vhost play directive %s, ret=%d", m.c_str(), ret); |
| 2687 | return ret; | 2660 | return ret; |
| @@ -3197,6 +3170,11 @@ bool SrsConfig::get_gop_cache(string vhost) | @@ -3197,6 +3170,11 @@ bool SrsConfig::get_gop_cache(string vhost) | ||
| 3197 | return SRS_PERF_GOP_CACHE; | 3170 | return SRS_PERF_GOP_CACHE; |
| 3198 | } | 3171 | } |
| 3199 | 3172 | ||
| 3173 | + conf = conf->get("play"); | ||
| 3174 | + if (!conf || conf->arg0().empty()) { | ||
| 3175 | + return SRS_PERF_GOP_CACHE; | ||
| 3176 | + } | ||
| 3177 | + | ||
| 3200 | conf = conf->get("gop_cache"); | 3178 | conf = conf->get("gop_cache"); |
| 3201 | if (!conf || conf->arg0().empty()) { | 3179 | if (!conf || conf->arg0().empty()) { |
| 3202 | return SRS_PERF_GOP_CACHE; | 3180 | return SRS_PERF_GOP_CACHE; |
| @@ -3317,6 +3295,11 @@ double SrsConfig::get_queue_length(string vhost) | @@ -3317,6 +3295,11 @@ double SrsConfig::get_queue_length(string vhost) | ||
| 3317 | return SRS_PERF_PLAY_QUEUE; | 3295 | return SRS_PERF_PLAY_QUEUE; |
| 3318 | } | 3296 | } |
| 3319 | 3297 | ||
| 3298 | + conf = conf->get("play"); | ||
| 3299 | + if (!conf || conf->arg0().empty()) { | ||
| 3300 | + return SRS_PERF_GOP_CACHE; | ||
| 3301 | + } | ||
| 3302 | + | ||
| 3320 | conf = conf->get("queue_length"); | 3303 | conf = conf->get("queue_length"); |
| 3321 | if (!conf || conf->arg0().empty()) { | 3304 | if (!conf || conf->arg0().empty()) { |
| 3322 | return SRS_PERF_PLAY_QUEUE; | 3305 | return SRS_PERF_PLAY_QUEUE; |
| @@ -5779,12 +5762,14 @@ int srs_config_transform_vhost(SrsConfDirective* root) | @@ -5779,12 +5762,14 @@ int srs_config_transform_vhost(SrsConfDirective* root) | ||
| 5779 | } | 5762 | } |
| 5780 | 5763 | ||
| 5781 | // SRS3.0, change the folowing like a shadow: | 5764 | // SRS3.0, change the folowing like a shadow: |
| 5782 | - // time_jitter, mix_correct, atc, atc_auto, mw_latency | 5765 | + // time_jitter, mix_correct, atc, atc_auto, mw_latency, gop_cache, queue_length |
| 5783 | // SRS1/2: | 5766 | // SRS1/2: |
| 5784 | // vhost { shadow; } | 5767 | // vhost { shadow; } |
| 5785 | // SRS3+: | 5768 | // SRS3+: |
| 5786 | // vhost { play { shadow; } } | 5769 | // vhost { play { shadow; } } |
| 5787 | - if (n == "time_jitter" || n == "mix_correct" || n == "atc" || n == "atc_auto" || n == "mw_latency") { | 5770 | + if (n == "time_jitter" || n == "mix_correct" || n == "atc" || n == "atc_auto" |
| 5771 | + || n == "mw_latency" || n == "gop_cache" || n == "queue_length" | ||
| 5772 | + ) { | ||
| 5788 | it = dir->directives.erase(it); | 5773 | it = dir->directives.erase(it); |
| 5789 | 5774 | ||
| 5790 | SrsConfDirective* play = dir->get_or_create("play"); | 5775 | SrsConfDirective* play = dir->get_or_create("play"); |
| @@ -125,16 +125,6 @@ int ISrsReloadHandler::on_reload_vhost_removed(string /*vhost*/) | @@ -125,16 +125,6 @@ int ISrsReloadHandler::on_reload_vhost_removed(string /*vhost*/) | ||
| 125 | return ERROR_SUCCESS; | 125 | return ERROR_SUCCESS; |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | -int ISrsReloadHandler::on_reload_vhost_gop_cache(string /*vhost*/) | ||
| 129 | -{ | ||
| 130 | - return ERROR_SUCCESS; | ||
| 131 | -} | ||
| 132 | - | ||
| 133 | -int ISrsReloadHandler::on_reload_vhost_queue_length(string /*vhost*/) | ||
| 134 | -{ | ||
| 135 | - return ERROR_SUCCESS; | ||
| 136 | -} | ||
| 137 | - | ||
| 138 | int ISrsReloadHandler::on_reload_vhost_play(string /*vhost*/) | 128 | int ISrsReloadHandler::on_reload_vhost_play(string /*vhost*/) |
| 139 | { | 129 | { |
| 140 | return ERROR_SUCCESS; | 130 | return ERROR_SUCCESS; |
| @@ -64,8 +64,6 @@ public: | @@ -64,8 +64,6 @@ public: | ||
| 64 | virtual int on_reload_vhost_http_remux_updated(std::string vhost); | 64 | virtual int on_reload_vhost_http_remux_updated(std::string vhost); |
| 65 | virtual int on_reload_vhost_added(std::string vhost); | 65 | virtual int on_reload_vhost_added(std::string vhost); |
| 66 | virtual int on_reload_vhost_removed(std::string vhost); | 66 | virtual int on_reload_vhost_removed(std::string vhost); |
| 67 | - virtual int on_reload_vhost_gop_cache(std::string vhost); | ||
| 68 | - virtual int on_reload_vhost_queue_length(std::string vhost); | ||
| 69 | virtual int on_reload_vhost_play(std::string vhost); | 67 | virtual int on_reload_vhost_play(std::string vhost); |
| 70 | virtual int on_reload_vhost_forward(std::string vhost); | 68 | virtual int on_reload_vhost_forward(std::string vhost); |
| 71 | virtual int on_reload_vhost_hls(std::string vhost); | 69 | virtual int on_reload_vhost_hls(std::string vhost); |
| @@ -594,11 +594,11 @@ void SrsGopCache::dispose() | @@ -594,11 +594,11 @@ void SrsGopCache::dispose() | ||
| 594 | clear(); | 594 | clear(); |
| 595 | } | 595 | } |
| 596 | 596 | ||
| 597 | -void SrsGopCache::set(bool enabled) | 597 | +void SrsGopCache::set(bool v) |
| 598 | { | 598 | { |
| 599 | - enable_gop_cache = enabled; | 599 | + enable_gop_cache = v; |
| 600 | 600 | ||
| 601 | - if (!enabled) { | 601 | + if (!v) { |
| 602 | srs_info("disable gop cache, clear %d packets.", (int)gop_cache.size()); | 602 | srs_info("disable gop cache, clear %d packets.", (int)gop_cache.size()); |
| 603 | clear(); | 603 | clear(); |
| 604 | return; | 604 | return; |
| @@ -607,6 +607,11 @@ void SrsGopCache::set(bool enabled) | @@ -607,6 +607,11 @@ void SrsGopCache::set(bool enabled) | ||
| 607 | srs_info("enable gop cache"); | 607 | srs_info("enable gop cache"); |
| 608 | } | 608 | } |
| 609 | 609 | ||
| 610 | +bool SrsGopCache::enabled() | ||
| 611 | +{ | ||
| 612 | + return enable_gop_cache; | ||
| 613 | +} | ||
| 614 | + | ||
| 610 | int SrsGopCache::cache(SrsSharedPtrMessage* shared_msg) | 615 | int SrsGopCache::cache(SrsSharedPtrMessage* shared_msg) |
| 611 | { | 616 | { |
| 612 | int ret = ERROR_SUCCESS; | 617 | int ret = ERROR_SUCCESS; |
| @@ -1043,7 +1048,7 @@ int SrsSource::initialize(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* h | @@ -1043,7 +1048,7 @@ int SrsSource::initialize(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* h | ||
| 1043 | return ret; | 1048 | return ret; |
| 1044 | } | 1049 | } |
| 1045 | 1050 | ||
| 1046 | -int SrsSource::on_reload_vhost_gop_cache(string vhost) | 1051 | +int SrsSource::on_reload_vhost_play(string vhost) |
| 1047 | { | 1052 | { |
| 1048 | int ret = ERROR_SUCCESS; | 1053 | int ret = ERROR_SUCCESS; |
| 1049 | 1054 | ||
| @@ -1051,33 +1056,52 @@ int SrsSource::on_reload_vhost_gop_cache(string vhost) | @@ -1051,33 +1056,52 @@ int SrsSource::on_reload_vhost_gop_cache(string vhost) | ||
| 1051 | return ret; | 1056 | return ret; |
| 1052 | } | 1057 | } |
| 1053 | 1058 | ||
| 1054 | - // gop cache changed. | ||
| 1055 | - bool enabled_cache = _srs_config->get_gop_cache(vhost); | 1059 | + // time_jitter |
| 1060 | + jitter_algorithm = (SrsRtmpJitterAlgorithm)_srs_config->get_time_jitter(_req->vhost); | ||
| 1056 | 1061 | ||
| 1057 | - srs_trace("vhost %s gop_cache changed to %d, source url=%s", | ||
| 1058 | - vhost.c_str(), enabled_cache, _req->get_stream_url().c_str()); | 1062 | + // mix_correct |
| 1063 | + if (true) { | ||
| 1064 | + bool v = _srs_config->get_mix_correct(_req->vhost); | ||
| 1059 | 1065 | ||
| 1060 | - set_cache(enabled_cache); | 1066 | + // when changed, clear the mix queue. |
| 1067 | + if (v != mix_correct) { | ||
| 1068 | + mix_queue->clear(); | ||
| 1069 | + } | ||
| 1070 | + mix_correct = v; | ||
| 1071 | + } | ||
| 1061 | 1072 | ||
| 1062 | - return ret; | ||
| 1063 | -} | 1073 | + // atc changed. |
| 1074 | + if (true) { | ||
| 1075 | + bool v = _srs_config->get_atc(vhost); | ||
| 1064 | 1076 | ||
| 1065 | -int SrsSource::on_reload_vhost_queue_length(string vhost) | ||
| 1066 | -{ | ||
| 1067 | - int ret = ERROR_SUCCESS; | 1077 | + if (v != atc) { |
| 1078 | + srs_warn("vhost %s atc changed to %d, connected client may corrupt.", vhost.c_str(), v); | ||
| 1079 | + gop_cache->clear(); | ||
| 1080 | + } | ||
| 1081 | + atc = v; | ||
| 1082 | + } | ||
| 1068 | 1083 | ||
| 1069 | - if (_req->vhost != vhost) { | ||
| 1070 | - return ret; | 1084 | + // gop cache changed. |
| 1085 | + if (true) { | ||
| 1086 | + bool v = _srs_config->get_gop_cache(vhost); | ||
| 1087 | + | ||
| 1088 | + if (v != gop_cache->enabled()) { | ||
| 1089 | + string url = _req->get_stream_url(); | ||
| 1090 | + srs_trace("vhost %s gop_cache changed to %d, source url=%s", vhost.c_str(), v, url.c_str()); | ||
| 1091 | + gop_cache->set(v); | ||
| 1092 | + } | ||
| 1071 | } | 1093 | } |
| 1072 | 1094 | ||
| 1073 | - double queue_size = _srs_config->get_queue_length(_req->vhost); | 1095 | + // queue length |
| 1096 | + if (true) { | ||
| 1097 | + double v = _srs_config->get_queue_length(_req->vhost); | ||
| 1074 | 1098 | ||
| 1075 | if (true) { | 1099 | if (true) { |
| 1076 | std::vector<SrsConsumer*>::iterator it; | 1100 | std::vector<SrsConsumer*>::iterator it; |
| 1077 | 1101 | ||
| 1078 | for (it = consumers.begin(); it != consumers.end(); ++it) { | 1102 | for (it = consumers.begin(); it != consumers.end(); ++it) { |
| 1079 | SrsConsumer* consumer = *it; | 1103 | SrsConsumer* consumer = *it; |
| 1080 | - consumer->set_queue_size(queue_size); | 1104 | + consumer->set_queue_size(v); |
| 1081 | } | 1105 | } |
| 1082 | 1106 | ||
| 1083 | srs_trace("consumers reload queue size success."); | 1107 | srs_trace("consumers reload queue size success."); |
| @@ -1088,51 +1112,16 @@ int SrsSource::on_reload_vhost_queue_length(string vhost) | @@ -1088,51 +1112,16 @@ int SrsSource::on_reload_vhost_queue_length(string vhost) | ||
| 1088 | 1112 | ||
| 1089 | for (it = forwarders.begin(); it != forwarders.end(); ++it) { | 1113 | for (it = forwarders.begin(); it != forwarders.end(); ++it) { |
| 1090 | SrsForwarder* forwarder = *it; | 1114 | SrsForwarder* forwarder = *it; |
| 1091 | - forwarder->set_queue_size(queue_size); | 1115 | + forwarder->set_queue_size(v); |
| 1092 | } | 1116 | } |
| 1093 | 1117 | ||
| 1094 | srs_trace("forwarders reload queue size success."); | 1118 | srs_trace("forwarders reload queue size success."); |
| 1095 | } | 1119 | } |
| 1096 | 1120 | ||
| 1097 | if (true) { | 1121 | if (true) { |
| 1098 | - publish_edge->set_queue_size(queue_size); | 1122 | + publish_edge->set_queue_size(v); |
| 1099 | srs_trace("publish_edge reload queue size success."); | 1123 | srs_trace("publish_edge reload queue size success."); |
| 1100 | } | 1124 | } |
| 1101 | - | ||
| 1102 | - return ret; | ||
| 1103 | -} | ||
| 1104 | - | ||
| 1105 | -int SrsSource::on_reload_vhost_play(string vhost) | ||
| 1106 | -{ | ||
| 1107 | - int ret = ERROR_SUCCESS; | ||
| 1108 | - | ||
| 1109 | - if (_req->vhost != vhost) { | ||
| 1110 | - return ret; | ||
| 1111 | - } | ||
| 1112 | - | ||
| 1113 | - // time_jitter | ||
| 1114 | - jitter_algorithm = (SrsRtmpJitterAlgorithm)_srs_config->get_time_jitter(_req->vhost); | ||
| 1115 | - | ||
| 1116 | - // mix_correct | ||
| 1117 | - if (true) { | ||
| 1118 | - bool v = _srs_config->get_mix_correct(_req->vhost); | ||
| 1119 | - | ||
| 1120 | - // when changed, clear the mix queue. | ||
| 1121 | - if (v != mix_correct) { | ||
| 1122 | - mix_queue->clear(); | ||
| 1123 | - } | ||
| 1124 | - mix_correct = v; | ||
| 1125 | - } | ||
| 1126 | - | ||
| 1127 | - // atc changed. | ||
| 1128 | - if (true) { | ||
| 1129 | - bool v = _srs_config->get_atc(vhost); | ||
| 1130 | - | ||
| 1131 | - if (v != atc) { | ||
| 1132 | - srs_warn("vhost %s atc changed to %d, connected client may corrupt.", vhost.c_str(), v); | ||
| 1133 | - gop_cache->clear(); | ||
| 1134 | - } | ||
| 1135 | - atc = v; | ||
| 1136 | } | 1125 | } |
| 1137 | 1126 | ||
| 1138 | return ret; | 1127 | return ret; |
| @@ -331,7 +331,8 @@ public: | @@ -331,7 +331,8 @@ public: | ||
| 331 | /** | 331 | /** |
| 332 | * to enable or disable the gop cache. | 332 | * to enable or disable the gop cache. |
| 333 | */ | 333 | */ |
| 334 | - virtual void set(bool enabled); | 334 | + virtual void set(bool v); |
| 335 | + virtual bool enabled(); | ||
| 335 | /** | 336 | /** |
| 336 | * only for h264 codec | 337 | * only for h264 codec |
| 337 | * 1. cache the gop when got h264 video packet. | 338 | * 1. cache the gop when got h264 video packet. |
| @@ -520,8 +521,6 @@ public: | @@ -520,8 +521,6 @@ public: | ||
| 520 | virtual int initialize(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* hh); | 521 | virtual int initialize(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* hh); |
| 521 | // interface ISrsReloadHandler | 522 | // interface ISrsReloadHandler |
| 522 | public: | 523 | public: |
| 523 | - virtual int on_reload_vhost_gop_cache(std::string vhost); | ||
| 524 | - virtual int on_reload_vhost_queue_length(std::string vhost); | ||
| 525 | virtual int on_reload_vhost_play(std::string vhost); | 524 | virtual int on_reload_vhost_play(std::string vhost); |
| 526 | virtual int on_reload_vhost_forward(std::string vhost); | 525 | virtual int on_reload_vhost_forward(std::string vhost); |
| 527 | virtual int on_reload_vhost_hls(std::string vhost); | 526 | virtual int on_reload_vhost_hls(std::string vhost); |
| @@ -230,18 +230,6 @@ int MockReloadHandler::on_reload_vhost_removed(string /*vhost*/) | @@ -230,18 +230,6 @@ int MockReloadHandler::on_reload_vhost_removed(string /*vhost*/) | ||
| 230 | return ERROR_SUCCESS; | 230 | return ERROR_SUCCESS; |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | -int MockReloadHandler::on_reload_vhost_gop_cache(string /*vhost*/) | ||
| 234 | -{ | ||
| 235 | - vhost_gop_cache_reloaded = true; | ||
| 236 | - return ERROR_SUCCESS; | ||
| 237 | -} | ||
| 238 | - | ||
| 239 | -int MockReloadHandler::on_reload_vhost_queue_length(string /*vhost*/) | ||
| 240 | -{ | ||
| 241 | - vhost_queue_length_reloaded = true; | ||
| 242 | - return ERROR_SUCCESS; | ||
| 243 | -} | ||
| 244 | - | ||
| 245 | int MockReloadHandler::on_reload_vhost_play(string /*vhost*/) | 233 | int MockReloadHandler::on_reload_vhost_play(string /*vhost*/) |
| 246 | { | 234 | { |
| 247 | vhost_time_jitter_reloaded = true; | 235 | vhost_time_jitter_reloaded = true; |
| @@ -85,8 +85,6 @@ public: | @@ -85,8 +85,6 @@ public: | ||
| 85 | virtual int on_reload_vhost_http_updated(); | 85 | virtual int on_reload_vhost_http_updated(); |
| 86 | virtual int on_reload_vhost_added(std::string vhost); | 86 | virtual int on_reload_vhost_added(std::string vhost); |
| 87 | virtual int on_reload_vhost_removed(std::string vhost); | 87 | virtual int on_reload_vhost_removed(std::string vhost); |
| 88 | - virtual int on_reload_vhost_gop_cache(std::string vhost); | ||
| 89 | - virtual int on_reload_vhost_queue_length(std::string vhost); | ||
| 90 | virtual int on_reload_vhost_play(std::string vhost); | 88 | virtual int on_reload_vhost_play(std::string vhost); |
| 91 | virtual int on_reload_vhost_forward(std::string vhost); | 89 | virtual int on_reload_vhost_forward(std::string vhost); |
| 92 | virtual int on_reload_vhost_hls(std::string vhost); | 90 | virtual int on_reload_vhost_hls(std::string vhost); |
-
请 注册 或 登录 后发表评论