Skip to content

Commit

Permalink
For ossrs#1110, Support params in http callback. 2.0.251
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Aug 4, 2018
1 parent 09dbda5 commit 85d3a50
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 16 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ Remark:

## History

* v2.0, 2018-08-04, For [#1110][bug #1110], Support params in http callback. 2.0.251
* v2.0, 2018-08-02, For [#1031][bug #1031], SRS edge support douyu.com. 2.0.250
* v2.0, 2018-07-21, Merge [#1119][bug #1119], fix memory leak. 2.0.249
* <strong>v2.0, 2018-07-18, [2.0 release3(2.0.248)][r2.0r3] released. 86775 lines.</strong>
Expand Down Expand Up @@ -1315,6 +1316,7 @@ Winlin
[bug #1176]: https://github.com/ossrs/srs/issues/1176
[bug #1119]: https://github.com/ossrs/srs/issues/1119
[bug #1031]: https://github.com/ossrs/srs/issues/1031
[bug #1110]: https://github.com/ossrs/srs/issues/1110
[bug #xxxxxxxxxx]: https://github.com/ossrs/srs/issues/xxxxxxxxxx

[exo #828]: https://github.com/google/ExoPlayer/pull/828
Expand Down
13 changes: 7 additions & 6 deletions trunk/conf/full.conf
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ vhost hooks.callback.srs.com {
# "action": "on_unpublish",
# "client_id": 1985,
# "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
# "stream": "livestream"
# "stream": "livestream", "param":"?token=xxx&salt=yyy"
# }
# if valid, the hook must return HTTP code 200(Stauts OK) and response
# an int value specifies the error code(0 corresponding to success):
Expand All @@ -751,7 +751,7 @@ vhost hooks.callback.srs.com {
# "action": "on_play",
# "client_id": 1985,
# "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
# "stream": "livestream",
# "stream": "livestream", "param":"?token=xxx&salt=yyy",
# "pageUrl": "http://www.test.com/live.html"
# }
# if valid, the hook must return HTTP code 200(Stauts OK) and response
Expand All @@ -766,7 +766,7 @@ vhost hooks.callback.srs.com {
# "action": "on_stop",
# "client_id": 1985,
# "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
# "stream": "livestream"
# "stream": "livestream", "param":"?token=xxx&salt=yyy"
# }
# if valid, the hook must return HTTP code 200(Stauts OK) and response
# an int value specifies the error code(0 corresponding to success):
Expand All @@ -780,7 +780,7 @@ vhost hooks.callback.srs.com {
# "action": "on_dvr",
# "client_id": 1985,
# "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
# "stream": "livestream",
# "stream": "livestream", "param":"?token=xxx&salt=yyy",
# "cwd": "/usr/local/srs",
# "file": "./objs/nginx/html/live/livestream.1420254068776.flv"
# }
Expand All @@ -794,7 +794,7 @@ vhost hooks.callback.srs.com {
# "action": "on_hls",
# "client_id": 1985,
# "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
# "stream": "livestream",
# "stream": "livestream", "param":"?token=xxx&salt=yyy",
# "duration": 9.36, // in seconds
# "cwd": "/usr/local/srs",
# "file": "./objs/nginx/html/live/livestream/2015-04-23/01/476584165.ts",
Expand All @@ -812,10 +812,11 @@ vhost hooks.callback.srs.com {
# so we use HTTP GET and use the variable following:
# [app], replace with the app.
# [stream], replace with the stream.
# [param], replace with the param.
# [ts_url], replace with the ts url.
# ignore any return data of server.
# @remark random select a url to report, not report all.
on_hls_notify http://127.0.0.1:8085/api/v1/hls/[app]/[stream][ts_url];
on_hls_notify http://127.0.0.1:8085/api/v1/hls/[app]/[stream]/[ts_url][param];
}
}

Expand Down
2 changes: 0 additions & 2 deletions trunk/ide/srs_xcode/srs_xcode.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@
3C1EE6C91AB1080900576EE9 /* origin.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = origin.conf; path = ../../../conf/origin.conf; sourceTree = "<group>"; };
3C1EE6CA1AB1080900576EE9 /* push.mpegts.over.udp.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = push.mpegts.over.udp.conf; path = ../../../conf/push.mpegts.over.udp.conf; sourceTree = "<group>"; };
3C1EE6CB1AB1080900576EE9 /* push.rtsp.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = push.rtsp.conf; path = ../../../conf/push.rtsp.conf; sourceTree = "<group>"; };
3C1EE6CC1AB1080900576EE9 /* ram.hls.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = ram.hls.conf; path = ../../../conf/ram.hls.conf; sourceTree = "<group>"; };
3C1EE6CD1AB1080900576EE9 /* realtime.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = realtime.conf; path = ../../../conf/realtime.conf; sourceTree = "<group>"; };
3C1EE6CE1AB1080900576EE9 /* rtmp.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = rtmp.conf; path = ../../../conf/rtmp.conf; sourceTree = "<group>"; };
3C1EE6CF1AB1080900576EE9 /* security.deny.publish.conf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = security.deny.publish.conf; path = ../../../conf/security.deny.publish.conf; sourceTree = "<group>"; };
Expand Down Expand Up @@ -703,7 +702,6 @@
3C1EE6C91AB1080900576EE9 /* origin.conf */,
3C1EE6CA1AB1080900576EE9 /* push.mpegts.over.udp.conf */,
3C1EE6CB1AB1080900576EE9 /* push.rtsp.conf */,
3C1EE6CC1AB1080900576EE9 /* ram.hls.conf */,
3C1EE6CD1AB1080900576EE9 /* realtime.conf */,
3C1EE6CE1AB1080900576EE9 /* rtmp.conf */,
3C1EE6CF1AB1080900576EE9 /* security.deny.publish.conf */,
Expand Down
21 changes: 18 additions & 3 deletions trunk/src/app/srs_app_http_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ int SrsHttpHooks::on_publish(string url, SrsRequest* req)

int client_id = _srs_context->get_id();

string stream = req->stream;
// Pass params in stream, @see https://github.com/ossrs/srs/issues/1031#issuecomment-409745733
if (!req->param.empty()) {
if (req->param.find("?") != 0) {
stream += "?";
}
stream += req->param;
}

std::stringstream ss;
ss << SRS_JOBJECT_START
<< SRS_JFIELD_STR("action", "on_publish") << SRS_JFIELD_CONT
Expand All @@ -139,7 +148,7 @@ int SrsHttpHooks::on_publish(string url, SrsRequest* req)
<< SRS_JFIELD_STR("vhost", req->vhost) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("app", req->app) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("tcUrl", req->tcUrl) << SRS_JFIELD_CONT // Add tcUrl for auth publish rtmp stream client
<< SRS_JFIELD_STR("stream", req->stream)
<< SRS_JFIELD_STR("stream", stream)
<< SRS_JOBJECT_END;

std::string data = ss.str();
Expand Down Expand Up @@ -172,7 +181,8 @@ void SrsHttpHooks::on_unpublish(string url, SrsRequest* req)
<< SRS_JFIELD_STR("ip", req->ip) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("vhost", req->vhost) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("app", req->app) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("stream", req->stream)
<< SRS_JFIELD_STR("stream", req->stream)<< SRS_JFIELD_CONT
<< SRS_JFIELD_STR("param", req->param)
<< SRS_JOBJECT_END;

std::string data = ss.str();
Expand Down Expand Up @@ -206,6 +216,7 @@ int SrsHttpHooks::on_play(string url, SrsRequest* req)
<< SRS_JFIELD_STR("vhost", req->vhost) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("app", req->app) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("stream", req->stream) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("param", req->param) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("pageUrl", req->pageUrl)
<< SRS_JOBJECT_END;

Expand Down Expand Up @@ -239,7 +250,8 @@ void SrsHttpHooks::on_stop(string url, SrsRequest* req)
<< SRS_JFIELD_STR("ip", req->ip) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("vhost", req->vhost) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("app", req->app) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("stream", req->stream)
<< SRS_JFIELD_STR("stream", req->stream) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("param", req->param)
<< SRS_JOBJECT_END;

std::string data = ss.str();
Expand Down Expand Up @@ -274,6 +286,7 @@ int SrsHttpHooks::on_dvr(int cid, string url, SrsRequest* req, string file)
<< SRS_JFIELD_STR("vhost", req->vhost) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("app", req->app) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("stream", req->stream) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("param", req->param) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("cwd", cwd) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("file", file)
<< SRS_JOBJECT_END;
Expand Down Expand Up @@ -316,6 +329,7 @@ int SrsHttpHooks::on_hls(int cid, string url, SrsRequest* req, string file, stri
<< SRS_JFIELD_STR("vhost", req->vhost) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("app", req->app) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("stream", req->stream) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("param", req->param) << SRS_JFIELD_CONT
<< SRS_JFIELD_ORG("duration", duration) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("cwd", cwd) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("file", file) << SRS_JFIELD_CONT
Expand Down Expand Up @@ -356,6 +370,7 @@ int SrsHttpHooks::on_hls_notify(int cid, std::string url, SrsRequest* req, std::
url = srs_string_replace(url, "[app]", req->app);
url = srs_string_replace(url, "[stream]", req->stream);
url = srs_string_replace(url, "[ts_url]", ts_url);
url = srs_string_replace(url, "[param]", req->param);

int64_t starttime = srs_update_system_time_ms();

Expand Down
8 changes: 4 additions & 4 deletions trunk/src/app/srs_app_rtmp_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ int SrsRtmpConn::stream_service_cycle()

srs_discovery_tc_url(req->tcUrl, req->schema, req->host, req->vhost, req->app, req->stream, req->port, req->param);
req->strip();
srs_trace("client identified, type=%s, stream_name=%s, duration=%.2f",
srs_client_type_string(type).c_str(), req->stream.c_str(), req->duration);
srs_trace("client identified, type=%s, stream_name=%s, duration=%.2f, param=%s",
srs_client_type_string(type).c_str(), req->stream.c_str(), req->duration, req->param.c_str());

// discovery vhost, resolve the vhost from config
SrsConfDirective* parsed_vhost = _srs_config->get_vhost(req->vhost);
Expand All @@ -460,10 +460,10 @@ int SrsRtmpConn::stream_service_cycle()
return ret;
}

srs_trace("connected stream, tcUrl=%s, pageUrl=%s, swfUrl=%s, schema=%s, vhost=%s, port=%s, app=%s, stream=%s, args=%s",
srs_trace("connected stream, tcUrl=%s, pageUrl=%s, swfUrl=%s, schema=%s, vhost=%s, port=%s, app=%s, stream=%s, param=%s, args=%s",
req->tcUrl.c_str(), req->pageUrl.c_str(), req->swfUrl.c_str(),
req->schema.c_str(), req->vhost.c_str(), req->port.c_str(),
req->app.c_str(), req->stream.c_str(), (req->args? "(obj)":"null"));
req->app.c_str(), req->stream.c_str(), req->param.c_str(), (req->args? "(obj)":"null"));

// do token traverse before serve it.
// @see https://github.com/ossrs/srs/pull/239
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 250
#define VERSION_REVISION 251

// generated by configure, only macros.
#include <srs_auto_headers.hpp>
Expand Down

0 comments on commit 85d3a50

Please sign in to comment.