Skip to content

Commit

Permalink
API: Add service_id for http_hooks, which identify the process, v6.0.…
Browse files Browse the repository at this point in the history
…28, v5.0.142 (#3424)

PICK 733aeaa

Co-authored-by: Winlin <winlin@vip.126.com>
Co-authored-by: Haibo Chen <495810242@qq.com>
  • Loading branch information
3 people committed Feb 25, 2023
1 parent 7fe0e28 commit 0a0fb23
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions trunk/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The changelog for SRS.

## SRS 5.0 Changelog

* v5.0, 2023-02-25, Merge [#3424](https://github.com/ossrs/srs/pull/3424): API: Add service_id for http_hooks, which identify the process. v5.0.142 (#3424)
* v5.0, 2023-02-22, Compatible with legacy RTMP URL. v5.0.142
* v5.0, 2023-02-12, Merge [#3409](https://github.com/ossrs/srs/pull/3409): SRT: Reduce latency to 200ms of srt2rtc.conf. v5.0.141 (#3409)
* v5.0, 2023-02-08, Merge [#3391](https://github.com/ossrs/srs/pull/3391): Config: Error when both HLS and HTTP-TS enabled. v5.0.140 (#3391)
Expand Down
10 changes: 10 additions & 0 deletions trunk/src/app/srs_app_http_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ srs_error_t SrsHttpHooks::on_connect(string url, SrsRequest* req)
SrsAutoFree(SrsJsonObject, obj);

obj->set("server_id", SrsJsonAny::str(stat->server_id().c_str()));
obj->set("service_id", SrsJsonAny::str(stat->service_id().c_str()));
obj->set("action", SrsJsonAny::str("on_connect"));
obj->set("client_id", SrsJsonAny::str(cid.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
Expand Down Expand Up @@ -91,6 +92,7 @@ void SrsHttpHooks::on_close(string url, SrsRequest* req, int64_t send_bytes, int
SrsAutoFree(SrsJsonObject, obj);

obj->set("server_id", SrsJsonAny::str(stat->server_id().c_str()));
obj->set("service_id", SrsJsonAny::str(stat->service_id().c_str()));
obj->set("action", SrsJsonAny::str("on_close"));
obj->set("client_id", SrsJsonAny::str(cid.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
Expand Down Expand Up @@ -130,6 +132,7 @@ srs_error_t SrsHttpHooks::on_publish(string url, SrsRequest* req)
SrsAutoFree(SrsJsonObject, obj);

obj->set("server_id", SrsJsonAny::str(stat->server_id().c_str()));
obj->set("service_id", SrsJsonAny::str(stat->service_id().c_str()));
obj->set("action", SrsJsonAny::str("on_publish"));
obj->set("client_id", SrsJsonAny::str(cid.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
Expand Down Expand Up @@ -173,6 +176,7 @@ void SrsHttpHooks::on_unpublish(string url, SrsRequest* req)
SrsAutoFree(SrsJsonObject, obj);

obj->set("server_id", SrsJsonAny::str(stat->server_id().c_str()));
obj->set("service_id", SrsJsonAny::str(stat->service_id().c_str()));
obj->set("action", SrsJsonAny::str("on_unpublish"));
obj->set("client_id", SrsJsonAny::str(cid.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
Expand Down Expand Up @@ -219,6 +223,7 @@ srs_error_t SrsHttpHooks::on_play(string url, SrsRequest* req)
SrsAutoFree(SrsJsonObject, obj);

obj->set("server_id", SrsJsonAny::str(stat->server_id().c_str()));
obj->set("service_id", SrsJsonAny::str(stat->service_id().c_str()));
obj->set("action", SrsJsonAny::str("on_play"));
obj->set("client_id", SrsJsonAny::str(cid.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
Expand Down Expand Up @@ -263,6 +268,7 @@ void SrsHttpHooks::on_stop(string url, SrsRequest* req)
SrsAutoFree(SrsJsonObject, obj);

obj->set("server_id", SrsJsonAny::str(stat->server_id().c_str()));
obj->set("service_id", SrsJsonAny::str(stat->service_id().c_str()));
obj->set("action", SrsJsonAny::str("on_stop"));
obj->set("client_id", SrsJsonAny::str(cid.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
Expand Down Expand Up @@ -310,6 +316,7 @@ srs_error_t SrsHttpHooks::on_dvr(SrsContextId c, string url, SrsRequest* req, st
SrsAutoFree(SrsJsonObject, obj);

obj->set("server_id", SrsJsonAny::str(stat->server_id().c_str()));
obj->set("service_id", SrsJsonAny::str(stat->service_id().c_str()));
obj->set("action", SrsJsonAny::str("on_dvr"));
obj->set("client_id", SrsJsonAny::str(cid.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
Expand Down Expand Up @@ -362,6 +369,7 @@ srs_error_t SrsHttpHooks::on_hls(SrsContextId c, string url, SrsRequest* req, st
SrsAutoFree(SrsJsonObject, obj);

obj->set("server_id", SrsJsonAny::str(stat->server_id().c_str()));
obj->set("service_id", SrsJsonAny::str(stat->service_id().c_str()));
obj->set("action", SrsJsonAny::str("on_hls"));
obj->set("client_id", SrsJsonAny::str(cid.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
Expand Down Expand Up @@ -413,6 +421,7 @@ srs_error_t SrsHttpHooks::on_hls_notify(SrsContextId c, std::string url, SrsRequ
SrsStatistic* stat = SrsStatistic::instance();

url = srs_string_replace(url, "[server_id]", stat->server_id().c_str());
url = srs_string_replace(url, "[service_id]", stat->service_id().c_str());
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);
Expand Down Expand Up @@ -537,6 +546,7 @@ srs_error_t SrsHttpHooks::on_forward_backend(string url, SrsRequest* req, std::v

obj->set("action", SrsJsonAny::str("on_forward"));
obj->set("server_id", SrsJsonAny::str(stat->server_id().c_str()));
obj->set("service_id", SrsJsonAny::str(stat->service_id().c_str()));
obj->set("client_id", SrsJsonAny::str(cid.c_str()));
obj->set("ip", SrsJsonAny::str(req->ip.c_str()));
obj->set("vhost", SrsJsonAny::str(req->vhost.c_str()));
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/core/srs_core_version5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

#define VERSION_MAJOR 5
#define VERSION_MINOR 0
#define VERSION_REVISION 142
#define VERSION_REVISION 143

#endif

0 comments on commit 0a0fb23

Please sign in to comment.