正在显示
8 个修改的文件
包含
50 行增加
和
37 行删除
| @@ -343,6 +343,7 @@ Remark: | @@ -343,6 +343,7 @@ Remark: | ||
| 343 | 343 | ||
| 344 | ## History | 344 | ## History |
| 345 | 345 | ||
| 346 | +* v2.0, 2015-09-14, for [#458][bug #458] http hooks use source thread cid. 2.0.188 | ||
| 346 | * v2.0, 2015-09-14, for [#475][bug #475] fix http hooks crash for st context switch. 2.0.187 | 347 | * v2.0, 2015-09-14, for [#475][bug #475] fix http hooks crash for st context switch. 2.0.187 |
| 347 | * v2.0, 2015-09-09, support reload utc_time. 2.0.186 | 348 | * v2.0, 2015-09-09, support reload utc_time. 2.0.186 |
| 348 | * <strong>v2.0, 2015-08-23, [2.0 alpha(2.0.185)][r2.0a0] released. 89022 lines.</strong> | 349 | * <strong>v2.0, 2015-08-23, [2.0 alpha(2.0.185)][r2.0a0] released. 89022 lines.</strong> |
| @@ -1026,6 +1027,7 @@ Winlin | @@ -1026,6 +1027,7 @@ Winlin | ||
| 1026 | [bug #92]: https://github.com/simple-rtmp-server/srs/issues/92 | 1027 | [bug #92]: https://github.com/simple-rtmp-server/srs/issues/92 |
| 1027 | [bug #380]: https://github.com/simple-rtmp-server/srs/issues/380 | 1028 | [bug #380]: https://github.com/simple-rtmp-server/srs/issues/380 |
| 1028 | [bug #475]: https://github.com/simple-rtmp-server/srs/issues/475 | 1029 | [bug #475]: https://github.com/simple-rtmp-server/srs/issues/475 |
| 1030 | +[bug #458]: https://github.com/simple-rtmp-server/srs/issues/458 | ||
| 1029 | [bug #454]: https://github.com/simple-rtmp-server/srs/issues/454 | 1031 | [bug #454]: https://github.com/simple-rtmp-server/srs/issues/454 |
| 1030 | [bug #442]: https://github.com/simple-rtmp-server/srs/issues/442 | 1032 | [bug #442]: https://github.com/simple-rtmp-server/srs/issues/442 |
| 1031 | [bug #169]: https://github.com/simple-rtmp-server/srs/issues/169 | 1033 | [bug #169]: https://github.com/simple-rtmp-server/srs/issues/169 |
| @@ -496,8 +496,9 @@ int SrsFlvSegment::on_reload_vhost_dvr(std::string /*vhost*/) | @@ -496,8 +496,9 @@ int SrsFlvSegment::on_reload_vhost_dvr(std::string /*vhost*/) | ||
| 496 | return ret; | 496 | return ret; |
| 497 | } | 497 | } |
| 498 | 498 | ||
| 499 | -SrsDvrAsyncCallOnDvr::SrsDvrAsyncCallOnDvr(SrsRequest* r, string p) | 499 | +SrsDvrAsyncCallOnDvr::SrsDvrAsyncCallOnDvr(int c, SrsRequest* r, string p) |
| 500 | { | 500 | { |
| 501 | + cid = c; | ||
| 501 | req = r->copy(); | 502 | req = r->copy(); |
| 502 | path = p; | 503 | path = p; |
| 503 | } | 504 | } |
| @@ -534,7 +535,7 @@ int SrsDvrAsyncCallOnDvr::call() | @@ -534,7 +535,7 @@ int SrsDvrAsyncCallOnDvr::call() | ||
| 534 | 535 | ||
| 535 | for (int i = 0; i < (int)hooks.size(); i++) { | 536 | for (int i = 0; i < (int)hooks.size(); i++) { |
| 536 | std::string url = hooks.at(i); | 537 | std::string url = hooks.at(i); |
| 537 | - if ((ret = SrsHttpHooks::on_dvr(url, req, path)) != ERROR_SUCCESS) { | 538 | + if ((ret = SrsHttpHooks::on_dvr(cid, url, req, path)) != ERROR_SUCCESS) { |
| 538 | srs_error("hook client on_dvr failed. url=%s, ret=%d", url.c_str(), ret); | 539 | srs_error("hook client on_dvr failed. url=%s, ret=%d", url.c_str(), ret); |
| 539 | return ret; | 540 | return ret; |
| 540 | } | 541 | } |
| @@ -638,7 +639,8 @@ int SrsDvrPlan::on_reap_segment() | @@ -638,7 +639,8 @@ int SrsDvrPlan::on_reap_segment() | ||
| 638 | { | 639 | { |
| 639 | int ret = ERROR_SUCCESS; | 640 | int ret = ERROR_SUCCESS; |
| 640 | 641 | ||
| 641 | - if ((ret = async->execute(new SrsDvrAsyncCallOnDvr(req, segment->get_path()))) != ERROR_SUCCESS) { | 642 | + int cid = _srs_context->get_id(); |
| 643 | + if ((ret = async->execute(new SrsDvrAsyncCallOnDvr(cid, req, segment->get_path()))) != ERROR_SUCCESS) { | ||
| 642 | return ret; | 644 | return ret; |
| 643 | } | 645 | } |
| 644 | 646 |
| @@ -181,10 +181,11 @@ public: | @@ -181,10 +181,11 @@ public: | ||
| 181 | class SrsDvrAsyncCallOnDvr : public ISrsAsyncCallTask | 181 | class SrsDvrAsyncCallOnDvr : public ISrsAsyncCallTask |
| 182 | { | 182 | { |
| 183 | private: | 183 | private: |
| 184 | + int cid; | ||
| 184 | std::string path; | 185 | std::string path; |
| 185 | SrsRequest* req; | 186 | SrsRequest* req; |
| 186 | public: | 187 | public: |
| 187 | - SrsDvrAsyncCallOnDvr(SrsRequest* r, std::string p); | 188 | + SrsDvrAsyncCallOnDvr(int c, SrsRequest* r, std::string p); |
| 188 | virtual ~SrsDvrAsyncCallOnDvr(); | 189 | virtual ~SrsDvrAsyncCallOnDvr(); |
| 189 | public: | 190 | public: |
| 190 | virtual int call(); | 191 | virtual int call(); |
| @@ -177,9 +177,10 @@ void SrsHlsSegment::update_duration(int64_t current_frame_dts) | @@ -177,9 +177,10 @@ void SrsHlsSegment::update_duration(int64_t current_frame_dts) | ||
| 177 | return; | 177 | return; |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | -SrsDvrAsyncCallOnHls::SrsDvrAsyncCallOnHls(SrsRequest* r, string p, string t, string m, string mu, int s, double d) | 180 | +SrsDvrAsyncCallOnHls::SrsDvrAsyncCallOnHls(int c, SrsRequest* r, string p, string t, string m, string mu, int s, double d) |
| 181 | { | 181 | { |
| 182 | req = r->copy(); | 182 | req = r->copy(); |
| 183 | + cid = c; | ||
| 183 | path = p; | 184 | path = p; |
| 184 | ts_url = t; | 185 | ts_url = t; |
| 185 | m3u8 = m; | 186 | m3u8 = m; |
| @@ -220,7 +221,7 @@ int SrsDvrAsyncCallOnHls::call() | @@ -220,7 +221,7 @@ int SrsDvrAsyncCallOnHls::call() | ||
| 220 | 221 | ||
| 221 | for (int i = 0; i < (int)hooks.size(); i++) { | 222 | for (int i = 0; i < (int)hooks.size(); i++) { |
| 222 | std::string url = hooks.at(i); | 223 | std::string url = hooks.at(i); |
| 223 | - if ((ret = SrsHttpHooks::on_hls(url, req, path, ts_url, m3u8, m3u8_url, seq_no, duration)) != ERROR_SUCCESS) { | 224 | + if ((ret = SrsHttpHooks::on_hls(cid, url, req, path, ts_url, m3u8, m3u8_url, seq_no, duration)) != ERROR_SUCCESS) { |
| 224 | srs_error("hook client on_hls failed. url=%s, ret=%d", url.c_str(), ret); | 225 | srs_error("hook client on_hls failed. url=%s, ret=%d", url.c_str(), ret); |
| 225 | return ret; | 226 | return ret; |
| 226 | } | 227 | } |
| @@ -235,8 +236,9 @@ string SrsDvrAsyncCallOnHls::to_string() | @@ -235,8 +236,9 @@ string SrsDvrAsyncCallOnHls::to_string() | ||
| 235 | return "on_hls: " + path; | 236 | return "on_hls: " + path; |
| 236 | } | 237 | } |
| 237 | 238 | ||
| 238 | -SrsDvrAsyncCallOnHlsNotify::SrsDvrAsyncCallOnHlsNotify(SrsRequest* r, string u) | 239 | +SrsDvrAsyncCallOnHlsNotify::SrsDvrAsyncCallOnHlsNotify(int c, SrsRequest* r, string u) |
| 239 | { | 240 | { |
| 241 | + cid = c; | ||
| 240 | req = r->copy(); | 242 | req = r->copy(); |
| 241 | ts_url = u; | 243 | ts_url = u; |
| 242 | } | 244 | } |
| @@ -274,7 +276,7 @@ int SrsDvrAsyncCallOnHlsNotify::call() | @@ -274,7 +276,7 @@ int SrsDvrAsyncCallOnHlsNotify::call() | ||
| 274 | int nb_notify = _srs_config->get_vhost_hls_nb_notify(req->vhost); | 276 | int nb_notify = _srs_config->get_vhost_hls_nb_notify(req->vhost); |
| 275 | for (int i = 0; i < (int)hooks.size(); i++) { | 277 | for (int i = 0; i < (int)hooks.size(); i++) { |
| 276 | std::string url = hooks.at(i); | 278 | std::string url = hooks.at(i); |
| 277 | - if ((ret = SrsHttpHooks::on_hls_notify(url, req, ts_url, nb_notify)) != ERROR_SUCCESS) { | 279 | + if ((ret = SrsHttpHooks::on_hls_notify(cid, url, req, ts_url, nb_notify)) != ERROR_SUCCESS) { |
| 278 | srs_error("hook client on_hls_notify failed. url=%s, ret=%d", url.c_str(), ret); | 280 | srs_error("hook client on_hls_notify failed. url=%s, ret=%d", url.c_str(), ret); |
| 279 | return ret; | 281 | return ret; |
| 280 | } | 282 | } |
| @@ -724,7 +726,8 @@ int SrsHlsMuxer::segment_close(string log_desc) | @@ -724,7 +726,8 @@ int SrsHlsMuxer::segment_close(string log_desc) | ||
| 724 | segments.push_back(current); | 726 | segments.push_back(current); |
| 725 | 727 | ||
| 726 | // use async to call the http hooks, for it will cause thread switch. | 728 | // use async to call the http hooks, for it will cause thread switch. |
| 727 | - if ((ret = async->execute(new SrsDvrAsyncCallOnHls(req, | 729 | + if ((ret = async->execute(new SrsDvrAsyncCallOnHls( |
| 730 | + _srs_context->get_id(), req, | ||
| 728 | current->full_path, current->uri, m3u8, m3u8_url, | 731 | current->full_path, current->uri, m3u8, m3u8_url, |
| 729 | current->sequence_no, current->duration))) != ERROR_SUCCESS) | 732 | current->sequence_no, current->duration))) != ERROR_SUCCESS) |
| 730 | { | 733 | { |
| @@ -732,7 +735,7 @@ int SrsHlsMuxer::segment_close(string log_desc) | @@ -732,7 +735,7 @@ int SrsHlsMuxer::segment_close(string log_desc) | ||
| 732 | } | 735 | } |
| 733 | 736 | ||
| 734 | // use async to call the http hooks, for it will cause thread switch. | 737 | // use async to call the http hooks, for it will cause thread switch. |
| 735 | - if ((ret = async->execute(new SrsDvrAsyncCallOnHlsNotify(req, current->uri))) != ERROR_SUCCESS) { | 738 | + if ((ret = async->execute(new SrsDvrAsyncCallOnHlsNotify(_srs_context->get_id(), req, current->uri))) != ERROR_SUCCESS) { |
| 736 | return ret; | 739 | return ret; |
| 737 | } | 740 | } |
| 738 | 741 |
| @@ -167,6 +167,7 @@ public: | @@ -167,6 +167,7 @@ public: | ||
| 167 | class SrsDvrAsyncCallOnHls : public ISrsAsyncCallTask | 167 | class SrsDvrAsyncCallOnHls : public ISrsAsyncCallTask |
| 168 | { | 168 | { |
| 169 | private: | 169 | private: |
| 170 | + int cid; | ||
| 170 | std::string path; | 171 | std::string path; |
| 171 | std::string ts_url; | 172 | std::string ts_url; |
| 172 | std::string m3u8; | 173 | std::string m3u8; |
| @@ -175,7 +176,7 @@ private: | @@ -175,7 +176,7 @@ private: | ||
| 175 | SrsRequest* req; | 176 | SrsRequest* req; |
| 176 | double duration; | 177 | double duration; |
| 177 | public: | 178 | public: |
| 178 | - SrsDvrAsyncCallOnHls(SrsRequest* r, std::string p, std::string t, std::string m, std::string mu, int s, double d); | 179 | + SrsDvrAsyncCallOnHls(int c, SrsRequest* r, std::string p, std::string t, std::string m, std::string mu, int s, double d); |
| 179 | virtual ~SrsDvrAsyncCallOnHls(); | 180 | virtual ~SrsDvrAsyncCallOnHls(); |
| 180 | public: | 181 | public: |
| 181 | virtual int call(); | 182 | virtual int call(); |
| @@ -188,10 +189,11 @@ public: | @@ -188,10 +189,11 @@ public: | ||
| 188 | class SrsDvrAsyncCallOnHlsNotify : public ISrsAsyncCallTask | 189 | class SrsDvrAsyncCallOnHlsNotify : public ISrsAsyncCallTask |
| 189 | { | 190 | { |
| 190 | private: | 191 | private: |
| 192 | + int cid; | ||
| 191 | std::string ts_url; | 193 | std::string ts_url; |
| 192 | SrsRequest* req; | 194 | SrsRequest* req; |
| 193 | public: | 195 | public: |
| 194 | - SrsDvrAsyncCallOnHlsNotify(SrsRequest* r, std::string u); | 196 | + SrsDvrAsyncCallOnHlsNotify(int c, SrsRequest* r, std::string u); |
| 195 | virtual ~SrsDvrAsyncCallOnHlsNotify(); | 197 | virtual ~SrsDvrAsyncCallOnHlsNotify(); |
| 196 | public: | 198 | public: |
| 197 | virtual int call(); | 199 | virtual int call(); |
| @@ -257,11 +257,11 @@ void SrsHttpHooks::on_stop(string url, SrsRequest* req) | @@ -257,11 +257,11 @@ void SrsHttpHooks::on_stop(string url, SrsRequest* req) | ||
| 257 | return; | 257 | return; |
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | -int SrsHttpHooks::on_dvr(string url, SrsRequest* req, string file) | 260 | +int SrsHttpHooks::on_dvr(int cid, string url, SrsRequest* req, string file) |
| 261 | { | 261 | { |
| 262 | int ret = ERROR_SUCCESS; | 262 | int ret = ERROR_SUCCESS; |
| 263 | 263 | ||
| 264 | - int client_id = _srs_context->get_id(); | 264 | + int client_id = cid; |
| 265 | std::string cwd = _srs_config->cwd(); | 265 | std::string cwd = _srs_config->cwd(); |
| 266 | 266 | ||
| 267 | std::stringstream ss; | 267 | std::stringstream ss; |
| @@ -293,11 +293,11 @@ int SrsHttpHooks::on_dvr(string url, SrsRequest* req, string file) | @@ -293,11 +293,11 @@ int SrsHttpHooks::on_dvr(string url, SrsRequest* req, string file) | ||
| 293 | return ret; | 293 | return ret; |
| 294 | } | 294 | } |
| 295 | 295 | ||
| 296 | -int SrsHttpHooks::on_hls(string url, SrsRequest* req, string file, string ts_url, string m3u8, string m3u8_url, int sn, double duration) | 296 | +int SrsHttpHooks::on_hls(int cid, string url, SrsRequest* req, string file, string ts_url, string m3u8, string m3u8_url, int sn, double duration) |
| 297 | { | 297 | { |
| 298 | int ret = ERROR_SUCCESS; | 298 | int ret = ERROR_SUCCESS; |
| 299 | 299 | ||
| 300 | - int client_id = _srs_context->get_id(); | 300 | + int client_id = cid; |
| 301 | std::string cwd = _srs_config->cwd(); | 301 | std::string cwd = _srs_config->cwd(); |
| 302 | 302 | ||
| 303 | std::stringstream ss; | 303 | std::stringstream ss; |
| @@ -334,11 +334,11 @@ int SrsHttpHooks::on_hls(string url, SrsRequest* req, string file, string ts_url | @@ -334,11 +334,11 @@ int SrsHttpHooks::on_hls(string url, SrsRequest* req, string file, string ts_url | ||
| 334 | return ret; | 334 | return ret; |
| 335 | } | 335 | } |
| 336 | 336 | ||
| 337 | -int SrsHttpHooks::on_hls_notify(std::string url, SrsRequest* req, std::string ts_url, int nb_notify) | 337 | +int SrsHttpHooks::on_hls_notify(int cid, std::string url, SrsRequest* req, std::string ts_url, int nb_notify) |
| 338 | { | 338 | { |
| 339 | int ret = ERROR_SUCCESS; | 339 | int ret = ERROR_SUCCESS; |
| 340 | 340 | ||
| 341 | - int client_id = _srs_context->get_id(); | 341 | + int client_id = cid; |
| 342 | std::string cwd = _srs_config->cwd(); | 342 | std::string cwd = _srs_config->cwd(); |
| 343 | 343 | ||
| 344 | if (srs_string_starts_with(ts_url, "http://") || srs_string_starts_with(ts_url, "https://")) { | 344 | if (srs_string_starts_with(ts_url, "http://") || srs_string_starts_with(ts_url, "https://")) { |
| @@ -90,32 +90,35 @@ public: | @@ -90,32 +90,35 @@ public: | ||
| 90 | */ | 90 | */ |
| 91 | static void on_stop(std::string url, SrsRequest* req); | 91 | static void on_stop(std::string url, SrsRequest* req); |
| 92 | /** | 92 | /** |
| 93 | - * on_dvr hook, when reap a dvr file. | ||
| 94 | - * @param url the api server url, to process the event. | ||
| 95 | - * ignore if empty. | ||
| 96 | - * @param file the file path, can be relative or absolute path. | ||
| 97 | - */ | ||
| 98 | - static int on_dvr(std::string url, SrsRequest* req, std::string file); | 93 | + * on_dvr hook, when reap a dvr file. |
| 94 | + * @param url the api server url, to process the event. | ||
| 95 | + * ignore if empty. | ||
| 96 | + * @param file the file path, can be relative or absolute path. | ||
| 97 | + * @param cid the source connection cid, for the on_dvr is async call. | ||
| 98 | + */ | ||
| 99 | + static int on_dvr(int cid, std::string url, SrsRequest* req, std::string file); | ||
| 99 | /** | 100 | /** |
| 100 | - * when hls reap segment, callback. | ||
| 101 | - * @param url the api server url, to process the event. | ||
| 102 | - * ignore if empty. | ||
| 103 | - * @param file the ts file path, can be relative or absolute path. | ||
| 104 | - * @param ts_url the ts url, which used for m3u8. | ||
| 105 | - * @param m3u8 the m3u8 file path, can be relative or absolute path. | ||
| 106 | - * @param m3u8_url the m3u8 url, which is used for the http mount path. | ||
| 107 | - * @param sn the seq_no, the sequence number of ts in hls/m3u8. | ||
| 108 | - * @param duration the segment duration in seconds. | ||
| 109 | - */ | ||
| 110 | - static int on_hls(std::string url, SrsRequest* req, std::string file, std::string ts_url, std::string m3u8, std::string m3u8_url, int sn, double duration); | 101 | + * when hls reap segment, callback. |
| 102 | + * @param url the api server url, to process the event. | ||
| 103 | + * ignore if empty. | ||
| 104 | + * @param file the ts file path, can be relative or absolute path. | ||
| 105 | + * @param ts_url the ts url, which used for m3u8. | ||
| 106 | + * @param m3u8 the m3u8 file path, can be relative or absolute path. | ||
| 107 | + * @param m3u8_url the m3u8 url, which is used for the http mount path. | ||
| 108 | + * @param sn the seq_no, the sequence number of ts in hls/m3u8. | ||
| 109 | + * @param duration the segment duration in seconds. | ||
| 110 | + * @param cid the source connection cid, for the on_dvr is async call. | ||
| 111 | + */ | ||
| 112 | + static int on_hls(int cid, std::string url, SrsRequest* req, std::string file, std::string ts_url, std::string m3u8, std::string m3u8_url, int sn, double duration); | ||
| 111 | /** | 113 | /** |
| 112 | * when hls reap segment, callback. | 114 | * when hls reap segment, callback. |
| 113 | * @param url the api server url, to process the event. | 115 | * @param url the api server url, to process the event. |
| 114 | * ignore if empty. | 116 | * ignore if empty. |
| 115 | * @param ts_url the ts uri, used to replace the variable [ts_url] in url. | 117 | * @param ts_url the ts uri, used to replace the variable [ts_url] in url. |
| 116 | * @param nb_notify the max bytes to read from notify server. | 118 | * @param nb_notify the max bytes to read from notify server. |
| 119 | + * @param cid the source connection cid, for the on_dvr is async call. | ||
| 117 | */ | 120 | */ |
| 118 | - static int on_hls_notify(std::string url, SrsRequest* req, std::string ts_url, int nb_notify); | 121 | + static int on_hls_notify(int cid, std::string url, SrsRequest* req, std::string ts_url, int nb_notify); |
| 119 | private: | 122 | private: |
| 120 | static int do_post(std::string url, std::string req, int& code, std::string& res); | 123 | static int do_post(std::string url, std::string req, int& code, std::string& res); |
| 121 | }; | 124 | }; |
| @@ -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 2 | 32 | #define VERSION_MAJOR 2 |
| 33 | #define VERSION_MINOR 0 | 33 | #define VERSION_MINOR 0 |
| 34 | -#define VERSION_REVISION 187 | 34 | +#define VERSION_REVISION 188 |
| 35 | 35 | ||
| 36 | // server info. | 36 | // server info. |
| 37 | #define RTMP_SIG_SRS_KEY "SRS" | 37 | #define RTMP_SIG_SRS_KEY "SRS" |
-
请 注册 或 登录 后发表评论