Skip to content

Commit

Permalink
For #1339, Support HTTP-FLV params. 2.0.262
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Apr 5, 2019
1 parent ab83394 commit 91c462b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@

# Apple-specific garbage files.
.AppleDouble

.idea
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
26 changes: 18 additions & 8 deletions trunk/src/app/srs_app_http_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -636,22 +636,27 @@ 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;

#ifdef SRS_AUTO_HTTP_CALLBACK
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.
// @see https://github.com/ossrs/srs/issues/475
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");
Expand All @@ -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;
}
Expand All @@ -673,20 +678,25 @@ 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.
// @see https://github.com/ossrs/srs/issues/475
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");
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions trunk/src/app/srs_app_http_stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 91c462b

Please sign in to comment.