1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-13 03:41:55 +00:00

Squash: Merge SRS4

This commit is contained in:
winlin 2021-08-13 14:29:32 +08:00
parent aad90c7f42
commit 24431d35ac
4 changed files with 37 additions and 10 deletions

View file

@ -21,6 +21,7 @@ The changelog for SRS.
## SRS 4.0 Changelog
* v4.0, 2021-08-13, RTC: Merge [#2526](https://github.com/ossrs/srs/pull/2526), fix codec issue for G.711 or H.263. 4.0.152
* v4.0, 2021-08-10, RTC: Merge [#2509](https://github.com/ossrs/srs/pull/2514), support http hooks n_play/stop/publish/unpublish. 4.0.151
* v4.0, 2021-08-07, Merge [#2514](https://github.com/ossrs/srs/pull/2514), Get original client ip instead of proxy ip, for rtc api #2514. 4.0.150
* v4.0, 2021-08-07, Fix [#2508](https://github.com/ossrs/srs/pull/2508), Support features query by API. 4.0.149

View file

@ -1090,7 +1090,7 @@ vhost hooks.callback.srs.com {
# "client_id": 1985,
# "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
# "tcUrl": "rtmp://video.test.com/live?key=d2fa801d08e3f90ed1e1670e6e52651a",
# "pageUrl": "http://www.test.com/live.html"
# "pageUrl": "http://www.test.com/live.html", "server_id": "vid-werty"
# }
# if valid, the hook must return HTTP code 200(Status OK) and response
# an int value specifies the error code(0 corresponding to success):
@ -1106,7 +1106,7 @@ vhost hooks.callback.srs.com {
# "action": "on_close",
# "client_id": 1985,
# "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
# "send_bytes": 10240, "recv_bytes": 10240
# "send_bytes": 10240, "recv_bytes": 10240, "server_id": "vid-werty"
# }
# if valid, the hook must return HTTP code 200(Status OK) and response
# an int value specifies the error code(0 corresponding to success):
@ -1122,7 +1122,7 @@ vhost hooks.callback.srs.com {
# "action": "on_publish",
# "client_id": 1985,
# "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
# "stream": "livestream", "param":"?token=xxx&salt=yyy"
# "stream": "livestream", "param":"?token=xxx&salt=yyy", "server_id": "vid-werty"
# }
# if valid, the hook must return HTTP code 200(Status OK) and response
# an int value specifies the error code(0 corresponding to success):
@ -1138,7 +1138,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", "param":"?token=xxx&salt=yyy"
# "stream": "livestream", "param":"?token=xxx&salt=yyy", "server_id": "vid-werty"
# }
# if valid, the hook must return HTTP code 200(Status OK) and response
# an int value specifies the error code(0 corresponding to success):
@ -1155,7 +1155,7 @@ vhost hooks.callback.srs.com {
# "client_id": 1985,
# "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
# "stream": "livestream", "param":"?token=xxx&salt=yyy",
# "pageUrl": "http://www.test.com/live.html"
# "pageUrl": "http://www.test.com/live.html", "server_id": "vid-werty"
# }
# if valid, the hook must return HTTP code 200(Status OK) and response
# an int value specifies the error code(0 corresponding to success):
@ -1171,7 +1171,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", "param":"?token=xxx&salt=yyy"
# "stream": "livestream", "param":"?token=xxx&salt=yyy", "server_id": "vid-werty"
# }
# if valid, the hook must return HTTP code 200(Status OK) and response
# an int value specifies the error code(0 corresponding to success):
@ -1189,7 +1189,7 @@ vhost hooks.callback.srs.com {
# "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
# "stream": "livestream", "param":"?token=xxx&salt=yyy",
# "cwd": "/usr/local/srs",
# "file": "./objs/nginx/html/live/livestream.1420254068776.flv"
# "file": "./objs/nginx/html/live/livestream.1420254068776.flv", "server_id": "vid-werty"
# }
# if valid, the hook must return HTTP code 200(Status OK) and response
# an int value specifies the error code(0 corresponding to success):
@ -1208,7 +1208,7 @@ vhost hooks.callback.srs.com {
# "url": "live/livestream/2015-04-23/01/476584165.ts",
# "m3u8": "./objs/nginx/html/live/livestream/live.m3u8",
# "m3u8_url": "live/livestream/live.m3u8",
# "seq_no": 100
# "seq_no": 100, "server_id": "vid-werty"
# }
# if valid, the hook must return HTTP code 200(Status OK) and response
# an int value specifies the error code(0 corresponding to success):
@ -1217,13 +1217,14 @@ vhost hooks.callback.srs.com {
# when srs reap a ts file of hls, call this hook,
# used to push file to cdn network, by get the ts file from cdn network.
# so we use HTTP GET and use the variable following:
# [server_id], replace with the server_id
# [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][param];
on_hls_notify http://127.0.0.1:8085/api/v1/hls/[server_id]/[app]/[stream]/[ts_url][param];
}
}

View file

@ -21,6 +21,7 @@ using namespace std;
#include <srs_app_http_conn.hpp>
#include <srs_protocol_amf0.hpp>
#include <srs_app_utility.hpp>
#include <srs_app_statistic.hpp>
#define SRS_HTTP_RESPONSE_OK SRS_XSTR(ERROR_SUCCESS)
@ -78,9 +79,12 @@ void SrsHttpHooks::on_close(string url, SrsRequest* req, int64_t send_bytes, int
SrsContextId cid = _srs_context->get_id();
SrsStatistic* stat = SrsStatistic::instance();
SrsJsonObject* obj = SrsJsonAny::object();
SrsAutoFree(SrsJsonObject, obj);
obj->set("server_id", SrsJsonAny::str(stat->server_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()));
@ -114,9 +118,12 @@ srs_error_t SrsHttpHooks::on_publish(string url, SrsRequest* req)
SrsContextId cid = _srs_context->get_id();
SrsStatistic* stat = SrsStatistic::instance();
SrsJsonObject* obj = SrsJsonAny::object();
SrsAutoFree(SrsJsonObject, obj);
obj->set("server_id", SrsJsonAny::str(stat->server_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()));
@ -148,9 +155,12 @@ void SrsHttpHooks::on_unpublish(string url, SrsRequest* req)
SrsContextId cid = _srs_context->get_id();
SrsStatistic* stat = SrsStatistic::instance();
SrsJsonObject* obj = SrsJsonAny::object();
SrsAutoFree(SrsJsonObject, obj);
obj->set("server_id", SrsJsonAny::str(stat->server_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()));
@ -184,9 +194,12 @@ srs_error_t SrsHttpHooks::on_play(string url, SrsRequest* req)
SrsContextId cid = _srs_context->get_id();
SrsStatistic* stat = SrsStatistic::instance();
SrsJsonObject* obj = SrsJsonAny::object();
SrsAutoFree(SrsJsonObject, obj);
obj->set("server_id", SrsJsonAny::str(stat->server_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()));
@ -218,9 +231,12 @@ void SrsHttpHooks::on_stop(string url, SrsRequest* req)
SrsContextId cid = _srs_context->get_id();
SrsStatistic* stat = SrsStatistic::instance();
SrsJsonObject* obj = SrsJsonAny::object();
SrsAutoFree(SrsJsonObject, obj);
obj->set("server_id", SrsJsonAny::str(stat->server_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()));
@ -255,9 +271,12 @@ srs_error_t SrsHttpHooks::on_dvr(SrsContextId c, string url, SrsRequest* req, st
SrsContextId cid = c;
std::string cwd = _srs_config->cwd();
SrsStatistic* stat = SrsStatistic::instance();
SrsJsonObject* obj = SrsJsonAny::object();
SrsAutoFree(SrsJsonObject, obj);
obj->set("server_id", SrsJsonAny::str(stat->server_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()));
@ -297,9 +316,12 @@ srs_error_t SrsHttpHooks::on_hls(SrsContextId c, string url, SrsRequest* req, st
ts_url = prefix + "/" + ts_url;
}
SrsStatistic* stat = SrsStatistic::instance();
SrsJsonObject* obj = SrsJsonAny::object();
SrsAutoFree(SrsJsonObject, obj);
obj->set("server_id", SrsJsonAny::str(stat->server_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()));
@ -341,6 +363,9 @@ srs_error_t SrsHttpHooks::on_hls_notify(SrsContextId c, std::string url, SrsRequ
url = ts_url;
}
SrsStatistic* stat = SrsStatistic::instance();
url = srs_string_replace(url, "[server_id]", stat->server_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);

View file

@ -9,6 +9,6 @@
#define VERSION_MAJOR 4
#define VERSION_MINOR 0
#define VERSION_REVISION 151
#define VERSION_REVISION 152
#endif