正在显示
9 个修改的文件
包含
79 行增加
和
98 行删除
| @@ -1108,6 +1108,26 @@ vhost play.srs.com { | @@ -1108,6 +1108,26 @@ vhost play.srs.com { | ||
| 1108 | # if off, use time_jitter to correct the timestamp if required. | 1108 | # if off, use time_jitter to correct the timestamp if required. |
| 1109 | # default: off | 1109 | # default: off |
| 1110 | mix_correct off; | 1110 | mix_correct off; |
| 1111 | + | ||
| 1112 | + # vhost for atc for hls/hds/rtmp backup. | ||
| 1113 | + # generally, atc default to off, server delivery rtmp stream to client(flash) timestamp from 0. | ||
| 1114 | + # when atc is on, server delivery rtmp stream by absolute time. | ||
| 1115 | + # atc is used, for instance, encoder will copy stream to master and slave server, | ||
| 1116 | + # server use atc to delivery stream to edge/client, where stream time from master/slave server | ||
| 1117 | + # is always the same, client/tools can slice RTMP stream to HLS according to the same time, | ||
| 1118 | + # if the time not the same, the HLS stream cannot slice to support system backup. | ||
| 1119 | + # | ||
| 1120 | + # @see http://www.adobe.com/cn/devnet/adobe-media-server/articles/varnish-sample-for-failover.html | ||
| 1121 | + # @see http://www.baidu.com/#wd=hds%20hls%20atc | ||
| 1122 | + # | ||
| 1123 | + # default: off | ||
| 1124 | + atc off; | ||
| 1125 | + # whether enable the auto atc, | ||
| 1126 | + # if enabled, detect the bravo_atc="true" in onMetaData packet, | ||
| 1127 | + # set atc to on if matched. | ||
| 1128 | + # always ignore the onMetaData if atc_auto is off. | ||
| 1129 | + # default: off | ||
| 1130 | + atc_auto off; | ||
| 1111 | } | 1131 | } |
| 1112 | } | 1132 | } |
| 1113 | 1133 | ||
| @@ -1121,24 +1141,9 @@ vhost jitter.srs.com { | @@ -1121,24 +1141,9 @@ vhost jitter.srs.com { | ||
| 1121 | 1141 | ||
| 1122 | # vhost for atc. | 1142 | # vhost for atc. |
| 1123 | vhost atc.srs.com { | 1143 | vhost atc.srs.com { |
| 1124 | - # vhost for atc for hls/hds/rtmp backup. | ||
| 1125 | - # generally, atc default to off, server delivery rtmp stream to client(flash) timestamp from 0. | ||
| 1126 | - # when atc is on, server delivery rtmp stream by absolute time. | ||
| 1127 | - # atc is used, for instance, encoder will copy stream to master and slave server, | ||
| 1128 | - # server use atc to delivery stream to edge/client, where stream time from master/slave server | ||
| 1129 | - # is always the same, client/tools can slice RTMP stream to HLS according to the same time, | ||
| 1130 | - # if the time not the same, the HLS stream cannot slice to support system backup. | ||
| 1131 | - # | ||
| 1132 | - # @see http://www.adobe.com/cn/devnet/adobe-media-server/articles/varnish-sample-for-failover.html | ||
| 1133 | - # @see http://www.baidu.com/#wd=hds%20hls%20atc | ||
| 1134 | - # | ||
| 1135 | - # default: off | 1144 | + # @see play.srs.com |
| 1136 | atc on; | 1145 | atc on; |
| 1137 | - # whether enable the auto atc, | ||
| 1138 | - # if enabled, detect the bravo_atc="true" in onMetaData packet, | ||
| 1139 | - # set atc to on if matched. | ||
| 1140 | - # always ignore the onMetaData if atc_auto is off. | ||
| 1141 | - # default: on | 1146 | + # @see play.srs.com |
| 1142 | atc_auto on; | 1147 | atc_auto on; |
| 1143 | } | 1148 | } |
| 1144 | 1149 |
| @@ -71,10 +71,10 @@ vhost vhost.srs.com { | @@ -71,10 +71,10 @@ vhost vhost.srs.com { | ||
| 71 | time_jitter full; | 71 | time_jitter full; |
| 72 | mix_correct off; | 72 | mix_correct off; |
| 73 | 73 | ||
| 74 | - # TODO | ||
| 75 | atc on; | 74 | atc on; |
| 76 | atc_auto on; | 75 | atc_auto on; |
| 77 | - | 76 | + |
| 77 | + # TODO | ||
| 78 | min_latency on; | 78 | min_latency on; |
| 79 | mw_latency 100; | 79 | mw_latency 100; |
| 80 | 80 |
| @@ -695,18 +695,6 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root) | @@ -695,18 +695,6 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root) | ||
| 695 | // ENABLED => ENABLED (modified) | 695 | // ENABLED => ENABLED (modified) |
| 696 | if (get_vhost_enabled(new_vhost) && get_vhost_enabled(old_vhost)) { | 696 | if (get_vhost_enabled(new_vhost) && get_vhost_enabled(old_vhost)) { |
| 697 | srs_trace("vhost %s maybe modified, reload its detail.", vhost.c_str()); | 697 | srs_trace("vhost %s maybe modified, reload its detail.", vhost.c_str()); |
| 698 | - // atc, only one per vhost | ||
| 699 | - if (!srs_directive_equals(new_vhost->get("atc"), old_vhost->get("atc"))) { | ||
| 700 | - for (it = subscribes.begin(); it != subscribes.end(); ++it) { | ||
| 701 | - ISrsReloadHandler* subscribe = *it; | ||
| 702 | - if ((ret = subscribe->on_reload_vhost_atc(vhost)) != ERROR_SUCCESS) { | ||
| 703 | - srs_error("vhost %s notify subscribes atc failed. ret=%d", vhost.c_str(), ret); | ||
| 704 | - return ret; | ||
| 705 | - } | ||
| 706 | - } | ||
| 707 | - srs_trace("vhost %s reload atc success.", vhost.c_str()); | ||
| 708 | - } | ||
| 709 | - | ||
| 710 | // gop_cache, only one per vhost | 698 | // gop_cache, only one per vhost |
| 711 | if (!srs_directive_equals(new_vhost->get("gop_cache"), old_vhost->get("gop_cache"))) { | 699 | if (!srs_directive_equals(new_vhost->get("gop_cache"), old_vhost->get("gop_cache"))) { |
| 712 | for (it = subscribes.begin(); it != subscribes.end(); ++it) { | 700 | for (it = subscribes.begin(); it != subscribes.end(); ++it) { |
| @@ -1742,14 +1730,6 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj) | @@ -1742,14 +1730,6 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj) | ||
| 1742 | obj->set("chunk_size", dir->dumps_arg0_to_number()); | 1730 | obj->set("chunk_size", dir->dumps_arg0_to_number()); |
| 1743 | } | 1731 | } |
| 1744 | 1732 | ||
| 1745 | - // atc | ||
| 1746 | - if ((dir = vhost->get("atc")) != NULL) { | ||
| 1747 | - obj->set("atc", dir->dumps_arg0_to_boolean()); | ||
| 1748 | - } | ||
| 1749 | - if ((dir = vhost->get("atc_auto")) != NULL) { | ||
| 1750 | - obj->set("atc_auto", dir->dumps_arg0_to_boolean()); | ||
| 1751 | - } | ||
| 1752 | - | ||
| 1753 | // mrw | 1733 | // mrw |
| 1754 | if ((dir = vhost->get("min_latency")) != NULL) { | 1734 | if ((dir = vhost->get("min_latency")) != NULL) { |
| 1755 | obj->set("min_latency", dir->dumps_arg0_to_boolean()); | 1735 | obj->set("min_latency", dir->dumps_arg0_to_boolean()); |
| @@ -1789,6 +1769,10 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj) | @@ -1789,6 +1769,10 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj) | ||
| 1789 | play->set("time_jitter", sdir->dumps_arg0_to_str()); | 1769 | play->set("time_jitter", sdir->dumps_arg0_to_str()); |
| 1790 | } else if (sdir->name == "mix_correct") { | 1770 | } else if (sdir->name == "mix_correct") { |
| 1791 | play->set("mix_correct", sdir->dumps_arg0_to_boolean()); | 1771 | play->set("mix_correct", sdir->dumps_arg0_to_boolean()); |
| 1772 | + } else if (sdir->name == "atc") { | ||
| 1773 | + play->set("atc", sdir->dumps_arg0_to_boolean()); | ||
| 1774 | + } else if (sdir->name == "atc_auto") { | ||
| 1775 | + play->set("atc_auto", sdir->dumps_arg0_to_boolean()); | ||
| 1792 | } | 1776 | } |
| 1793 | } | 1777 | } |
| 1794 | } | 1778 | } |
| @@ -2671,8 +2655,7 @@ int SrsConfig::check_config() | @@ -2671,8 +2655,7 @@ int SrsConfig::check_config() | ||
| 2671 | && n != "dvr" && n != "ingest" && n != "hls" && n != "http_hooks" | 2655 | && n != "dvr" && n != "ingest" && n != "hls" && n != "http_hooks" |
| 2672 | && n != "gop_cache" && n != "queue_length" | 2656 | && n != "gop_cache" && n != "queue_length" |
| 2673 | && n != "refer" && n != "forward" && n != "transcode" && n != "bandcheck" | 2657 | && n != "refer" && n != "forward" && n != "transcode" && n != "bandcheck" |
| 2674 | - && n != "atc" && n != "atc_auto" && n != "debug_srs_upnode" | ||
| 2675 | - && n != "play" && n != "publish" && n != "mw_latency" && n != "min_latency" | 2658 | + && n != "debug_srs_upnode" && n != "play" && n != "publish" && n != "mw_latency" && n != "min_latency" |
| 2676 | && n != "tcp_nodelay" && n != "send_min_interval" && n != "reduce_sequence_header" | 2659 | && n != "tcp_nodelay" && n != "send_min_interval" && n != "reduce_sequence_header" |
| 2677 | && n != "security" && n != "http_remux" | 2660 | && n != "security" && n != "http_remux" |
| 2678 | && n != "http_static" && n != "hds" && n != "exec" | 2661 | && n != "http_static" && n != "hds" && n != "exec" |
| @@ -2714,7 +2697,7 @@ int SrsConfig::check_config() | @@ -2714,7 +2697,7 @@ int SrsConfig::check_config() | ||
| 2714 | } else if (n == "play") { | 2697 | } else if (n == "play") { |
| 2715 | for (int j = 0; j < (int)conf->directives.size(); j++) { | 2698 | for (int j = 0; j < (int)conf->directives.size(); j++) { |
| 2716 | string m = conf->at(j)->name.c_str(); | 2699 | string m = conf->at(j)->name.c_str(); |
| 2717 | - if (m != "time_jitter" && m != "mix_correct") { | 2700 | + if (m != "time_jitter" && m != "mix_correct" && m != "atc" && m != "atc_auto" ) { |
| 2718 | ret = ERROR_SYSTEM_CONFIG_INVALID; | 2701 | ret = ERROR_SYSTEM_CONFIG_INVALID; |
| 2719 | srs_error("unsupported vhost play directive %s, ret=%d", m.c_str(), ret); | 2702 | srs_error("unsupported vhost play directive %s, ret=%d", m.c_str(), ret); |
| 2720 | return ret; | 2703 | return ret; |
| @@ -3264,6 +3247,11 @@ bool SrsConfig::get_atc(string vhost) | @@ -3264,6 +3247,11 @@ bool SrsConfig::get_atc(string vhost) | ||
| 3264 | return DEFAULT; | 3247 | return DEFAULT; |
| 3265 | } | 3248 | } |
| 3266 | 3249 | ||
| 3250 | + conf = conf->get("play"); | ||
| 3251 | + if (!conf || conf->arg0().empty()) { | ||
| 3252 | + return DEFAULT; | ||
| 3253 | + } | ||
| 3254 | + | ||
| 3267 | conf = conf->get("atc"); | 3255 | conf = conf->get("atc"); |
| 3268 | if (!conf || conf->arg0().empty()) { | 3256 | if (!conf || conf->arg0().empty()) { |
| 3269 | return DEFAULT; | 3257 | return DEFAULT; |
| @@ -3281,6 +3269,11 @@ bool SrsConfig::get_atc_auto(string vhost) | @@ -3281,6 +3269,11 @@ bool SrsConfig::get_atc_auto(string vhost) | ||
| 3281 | return DEFAULT; | 3269 | return DEFAULT; |
| 3282 | } | 3270 | } |
| 3283 | 3271 | ||
| 3272 | + conf = conf->get("play"); | ||
| 3273 | + if (!conf || conf->arg0().empty()) { | ||
| 3274 | + return DEFAULT; | ||
| 3275 | + } | ||
| 3276 | + | ||
| 3284 | conf = conf->get("atc_auto"); | 3277 | conf = conf->get("atc_auto"); |
| 3285 | if (!conf || conf->arg0().empty()) { | 3278 | if (!conf || conf->arg0().empty()) { |
| 3286 | return DEFAULT; | 3279 | return DEFAULT; |
| @@ -5696,13 +5689,14 @@ int srs_config_transform_vhost(SrsConfDirective* root) | @@ -5696,13 +5689,14 @@ int srs_config_transform_vhost(SrsConfDirective* root) | ||
| 5696 | std::vector<SrsConfDirective*>::iterator it; | 5689 | std::vector<SrsConfDirective*>::iterator it; |
| 5697 | for (it = dir->directives.begin(); it != dir->directives.end();) { | 5690 | for (it = dir->directives.begin(); it != dir->directives.end();) { |
| 5698 | SrsConfDirective* conf = *it; | 5691 | SrsConfDirective* conf = *it; |
| 5692 | + string n = conf->name; | ||
| 5699 | 5693 | ||
| 5700 | // SRS2.0, rename vhost http to http_static | 5694 | // SRS2.0, rename vhost http to http_static |
| 5701 | // SRS1: | 5695 | // SRS1: |
| 5702 | // vhost { http {} } | 5696 | // vhost { http {} } |
| 5703 | // SRS2+: | 5697 | // SRS2+: |
| 5704 | // vhost { http_static {} } | 5698 | // vhost { http_static {} } |
| 5705 | - if (conf->name == "http") { | 5699 | + if (n == "http") { |
| 5706 | conf->name = "http_static"; | 5700 | conf->name = "http_static"; |
| 5707 | ++it; | 5701 | ++it; |
| 5708 | continue; | 5702 | continue; |
| @@ -5713,19 +5707,19 @@ int srs_config_transform_vhost(SrsConfDirective* root) | @@ -5713,19 +5707,19 @@ int srs_config_transform_vhost(SrsConfDirective* root) | ||
| 5713 | // vhost { refer; refer_play; refer_publish; } | 5707 | // vhost { refer; refer_play; refer_publish; } |
| 5714 | // SRS3+: | 5708 | // SRS3+: |
| 5715 | // vhost { refer { enabled; all; play; publish; } } | 5709 | // vhost { refer { enabled; all; play; publish; } } |
| 5716 | - if ((conf->name == "refer" && conf->directives.empty()) || conf->name == "refer_play" || conf->name == "refer_publish") { | 5710 | + if ((n == "refer" && conf->directives.empty()) || n == "refer_play" || n == "refer_publish") { |
| 5717 | // remove the old one first, for name duplicated. | 5711 | // remove the old one first, for name duplicated. |
| 5718 | it = dir->directives.erase(it); | 5712 | it = dir->directives.erase(it); |
| 5719 | 5713 | ||
| 5720 | SrsConfDirective* refer = dir->get_or_create("refer"); | 5714 | SrsConfDirective* refer = dir->get_or_create("refer"); |
| 5721 | refer->get_or_create("enabled", "on"); | 5715 | refer->get_or_create("enabled", "on"); |
| 5722 | - if (conf->name == "refer") { | 5716 | + if (n == "refer") { |
| 5723 | SrsConfDirective* all = refer->get_or_create("all"); | 5717 | SrsConfDirective* all = refer->get_or_create("all"); |
| 5724 | all->args = conf->args; | 5718 | all->args = conf->args; |
| 5725 | - } else if (conf->name == "play") { | 5719 | + } else if (n == "play") { |
| 5726 | SrsConfDirective* play = refer->get_or_create("play"); | 5720 | SrsConfDirective* play = refer->get_or_create("play"); |
| 5727 | play->args = conf->args; | 5721 | play->args = conf->args; |
| 5728 | - } else if (conf->name == "publish") { | 5722 | + } else if (n == "publish") { |
| 5729 | SrsConfDirective* publish = refer->get_or_create("publish"); | 5723 | SrsConfDirective* publish = refer->get_or_create("publish"); |
| 5730 | publish->args = conf->args; | 5724 | publish->args = conf->args; |
| 5731 | } | 5725 | } |
| @@ -5740,7 +5734,7 @@ int srs_config_transform_vhost(SrsConfDirective* root) | @@ -5740,7 +5734,7 @@ int srs_config_transform_vhost(SrsConfDirective* root) | ||
| 5740 | // vhost { mr { enabled; latency; } } | 5734 | // vhost { mr { enabled; latency; } } |
| 5741 | // SRS3+: | 5735 | // SRS3+: |
| 5742 | // vhost { publish { mr; mr_latency; } } | 5736 | // vhost { publish { mr; mr_latency; } } |
| 5743 | - if (conf->name == "mr") { | 5737 | + if (n == "mr") { |
| 5744 | it = dir->directives.erase(it); | 5738 | it = dir->directives.erase(it); |
| 5745 | 5739 | ||
| 5746 | SrsConfDirective* publish = dir->get_or_create("publish"); | 5740 | SrsConfDirective* publish = dir->get_or_create("publish"); |
| @@ -5766,7 +5760,7 @@ int srs_config_transform_vhost(SrsConfDirective* root) | @@ -5766,7 +5760,7 @@ int srs_config_transform_vhost(SrsConfDirective* root) | ||
| 5766 | // vhost { publish_1stpkt_timeout; } | 5760 | // vhost { publish_1stpkt_timeout; } |
| 5767 | // SRS3+: | 5761 | // SRS3+: |
| 5768 | // vhost { publish { firstpkt_timeout; } } | 5762 | // vhost { publish { firstpkt_timeout; } } |
| 5769 | - if (conf->name == "publish_1stpkt_timeout") { | 5763 | + if (n == "publish_1stpkt_timeout") { |
| 5770 | it = dir->directives.erase(it); | 5764 | it = dir->directives.erase(it); |
| 5771 | 5765 | ||
| 5772 | SrsConfDirective* publish = dir->get_or_create("publish"); | 5766 | SrsConfDirective* publish = dir->get_or_create("publish"); |
| @@ -5783,7 +5777,7 @@ int srs_config_transform_vhost(SrsConfDirective* root) | @@ -5783,7 +5777,7 @@ int srs_config_transform_vhost(SrsConfDirective* root) | ||
| 5783 | // vhost { publish_normal_timeout; } | 5777 | // vhost { publish_normal_timeout; } |
| 5784 | // SRS3+: | 5778 | // SRS3+: |
| 5785 | // vhost { publish { normal_timeout; } } | 5779 | // vhost { publish { normal_timeout; } } |
| 5786 | - if (conf->name == "publish_normal_timeout") { | 5780 | + if (n == "publish_normal_timeout") { |
| 5787 | it = dir->directives.erase(it); | 5781 | it = dir->directives.erase(it); |
| 5788 | 5782 | ||
| 5789 | SrsConfDirective* publish = dir->get_or_create("publish"); | 5783 | SrsConfDirective* publish = dir->get_or_create("publish"); |
| @@ -5796,12 +5790,12 @@ int srs_config_transform_vhost(SrsConfDirective* root) | @@ -5796,12 +5790,12 @@ int srs_config_transform_vhost(SrsConfDirective* root) | ||
| 5796 | } | 5790 | } |
| 5797 | 5791 | ||
| 5798 | // SRS3.0, change the folowing like a shadow: | 5792 | // SRS3.0, change the folowing like a shadow: |
| 5799 | - // time_jitter, mix_correct | 5793 | + // time_jitter, mix_correct, atc, atc_auto |
| 5800 | // SRS1/2: | 5794 | // SRS1/2: |
| 5801 | // vhost { shadow; } | 5795 | // vhost { shadow; } |
| 5802 | // SRS3+: | 5796 | // SRS3+: |
| 5803 | // vhost { play { shadow; } } | 5797 | // vhost { play { shadow; } } |
| 5804 | - if (conf->name == "time_jitter" || conf->name == "mix_correct") { | 5798 | + if (n == "time_jitter" || n == "mix_correct" || n == "atc" || n == "atc_auto") { |
| 5805 | it = dir->directives.erase(it); | 5799 | it = dir->directives.erase(it); |
| 5806 | 5800 | ||
| 5807 | SrsConfDirective* play = dir->get_or_create("play"); | 5801 | SrsConfDirective* play = dir->get_or_create("play"); |
| @@ -125,11 +125,6 @@ int ISrsReloadHandler::on_reload_vhost_removed(string /*vhost*/) | @@ -125,11 +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_atc(string /*vhost*/) | ||
| 129 | -{ | ||
| 130 | - return ERROR_SUCCESS; | ||
| 131 | -} | ||
| 132 | - | ||
| 133 | int ISrsReloadHandler::on_reload_vhost_gop_cache(string /*vhost*/) | 128 | int ISrsReloadHandler::on_reload_vhost_gop_cache(string /*vhost*/) |
| 134 | { | 129 | { |
| 135 | return ERROR_SUCCESS; | 130 | return ERROR_SUCCESS; |
| @@ -64,7 +64,6 @@ public: | @@ -64,7 +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_atc(std::string vhost); | ||
| 68 | virtual int on_reload_vhost_gop_cache(std::string vhost); | 67 | virtual int on_reload_vhost_gop_cache(std::string vhost); |
| 69 | virtual int on_reload_vhost_queue_length(std::string vhost); | 68 | virtual int on_reload_vhost_queue_length(std::string vhost); |
| 70 | virtual int on_reload_vhost_play(std::string vhost); | 69 | virtual int on_reload_vhost_play(std::string vhost); |
| @@ -1043,25 +1043,6 @@ int SrsSource::initialize(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* h | @@ -1043,25 +1043,6 @@ int SrsSource::initialize(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* h | ||
| 1043 | return ret; | 1043 | return ret; |
| 1044 | } | 1044 | } |
| 1045 | 1045 | ||
| 1046 | -int SrsSource::on_reload_vhost_atc(string vhost) | ||
| 1047 | -{ | ||
| 1048 | - int ret = ERROR_SUCCESS; | ||
| 1049 | - | ||
| 1050 | - if (_req->vhost != vhost) { | ||
| 1051 | - return ret; | ||
| 1052 | - } | ||
| 1053 | - | ||
| 1054 | - // atc changed. | ||
| 1055 | - bool enabled_atc = _srs_config->get_atc(vhost); | ||
| 1056 | - | ||
| 1057 | - srs_warn("vhost %s atc changed to %d, connected client may corrupt.", | ||
| 1058 | - vhost.c_str(), enabled_atc); | ||
| 1059 | - | ||
| 1060 | - gop_cache->clear(); | ||
| 1061 | - | ||
| 1062 | - return ret; | ||
| 1063 | -} | ||
| 1064 | - | ||
| 1065 | int SrsSource::on_reload_vhost_gop_cache(string vhost) | 1046 | int SrsSource::on_reload_vhost_gop_cache(string vhost) |
| 1066 | { | 1047 | { |
| 1067 | int ret = ERROR_SUCCESS; | 1048 | int ret = ERROR_SUCCESS; |
| @@ -1133,13 +1114,26 @@ int SrsSource::on_reload_vhost_play(string vhost) | @@ -1133,13 +1114,26 @@ int SrsSource::on_reload_vhost_play(string vhost) | ||
| 1133 | jitter_algorithm = (SrsRtmpJitterAlgorithm)_srs_config->get_time_jitter(_req->vhost); | 1114 | jitter_algorithm = (SrsRtmpJitterAlgorithm)_srs_config->get_time_jitter(_req->vhost); |
| 1134 | 1115 | ||
| 1135 | // mix_correct | 1116 | // mix_correct |
| 1136 | - bool v = _srs_config->get_mix_correct(_req->vhost); | 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 | + } | ||
| 1137 | 1126 | ||
| 1138 | - // when changed, clear the mix queue. | ||
| 1139 | - if (v != mix_correct) { | ||
| 1140 | - mix_queue->clear(); | 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; | ||
| 1141 | } | 1136 | } |
| 1142 | - mix_correct = v; | ||
| 1143 | 1137 | ||
| 1144 | return ret; | 1138 | return ret; |
| 1145 | } | 1139 | } |
| @@ -451,11 +451,20 @@ private: | @@ -451,11 +451,20 @@ private: | ||
| 451 | std::vector<SrsConsumer*> consumers; | 451 | std::vector<SrsConsumer*> consumers; |
| 452 | // the time jitter algorithm for vhost. | 452 | // the time jitter algorithm for vhost. |
| 453 | SrsRtmpJitterAlgorithm jitter_algorithm; | 453 | SrsRtmpJitterAlgorithm jitter_algorithm; |
| 454 | - // whether use interlaced/mixed algorithm to correct timestamp. | 454 | + // for play, whether use interlaced/mixed algorithm to correct timestamp. |
| 455 | bool mix_correct; | 455 | bool mix_correct; |
| 456 | + // the mix queue to implements the mix correct algorithm. | ||
| 456 | SrsMixQueue* mix_queue; | 457 | SrsMixQueue* mix_queue; |
| 458 | + /** | ||
| 459 | + * for play, whether enabled atc. | ||
| 460 | + * atc whether atc(use absolute time and donot adjust time), | ||
| 461 | + * directly use msg time and donot adjust if atc is true, | ||
| 462 | + * otherwise, adjust msg time to start from 0 to make flash happy. | ||
| 463 | + */ | ||
| 464 | + bool atc; | ||
| 457 | // whether stream is monotonically increase. | 465 | // whether stream is monotonically increase. |
| 458 | bool is_monotonically_increase; | 466 | bool is_monotonically_increase; |
| 467 | + // the time of the packet we just got. | ||
| 459 | int64_t last_packet_time; | 468 | int64_t last_packet_time; |
| 460 | // hls handler. | 469 | // hls handler. |
| 461 | #ifdef SRS_AUTO_HLS | 470 | #ifdef SRS_AUTO_HLS |
| @@ -491,13 +500,6 @@ private: | @@ -491,13 +500,6 @@ private: | ||
| 491 | * can publish, true when is not streaming | 500 | * can publish, true when is not streaming |
| 492 | */ | 501 | */ |
| 493 | bool _can_publish; | 502 | bool _can_publish; |
| 494 | - /** | ||
| 495 | - * atc whether atc(use absolute time and donot adjust time), | ||
| 496 | - * directly use msg time and donot adjust if atc is true, | ||
| 497 | - * otherwise, adjust msg time to start from 0 to make flash happy. | ||
| 498 | - */ | ||
| 499 | - // TODO: FIXME: to support reload atc. | ||
| 500 | - bool atc; | ||
| 501 | private: | 503 | private: |
| 502 | SrsSharedPtrMessage* cache_metadata; | 504 | SrsSharedPtrMessage* cache_metadata; |
| 503 | // the cached video sequence header. | 505 | // the cached video sequence header. |
| @@ -518,7 +520,6 @@ public: | @@ -518,7 +520,6 @@ public: | ||
| 518 | virtual int initialize(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* hh); | 520 | virtual int initialize(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* hh); |
| 519 | // interface ISrsReloadHandler | 521 | // interface ISrsReloadHandler |
| 520 | public: | 522 | public: |
| 521 | - virtual int on_reload_vhost_atc(std::string vhost); | ||
| 522 | virtual int on_reload_vhost_gop_cache(std::string vhost); | 523 | virtual int on_reload_vhost_gop_cache(std::string vhost); |
| 523 | virtual int on_reload_vhost_queue_length(std::string vhost); | 524 | virtual int on_reload_vhost_queue_length(std::string vhost); |
| 524 | virtual int on_reload_vhost_play(std::string vhost); | 525 | virtual int on_reload_vhost_play(std::string vhost); |
| @@ -230,12 +230,6 @@ int MockReloadHandler::on_reload_vhost_removed(string /*vhost*/) | @@ -230,12 +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_atc(string /*vhost*/) | ||
| 234 | -{ | ||
| 235 | - vhost_atc_reloaded = true; | ||
| 236 | - return ERROR_SUCCESS; | ||
| 237 | -} | ||
| 238 | - | ||
| 239 | int MockReloadHandler::on_reload_vhost_gop_cache(string /*vhost*/) | 233 | int MockReloadHandler::on_reload_vhost_gop_cache(string /*vhost*/) |
| 240 | { | 234 | { |
| 241 | vhost_gop_cache_reloaded = true; | 235 | vhost_gop_cache_reloaded = true; |
| @@ -85,7 +85,6 @@ public: | @@ -85,7 +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_atc(std::string vhost); | ||
| 89 | virtual int on_reload_vhost_gop_cache(std::string vhost); | 88 | virtual int on_reload_vhost_gop_cache(std::string vhost); |
| 90 | virtual int on_reload_vhost_queue_length(std::string vhost); | 89 | virtual int on_reload_vhost_queue_length(std::string vhost); |
| 91 | virtual int on_reload_vhost_play(std::string vhost); | 90 | virtual int on_reload_vhost_play(std::string vhost); |
-
请 注册 或 登录 后发表评论