Merge branch 3.0release into develop

min
winlin 6 years ago
commit 85db08cef9

2
.gitignore vendored

@ -29,3 +29,5 @@
# Apple-specific garbage files. # Apple-specific garbage files.
.AppleDouble .AppleDouble
.idea

@ -213,6 +213,7 @@ Please select according to languages:
### V2 changes ### V2 changes
* 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-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 [#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 * v2.0, 2018-11-11, Merge [#1263][bug #1263], Fix string trim bug. 2.0.259
@ -1446,6 +1447,7 @@ Winlin
[bug #1263]: https://github.com/ossrs/srs/issues/1263 [bug #1263]: https://github.com/ossrs/srs/issues/1263
[bug #1261]: https://github.com/ossrs/srs/issues/1261 [bug #1261]: https://github.com/ossrs/srs/issues/1261
[bug #1274]: https://github.com/ossrs/srs/pull/1274 [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 [bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx
[bug #735]: https://github.com/ossrs/srs/issues/735 [bug #735]: https://github.com/ossrs/srs/issues/735

@ -489,13 +489,13 @@ srs_error_t SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
if ((err = http_hooks_on_play()) != srs_success) { if ((err = http_hooks_on_play(r)) != srs_success) {
return srs_error_wrap(err, "http hook"); return srs_error_wrap(err, "http hook");
} }
err = do_serve_http(w, r); err = do_serve_http(w, r);
http_hooks_on_stop(); http_hooks_on_stop(r);
return err; return err;
} }
@ -658,7 +658,7 @@ srs_error_t SrsLiveStream::do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
return err; return err;
} }
srs_error_t SrsLiveStream::http_hooks_on_play() srs_error_t SrsLiveStream::http_hooks_on_play(ISrsHttpMessage* r)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -666,13 +666,18 @@ srs_error_t SrsLiveStream::http_hooks_on_play()
return err; return err;
} }
// Create request to report for the specified connection.
SrsHttpMessage* hr = dynamic_cast<SrsHttpMessage*>(r);
SrsRequest* nreq = hr->to_request(req->vhost);
SrsAutoFree(SrsRequest, nreq);
// the http hooks will cause context switch, // the http hooks will cause context switch,
// so we must copy all hooks for the on_connect may freed. // so we must copy all hooks for the on_connect may freed.
// @see https://github.com/ossrs/srs/issues/475 // @see https://github.com/ossrs/srs/issues/475
vector<string> hooks; vector<string> hooks;
if (true) { if (true) {
SrsConfDirective* conf = _srs_config->get_vhost_on_play(req->vhost); SrsConfDirective* conf = _srs_config->get_vhost_on_play(nreq->vhost);
if (!conf) { if (!conf) {
return err; return err;
@ -683,27 +688,32 @@ srs_error_t SrsLiveStream::http_hooks_on_play()
for (int i = 0; i < (int)hooks.size(); i++) { for (int i = 0; i < (int)hooks.size(); i++) {
std::string url = hooks.at(i); std::string url = hooks.at(i);
if ((err = SrsHttpHooks::on_play(url, req)) != srs_success) { if ((err = SrsHttpHooks::on_play(url, nreq)) != srs_success) {
return srs_error_wrap(err, "rtmp on_play %s", url.c_str()); return srs_error_wrap(err, "http on_play %s", url.c_str());
} }
} }
return err; return err;
} }
void SrsLiveStream::http_hooks_on_stop() void SrsLiveStream::http_hooks_on_stop(ISrsHttpMessage* r)
{ {
if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) { if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) {
return; return;
} }
// Create request to report for the specified connection.
SrsHttpMessage* hr = dynamic_cast<SrsHttpMessage*>(r);
SrsRequest* nreq = hr->to_request(req->vhost);
SrsAutoFree(SrsRequest, nreq);
// the http hooks will cause context switch, // the http hooks will cause context switch,
// so we must copy all hooks for the on_connect may freed. // so we must copy all hooks for the on_connect may freed.
// @see https://github.com/ossrs/srs/issues/475 // @see https://github.com/ossrs/srs/issues/475
vector<string> hooks; vector<string> hooks;
if (true) { if (true) {
SrsConfDirective* conf = _srs_config->get_vhost_on_stop(req->vhost); SrsConfDirective* conf = _srs_config->get_vhost_on_stop(nreq->vhost);
if (!conf) { if (!conf) {
srs_info("ignore the empty http callback: on_stop"); srs_info("ignore the empty http callback: on_stop");
@ -715,7 +725,7 @@ void SrsLiveStream::http_hooks_on_stop()
for (int i = 0; i < (int)hooks.size(); i++) { for (int i = 0; i < (int)hooks.size(); i++) {
std::string url = hooks.at(i); std::string url = hooks.at(i);
SrsHttpHooks::on_stop(url, req); SrsHttpHooks::on_stop(url, nreq);
} }
return; return;

@ -229,8 +229,8 @@ public:
virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r); virtual srs_error_t serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
private: private:
virtual srs_error_t do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r); virtual srs_error_t do_serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
virtual srs_error_t http_hooks_on_play(); virtual srs_error_t http_hooks_on_play(ISrsHttpMessage* r);
virtual void http_hooks_on_stop(); virtual void http_hooks_on_stop(ISrsHttpMessage* r);
virtual srs_error_t streaming_send_messages(ISrsBufferEncoder* enc, SrsSharedPtrMessage** msgs, int nb_msgs); virtual srs_error_t streaming_send_messages(ISrsBufferEncoder* enc, SrsSharedPtrMessage** msgs, int nb_msgs);
}; };

@ -594,6 +594,11 @@ SrsRequest* SrsHttpMessage::to_request(string vhost)
req->pageUrl = get_request_header("Referer"); req->pageUrl = get_request_header("Referer");
req->objectEncoding = 0; req->objectEncoding = 0;
std::string query = _uri->get_query();
if (!query.empty()) {
req->tcUrl = req->tcUrl + "?" + query;
}
srs_discovery_tc_url(req->tcUrl, req->schema, req->host, req->vhost, req->app, req->stream, req->port, req->param); srs_discovery_tc_url(req->tcUrl, req->schema, req->host, req->vhost, req->app, req->stream, req->port, req->param);
req->strip(); req->strip();

Loading…
Cancel
Save