for #459, dvr support apply filter for ng-control dvr module.
正在显示
13 个修改的文件
包含
273 行增加
和
98 行删除
| @@ -344,8 +344,9 @@ Remark: | @@ -344,8 +344,9 @@ Remark: | ||
| 344 | 344 | ||
| 345 | ## History | 345 | ## History |
| 346 | 346 | ||
| 347 | -* v3.0, 2015-09-14, fix [#319][bug #319], http raw api support update global and vhost. 3.0.4 | ||
| 348 | -* v3.0, 2015-08-31, fix [#319][bug #319], http raw api support query global and vhost. 3.0.3 | 347 | +* v3.0, 2015-09-14, fix [#459][bug #459], dvr support apply filter for ng-control dvr module. |
| 348 | +* v3.0, 2015-09-14, fix [#319][bug #319], http raw api support update global and vhost. 3.0.3 | ||
| 349 | +* v3.0, 2015-08-31, fix [#319][bug #319], http raw api support query global and vhost. | ||
| 349 | * v3.0, 2015-08-28, fix [#471][bug #471], api response the width and height. 3.0.2 | 350 | * v3.0, 2015-08-28, fix [#471][bug #471], api response the width and height. 3.0.2 |
| 350 | * v3.0, 2015-08-25, fix [#367][bug #367], support nginx-rtmp exec. 3.0.1 | 351 | * v3.0, 2015-08-25, fix [#367][bug #367], support nginx-rtmp exec. 3.0.1 |
| 351 | * <strong>v2.0, 2015-08-23, [2.0 alpha0(2.0.185)][r2.0a0] released. 89022 lines.</strong> | 352 | * <strong>v2.0, 2015-08-23, [2.0 alpha0(2.0.185)][r2.0a0] released. 89022 lines.</strong> |
| @@ -1063,6 +1063,13 @@ vhost dvr.srs.com { | @@ -1063,6 +1063,13 @@ vhost dvr.srs.com { | ||
| 1063 | # whether enabled dvr features | 1063 | # whether enabled dvr features |
| 1064 | # default: off | 1064 | # default: off |
| 1065 | enabled on; | 1065 | enabled on; |
| 1066 | + # the filter for dvr to aplly to. | ||
| 1067 | + # all, dvr all streams of all apps. | ||
| 1068 | + # <app>/<stream>, apply to specified stream of app. | ||
| 1069 | + # for example, to dvr the following two streams: | ||
| 1070 | + # live/stream1 live/stream2 | ||
| 1071 | + # default: all | ||
| 1072 | + dvr_apply all; | ||
| 1066 | # the dvr plan. canbe: | 1073 | # the dvr plan. canbe: |
| 1067 | # session reap flv when session end(unpublish). | 1074 | # session reap flv when session end(unpublish). |
| 1068 | # segment reap flv when flv duration exceed the specified dvr_duration. | 1075 | # segment reap flv when flv duration exceed the specified dvr_duration. |
| @@ -832,8 +832,8 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root) | @@ -832,8 +832,8 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root) | ||
| 832 | srs_trace("vhost %s reload hds success.", vhost.c_str()); | 832 | srs_trace("vhost %s reload hds success.", vhost.c_str()); |
| 833 | } | 833 | } |
| 834 | 834 | ||
| 835 | - // dvr, only one per vhost | ||
| 836 | - if (!srs_directive_equals(new_vhost->get("dvr"), old_vhost->get("dvr"))) { | 835 | + // dvr, only one per vhost, except the dvr_apply |
| 836 | + if (!srs_directive_equals(new_vhost->get("dvr"), old_vhost->get("dvr"), "dvr_apply")) { | ||
| 837 | for (it = subscribes.begin(); it != subscribes.end(); ++it) { | 837 | for (it = subscribes.begin(); it != subscribes.end(); ++it) { |
| 838 | ISrsReloadHandler* subscribe = *it; | 838 | ISrsReloadHandler* subscribe = *it; |
| 839 | if ((ret = subscribe->on_reload_vhost_dvr(vhost)) != ERROR_SUCCESS) { | 839 | if ((ret = subscribe->on_reload_vhost_dvr(vhost)) != ERROR_SUCCESS) { |
| @@ -843,6 +843,24 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root) | @@ -843,6 +843,24 @@ int SrsConfig::reload_vhost(SrsConfDirective* old_root) | ||
| 843 | } | 843 | } |
| 844 | srs_trace("vhost %s reload dvr success.", vhost.c_str()); | 844 | srs_trace("vhost %s reload dvr success.", vhost.c_str()); |
| 845 | } | 845 | } |
| 846 | + // dvr_apply, the dynamic dvr filter. | ||
| 847 | + if (true) { | ||
| 848 | + // we must reload the dvr_apply, for it's apply to specified stream, | ||
| 849 | + // and we donot want one stream reload take effect on another one. | ||
| 850 | + // @see https://github.com/simple-rtmp-server/srs/issues/459#issuecomment-140296597 | ||
| 851 | + SrsConfDirective* nda = new_vhost->get("dvr")? new_vhost->get("dvr")->get("dvr_apply") : NULL; | ||
| 852 | + SrsConfDirective* oda = old_vhost->get("dvr")? old_vhost->get("dvr")->get("dvr_apply") : NULL; | ||
| 853 | + if (!srs_directive_equals(nda, oda)) { | ||
| 854 | + for (it = subscribes.begin(); it != subscribes.end(); ++it) { | ||
| 855 | + ISrsReloadHandler* subscribe = *it; | ||
| 856 | + if ((ret = subscribe->on_reload_vhost_dvr_apply(vhost)) != ERROR_SUCCESS) { | ||
| 857 | + srs_error("vhost %s notify subscribes dvr_apply failed. ret=%d", vhost.c_str(), ret); | ||
| 858 | + return ret; | ||
| 859 | + } | ||
| 860 | + } | ||
| 861 | + srs_trace("vhost %s reload dvr_apply success.", vhost.c_str()); | ||
| 862 | + } | ||
| 863 | + } | ||
| 846 | 864 | ||
| 847 | // exec, only one per vhost | 865 | // exec, only one per vhost |
| 848 | if (!srs_directive_equals(new_vhost->get("exec"), old_vhost->get("exec"))) { | 866 | if (!srs_directive_equals(new_vhost->get("exec"), old_vhost->get("exec"))) { |
| @@ -2070,6 +2088,8 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj) | @@ -2070,6 +2088,8 @@ int SrsConfig::vhost_to_json(SrsConfDirective* vhost, SrsAmf0Object* obj) | ||
| 2070 | 2088 | ||
| 2071 | if (sdir->name == "dvr_plan") { | 2089 | if (sdir->name == "dvr_plan") { |
| 2072 | dvr->set("dvr_plan", sdir->dumps_arg0_to_str()); | 2090 | dvr->set("dvr_plan", sdir->dumps_arg0_to_str()); |
| 2091 | + } else if (sdir->name == "dvr_apply") { | ||
| 2092 | + dvr->set("dvr_apply", sdir->dumps_args()); | ||
| 2073 | } else if (sdir->name == "dvr_path") { | 2093 | } else if (sdir->name == "dvr_path") { |
| 2074 | dvr->set("dvr_path", sdir->dumps_arg0_to_str()); | 2094 | dvr->set("dvr_path", sdir->dumps_arg0_to_str()); |
| 2075 | } else if (sdir->name == "dvr_duration") { | 2095 | } else if (sdir->name == "dvr_duration") { |
| @@ -3141,7 +3161,7 @@ int SrsConfig::check_config() | @@ -3141,7 +3161,7 @@ int SrsConfig::check_config() | ||
| 3141 | if (n == "dvr") { | 3161 | if (n == "dvr") { |
| 3142 | for (int j = 0; j < (int)conf->directives.size(); j++) { | 3162 | for (int j = 0; j < (int)conf->directives.size(); j++) { |
| 3143 | string m = conf->at(j)->name.c_str(); | 3163 | string m = conf->at(j)->name.c_str(); |
| 3144 | - if (m != "enabled" && m != "dvr_path" && m != "dvr_plan" | 3164 | + if (m != "enabled" && m != "dvr_apply" && m != "dvr_path" && m != "dvr_plan" |
| 3145 | && m != "dvr_duration" && m != "dvr_wait_keyframe" && m != "time_jitter" | 3165 | && m != "dvr_duration" && m != "dvr_wait_keyframe" && m != "time_jitter" |
| 3146 | ) { | 3166 | ) { |
| 3147 | ret = ERROR_SYSTEM_CONFIG_INVALID; | 3167 | ret = ERROR_SYSTEM_CONFIG_INVALID; |
| @@ -5558,6 +5578,22 @@ bool SrsConfig::get_dvr_enabled(string vhost) | @@ -5558,6 +5578,22 @@ bool SrsConfig::get_dvr_enabled(string vhost) | ||
| 5558 | return SRS_CONF_PERFER_FALSE(conf->arg0()); | 5578 | return SRS_CONF_PERFER_FALSE(conf->arg0()); |
| 5559 | } | 5579 | } |
| 5560 | 5580 | ||
| 5581 | +SrsConfDirective* SrsConfig::get_dvr_apply(string vhost) | ||
| 5582 | +{ | ||
| 5583 | + SrsConfDirective* conf = get_dvr(vhost); | ||
| 5584 | + if (!conf) { | ||
| 5585 | + return NULL; | ||
| 5586 | + } | ||
| 5587 | + | ||
| 5588 | + conf = conf->get("dvr_apply"); | ||
| 5589 | + if (!conf || conf->arg0().empty()) { | ||
| 5590 | + return NULL; | ||
| 5591 | + } | ||
| 5592 | + | ||
| 5593 | + return conf; | ||
| 5594 | + | ||
| 5595 | +} | ||
| 5596 | + | ||
| 5561 | string SrsConfig::get_dvr_path(string vhost) | 5597 | string SrsConfig::get_dvr_path(string vhost) |
| 5562 | { | 5598 | { |
| 5563 | static string DEFAULT = "./objs/nginx/html/[app]/[stream].[timestamp].flv"; | 5599 | static string DEFAULT = "./objs/nginx/html/[app]/[stream].[timestamp].flv"; |
| @@ -6179,7 +6215,7 @@ namespace _srs_internal | @@ -6179,7 +6215,7 @@ namespace _srs_internal | ||
| 6179 | } | 6215 | } |
| 6180 | }; | 6216 | }; |
| 6181 | 6217 | ||
| 6182 | -bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b) | 6218 | +bool srs_directive_equals_self(SrsConfDirective* a, SrsConfDirective* b) |
| 6183 | { | 6219 | { |
| 6184 | // both NULL, equal. | 6220 | // both NULL, equal. |
| 6185 | if (!a && !b) { | 6221 | if (!a && !b) { |
| @@ -6208,6 +6244,20 @@ bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b) | @@ -6208,6 +6244,20 @@ bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b) | ||
| 6208 | return false; | 6244 | return false; |
| 6209 | } | 6245 | } |
| 6210 | 6246 | ||
| 6247 | + return true; | ||
| 6248 | +} | ||
| 6249 | + | ||
| 6250 | +bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b) | ||
| 6251 | +{ | ||
| 6252 | + // both NULL, equal. | ||
| 6253 | + if (!a && !b) { | ||
| 6254 | + return true; | ||
| 6255 | + } | ||
| 6256 | + | ||
| 6257 | + if (!srs_directive_equals_self(a, b)) { | ||
| 6258 | + return false; | ||
| 6259 | + } | ||
| 6260 | + | ||
| 6211 | for (int i = 0; i < (int)a->directives.size(); i++) { | 6261 | for (int i = 0; i < (int)a->directives.size(); i++) { |
| 6212 | SrsConfDirective* a0 = a->at(i); | 6262 | SrsConfDirective* a0 = a->at(i); |
| 6213 | SrsConfDirective* b0 = b->at(i); | 6263 | SrsConfDirective* b0 = b->at(i); |
| @@ -6220,6 +6270,34 @@ bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b) | @@ -6220,6 +6270,34 @@ bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b) | ||
| 6220 | return true; | 6270 | return true; |
| 6221 | } | 6271 | } |
| 6222 | 6272 | ||
| 6273 | +bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b, string except) | ||
| 6274 | +{ | ||
| 6275 | + // both NULL, equal. | ||
| 6276 | + if (!a && !b) { | ||
| 6277 | + return true; | ||
| 6278 | + } | ||
| 6279 | + | ||
| 6280 | + if (!srs_directive_equals_self(a, b)) { | ||
| 6281 | + return false; | ||
| 6282 | + } | ||
| 6283 | + | ||
| 6284 | + for (int i = 0; i < (int)a->directives.size(); i++) { | ||
| 6285 | + SrsConfDirective* a0 = a->at(i); | ||
| 6286 | + SrsConfDirective* b0 = b->at(i); | ||
| 6287 | + | ||
| 6288 | + // donot compare the except child directive. | ||
| 6289 | + if (a0->name == except) { | ||
| 6290 | + continue; | ||
| 6291 | + } | ||
| 6292 | + | ||
| 6293 | + if (!srs_directive_equals(a0, b0, except)) { | ||
| 6294 | + return false; | ||
| 6295 | + } | ||
| 6296 | + } | ||
| 6297 | + | ||
| 6298 | + return true; | ||
| 6299 | +} | ||
| 6300 | + | ||
| 6223 | bool srs_config_hls_is_on_error_ignore(string strategy) | 6301 | bool srs_config_hls_is_on_error_ignore(string strategy) |
| 6224 | { | 6302 | { |
| 6225 | return strategy == "ignore"; | 6303 | return strategy == "ignore"; |
| @@ -6270,6 +6348,27 @@ bool srs_stream_caster_is_flv(string caster) | @@ -6270,6 +6348,27 @@ bool srs_stream_caster_is_flv(string caster) | ||
| 6270 | return caster == "flv"; | 6348 | return caster == "flv"; |
| 6271 | } | 6349 | } |
| 6272 | 6350 | ||
| 6351 | +bool srs_config_apply_filter(SrsConfDirective* dvr_apply, SrsRequest* req) | ||
| 6352 | +{ | ||
| 6353 | + static bool DEFAULT = true; | ||
| 6354 | + | ||
| 6355 | + if (!dvr_apply || dvr_apply->args.empty()) { | ||
| 6356 | + return DEFAULT; | ||
| 6357 | + } | ||
| 6358 | + | ||
| 6359 | + vector<string>& args = dvr_apply->args; | ||
| 6360 | + if (args.size() == 1 && dvr_apply->arg0() == "all") { | ||
| 6361 | + return true; | ||
| 6362 | + } | ||
| 6363 | + | ||
| 6364 | + string id = req->app + "/" + req->stream; | ||
| 6365 | + if (::find(args.begin(), args.end(), id) != args.end()) { | ||
| 6366 | + return true; | ||
| 6367 | + } | ||
| 6368 | + | ||
| 6369 | + return false; | ||
| 6370 | +} | ||
| 6371 | + | ||
| 6273 | string srs_config_bool2switch(const string& sbool) | 6372 | string srs_config_bool2switch(const string& sbool) |
| 6274 | { | 6373 | { |
| 6275 | return sbool == "true"? "on":"off"; | 6374 | return sbool == "true"? "on":"off"; |
| @@ -35,6 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -35,6 +35,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 35 | 35 | ||
| 36 | #include <srs_app_reload.hpp> | 36 | #include <srs_app_reload.hpp> |
| 37 | 37 | ||
| 38 | +class SrsRequest; | ||
| 38 | class SrsFileWriter; | 39 | class SrsFileWriter; |
| 39 | class SrsAmf0Object; | 40 | class SrsAmf0Object; |
| 40 | class SrsAmf0StrictArray; | 41 | class SrsAmf0StrictArray; |
| @@ -1116,6 +1117,11 @@ public: | @@ -1116,6 +1117,11 @@ public: | ||
| 1116 | */ | 1117 | */ |
| 1117 | virtual bool get_dvr_enabled(std::string vhost); | 1118 | virtual bool get_dvr_enabled(std::string vhost); |
| 1118 | /** | 1119 | /** |
| 1120 | + * get the filter of dvr to apply to. | ||
| 1121 | + * @remark user can use srs_config_apply_filter(conf, req):bool to check it. | ||
| 1122 | + */ | ||
| 1123 | + virtual SrsConfDirective* get_dvr_apply(std::string vhost); | ||
| 1124 | + /** | ||
| 1119 | * get the dvr path, the flv file to save in. | 1125 | * get the dvr path, the flv file to save in. |
| 1120 | */ | 1126 | */ |
| 1121 | virtual std::string get_dvr_path(std::string vhost); | 1127 | virtual std::string get_dvr_path(std::string vhost); |
| @@ -1308,8 +1314,9 @@ namespace _srs_internal | @@ -1308,8 +1314,9 @@ namespace _srs_internal | ||
| 1308 | 1314 | ||
| 1309 | /** | 1315 | /** |
| 1310 | * deep compare directive. | 1316 | * deep compare directive. |
| 1311 | -*/ | 1317 | + */ |
| 1312 | extern bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b); | 1318 | extern bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b); |
| 1319 | +extern bool srs_directive_equals(SrsConfDirective* a, SrsConfDirective* b, std::string except); | ||
| 1313 | 1320 | ||
| 1314 | /** | 1321 | /** |
| 1315 | * helper utilities, used for compare the consts values. | 1322 | * helper utilities, used for compare the consts values. |
| @@ -1324,6 +1331,8 @@ extern bool srs_config_dvr_is_plan_append(std::string plan); | @@ -1324,6 +1331,8 @@ extern bool srs_config_dvr_is_plan_append(std::string plan); | ||
| 1324 | extern bool srs_stream_caster_is_udp(std::string caster); | 1331 | extern bool srs_stream_caster_is_udp(std::string caster); |
| 1325 | extern bool srs_stream_caster_is_rtsp(std::string caster); | 1332 | extern bool srs_stream_caster_is_rtsp(std::string caster); |
| 1326 | extern bool srs_stream_caster_is_flv(std::string caster); | 1333 | extern bool srs_stream_caster_is_flv(std::string caster); |
| 1334 | +// whether the dvr_apply active the stream specified by req. | ||
| 1335 | +extern bool srs_config_apply_filter(SrsConfDirective* dvr_apply, SrsRequest* req); | ||
| 1327 | 1336 | ||
| 1328 | /** | 1337 | /** |
| 1329 | * convert bool in str to on/off | 1338 | * convert bool in str to on/off |
| @@ -972,10 +972,16 @@ SrsDvr::SrsDvr() | @@ -972,10 +972,16 @@ SrsDvr::SrsDvr() | ||
| 972 | { | 972 | { |
| 973 | source = NULL; | 973 | source = NULL; |
| 974 | plan = NULL; | 974 | plan = NULL; |
| 975 | + req = NULL; | ||
| 976 | + actived = false; | ||
| 977 | + | ||
| 978 | + _srs_config->subscribe(this); | ||
| 975 | } | 979 | } |
| 976 | 980 | ||
| 977 | SrsDvr::~SrsDvr() | 981 | SrsDvr::~SrsDvr() |
| 978 | { | 982 | { |
| 983 | + _srs_config->unsubscribe(this); | ||
| 984 | + | ||
| 979 | srs_freep(plan); | 985 | srs_freep(plan); |
| 980 | } | 986 | } |
| 981 | 987 | ||
| @@ -983,30 +989,39 @@ int SrsDvr::initialize(SrsSource* s, SrsRequest* r) | @@ -983,30 +989,39 @@ int SrsDvr::initialize(SrsSource* s, SrsRequest* r) | ||
| 983 | { | 989 | { |
| 984 | int ret = ERROR_SUCCESS; | 990 | int ret = ERROR_SUCCESS; |
| 985 | 991 | ||
| 992 | + req = r; | ||
| 986 | source = s; | 993 | source = s; |
| 987 | 994 | ||
| 995 | + SrsConfDirective* conf = _srs_config->get_dvr_apply(r->vhost); | ||
| 996 | + actived = srs_config_apply_filter(conf, r); | ||
| 997 | + | ||
| 988 | srs_freep(plan); | 998 | srs_freep(plan); |
| 989 | plan = SrsDvrPlan::create_plan(r->vhost); | 999 | plan = SrsDvrPlan::create_plan(r->vhost); |
| 990 | 1000 | ||
| 991 | if ((ret = plan->initialize(r)) != ERROR_SUCCESS) { | 1001 | if ((ret = plan->initialize(r)) != ERROR_SUCCESS) { |
| 992 | return ret; | 1002 | return ret; |
| 993 | } | 1003 | } |
| 994 | - | ||
| 995 | - if ((ret = source->on_dvr_request_sh()) != ERROR_SUCCESS) { | ||
| 996 | - return ret; | ||
| 997 | - } | ||
| 998 | 1004 | ||
| 999 | return ret; | 1005 | return ret; |
| 1000 | } | 1006 | } |
| 1001 | 1007 | ||
| 1002 | -int SrsDvr::on_publish(SrsRequest* /*r*/) | 1008 | +int SrsDvr::on_publish(bool fetch_sequence_header) |
| 1003 | { | 1009 | { |
| 1004 | int ret = ERROR_SUCCESS; | 1010 | int ret = ERROR_SUCCESS; |
| 1005 | 1011 | ||
| 1012 | + // the dvr for this stream is not actived. | ||
| 1013 | + if (!actived) { | ||
| 1014 | + return ret; | ||
| 1015 | + } | ||
| 1016 | + | ||
| 1006 | if ((ret = plan->on_publish()) != ERROR_SUCCESS) { | 1017 | if ((ret = plan->on_publish()) != ERROR_SUCCESS) { |
| 1007 | return ret; | 1018 | return ret; |
| 1008 | } | 1019 | } |
| 1009 | 1020 | ||
| 1021 | + if (fetch_sequence_header && (ret = source->on_dvr_request_sh()) != ERROR_SUCCESS) { | ||
| 1022 | + return ret; | ||
| 1023 | + } | ||
| 1024 | + | ||
| 1010 | return ret; | 1025 | return ret; |
| 1011 | } | 1026 | } |
| 1012 | 1027 | ||
| @@ -1019,6 +1034,11 @@ void SrsDvr::on_unpublish() | @@ -1019,6 +1034,11 @@ void SrsDvr::on_unpublish() | ||
| 1019 | int SrsDvr::on_meta_data(SrsOnMetaDataPacket* m) | 1034 | int SrsDvr::on_meta_data(SrsOnMetaDataPacket* m) |
| 1020 | { | 1035 | { |
| 1021 | int ret = ERROR_SUCCESS; | 1036 | int ret = ERROR_SUCCESS; |
| 1037 | + | ||
| 1038 | + // the dvr for this stream is not actived. | ||
| 1039 | + if (!actived) { | ||
| 1040 | + return ret; | ||
| 1041 | + } | ||
| 1022 | 1042 | ||
| 1023 | int size = 0; | 1043 | int size = 0; |
| 1024 | char* payload = NULL; | 1044 | char* payload = NULL; |
| @@ -1040,14 +1060,42 @@ int SrsDvr::on_meta_data(SrsOnMetaDataPacket* m) | @@ -1040,14 +1060,42 @@ int SrsDvr::on_meta_data(SrsOnMetaDataPacket* m) | ||
| 1040 | 1060 | ||
| 1041 | int SrsDvr::on_audio(SrsSharedPtrMessage* shared_audio) | 1061 | int SrsDvr::on_audio(SrsSharedPtrMessage* shared_audio) |
| 1042 | { | 1062 | { |
| 1063 | + // the dvr for this stream is not actived. | ||
| 1064 | + if (!actived) { | ||
| 1065 | + return ERROR_SUCCESS; | ||
| 1066 | + } | ||
| 1067 | + | ||
| 1043 | return plan->on_audio(shared_audio); | 1068 | return plan->on_audio(shared_audio); |
| 1044 | } | 1069 | } |
| 1045 | 1070 | ||
| 1046 | int SrsDvr::on_video(SrsSharedPtrMessage* shared_video) | 1071 | int SrsDvr::on_video(SrsSharedPtrMessage* shared_video) |
| 1047 | { | 1072 | { |
| 1073 | + // the dvr for this stream is not actived. | ||
| 1074 | + if (!actived) { | ||
| 1075 | + return ERROR_SUCCESS; | ||
| 1076 | + } | ||
| 1077 | + | ||
| 1048 | return plan->on_video(shared_video); | 1078 | return plan->on_video(shared_video); |
| 1049 | } | 1079 | } |
| 1050 | 1080 | ||
| 1081 | +int SrsDvr::on_reload_vhost_dvr_apply(string vhost) | ||
| 1082 | +{ | ||
| 1083 | + int ret = ERROR_SUCCESS; | ||
| 1084 | + | ||
| 1085 | + SrsConfDirective* conf = _srs_config->get_dvr_apply(req->vhost); | ||
| 1086 | + bool v = srs_config_apply_filter(conf, req); | ||
| 1087 | + | ||
| 1088 | + // the apply changed, republish the dvr. | ||
| 1089 | + if (v != actived) { | ||
| 1090 | + actived = v; | ||
| 1091 | + | ||
| 1092 | + on_unpublish(); | ||
| 1093 | + return on_publish(true); | ||
| 1094 | + } | ||
| 1095 | + | ||
| 1096 | + return ret; | ||
| 1097 | +} | ||
| 1098 | + | ||
| 1051 | #endif | 1099 | #endif |
| 1052 | 1100 | ||
| 1053 | 1101 |
| @@ -297,27 +297,33 @@ private: | @@ -297,27 +297,33 @@ private: | ||
| 297 | * dvr(digital video recorder) to record RTMP stream to flv file. | 297 | * dvr(digital video recorder) to record RTMP stream to flv file. |
| 298 | * TODO: FIXME: add utest for it. | 298 | * TODO: FIXME: add utest for it. |
| 299 | */ | 299 | */ |
| 300 | -class SrsDvr | 300 | +class SrsDvr : public ISrsReloadHandler |
| 301 | { | 301 | { |
| 302 | private: | 302 | private: |
| 303 | SrsSource* source; | 303 | SrsSource* source; |
| 304 | -private: | ||
| 305 | SrsDvrPlan* plan; | 304 | SrsDvrPlan* plan; |
| 305 | + SrsRequest* req; | ||
| 306 | +private: | ||
| 307 | + // whether the dvr is actived by filter, which is specified by dvr_apply. | ||
| 308 | + // we always initialize the dvr, which crote plan and segment object, | ||
| 309 | + // but they never create actual piece of file util the apply active it. | ||
| 310 | + bool actived; | ||
| 306 | public: | 311 | public: |
| 307 | SrsDvr(); | 312 | SrsDvr(); |
| 308 | virtual ~SrsDvr(); | 313 | virtual ~SrsDvr(); |
| 309 | public: | 314 | public: |
| 310 | /** | 315 | /** |
| 311 | - * initialize dvr, create dvr plan. | ||
| 312 | - * when system initialize(encoder publish at first time, or reload), | ||
| 313 | - * initialize the dvr will reinitialize the plan, the whole dvr framework. | ||
| 314 | - */ | 316 | + * initialize dvr, create dvr plan. |
| 317 | + * when system initialize(encoder publish at first time, or reload), | ||
| 318 | + * initialize the dvr will reinitialize the plan, the whole dvr framework. | ||
| 319 | + */ | ||
| 315 | virtual int initialize(SrsSource* s, SrsRequest* r); | 320 | virtual int initialize(SrsSource* s, SrsRequest* r); |
| 316 | /** | 321 | /** |
| 317 | - * publish stream event, | ||
| 318 | - * when encoder start to publish RTMP stream. | ||
| 319 | - */ | ||
| 320 | - virtual int on_publish(SrsRequest* r); | 322 | + * publish stream event, |
| 323 | + * when encoder start to publish RTMP stream. | ||
| 324 | + * @param fetch_sequence_header whether fetch sequence from source. | ||
| 325 | + */ | ||
| 326 | + virtual int on_publish(bool fetch_sequence_header); | ||
| 321 | /** | 327 | /** |
| 322 | * the unpublish event., | 328 | * the unpublish event., |
| 323 | * when encoder stop(unpublish) to publish RTMP stream. | 329 | * when encoder stop(unpublish) to publish RTMP stream. |
| @@ -337,6 +343,9 @@ public: | @@ -337,6 +343,9 @@ public: | ||
| 337 | * @param shared_video, directly ptr, copy it if need to save it. | 343 | * @param shared_video, directly ptr, copy it if need to save it. |
| 338 | */ | 344 | */ |
| 339 | virtual int on_video(SrsSharedPtrMessage* shared_video); | 345 | virtual int on_video(SrsSharedPtrMessage* shared_video); |
| 346 | +// interface ISrsReloadHandler | ||
| 347 | +public: | ||
| 348 | + virtual int on_reload_vhost_dvr_apply(std::string vhost); | ||
| 340 | }; | 349 | }; |
| 341 | 350 | ||
| 342 | #endif | 351 | #endif |
| @@ -1163,7 +1163,7 @@ int SrsHlsCache::reap_segment(string log_desc, SrsHlsMuxer* muxer, int64_t segme | @@ -1163,7 +1163,7 @@ int SrsHlsCache::reap_segment(string log_desc, SrsHlsMuxer* muxer, int64_t segme | ||
| 1163 | 1163 | ||
| 1164 | SrsHls::SrsHls() | 1164 | SrsHls::SrsHls() |
| 1165 | { | 1165 | { |
| 1166 | - _req = NULL; | 1166 | + req = NULL; |
| 1167 | source = NULL; | 1167 | source = NULL; |
| 1168 | handler = NULL; | 1168 | handler = NULL; |
| 1169 | 1169 | ||
| @@ -1184,7 +1184,6 @@ SrsHls::SrsHls() | @@ -1184,7 +1184,6 @@ SrsHls::SrsHls() | ||
| 1184 | 1184 | ||
| 1185 | SrsHls::~SrsHls() | 1185 | SrsHls::~SrsHls() |
| 1186 | { | 1186 | { |
| 1187 | - srs_freep(_req); | ||
| 1188 | srs_freep(codec); | 1187 | srs_freep(codec); |
| 1189 | srs_freep(sample); | 1188 | srs_freep(sample); |
| 1190 | srs_freep(jitter); | 1189 | srs_freep(jitter); |
| @@ -1214,11 +1213,11 @@ int SrsHls::cycle() | @@ -1214,11 +1213,11 @@ int SrsHls::cycle() | ||
| 1214 | last_update_time = srs_get_system_time_ms(); | 1213 | last_update_time = srs_get_system_time_ms(); |
| 1215 | } | 1214 | } |
| 1216 | 1215 | ||
| 1217 | - if (!_req) { | 1216 | + if (!req) { |
| 1218 | return ret; | 1217 | return ret; |
| 1219 | } | 1218 | } |
| 1220 | 1219 | ||
| 1221 | - int hls_dispose = _srs_config->get_hls_dispose(_req->vhost) * 1000; | 1220 | + int hls_dispose = _srs_config->get_hls_dispose(req->vhost) * 1000; |
| 1222 | if (hls_dispose <= 0) { | 1221 | if (hls_dispose <= 0) { |
| 1223 | return ret; | 1222 | return ret; |
| 1224 | } | 1223 | } |
| @@ -1232,18 +1231,19 @@ int SrsHls::cycle() | @@ -1232,18 +1231,19 @@ int SrsHls::cycle() | ||
| 1232 | } | 1231 | } |
| 1233 | hls_can_dispose = false; | 1232 | hls_can_dispose = false; |
| 1234 | 1233 | ||
| 1235 | - srs_trace("hls cycle to dispose hls %s, timeout=%dms", _req->get_stream_url().c_str(), hls_dispose); | 1234 | + srs_trace("hls cycle to dispose hls %s, timeout=%dms", req->get_stream_url().c_str(), hls_dispose); |
| 1236 | dispose(); | 1235 | dispose(); |
| 1237 | 1236 | ||
| 1238 | return ret; | 1237 | return ret; |
| 1239 | } | 1238 | } |
| 1240 | 1239 | ||
| 1241 | -int SrsHls::initialize(SrsSource* s, ISrsHlsHandler* h) | 1240 | +int SrsHls::initialize(SrsSource* s, ISrsHlsHandler* h, SrsRequest* r) |
| 1242 | { | 1241 | { |
| 1243 | int ret = ERROR_SUCCESS; | 1242 | int ret = ERROR_SUCCESS; |
| 1244 | 1243 | ||
| 1245 | source = s; | 1244 | source = s; |
| 1246 | handler = h; | 1245 | handler = h; |
| 1246 | + req = r; | ||
| 1247 | 1247 | ||
| 1248 | if ((ret = muxer->initialize(h)) != ERROR_SUCCESS) { | 1248 | if ((ret = muxer->initialize(h)) != ERROR_SUCCESS) { |
| 1249 | return ret; | 1249 | return ret; |
| @@ -1252,13 +1252,10 @@ int SrsHls::initialize(SrsSource* s, ISrsHlsHandler* h) | @@ -1252,13 +1252,10 @@ int SrsHls::initialize(SrsSource* s, ISrsHlsHandler* h) | ||
| 1252 | return ret; | 1252 | return ret; |
| 1253 | } | 1253 | } |
| 1254 | 1254 | ||
| 1255 | -int SrsHls::on_publish(SrsRequest* req, bool fetch_sequence_header) | 1255 | +int SrsHls::on_publish(bool fetch_sequence_header) |
| 1256 | { | 1256 | { |
| 1257 | int ret = ERROR_SUCCESS; | 1257 | int ret = ERROR_SUCCESS; |
| 1258 | 1258 | ||
| 1259 | - srs_freep(_req); | ||
| 1260 | - _req = req->copy(); | ||
| 1261 | - | ||
| 1262 | // update the hls time, for hls_dispose. | 1259 | // update the hls time, for hls_dispose. |
| 1263 | last_update_time = srs_get_system_time_ms(); | 1260 | last_update_time = srs_get_system_time_ms(); |
| 1264 | 1261 | ||
| @@ -1412,7 +1409,7 @@ int SrsHls::on_video(SrsSharedPtrMessage* shared_video, bool is_sps_pps) | @@ -1412,7 +1409,7 @@ int SrsHls::on_video(SrsSharedPtrMessage* shared_video, bool is_sps_pps) | ||
| 1412 | // user can disable the sps parse to workaround when parse sps failed. | 1409 | // user can disable the sps parse to workaround when parse sps failed. |
| 1413 | // @see https://github.com/simple-rtmp-server/srs/issues/474 | 1410 | // @see https://github.com/simple-rtmp-server/srs/issues/474 |
| 1414 | if (is_sps_pps) { | 1411 | if (is_sps_pps) { |
| 1415 | - codec->avc_parse_sps = _srs_config->get_parse_sps(_req->vhost); | 1412 | + codec->avc_parse_sps = _srs_config->get_parse_sps(req->vhost); |
| 1416 | } | 1413 | } |
| 1417 | 1414 | ||
| 1418 | sample->clear(); | 1415 | sample->clear(); |
| @@ -388,7 +388,7 @@ private: | @@ -388,7 +388,7 @@ private: | ||
| 388 | SrsHlsCache* hls_cache; | 388 | SrsHlsCache* hls_cache; |
| 389 | ISrsHlsHandler* handler; | 389 | ISrsHlsHandler* handler; |
| 390 | private: | 390 | private: |
| 391 | - SrsRequest* _req; | 391 | + SrsRequest* req; |
| 392 | bool hls_enabled; | 392 | bool hls_enabled; |
| 393 | bool hls_can_dispose; | 393 | bool hls_can_dispose; |
| 394 | int64_t last_update_time; | 394 | int64_t last_update_time; |
| @@ -422,13 +422,13 @@ public: | @@ -422,13 +422,13 @@ public: | ||
| 422 | /** | 422 | /** |
| 423 | * initialize the hls by handler and source. | 423 | * initialize the hls by handler and source. |
| 424 | */ | 424 | */ |
| 425 | - virtual int initialize(SrsSource* s, ISrsHlsHandler* h); | 425 | + virtual int initialize(SrsSource* s, ISrsHlsHandler* h, SrsRequest* r); |
| 426 | /** | 426 | /** |
| 427 | * publish stream event, continue to write the m3u8, | 427 | * publish stream event, continue to write the m3u8, |
| 428 | * for the muxer object not destroyed. | 428 | * for the muxer object not destroyed. |
| 429 | * @param fetch_sequence_header whether fetch sequence from source. | 429 | * @param fetch_sequence_header whether fetch sequence from source. |
| 430 | */ | 430 | */ |
| 431 | - virtual int on_publish(SrsRequest* req, bool fetch_sequence_header); | 431 | + virtual int on_publish(bool fetch_sequence_header); |
| 432 | /** | 432 | /** |
| 433 | * the unpublish event, only close the muxer, donot destroy the | 433 | * the unpublish event, only close the muxer, donot destroy the |
| 434 | * muxer, for when we continue to publish, the m3u8 will continue. | 434 | * muxer, for when we continue to publish, the m3u8 will continue. |
| @@ -155,6 +155,11 @@ int ISrsReloadHandler::on_reload_vhost_dvr(string /*vhost*/) | @@ -155,6 +155,11 @@ int ISrsReloadHandler::on_reload_vhost_dvr(string /*vhost*/) | ||
| 155 | return ERROR_SUCCESS; | 155 | return ERROR_SUCCESS; |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | +int ISrsReloadHandler::on_reload_vhost_dvr_apply(string /*vhost*/) | ||
| 159 | +{ | ||
| 160 | + return ERROR_SUCCESS; | ||
| 161 | +} | ||
| 162 | + | ||
| 158 | int ISrsReloadHandler::on_reload_vhost_publish(string /*vhost*/) | 163 | int ISrsReloadHandler::on_reload_vhost_publish(string /*vhost*/) |
| 159 | { | 164 | { |
| 160 | return ERROR_SUCCESS; | 165 | return ERROR_SUCCESS; |
| @@ -70,6 +70,7 @@ public: | @@ -70,6 +70,7 @@ public: | ||
| 70 | virtual int on_reload_vhost_hls(std::string vhost); | 70 | virtual int on_reload_vhost_hls(std::string vhost); |
| 71 | virtual int on_reload_vhost_hds(std::string vhost); | 71 | virtual int on_reload_vhost_hds(std::string vhost); |
| 72 | virtual int on_reload_vhost_dvr(std::string vhost); | 72 | virtual int on_reload_vhost_dvr(std::string vhost); |
| 73 | + virtual int on_reload_vhost_dvr_apply(std::string vhost); | ||
| 73 | virtual int on_reload_vhost_publish(std::string vhost); | 74 | virtual int on_reload_vhost_publish(std::string vhost); |
| 74 | virtual int on_reload_vhost_tcp_nodelay(std::string vhost); | 75 | virtual int on_reload_vhost_tcp_nodelay(std::string vhost); |
| 75 | virtual int on_reload_vhost_realtime(std::string vhost); | 76 | virtual int on_reload_vhost_realtime(std::string vhost); |
| @@ -771,7 +771,7 @@ SrsSource* SrsSource::fetch(SrsRequest* r) | @@ -771,7 +771,7 @@ SrsSource* SrsSource::fetch(SrsRequest* r) | ||
| 771 | // we always update the request of resource, | 771 | // we always update the request of resource, |
| 772 | // for origin auth is on, the token in request maybe invalid, | 772 | // for origin auth is on, the token in request maybe invalid, |
| 773 | // and we only need to update the token of request, it's simple. | 773 | // and we only need to update the token of request, it's simple. |
| 774 | - source->_req->update_auth(r); | 774 | + source->req->update_auth(r); |
| 775 | 775 | ||
| 776 | return source; | 776 | return source; |
| 777 | } | 777 | } |
| @@ -900,7 +900,7 @@ SrsSharedPtrMessage* SrsMixQueue::pop() | @@ -900,7 +900,7 @@ SrsSharedPtrMessage* SrsMixQueue::pop() | ||
| 900 | 900 | ||
| 901 | SrsSource::SrsSource() | 901 | SrsSource::SrsSource() |
| 902 | { | 902 | { |
| 903 | - _req = NULL; | 903 | + req = NULL; |
| 904 | jitter_algorithm = SrsRtmpJitterAlgorithmOFF; | 904 | jitter_algorithm = SrsRtmpJitterAlgorithmOFF; |
| 905 | mix_correct = false; | 905 | mix_correct = false; |
| 906 | mix_queue = new SrsMixQueue(); | 906 | mix_queue = new SrsMixQueue(); |
| @@ -977,7 +977,7 @@ SrsSource::~SrsSource() | @@ -977,7 +977,7 @@ SrsSource::~SrsSource() | ||
| 977 | srs_freep(hds); | 977 | srs_freep(hds); |
| 978 | #endif | 978 | #endif |
| 979 | 979 | ||
| 980 | - srs_freep(_req); | 980 | + srs_freep(req); |
| 981 | } | 981 | } |
| 982 | 982 | ||
| 983 | void SrsSource::dispose() | 983 | void SrsSource::dispose() |
| @@ -1014,36 +1014,36 @@ int SrsSource::initialize(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* h | @@ -1014,36 +1014,36 @@ int SrsSource::initialize(SrsRequest* r, ISrsSourceHandler* h, ISrsHlsHandler* h | ||
| 1014 | 1014 | ||
| 1015 | srs_assert(h); | 1015 | srs_assert(h); |
| 1016 | srs_assert(hh); | 1016 | srs_assert(hh); |
| 1017 | - srs_assert(!_req); | 1017 | + srs_assert(!req); |
| 1018 | 1018 | ||
| 1019 | handler = h; | 1019 | handler = h; |
| 1020 | - _req = r->copy(); | ||
| 1021 | - atc = _srs_config->get_atc(_req->vhost); | 1020 | + req = r->copy(); |
| 1021 | + atc = _srs_config->get_atc(req->vhost); | ||
| 1022 | 1022 | ||
| 1023 | #ifdef SRS_AUTO_HLS | 1023 | #ifdef SRS_AUTO_HLS |
| 1024 | - if ((ret = hls->initialize(this, hh)) != ERROR_SUCCESS) { | 1024 | + if ((ret = hls->initialize(this, hh, req)) != ERROR_SUCCESS) { |
| 1025 | return ret; | 1025 | return ret; |
| 1026 | } | 1026 | } |
| 1027 | #endif | 1027 | #endif |
| 1028 | 1028 | ||
| 1029 | #ifdef SRS_AUTO_DVR | 1029 | #ifdef SRS_AUTO_DVR |
| 1030 | - if ((ret = dvr->initialize(this, _req)) != ERROR_SUCCESS) { | 1030 | + if ((ret = dvr->initialize(this, req)) != ERROR_SUCCESS) { |
| 1031 | return ret; | 1031 | return ret; |
| 1032 | } | 1032 | } |
| 1033 | #endif | 1033 | #endif |
| 1034 | 1034 | ||
| 1035 | - if ((ret = play_edge->initialize(this, _req)) != ERROR_SUCCESS) { | 1035 | + if ((ret = play_edge->initialize(this, req)) != ERROR_SUCCESS) { |
| 1036 | return ret; | 1036 | return ret; |
| 1037 | } | 1037 | } |
| 1038 | - if ((ret = publish_edge->initialize(this, _req)) != ERROR_SUCCESS) { | 1038 | + if ((ret = publish_edge->initialize(this, req)) != ERROR_SUCCESS) { |
| 1039 | return ret; | 1039 | return ret; |
| 1040 | } | 1040 | } |
| 1041 | 1041 | ||
| 1042 | - double queue_size = _srs_config->get_queue_length(_req->vhost); | 1042 | + double queue_size = _srs_config->get_queue_length(req->vhost); |
| 1043 | publish_edge->set_queue_size(queue_size); | 1043 | publish_edge->set_queue_size(queue_size); |
| 1044 | 1044 | ||
| 1045 | - jitter_algorithm = (SrsRtmpJitterAlgorithm)_srs_config->get_time_jitter(_req->vhost); | ||
| 1046 | - mix_correct = _srs_config->get_mix_correct(_req->vhost); | 1045 | + jitter_algorithm = (SrsRtmpJitterAlgorithm)_srs_config->get_time_jitter(req->vhost); |
| 1046 | + mix_correct = _srs_config->get_mix_correct(req->vhost); | ||
| 1047 | 1047 | ||
| 1048 | return ret; | 1048 | return ret; |
| 1049 | } | 1049 | } |
| @@ -1052,16 +1052,16 @@ int SrsSource::on_reload_vhost_play(string vhost) | @@ -1052,16 +1052,16 @@ int SrsSource::on_reload_vhost_play(string vhost) | ||
| 1052 | { | 1052 | { |
| 1053 | int ret = ERROR_SUCCESS; | 1053 | int ret = ERROR_SUCCESS; |
| 1054 | 1054 | ||
| 1055 | - if (_req->vhost != vhost) { | 1055 | + if (req->vhost != vhost) { |
| 1056 | return ret; | 1056 | return ret; |
| 1057 | } | 1057 | } |
| 1058 | 1058 | ||
| 1059 | // time_jitter | 1059 | // time_jitter |
| 1060 | - jitter_algorithm = (SrsRtmpJitterAlgorithm)_srs_config->get_time_jitter(_req->vhost); | 1060 | + jitter_algorithm = (SrsRtmpJitterAlgorithm)_srs_config->get_time_jitter(req->vhost); |
| 1061 | 1061 | ||
| 1062 | // mix_correct | 1062 | // mix_correct |
| 1063 | if (true) { | 1063 | if (true) { |
| 1064 | - bool v = _srs_config->get_mix_correct(_req->vhost); | 1064 | + bool v = _srs_config->get_mix_correct(req->vhost); |
| 1065 | 1065 | ||
| 1066 | // when changed, clear the mix queue. | 1066 | // when changed, clear the mix queue. |
| 1067 | if (v != mix_correct) { | 1067 | if (v != mix_correct) { |
| @@ -1086,7 +1086,7 @@ int SrsSource::on_reload_vhost_play(string vhost) | @@ -1086,7 +1086,7 @@ int SrsSource::on_reload_vhost_play(string vhost) | ||
| 1086 | bool v = _srs_config->get_gop_cache(vhost); | 1086 | bool v = _srs_config->get_gop_cache(vhost); |
| 1087 | 1087 | ||
| 1088 | if (v != gop_cache->enabled()) { | 1088 | if (v != gop_cache->enabled()) { |
| 1089 | - string url = _req->get_stream_url(); | 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()); | 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); | 1091 | gop_cache->set(v); |
| 1092 | } | 1092 | } |
| @@ -1094,7 +1094,7 @@ int SrsSource::on_reload_vhost_play(string vhost) | @@ -1094,7 +1094,7 @@ int SrsSource::on_reload_vhost_play(string vhost) | ||
| 1094 | 1094 | ||
| 1095 | // queue length | 1095 | // queue length |
| 1096 | if (true) { | 1096 | if (true) { |
| 1097 | - double v = _srs_config->get_queue_length(_req->vhost); | 1097 | + double v = _srs_config->get_queue_length(req->vhost); |
| 1098 | 1098 | ||
| 1099 | if (true) { | 1099 | if (true) { |
| 1100 | std::vector<SrsConsumer*>::iterator it; | 1100 | std::vector<SrsConsumer*>::iterator it; |
| @@ -1131,7 +1131,7 @@ int SrsSource::on_reload_vhost_forward(string vhost) | @@ -1131,7 +1131,7 @@ int SrsSource::on_reload_vhost_forward(string vhost) | ||
| 1131 | { | 1131 | { |
| 1132 | int ret = ERROR_SUCCESS; | 1132 | int ret = ERROR_SUCCESS; |
| 1133 | 1133 | ||
| 1134 | - if (_req->vhost != vhost) { | 1134 | + if (req->vhost != vhost) { |
| 1135 | return ret; | 1135 | return ret; |
| 1136 | } | 1136 | } |
| 1137 | 1137 | ||
| @@ -1153,7 +1153,7 @@ int SrsSource::on_reload_vhost_hls(string vhost) | @@ -1153,7 +1153,7 @@ int SrsSource::on_reload_vhost_hls(string vhost) | ||
| 1153 | { | 1153 | { |
| 1154 | int ret = ERROR_SUCCESS; | 1154 | int ret = ERROR_SUCCESS; |
| 1155 | 1155 | ||
| 1156 | - if (_req->vhost != vhost) { | 1156 | + if (req->vhost != vhost) { |
| 1157 | return ret; | 1157 | return ret; |
| 1158 | } | 1158 | } |
| 1159 | 1159 | ||
| @@ -1161,7 +1161,7 @@ int SrsSource::on_reload_vhost_hls(string vhost) | @@ -1161,7 +1161,7 @@ int SrsSource::on_reload_vhost_hls(string vhost) | ||
| 1161 | 1161 | ||
| 1162 | #ifdef SRS_AUTO_HLS | 1162 | #ifdef SRS_AUTO_HLS |
| 1163 | hls->on_unpublish(); | 1163 | hls->on_unpublish(); |
| 1164 | - if ((ret = hls->on_publish(_req, true)) != ERROR_SUCCESS) { | 1164 | + if ((ret = hls->on_publish(true)) != ERROR_SUCCESS) { |
| 1165 | srs_error("hls publish failed. ret=%d", ret); | 1165 | srs_error("hls publish failed. ret=%d", ret); |
| 1166 | return ret; | 1166 | return ret; |
| 1167 | } | 1167 | } |
| @@ -1175,7 +1175,7 @@ int SrsSource::on_reload_vhost_hds(string vhost) | @@ -1175,7 +1175,7 @@ int SrsSource::on_reload_vhost_hds(string vhost) | ||
| 1175 | { | 1175 | { |
| 1176 | int ret = ERROR_SUCCESS; | 1176 | int ret = ERROR_SUCCESS; |
| 1177 | 1177 | ||
| 1178 | - if (_req->vhost != vhost) { | 1178 | + if (req->vhost != vhost) { |
| 1179 | return ret; | 1179 | return ret; |
| 1180 | } | 1180 | } |
| 1181 | 1181 | ||
| @@ -1183,7 +1183,7 @@ int SrsSource::on_reload_vhost_hds(string vhost) | @@ -1183,7 +1183,7 @@ int SrsSource::on_reload_vhost_hds(string vhost) | ||
| 1183 | 1183 | ||
| 1184 | #ifdef SRS_AUTO_HDS | 1184 | #ifdef SRS_AUTO_HDS |
| 1185 | hds->on_unpublish(); | 1185 | hds->on_unpublish(); |
| 1186 | - if ((ret = hds->on_publish(_req)) != ERROR_SUCCESS) { | 1186 | + if ((ret = hds->on_publish(req)) != ERROR_SUCCESS) { |
| 1187 | srs_error("hds publish failed. ret=%d", ret); | 1187 | srs_error("hds publish failed. ret=%d", ret); |
| 1188 | return ret; | 1188 | return ret; |
| 1189 | } | 1189 | } |
| @@ -1197,7 +1197,7 @@ int SrsSource::on_reload_vhost_dvr(string vhost) | @@ -1197,7 +1197,7 @@ int SrsSource::on_reload_vhost_dvr(string vhost) | ||
| 1197 | { | 1197 | { |
| 1198 | int ret = ERROR_SUCCESS; | 1198 | int ret = ERROR_SUCCESS; |
| 1199 | 1199 | ||
| 1200 | - if (_req->vhost != vhost) { | 1200 | + if (req->vhost != vhost) { |
| 1201 | return ret; | 1201 | return ret; |
| 1202 | } | 1202 | } |
| 1203 | 1203 | ||
| @@ -1208,12 +1208,12 @@ int SrsSource::on_reload_vhost_dvr(string vhost) | @@ -1208,12 +1208,12 @@ int SrsSource::on_reload_vhost_dvr(string vhost) | ||
| 1208 | dvr->on_unpublish(); | 1208 | dvr->on_unpublish(); |
| 1209 | 1209 | ||
| 1210 | // reinitialize the dvr, update plan. | 1210 | // reinitialize the dvr, update plan. |
| 1211 | - if ((ret = dvr->initialize(this, _req)) != ERROR_SUCCESS) { | 1211 | + if ((ret = dvr->initialize(this, req)) != ERROR_SUCCESS) { |
| 1212 | return ret; | 1212 | return ret; |
| 1213 | } | 1213 | } |
| 1214 | 1214 | ||
| 1215 | // start to publish by new plan. | 1215 | // start to publish by new plan. |
| 1216 | - if ((ret = dvr->on_publish(_req)) != ERROR_SUCCESS) { | 1216 | + if ((ret = dvr->on_publish(true)) != ERROR_SUCCESS) { |
| 1217 | srs_error("dvr publish failed. ret=%d", ret); | 1217 | srs_error("dvr publish failed. ret=%d", ret); |
| 1218 | return ret; | 1218 | return ret; |
| 1219 | } | 1219 | } |
| @@ -1228,7 +1228,7 @@ int SrsSource::on_reload_vhost_transcode(string vhost) | @@ -1228,7 +1228,7 @@ int SrsSource::on_reload_vhost_transcode(string vhost) | ||
| 1228 | { | 1228 | { |
| 1229 | int ret = ERROR_SUCCESS; | 1229 | int ret = ERROR_SUCCESS; |
| 1230 | 1230 | ||
| 1231 | - if (_req->vhost != vhost) { | 1231 | + if (req->vhost != vhost) { |
| 1232 | return ret; | 1232 | return ret; |
| 1233 | } | 1233 | } |
| 1234 | 1234 | ||
| @@ -1236,7 +1236,7 @@ int SrsSource::on_reload_vhost_transcode(string vhost) | @@ -1236,7 +1236,7 @@ int SrsSource::on_reload_vhost_transcode(string vhost) | ||
| 1236 | 1236 | ||
| 1237 | #ifdef SRS_AUTO_TRANSCODE | 1237 | #ifdef SRS_AUTO_TRANSCODE |
| 1238 | encoder->on_unpublish(); | 1238 | encoder->on_unpublish(); |
| 1239 | - if ((ret = encoder->on_publish(_req)) != ERROR_SUCCESS) { | 1239 | + if ((ret = encoder->on_publish(req)) != ERROR_SUCCESS) { |
| 1240 | srs_error("start encoder failed. ret=%d", ret); | 1240 | srs_error("start encoder failed. ret=%d", ret); |
| 1241 | return ret; | 1241 | return ret; |
| 1242 | } | 1242 | } |
| @@ -1250,14 +1250,14 @@ int SrsSource::on_reload_vhost_exec(string vhost) | @@ -1250,14 +1250,14 @@ int SrsSource::on_reload_vhost_exec(string vhost) | ||
| 1250 | { | 1250 | { |
| 1251 | int ret = ERROR_SUCCESS; | 1251 | int ret = ERROR_SUCCESS; |
| 1252 | 1252 | ||
| 1253 | - if (_req->vhost != vhost) { | 1253 | + if (req->vhost != vhost) { |
| 1254 | return ret; | 1254 | return ret; |
| 1255 | } | 1255 | } |
| 1256 | 1256 | ||
| 1257 | // TODO: FIXME: maybe should ignore when publish already stopped? | 1257 | // TODO: FIXME: maybe should ignore when publish already stopped? |
| 1258 | 1258 | ||
| 1259 | ng_exec->on_unpublish(); | 1259 | ng_exec->on_unpublish(); |
| 1260 | - if ((ret = ng_exec->on_publish(_req)) != ERROR_SUCCESS) { | 1260 | + if ((ret = ng_exec->on_publish(req)) != ERROR_SUCCESS) { |
| 1261 | srs_error("start exec failed. ret=%d", ret); | 1261 | srs_error("start exec failed. ret=%d", ret); |
| 1262 | return ret; | 1262 | return ret; |
| 1263 | } | 1263 | } |
| @@ -1433,8 +1433,8 @@ int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata | @@ -1433,8 +1433,8 @@ int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata | ||
| 1433 | metadata->metadata->set("server_version", SrsAmf0Any::str(RTMP_SIG_SRS_VERSION)); | 1433 | metadata->metadata->set("server_version", SrsAmf0Any::str(RTMP_SIG_SRS_VERSION)); |
| 1434 | 1434 | ||
| 1435 | // if allow atc_auto and bravo-atc detected, open atc for vhost. | 1435 | // if allow atc_auto and bravo-atc detected, open atc for vhost. |
| 1436 | - atc = _srs_config->get_atc(_req->vhost); | ||
| 1437 | - if (_srs_config->get_atc_auto(_req->vhost)) { | 1436 | + atc = _srs_config->get_atc(req->vhost); |
| 1437 | + if (_srs_config->get_atc_auto(req->vhost)) { | ||
| 1438 | if ((prop = metadata->metadata->get_property("bravo_atc")) != NULL) { | 1438 | if ((prop = metadata->metadata->get_property("bravo_atc")) != NULL) { |
| 1439 | if (prop->is_string() && prop->to_str() == "true") { | 1439 | if (prop->is_string() && prop->to_str() == "true") { |
| 1440 | atc = true; | 1440 | atc = true; |
| @@ -1459,7 +1459,7 @@ int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata | @@ -1459,7 +1459,7 @@ int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata | ||
| 1459 | 1459 | ||
| 1460 | // when already got metadata, drop when reduce sequence header. | 1460 | // when already got metadata, drop when reduce sequence header. |
| 1461 | bool drop_for_reduce = false; | 1461 | bool drop_for_reduce = false; |
| 1462 | - if (cache_metadata && _srs_config->get_reduce_sequence_header(_req->vhost)) { | 1462 | + if (cache_metadata && _srs_config->get_reduce_sequence_header(req->vhost)) { |
| 1463 | drop_for_reduce = true; | 1463 | drop_for_reduce = true; |
| 1464 | srs_warn("drop for reduce sh metadata, size=%d", msg->size); | 1464 | srs_warn("drop for reduce sh metadata, size=%d", msg->size); |
| 1465 | } | 1465 | } |
| @@ -1560,7 +1560,7 @@ int SrsSource::on_audio_imp(SrsSharedPtrMessage* msg) | @@ -1560,7 +1560,7 @@ int SrsSource::on_audio_imp(SrsSharedPtrMessage* msg) | ||
| 1560 | 1560 | ||
| 1561 | // whether consumer should drop for the duplicated sequence header. | 1561 | // whether consumer should drop for the duplicated sequence header. |
| 1562 | bool drop_for_reduce = false; | 1562 | bool drop_for_reduce = false; |
| 1563 | - if (is_sequence_header && cache_sh_audio && _srs_config->get_reduce_sequence_header(_req->vhost)) { | 1563 | + if (is_sequence_header && cache_sh_audio && _srs_config->get_reduce_sequence_header(req->vhost)) { |
| 1564 | if (cache_sh_audio->size == msg->size) { | 1564 | if (cache_sh_audio->size == msg->size) { |
| 1565 | drop_for_reduce = srs_bytes_equals(cache_sh_audio->payload, msg->payload, msg->size); | 1565 | drop_for_reduce = srs_bytes_equals(cache_sh_audio->payload, msg->payload, msg->size); |
| 1566 | srs_warn("drop for reduce sh audio, size=%d", msg->size); | 1566 | srs_warn("drop for reduce sh audio, size=%d", msg->size); |
| @@ -1583,7 +1583,7 @@ int SrsSource::on_audio_imp(SrsSharedPtrMessage* msg) | @@ -1583,7 +1583,7 @@ int SrsSource::on_audio_imp(SrsSharedPtrMessage* msg) | ||
| 1583 | 1583 | ||
| 1584 | // when got audio stream info. | 1584 | // when got audio stream info. |
| 1585 | SrsStatistic* stat = SrsStatistic::instance(); | 1585 | SrsStatistic* stat = SrsStatistic::instance(); |
| 1586 | - if ((ret = stat->on_audio_info(_req, SrsCodecAudioAAC, sample.sound_rate, sample.sound_type, codec.aac_object)) != ERROR_SUCCESS) { | 1586 | + if ((ret = stat->on_audio_info(req, SrsCodecAudioAAC, sample.sound_rate, sample.sound_type, codec.aac_object)) != ERROR_SUCCESS) { |
| 1587 | return ret; | 1587 | return ret; |
| 1588 | } | 1588 | } |
| 1589 | 1589 | ||
| @@ -1600,7 +1600,7 @@ int SrsSource::on_audio_imp(SrsSharedPtrMessage* msg) | @@ -1600,7 +1600,7 @@ int SrsSource::on_audio_imp(SrsSharedPtrMessage* msg) | ||
| 1600 | if ((ret = hls->on_audio(msg)) != ERROR_SUCCESS) { | 1600 | if ((ret = hls->on_audio(msg)) != ERROR_SUCCESS) { |
| 1601 | // apply the error strategy for hls. | 1601 | // apply the error strategy for hls. |
| 1602 | // @see https://github.com/simple-rtmp-server/srs/issues/264 | 1602 | // @see https://github.com/simple-rtmp-server/srs/issues/264 |
| 1603 | - std::string hls_error_strategy = _srs_config->get_hls_on_error(_req->vhost); | 1603 | + std::string hls_error_strategy = _srs_config->get_hls_on_error(req->vhost); |
| 1604 | if (srs_config_hls_is_on_error_ignore(hls_error_strategy)) { | 1604 | if (srs_config_hls_is_on_error_ignore(hls_error_strategy)) { |
| 1605 | srs_warn("hls process audio message failed, ignore and disable hls. ret=%d", ret); | 1605 | srs_warn("hls process audio message failed, ignore and disable hls. ret=%d", ret); |
| 1606 | 1606 | ||
| @@ -1775,7 +1775,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg) | @@ -1775,7 +1775,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg) | ||
| 1775 | 1775 | ||
| 1776 | // whether consumer should drop for the duplicated sequence header. | 1776 | // whether consumer should drop for the duplicated sequence header. |
| 1777 | bool drop_for_reduce = false; | 1777 | bool drop_for_reduce = false; |
| 1778 | - if (is_sequence_header && cache_sh_video && _srs_config->get_reduce_sequence_header(_req->vhost)) { | 1778 | + if (is_sequence_header && cache_sh_video && _srs_config->get_reduce_sequence_header(req->vhost)) { |
| 1779 | if (cache_sh_video->size == msg->size) { | 1779 | if (cache_sh_video->size == msg->size) { |
| 1780 | drop_for_reduce = srs_bytes_equals(cache_sh_video->payload, msg->payload, msg->size); | 1780 | drop_for_reduce = srs_bytes_equals(cache_sh_video->payload, msg->payload, msg->size); |
| 1781 | srs_warn("drop for reduce sh video, size=%d", msg->size); | 1781 | srs_warn("drop for reduce sh video, size=%d", msg->size); |
| @@ -1793,7 +1793,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg) | @@ -1793,7 +1793,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg) | ||
| 1793 | 1793 | ||
| 1794 | // user can disable the sps parse to workaround when parse sps failed. | 1794 | // user can disable the sps parse to workaround when parse sps failed. |
| 1795 | // @see https://github.com/simple-rtmp-server/srs/issues/474 | 1795 | // @see https://github.com/simple-rtmp-server/srs/issues/474 |
| 1796 | - codec.avc_parse_sps = _srs_config->get_parse_sps(_req->vhost); | 1796 | + codec.avc_parse_sps = _srs_config->get_parse_sps(req->vhost); |
| 1797 | 1797 | ||
| 1798 | SrsCodecSample sample; | 1798 | SrsCodecSample sample; |
| 1799 | if ((ret = codec.video_avc_demux(msg->payload, msg->size, &sample)) != ERROR_SUCCESS) { | 1799 | if ((ret = codec.video_avc_demux(msg->payload, msg->size, &sample)) != ERROR_SUCCESS) { |
| @@ -1803,7 +1803,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg) | @@ -1803,7 +1803,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg) | ||
| 1803 | 1803 | ||
| 1804 | // when got video stream info. | 1804 | // when got video stream info. |
| 1805 | SrsStatistic* stat = SrsStatistic::instance(); | 1805 | SrsStatistic* stat = SrsStatistic::instance(); |
| 1806 | - if ((ret = stat->on_video_info(_req, SrsCodecVideoAVC, codec.avc_profile, codec.avc_level, codec.width, codec.height)) != ERROR_SUCCESS) { | 1806 | + if ((ret = stat->on_video_info(req, SrsCodecVideoAVC, codec.avc_profile, codec.avc_level, codec.width, codec.height)) != ERROR_SUCCESS) { |
| 1807 | return ret; | 1807 | return ret; |
| 1808 | } | 1808 | } |
| 1809 | 1809 | ||
| @@ -1818,7 +1818,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg) | @@ -1818,7 +1818,7 @@ int SrsSource::on_video_imp(SrsSharedPtrMessage* msg) | ||
| 1818 | if ((ret = hls->on_video(msg, is_sequence_header)) != ERROR_SUCCESS) { | 1818 | if ((ret = hls->on_video(msg, is_sequence_header)) != ERROR_SUCCESS) { |
| 1819 | // apply the error strategy for hls. | 1819 | // apply the error strategy for hls. |
| 1820 | // @see https://github.com/simple-rtmp-server/srs/issues/264 | 1820 | // @see https://github.com/simple-rtmp-server/srs/issues/264 |
| 1821 | - std::string hls_error_strategy = _srs_config->get_hls_on_error(_req->vhost); | 1821 | + std::string hls_error_strategy = _srs_config->get_hls_on_error(req->vhost); |
| 1822 | if (srs_config_hls_is_on_error_ignore(hls_error_strategy)) { | 1822 | if (srs_config_hls_is_on_error_ignore(hls_error_strategy)) { |
| 1823 | srs_warn("hls process video message failed, ignore and disable hls. ret=%d", ret); | 1823 | srs_warn("hls process video message failed, ignore and disable hls. ret=%d", ret); |
| 1824 | 1824 | ||
| @@ -2028,7 +2028,7 @@ int SrsSource::on_publish() | @@ -2028,7 +2028,7 @@ int SrsSource::on_publish() | ||
| 2028 | int ret = ERROR_SUCCESS; | 2028 | int ret = ERROR_SUCCESS; |
| 2029 | 2029 | ||
| 2030 | // update the request object. | 2030 | // update the request object. |
| 2031 | - srs_assert(_req); | 2031 | + srs_assert(req); |
| 2032 | 2032 | ||
| 2033 | _can_publish = false; | 2033 | _can_publish = false; |
| 2034 | 2034 | ||
| @@ -2051,49 +2051,48 @@ int SrsSource::on_publish() | @@ -2051,49 +2051,48 @@ int SrsSource::on_publish() | ||
| 2051 | 2051 | ||
| 2052 | // TODO: FIXME: use initialize to set req. | 2052 | // TODO: FIXME: use initialize to set req. |
| 2053 | #ifdef SRS_AUTO_TRANSCODE | 2053 | #ifdef SRS_AUTO_TRANSCODE |
| 2054 | - if ((ret = encoder->on_publish(_req)) != ERROR_SUCCESS) { | 2054 | + if ((ret = encoder->on_publish(req)) != ERROR_SUCCESS) { |
| 2055 | srs_error("start encoder failed. ret=%d", ret); | 2055 | srs_error("start encoder failed. ret=%d", ret); |
| 2056 | return ret; | 2056 | return ret; |
| 2057 | } | 2057 | } |
| 2058 | #endif | 2058 | #endif |
| 2059 | 2059 | ||
| 2060 | - // TODO: FIXME: use initialize to set req. | ||
| 2061 | #ifdef SRS_AUTO_HLS | 2060 | #ifdef SRS_AUTO_HLS |
| 2062 | - if ((ret = hls->on_publish(_req, false)) != ERROR_SUCCESS) { | 2061 | + if ((ret = hls->on_publish(false)) != ERROR_SUCCESS) { |
| 2063 | srs_error("start hls failed. ret=%d", ret); | 2062 | srs_error("start hls failed. ret=%d", ret); |
| 2064 | return ret; | 2063 | return ret; |
| 2065 | } | 2064 | } |
| 2066 | #endif | 2065 | #endif |
| 2067 | 2066 | ||
| 2068 | - // TODO: FIXME: use initialize to set req. | ||
| 2069 | #ifdef SRS_AUTO_DVR | 2067 | #ifdef SRS_AUTO_DVR |
| 2070 | - if ((ret = dvr->on_publish(_req)) != ERROR_SUCCESS) { | 2068 | + if ((ret = dvr->on_publish(false)) != ERROR_SUCCESS) { |
| 2071 | srs_error("start dvr failed. ret=%d", ret); | 2069 | srs_error("start dvr failed. ret=%d", ret); |
| 2072 | return ret; | 2070 | return ret; |
| 2073 | } | 2071 | } |
| 2074 | #endif | 2072 | #endif |
| 2075 | - | 2073 | + |
| 2074 | + // TODO: FIXME: use initialize to set req. | ||
| 2076 | #ifdef SRS_AUTO_HDS | 2075 | #ifdef SRS_AUTO_HDS |
| 2077 | - if ((ret = hds->on_publish(_req)) != ERROR_SUCCESS) { | 2076 | + if ((ret = hds->on_publish(req)) != ERROR_SUCCESS) { |
| 2078 | srs_error("start hds failed. ret=%d", ret); | 2077 | srs_error("start hds failed. ret=%d", ret); |
| 2079 | return ret; | 2078 | return ret; |
| 2080 | } | 2079 | } |
| 2081 | #endif | 2080 | #endif |
| 2082 | 2081 | ||
| 2083 | // TODO: FIXME: use initialize to set req. | 2082 | // TODO: FIXME: use initialize to set req. |
| 2084 | - if ((ret = ng_exec->on_publish(_req)) != ERROR_SUCCESS) { | 2083 | + if ((ret = ng_exec->on_publish(req)) != ERROR_SUCCESS) { |
| 2085 | srs_error("start exec failed. ret=%d", ret); | 2084 | srs_error("start exec failed. ret=%d", ret); |
| 2086 | return ret; | 2085 | return ret; |
| 2087 | } | 2086 | } |
| 2088 | 2087 | ||
| 2089 | // notify the handler. | 2088 | // notify the handler. |
| 2090 | srs_assert(handler); | 2089 | srs_assert(handler); |
| 2091 | - if ((ret = handler->on_publish(this, _req)) != ERROR_SUCCESS) { | 2090 | + if ((ret = handler->on_publish(this, req)) != ERROR_SUCCESS) { |
| 2092 | srs_error("handle on publish failed. ret=%d", ret); | 2091 | srs_error("handle on publish failed. ret=%d", ret); |
| 2093 | return ret; | 2092 | return ret; |
| 2094 | } | 2093 | } |
| 2095 | SrsStatistic* stat = SrsStatistic::instance(); | 2094 | SrsStatistic* stat = SrsStatistic::instance(); |
| 2096 | - stat->on_stream_publish(_req, _source_id); | 2095 | + stat->on_stream_publish(req, _source_id); |
| 2097 | 2096 | ||
| 2098 | return ret; | 2097 | return ret; |
| 2099 | } | 2098 | } |
| @@ -2135,8 +2134,8 @@ void SrsSource::on_unpublish() | @@ -2135,8 +2134,8 @@ void SrsSource::on_unpublish() | ||
| 2135 | // notify the handler. | 2134 | // notify the handler. |
| 2136 | srs_assert(handler); | 2135 | srs_assert(handler); |
| 2137 | SrsStatistic* stat = SrsStatistic::instance(); | 2136 | SrsStatistic* stat = SrsStatistic::instance(); |
| 2138 | - stat->on_stream_close(_req); | ||
| 2139 | - handler->on_unpublish(this, _req); | 2137 | + stat->on_stream_close(req); |
| 2138 | + handler->on_unpublish(this, req); | ||
| 2140 | } | 2139 | } |
| 2141 | 2140 | ||
| 2142 | int SrsSource::create_consumer(SrsConsumer*& consumer, bool ds, bool dm, bool dg) | 2141 | int SrsSource::create_consumer(SrsConsumer*& consumer, bool ds, bool dm, bool dg) |
| @@ -2146,7 +2145,7 @@ int SrsSource::create_consumer(SrsConsumer*& consumer, bool ds, bool dm, bool dg | @@ -2146,7 +2145,7 @@ int SrsSource::create_consumer(SrsConsumer*& consumer, bool ds, bool dm, bool dg | ||
| 2146 | consumer = new SrsConsumer(this); | 2145 | consumer = new SrsConsumer(this); |
| 2147 | consumers.push_back(consumer); | 2146 | consumers.push_back(consumer); |
| 2148 | 2147 | ||
| 2149 | - double queue_size = _srs_config->get_queue_length(_req->vhost); | 2148 | + double queue_size = _srs_config->get_queue_length(req->vhost); |
| 2150 | consumer->set_queue_size(queue_size); | 2149 | consumer->set_queue_size(queue_size); |
| 2151 | 2150 | ||
| 2152 | // if atc, update the sequence header to gop cache time. | 2151 | // if atc, update the sequence header to gop cache time. |
| @@ -2197,7 +2196,7 @@ int SrsSource::create_consumer(SrsConsumer*& consumer, bool ds, bool dm, bool dg | @@ -2197,7 +2196,7 @@ int SrsSource::create_consumer(SrsConsumer*& consumer, bool ds, bool dm, bool dg | ||
| 2197 | } | 2196 | } |
| 2198 | 2197 | ||
| 2199 | // for edge, when play edge stream, check the state | 2198 | // for edge, when play edge stream, check the state |
| 2200 | - if (_srs_config->get_vhost_is_edge(_req->vhost)) { | 2199 | + if (_srs_config->get_vhost_is_edge(req->vhost)) { |
| 2201 | // notice edge to start for the first client. | 2200 | // notice edge to start for the first client. |
| 2202 | if ((ret = play_edge->on_client_play()) != ERROR_SUCCESS) { | 2201 | if ((ret = play_edge->on_client_play()) != ERROR_SUCCESS) { |
| 2203 | srs_error("notice edge start play stream failed. ret=%d", ret); | 2202 | srs_error("notice edge start play stream failed. ret=%d", ret); |
| @@ -2251,11 +2250,11 @@ int SrsSource::create_forwarders() | @@ -2251,11 +2250,11 @@ int SrsSource::create_forwarders() | ||
| 2251 | { | 2250 | { |
| 2252 | int ret = ERROR_SUCCESS; | 2251 | int ret = ERROR_SUCCESS; |
| 2253 | 2252 | ||
| 2254 | - if (_srs_config->get_forward_enabled(_req->vhost)) { | 2253 | + if (_srs_config->get_forward_enabled(req->vhost)) { |
| 2255 | return ret; | 2254 | return ret; |
| 2256 | } | 2255 | } |
| 2257 | 2256 | ||
| 2258 | - SrsConfDirective* conf = _srs_config->get_forwards(_req->vhost); | 2257 | + SrsConfDirective* conf = _srs_config->get_forwards(req->vhost); |
| 2259 | for (int i = 0; conf && i < (int)conf->args.size(); i++) { | 2258 | for (int i = 0; conf && i < (int)conf->args.size(); i++) { |
| 2260 | std::string forward_server = conf->args.at(i); | 2259 | std::string forward_server = conf->args.at(i); |
| 2261 | 2260 | ||
| @@ -2263,17 +2262,17 @@ int SrsSource::create_forwarders() | @@ -2263,17 +2262,17 @@ int SrsSource::create_forwarders() | ||
| 2263 | forwarders.push_back(forwarder); | 2262 | forwarders.push_back(forwarder); |
| 2264 | 2263 | ||
| 2265 | // initialize the forwarder with request. | 2264 | // initialize the forwarder with request. |
| 2266 | - if ((ret = forwarder->initialize(_req, forward_server)) != ERROR_SUCCESS) { | 2265 | + if ((ret = forwarder->initialize(req, forward_server)) != ERROR_SUCCESS) { |
| 2267 | return ret; | 2266 | return ret; |
| 2268 | } | 2267 | } |
| 2269 | 2268 | ||
| 2270 | - double queue_size = _srs_config->get_queue_length(_req->vhost); | 2269 | + double queue_size = _srs_config->get_queue_length(req->vhost); |
| 2271 | forwarder->set_queue_size(queue_size); | 2270 | forwarder->set_queue_size(queue_size); |
| 2272 | 2271 | ||
| 2273 | if ((ret = forwarder->on_publish()) != ERROR_SUCCESS) { | 2272 | if ((ret = forwarder->on_publish()) != ERROR_SUCCESS) { |
| 2274 | srs_error("start forwarder failed. " | 2273 | srs_error("start forwarder failed. " |
| 2275 | "vhost=%s, app=%s, stream=%s, forward-to=%s", | 2274 | "vhost=%s, app=%s, stream=%s, forward-to=%s", |
| 2276 | - _req->vhost.c_str(), _req->app.c_str(), _req->stream.c_str(), | 2275 | + req->vhost.c_str(), req->app.c_str(), req->stream.c_str(), |
| 2277 | forward_server.c_str()); | 2276 | forward_server.c_str()); |
| 2278 | return ret; | 2277 | return ret; |
| 2279 | } | 2278 | } |
| @@ -451,7 +451,7 @@ private: | @@ -451,7 +451,7 @@ private: | ||
| 451 | // invoke the on_source_id_changed() to let all clients know. | 451 | // invoke the on_source_id_changed() to let all clients know. |
| 452 | int _source_id; | 452 | int _source_id; |
| 453 | // deep copy of client request. | 453 | // deep copy of client request. |
| 454 | - SrsRequest* _req; | 454 | + SrsRequest* req; |
| 455 | // to delivery stream to clients. | 455 | // to delivery stream to clients. |
| 456 | std::vector<SrsConsumer*> consumers; | 456 | std::vector<SrsConsumer*> consumers; |
| 457 | // the time jitter algorithm for vhost. | 457 | // the time jitter algorithm for vhost. |
| @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | // current release version | 31 | // current release version |
| 32 | #define VERSION_MAJOR 3 | 32 | #define VERSION_MAJOR 3 |
| 33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
| 34 | -#define VERSION_REVISION 4 | 34 | +#define VERSION_REVISION 3 |
| 35 | 35 | ||
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
-
请 注册 或 登录 后发表评论