正在显示
5 个修改的文件
包含
28 行增加
和
15 行删除
| @@ -190,6 +190,7 @@ usr sys idl wai hiq siq| read writ| recv send| in out | int csw | @@ -190,6 +190,7 @@ usr sys idl wai hiq siq| read writ| recv send| in out | int csw | ||
| 190 | * nginx v1.5.0: 139524 lines <br/> | 190 | * nginx v1.5.0: 139524 lines <br/> |
| 191 | 191 | ||
| 192 | ### History | 192 | ### History |
| 193 | +* v0.8, 2013-12-08, support multiple http hooks for a event. | ||
| 193 | * v0.8, 2013-12-07, support http callback hooks, on_connect. | 194 | * v0.8, 2013-12-07, support http callback hooks, on_connect. |
| 194 | * v0.8, 2013-12-07, support network based cli and json result, add CherryPy 3.2.4. | 195 | * v0.8, 2013-12-07, support network based cli and json result, add CherryPy 3.2.4. |
| 195 | * v0.8, 2013-12-07, update http/hls/rtmp load test tool [st_load](https://github.com/winlinvip/st-load), use srs rtmp sdk. | 196 | * v0.8, 2013-12-07, update http/hls/rtmp load test tool [st_load](https://github.com/winlinvip/st-load), use srs rtmp sdk. |
| @@ -87,12 +87,14 @@ vhost dev { | @@ -87,12 +87,14 @@ vhost dev { | ||
| 87 | hls_window 30; | 87 | hls_window 30; |
| 88 | #forward 127.0.0.1:19350; | 88 | #forward 127.0.0.1:19350; |
| 89 | #forward 127.0.0.1:1936; | 89 | #forward 127.0.0.1:1936; |
| 90 | - on_connect http://127.0.0.1:8085/api/v1/clients; | 90 | + http_hooks { |
| 91 | + on_connect http://127.0.0.1:8085/api/v1/clients http://localhost:8085/api/v1/clients; | ||
| 91 | on_close http://127.0.0.1:8085/api/v1/clients; | 92 | on_close http://127.0.0.1:8085/api/v1/clients; |
| 92 | on_publish http://127.0.0.1:8085/api/v1/streams; | 93 | on_publish http://127.0.0.1:8085/api/v1/streams; |
| 93 | on_unpublish http://127.0.0.1:8085/api/v1/streams; | 94 | on_unpublish http://127.0.0.1:8085/api/v1/streams; |
| 94 | on_play http://127.0.0.1:8085/api/v1/sessions; | 95 | on_play http://127.0.0.1:8085/api/v1/sessions; |
| 95 | on_stop http://127.0.0.1:8085/api/v1/sessions; | 96 | on_stop http://127.0.0.1:8085/api/v1/sessions; |
| 97 | + } | ||
| 96 | transcode { | 98 | transcode { |
| 97 | enabled off; | 99 | enabled off; |
| 98 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; | 100 | ffmpeg ./objs/ffmpeg/bin/ffmpeg; |
| @@ -133,6 +135,7 @@ vhost dev { | @@ -133,6 +135,7 @@ vhost dev { | ||
| 133 | } | 135 | } |
| 134 | # the http hook callback vhost, srs will invoke the hooks for specified events. | 136 | # the http hook callback vhost, srs will invoke the hooks for specified events. |
| 135 | vhost hooks.callback.vhost.com { | 137 | vhost hooks.callback.vhost.com { |
| 138 | + http_hooks { | ||
| 136 | # when client connect to vhost/app, call the hook, | 139 | # when client connect to vhost/app, call the hook, |
| 137 | # the request in the POST data string is a object encode by json: | 140 | # the request in the POST data string is a object encode by json: |
| 138 | # { | 141 | # { |
| @@ -142,7 +145,10 @@ vhost hooks.callback.vhost.com { | @@ -142,7 +145,10 @@ vhost hooks.callback.vhost.com { | ||
| 142 | # if valid, the hook must return HTTP code 200(Stauts OK) and response | 145 | # if valid, the hook must return HTTP code 200(Stauts OK) and response |
| 143 | # an int value specifies the error code(0 corresponding to success): | 146 | # an int value specifies the error code(0 corresponding to success): |
| 144 | # 0 | 147 | # 0 |
| 145 | - on_connect http://127.0.0.1:8085/api/v1/clients; | 148 | + # support multiple api hooks, format: |
| 149 | + # on_connect http://xxx/api0 http://xxx/api1 http://xxx/apiN | ||
| 150 | + on_connect http://127.0.0.1:8085/api/v1/clients http://localhost:8085/api/v1/clients; | ||
| 151 | + } | ||
| 146 | } | 152 | } |
| 147 | # the mirror filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#Filtering-Introduction | 153 | # the mirror filter of ffmpeg, @see: http://ffmpeg.org/ffmpeg-filters.html#Filtering-Introduction |
| 148 | vhost mirror.transcode.vhost.com { | 154 | vhost mirror.transcode.vhost.com { |
trunk/src/core/srs_core_client.cpp
100644 → 100755
| @@ -251,16 +251,19 @@ int SrsClient::check_vhost() | @@ -251,16 +251,19 @@ int SrsClient::check_vhost() | ||
| 251 | 251 | ||
| 252 | #ifdef SRS_HTTP | 252 | #ifdef SRS_HTTP |
| 253 | // HTTP: on_connect | 253 | // HTTP: on_connect |
| 254 | - std::string on_connect = config->get_vhost_on_connect(req->vhost); | ||
| 255 | - if (on_connect.empty()) { | 254 | + SrsConfDirective* on_connect = config->get_vhost_on_connect(req->vhost); |
| 255 | + if (!on_connect) { | ||
| 256 | srs_info("ignore the empty http callback: on_connect"); | 256 | srs_info("ignore the empty http callback: on_connect"); |
| 257 | return ret; | 257 | return ret; |
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | - if ((ret = http_hooks->on_connect(on_connect, ip, req)) != ERROR_SUCCESS) { | ||
| 261 | - srs_error("hook client failed. ret=%d", ret); | 260 | + for (int i = 0; i < (int)on_connect->args.size(); i++) { |
| 261 | + std::string url = on_connect->args.at(i); | ||
| 262 | + if ((ret = http_hooks->on_connect(url, ip, req)) != ERROR_SUCCESS) { | ||
| 263 | + srs_error("hook client failed. url=%s, ret=%d", url.c_str(), ret); | ||
| 262 | return ret; | 264 | return ret; |
| 263 | } | 265 | } |
| 266 | + } | ||
| 264 | #endif | 267 | #endif |
| 265 | 268 | ||
| 266 | return ret; | 269 | return ret; |
trunk/src/core/srs_core_config.cpp
100644 → 100755
| @@ -344,7 +344,10 @@ int SrsConfDirective::read_token(SrsFileBuffer* buffer, std::vector<std::string> | @@ -344,7 +344,10 @@ int SrsConfDirective::read_token(SrsFileBuffer* buffer, std::vector<std::string> | ||
| 344 | memcpy(word, pstart, len); | 344 | memcpy(word, pstart, len); |
| 345 | word[len - 1] = 0; | 345 | word[len - 1] = 0; |
| 346 | 346 | ||
| 347 | - args.push_back(word); | 347 | + std::string word_str = word; |
| 348 | + if (!word_str.empty()) { | ||
| 349 | + args.push_back(word_str); | ||
| 350 | + } | ||
| 348 | srs_freepa(word); | 351 | srs_freepa(word); |
| 349 | 352 | ||
| 350 | if (ch == ';') { | 353 | if (ch == ';') { |
| @@ -559,20 +562,20 @@ SrsConfDirective* SrsConfig::get_vhost(std::string vhost) | @@ -559,20 +562,20 @@ SrsConfDirective* SrsConfig::get_vhost(std::string vhost) | ||
| 559 | return NULL; | 562 | return NULL; |
| 560 | } | 563 | } |
| 561 | 564 | ||
| 562 | -std::string SrsConfig::get_vhost_on_connect(std::string vhost) | 565 | +SrsConfDirective* SrsConfig::get_vhost_on_connect(std::string vhost) |
| 563 | { | 566 | { |
| 564 | - SrsConfDirective* vhost_conf = get_vhost(vhost); | 567 | + SrsConfDirective* conf = get_vhost(vhost); |
| 565 | 568 | ||
| 566 | - if (!vhost_conf) { | ||
| 567 | - return ""; | 569 | + if (!conf) { |
| 570 | + return NULL; | ||
| 568 | } | 571 | } |
| 569 | 572 | ||
| 570 | - SrsConfDirective* conf = vhost_conf->get("on_connect"); | 573 | + conf = conf->get("http_hooks"); |
| 571 | if (!conf) { | 574 | if (!conf) { |
| 572 | - return ""; | 575 | + return NULL; |
| 573 | } | 576 | } |
| 574 | 577 | ||
| 575 | - return conf->arg0(); | 578 | + return conf->get("on_connect"); |
| 576 | } | 579 | } |
| 577 | 580 | ||
| 578 | bool SrsConfig::get_vhost_enabled(std::string vhost) | 581 | bool SrsConfig::get_vhost_enabled(std::string vhost) |
trunk/src/core/srs_core_config.hpp
100644 → 100755
| @@ -119,7 +119,7 @@ public: | @@ -119,7 +119,7 @@ public: | ||
| 119 | public: | 119 | public: |
| 120 | virtual SrsConfDirective* get_vhost(std::string vhost); | 120 | virtual SrsConfDirective* get_vhost(std::string vhost); |
| 121 | virtual bool get_vhost_enabled(std::string vhost); | 121 | virtual bool get_vhost_enabled(std::string vhost); |
| 122 | - virtual std::string get_vhost_on_connect(std::string vhost); | 122 | + virtual SrsConfDirective* get_vhost_on_connect(std::string vhost); |
| 123 | virtual SrsConfDirective* get_transcode(std::string vhost, std::string scope); | 123 | virtual SrsConfDirective* get_transcode(std::string vhost, std::string scope); |
| 124 | virtual bool get_transcode_enabled(SrsConfDirective* transcode); | 124 | virtual bool get_transcode_enabled(SrsConfDirective* transcode); |
| 125 | virtual std::string get_transcode_ffmpeg(SrsConfDirective* transcode); | 125 | virtual std::string get_transcode_ffmpeg(SrsConfDirective* transcode); |
-
请 注册 或 登录 后发表评论