From 31d2de3f23871de583ba1bfc5dbec9d857872673 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 21 Jul 2015 10:50:57 +0800 Subject: [PATCH 1/2] fix #435, add pageUrl for HTTP callback on_play. --- README.md | 1 + trunk/conf/full.conf | 8 +++++--- trunk/research/api-server/server.py | 14 ++++++++------ trunk/src/app/srs_app_http_hooks.cpp | 3 ++- trunk/src/app/srs_app_reload.hpp | 1 + trunk/src/app/srs_app_server.cpp | 4 ++++ 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 5c17108ad..570f13142 100755 --- a/README.md +++ b/README.md @@ -344,6 +344,7 @@ Remark: ### SRS 2.0 history +* v2.0, 2015-07-21, fix [#435](https://github.com/simple-rtmp-server/srs/issues/435) add pageUrl for HTTP callback on_play. * v2.0, 2015-07-20, refine the hls, ignore packet when no sequence header. 2.0.179 * v2.0, 2015-07-16, for [#441](https://github.com/simple-rtmp-server/srs/issues/441) use 30s timeout for first msg. 2.0.178 * v2.0, 2015-07-14, refine hls disable the time jitter, support not mix monotonically increase. 2.0.177 diff --git a/trunk/conf/full.conf b/trunk/conf/full.conf index a12061bbc..a295cd8bf 100644 --- a/trunk/conf/full.conf +++ b/trunk/conf/full.conf @@ -434,7 +434,7 @@ vhost ingest.srs.com { # vhost for http static and flv vod stream for each vhost. vhost http.static.srs.com { # http static vhost specified config - http { + http_static { # whether enabled the http static service for vhost. # default: off enabled on; @@ -707,7 +707,8 @@ vhost hooks.callback.srs.com { # { # "action": "on_close", # "client_id": 1985, - # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live" + # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", + # "send_bytes": 10240, "recv_bytes": 10240 # } # if valid, the hook must return HTTP code 200(Stauts OK) and response # an int value specifies the error code(0 corresponding to success): @@ -749,7 +750,8 @@ 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", + # "pageUrl": "http://www.test.com/live.html" # } # if valid, the hook must return HTTP code 200(Stauts OK) and response # an int value specifies the error code(0 corresponding to success): diff --git a/trunk/research/api-server/server.py b/trunk/research/api-server/server.py index fac4b50e8..3ec083458 100755 --- a/trunk/research/api-server/server.py +++ b/trunk/research/api-server/server.py @@ -96,7 +96,8 @@ class RESTClients(object): { "action": "on_close", "client_id": 1985, - "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live" + "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", + "send_bytes": 10240, "recv_bytes": 10240 } if valid, the hook must return HTTP code 200(Stauts OK) and response an int value specifies the error code(0 corresponding to success): @@ -145,8 +146,8 @@ class RESTClients(object): def __on_close(self, req): code = Error.success - trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s"%( - req["action"], req["client_id"], req["ip"], req["vhost"], req["app"] + trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, send_bytes=%s, recv_bytes=%s"%( + req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["send_bytes"], req["recv_bytes"] )) # TODO: process the on_close event @@ -450,7 +451,8 @@ class RESTSessions(object): "action": "on_play", "client_id": 1985, "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", - "stream": "livestream" + "stream": "livestream", + "pageUrl": "http://www.test.com/live.html" } on_stop: when client(encoder) stop publish to vhost/app/stream, call the hook, @@ -497,8 +499,8 @@ class RESTSessions(object): def __on_play(self, req): code = Error.success - trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s"%( - req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"] + trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s, pageUrl=%s"%( + req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"], req["pageUrl"] )) # TODO: process the on_play event diff --git a/trunk/src/app/srs_app_http_hooks.cpp b/trunk/src/app/srs_app_http_hooks.cpp index 3c1eda3ea..426b3313f 100644 --- a/trunk/src/app/srs_app_http_hooks.cpp +++ b/trunk/src/app/srs_app_http_hooks.cpp @@ -203,7 +203,8 @@ int SrsHttpHooks::on_play(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("pageUrl", req->pageUrl) << SRS_JOBJECT_END; std::string data = ss.str(); diff --git a/trunk/src/app/srs_app_reload.hpp b/trunk/src/app/srs_app_reload.hpp index 4d77e882c..f05370cff 100644 --- a/trunk/src/app/srs_app_reload.hpp +++ b/trunk/src/app/srs_app_reload.hpp @@ -57,6 +57,7 @@ public: virtual int on_reload_http_stream_disabled(); virtual int on_reload_http_stream_updated(); public: + // TODO: FIXME: should rename to http_static virtual int on_reload_vhost_http_updated(); virtual int on_reload_vhost_http_remux_updated(std::string vhost); virtual int on_reload_vhost_added(std::string vhost); diff --git a/trunk/src/app/srs_app_server.cpp b/trunk/src/app/srs_app_server.cpp index 3591c8289..147dfbd17 100644 --- a/trunk/src/app/srs_app_server.cpp +++ b/trunk/src/app/srs_app_server.cpp @@ -1270,6 +1270,7 @@ int SrsServer::on_reload_vhost_added(std::string vhost) return ret; } + // TODO: FIXME: should handle the event in SrsHttpStaticServer if ((ret = on_reload_vhost_http_updated()) != ERROR_SUCCESS) { return ret; } @@ -1283,6 +1284,7 @@ int SrsServer::on_reload_vhost_removed(std::string /*vhost*/) int ret = ERROR_SUCCESS; #ifdef SRS_AUTO_HTTP_SERVER + // TODO: FIXME: should handle the event in SrsHttpStaticServer if ((ret = on_reload_vhost_http_updated()) != ERROR_SUCCESS) { return ret; } @@ -1335,6 +1337,7 @@ int SrsServer::on_reload_http_stream_disabled() return ret; } +// TODO: FIXME: rename to http_remux int SrsServer::on_reload_http_stream_updated() { int ret = ERROR_SUCCESS; @@ -1344,6 +1347,7 @@ int SrsServer::on_reload_http_stream_updated() return ret; } + // TODO: FIXME: should handle the event in SrsHttpStaticServer if ((ret = on_reload_vhost_http_updated()) != ERROR_SUCCESS) { return ret; } From 89183c52c9aa9ed9df66af60637a1320873e27b7 Mon Sep 17 00:00:00 2001 From: winlin Date: Tue, 21 Jul 2015 11:41:02 +0800 Subject: [PATCH 2/2] update hls and transcode wiki --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 570f13142..4a9ef6d77 100755 --- a/README.md +++ b/README.md @@ -119,9 +119,9 @@ cd srs/trunk * Usage: How to delivery RTMP Cluster?([CN][v1_CN_SampleRTMPCluster], [EN][v1_EN_SampleRTMPCluster]) * Usage: How to delivery HTTP FLV Live Streaming?([CN][v2_CN_SampleHttpFlv], [EN][v2_EN_SampleHttpFlv]) * Usage: How to delivery HTTP FLV Live Streaming Cluster?([CN][v2_CN_SampleHttpFlvCluster], [EN][v2_EN_SampleHttpFlvCluster]) -* Usage: How to delivery HLS?([CN][v1_CN_SampleHLS], [EN][v1_EN_SampleHLS]) -* Usage: How to delivery HLS for other codec?([CN][v1_CN_SampleTranscode2HLS], [EN][v1_EN_SampleTranscode2HLS]) -* Usage: How to transode RTMP stream by SRS?([CN][v1_CN_SampleFFMPEG], [EN][v1_EN_SampleFFMPEG]) +* Usage: How to delivery HLS?([CN][v2_CN_SampleHLS], [EN][v2_EN_SampleHLS]) +* Usage: How to delivery HLS for other codec?([CN][v2_CN_SampleTranscode2HLS], [EN][v2_EN_SampleTranscode2HLS]) +* Usage: How to transode RTMP stream by SRS?([CN][v2_CN_SampleFFMPEG], [EN][v2_EN_SampleFFMPEG]) * Usage: How to forward stream to other server?([CN][v1_CN_SampleForward], [EN][v1_EN_SampleForward]) * Usage: How to deploy low lantency application?([CN][v2_CN_SampleRealtime], [EN][v2_EN_SampleRealtime]) * Usage: How to deploy SRS on ARM?([CN][v1_CN_SampleARM], [EN][v1_EN_SampleARM]) @@ -904,12 +904,12 @@ Winlin [v1_EN_SampleRTMP]: https://github.com/simple-rtmp-server/srs/wiki/v1_EN_SampleRTMP [v1_CN_SampleRTMPCluster]: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_SampleRTMPCluster [v1_EN_SampleRTMPCluster]: https://github.com/simple-rtmp-server/srs/wiki/v1_EN_SampleRTMPCluster -[v1_CN_SampleHLS]: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_SampleHLS -[v1_EN_SampleHLS]: https://github.com/simple-rtmp-server/srs/wiki/v1_EN_SampleHLS -[v1_CN_SampleTranscode2HLS]: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_SampleTranscode2HLS -[v1_EN_SampleTranscode2HLS]: https://github.com/simple-rtmp-server/srs/wiki/v1_EN_SampleTranscode2HLS -[v1_CN_SampleFFMPEG]: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_SampleFFMPEG -[v1_EN_SampleFFMPEG]: https://github.com/simple-rtmp-server/srs/wiki/v1_EN_SampleFFMPEG +[v2_CN_SampleHLS]: https://github.com/simple-rtmp-server/srs/wiki/v2_CN_SampleHLS +[v2_EN_SampleHLS]: https://github.com/simple-rtmp-server/srs/wiki/v2_EN_SampleHLS +[v2_CN_SampleTranscode2HLS]: https://github.com/simple-rtmp-server/srs/wiki/v2_CN_SampleTranscode2HLS +[v2_EN_SampleTranscode2HLS]: https://github.com/simple-rtmp-server/srs/wiki/v2_EN_SampleTranscode2HLS +[v2_CN_SampleFFMPEG]: https://github.com/simple-rtmp-server/srs/wiki/v2_CN_SampleFFMPEG +[v2_EN_SampleFFMPEG]: https://github.com/simple-rtmp-server/srs/wiki/v2_EN_SampleFFMPEG [v1_CN_SampleForward]: https://github.com/simple-rtmp-server/srs/wiki/v1_CN_SampleForward [v1_EN_SampleForward]: https://github.com/simple-rtmp-server/srs/wiki/v1_EN_SampleForward [v2_CN_SampleRealtime]: https://github.com/simple-rtmp-server/srs/wiki/v2_CN_SampleRealtime