1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-12 11:21:52 +00:00

For #1339, Support HTTP-FLV params. 2.0.262

This commit is contained in:
winlin 2019-04-05 18:16:05 +08:00
parent ab833943e1
commit 91c462b6ba
5 changed files with 25 additions and 11 deletions

2
.gitignore vendored
View file

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

View file

@ -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

View file

@ -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<SrsHttpMessage*>(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<string> 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<SrsHttpMessage*>(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<string> 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

View file

@ -233,8 +233,8 @@ public:
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);
};

View file

@ -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 <srs_auto_headers.hpp>