From 91c462b6bad90ed8f1f2366dc552e82057641d97 Mon Sep 17 00:00:00 2001 From: winlin Date: Fri, 5 Apr 2019 18:16:05 +0800 Subject: [PATCH] For #1339, Support HTTP-FLV params. 2.0.262 --- .gitignore | 2 ++ README.md | 2 ++ trunk/src/app/srs_app_http_stream.cpp | 26 ++++++++++++++++++-------- trunk/src/app/srs_app_http_stream.hpp | 4 ++-- trunk/src/core/srs_core.hpp | 2 +- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 399419fa4f..c8ddaf1eb9 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,5 @@ # Apple-specific garbage files. .AppleDouble + +.idea diff --git a/README.md b/README.md index bc957e25c1..c25da2bc6f 100755 --- a/README.md +++ b/README.md @@ -335,6 +335,7 @@ Remark: ## History +* v2.0, 2019-04-05, Merge [#1339][bug #1339], Support HTTP-FLV params. 2.0.262 * v2.0, 2018-12-01, Merge [#1274][bug #1274], Upgrade to FFMPEG 4.1 and X264 157. 2.0.261 * v2.0, 2018-11-11, Merge [#1261][bug #1261], Support `_definst_` for Wowza. 2.0.260 * v2.0, 2018-11-11, Merge [#1263][bug #1263], Fix string trim bug. 2.0.259 @@ -1342,6 +1343,7 @@ Winlin [bug #1263]: https://github.com/ossrs/srs/issues/1263 [bug #1261]: https://github.com/ossrs/srs/issues/1261 [bug #1274]: https://github.com/ossrs/srs/pull/1274 +[bug #1339]: https://github.com/ossrs/srs/pull/1339 [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx [exo #828]: https://github.com/google/ExoPlayer/pull/828 diff --git a/trunk/src/app/srs_app_http_stream.cpp b/trunk/src/app/srs_app_http_stream.cpp index 53f21b1bc1..aacf5bce4e 100755 --- a/trunk/src/app/srs_app_http_stream.cpp +++ b/trunk/src/app/srs_app_http_stream.cpp @@ -481,14 +481,14 @@ int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) { int ret = ERROR_SUCCESS; - if ((ret = http_hooks_on_play()) != ERROR_SUCCESS) { + if ((ret = http_hooks_on_play(r)) != ERROR_SUCCESS) { srs_error("http hook on_play failed. ret=%d", ret); return ret; } ret = do_serve_http(w, r); - http_hooks_on_stop(); + http_hooks_on_stop(r); return ret; } @@ -636,7 +636,7 @@ int SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r) return ret; } -int SrsLiveStream::http_hooks_on_play() +int SrsLiveStream::http_hooks_on_play(ISrsHttpMessage* r) { int ret = ERROR_SUCCESS; @@ -644,6 +644,11 @@ int SrsLiveStream::http_hooks_on_play() if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) { return ret; } + + // Create request to report for the specified connection. + SrsHttpMessage* hr = dynamic_cast(r); + SrsRequest* nreq = hr->to_request(req->vhost); + SrsAutoFree(SrsRequest, nreq); // the http hooks will cause context switch, // so we must copy all hooks for the on_connect may freed. @@ -651,7 +656,7 @@ int SrsLiveStream::http_hooks_on_play() vector hooks; if (true) { - SrsConfDirective* conf = _srs_config->get_vhost_on_play(req->vhost); + SrsConfDirective* conf = _srs_config->get_vhost_on_play(nreq->vhost); if (!conf) { srs_info("ignore the empty http callback: on_play"); @@ -663,7 +668,7 @@ int SrsLiveStream::http_hooks_on_play() for (int i = 0; i < (int)hooks.size(); i++) { std::string url = hooks.at(i); - if ((ret = SrsHttpHooks::on_play(url, req)) != ERROR_SUCCESS) { + if ((ret = SrsHttpHooks::on_play(url, nreq)) != ERROR_SUCCESS) { srs_error("hook client on_play failed. url=%s, ret=%d", url.c_str(), ret); return ret; } @@ -673,12 +678,17 @@ int SrsLiveStream::http_hooks_on_play() return ret; } -void SrsLiveStream::http_hooks_on_stop() +void SrsLiveStream::http_hooks_on_stop(ISrsHttpMessage* r) { #ifdef SRS_AUTO_HTTP_CALLBACK if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) { return; } + + // Create request to report for the specified connection. + SrsHttpMessage* hr = dynamic_cast(r); + SrsRequest* nreq = hr->to_request(req->vhost); + SrsAutoFree(SrsRequest, nreq); // the http hooks will cause context switch, // so we must copy all hooks for the on_connect may freed. @@ -686,7 +696,7 @@ void SrsLiveStream::http_hooks_on_stop() vector hooks; if (true) { - SrsConfDirective* conf = _srs_config->get_vhost_on_stop(req->vhost); + SrsConfDirective* conf = _srs_config->get_vhost_on_stop(nreq->vhost); if (!conf) { srs_info("ignore the empty http callback: on_stop"); @@ -698,7 +708,7 @@ void SrsLiveStream::http_hooks_on_stop() for (int i = 0; i < (int)hooks.size(); i++) { std::string url = hooks.at(i); - SrsHttpHooks::on_stop(url, req); + SrsHttpHooks::on_stop(url, nreq); } #endif diff --git a/trunk/src/app/srs_app_http_stream.hpp b/trunk/src/app/srs_app_http_stream.hpp index 18c84a5d05..391b670a22 100755 --- a/trunk/src/app/srs_app_http_stream.hpp +++ b/trunk/src/app/srs_app_http_stream.hpp @@ -233,8 +233,8 @@ class SrsLiveStream : public ISrsHttpHandler virtual int serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r); private: virtual int do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r); - virtual int http_hooks_on_play(); - virtual void http_hooks_on_stop(); + virtual int http_hooks_on_play(ISrsHttpMessage* r); + virtual void http_hooks_on_stop(ISrsHttpMessage* r); virtual int streaming_send_messages(ISrsStreamEncoder* enc, SrsSharedPtrMessage** msgs, int nb_msgs); }; diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index a2728fdc28..07d075ed7f 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR 2 #define VERSION_MINOR 0 -#define VERSION_REVISION 261 +#define VERSION_REVISION 262 // generated by configure, only macros. #include