正在显示
6 个修改的文件
包含
16 行增加
和
8 行删除
| @@ -754,6 +754,7 @@ vhost hooks.callback.srs.com { | @@ -754,6 +754,7 @@ vhost hooks.callback.srs.com { | ||
| 754 | # "client_id": 1985, | 754 | # "client_id": 1985, |
| 755 | # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", | 755 | # "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", |
| 756 | # "stream": "livestream", | 756 | # "stream": "livestream", |
| 757 | + # "duration": 9.36, // in seconds | ||
| 757 | # "cwd": "/usr/local/srs", | 758 | # "cwd": "/usr/local/srs", |
| 758 | # "file": "./objs/nginx/html/live/livestream.1420254068776-100.ts", | 759 | # "file": "./objs/nginx/html/live/livestream.1420254068776-100.ts", |
| 759 | # "seq_no": 100 | 760 | # "seq_no": 100 |
| @@ -328,8 +328,11 @@ class RESTHls(object): | @@ -328,8 +328,11 @@ class RESTHls(object): | ||
| 328 | { | 328 | { |
| 329 | "action": "on_dvr", | 329 | "action": "on_dvr", |
| 330 | "client_id": 1985, | 330 | "client_id": 1985, |
| 331 | - "ip": "192.168.1.10", "vhost": "video.test.com", "app": "live", | 331 | + "ip": "192.168.1.10", |
| 332 | + "vhost": "video.test.com", | ||
| 333 | + "app": "live", | ||
| 332 | "stream": "livestream", | 334 | "stream": "livestream", |
| 335 | + "duration": 9.68, // in seconds | ||
| 333 | "cwd": "/usr/local/srs", | 336 | "cwd": "/usr/local/srs", |
| 334 | "file": "./objs/nginx/html/live/livestream.1420254068776-100.ts", | 337 | "file": "./objs/nginx/html/live/livestream.1420254068776-100.ts", |
| 335 | "seq_no": 100 | 338 | "seq_no": 100 |
| @@ -368,8 +371,8 @@ class RESTHls(object): | @@ -368,8 +371,8 @@ class RESTHls(object): | ||
| 368 | def __on_hls(self, req): | 371 | def __on_hls(self, req): |
| 369 | code = Error.success | 372 | code = Error.success |
| 370 | 373 | ||
| 371 | - trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s, cwd=%s, file=%s, seq_no=%s"%( | ||
| 372 | - req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"], | 374 | + trace("srs %s: client id=%s, ip=%s, vhost=%s, app=%s, stream=%s, duration=%s, cwd=%s, file=%s, seq_no=%s"%( |
| 375 | + req["action"], req["client_id"], req["ip"], req["vhost"], req["app"], req["stream"], req["duration"], | ||
| 373 | req["cwd"], req["file"], req["seq_no"] | 376 | req["cwd"], req["file"], req["seq_no"] |
| 374 | )) | 377 | )) |
| 375 | 378 |
| @@ -170,11 +170,12 @@ void SrsHlsSegment::update_duration(int64_t current_frame_dts) | @@ -170,11 +170,12 @@ void SrsHlsSegment::update_duration(int64_t current_frame_dts) | ||
| 170 | return; | 170 | return; |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | -SrsDvrAsyncCallOnHls::SrsDvrAsyncCallOnHls(SrsRequest* r, string p, int s) | 173 | +SrsDvrAsyncCallOnHls::SrsDvrAsyncCallOnHls(SrsRequest* r, string p, int s, double d) |
| 174 | { | 174 | { |
| 175 | req = r; | 175 | req = r; |
| 176 | path = p; | 176 | path = p; |
| 177 | seq_no = s; | 177 | seq_no = s; |
| 178 | + duration = d; | ||
| 178 | } | 179 | } |
| 179 | 180 | ||
| 180 | SrsDvrAsyncCallOnHls::~SrsDvrAsyncCallOnHls() | 181 | SrsDvrAsyncCallOnHls::~SrsDvrAsyncCallOnHls() |
| @@ -199,7 +200,7 @@ int SrsDvrAsyncCallOnHls::call() | @@ -199,7 +200,7 @@ int SrsDvrAsyncCallOnHls::call() | ||
| 199 | int sn = seq_no; | 200 | int sn = seq_no; |
| 200 | for (int i = 0; i < (int)on_hls->args.size(); i++) { | 201 | for (int i = 0; i < (int)on_hls->args.size(); i++) { |
| 201 | std::string url = on_hls->args.at(i); | 202 | std::string url = on_hls->args.at(i); |
| 202 | - if ((ret = SrsHttpHooks::on_hls(url, req, file, sn)) != ERROR_SUCCESS) { | 203 | + if ((ret = SrsHttpHooks::on_hls(url, req, file, sn, duration)) != ERROR_SUCCESS) { |
| 203 | srs_error("hook client on_hls failed. url=%s, ret=%d", url.c_str(), ret); | 204 | srs_error("hook client on_hls failed. url=%s, ret=%d", url.c_str(), ret); |
| 204 | return ret; | 205 | return ret; |
| 205 | } | 206 | } |
| @@ -164,8 +164,9 @@ private: | @@ -164,8 +164,9 @@ private: | ||
| 164 | std::string path; | 164 | std::string path; |
| 165 | int seq_no; | 165 | int seq_no; |
| 166 | SrsRequest* req; | 166 | SrsRequest* req; |
| 167 | + double duration; | ||
| 167 | public: | 168 | public: |
| 168 | - SrsDvrAsyncCallOnHls(SrsRequest* r, std::string p, int s); | 169 | + SrsDvrAsyncCallOnHls(SrsRequest* r, std::string p, int s, double d); |
| 169 | virtual ~SrsDvrAsyncCallOnHls(); | 170 | virtual ~SrsDvrAsyncCallOnHls(); |
| 170 | public: | 171 | public: |
| 171 | virtual int call(); | 172 | virtual int call(); |
| @@ -287,7 +287,7 @@ int SrsHttpHooks::on_dvr(string url, SrsRequest* req, string file) | @@ -287,7 +287,7 @@ int SrsHttpHooks::on_dvr(string url, SrsRequest* req, string file) | ||
| 287 | return ret; | 287 | return ret; |
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | -int SrsHttpHooks::on_hls(string url, SrsRequest* req, string file, int sn) | 290 | +int SrsHttpHooks::on_hls(string url, SrsRequest* req, string file, int sn, double duration) |
| 291 | { | 291 | { |
| 292 | int ret = ERROR_SUCCESS; | 292 | int ret = ERROR_SUCCESS; |
| 293 | 293 | ||
| @@ -302,6 +302,7 @@ int SrsHttpHooks::on_hls(string url, SrsRequest* req, string file, int sn) | @@ -302,6 +302,7 @@ int SrsHttpHooks::on_hls(string url, SrsRequest* req, string file, int sn) | ||
| 302 | << SRS_JFIELD_STR("vhost", req->vhost) << SRS_JFIELD_CONT | 302 | << SRS_JFIELD_STR("vhost", req->vhost) << SRS_JFIELD_CONT |
| 303 | << SRS_JFIELD_STR("app", req->app) << SRS_JFIELD_CONT | 303 | << SRS_JFIELD_STR("app", req->app) << SRS_JFIELD_CONT |
| 304 | << SRS_JFIELD_STR("stream", req->stream) << SRS_JFIELD_CONT | 304 | << SRS_JFIELD_STR("stream", req->stream) << SRS_JFIELD_CONT |
| 305 | + << SRS_JFIELD_ORG("duration", duration) << SRS_JFIELD_CONT | ||
| 305 | << SRS_JFIELD_STR("cwd", cwd) << SRS_JFIELD_CONT | 306 | << SRS_JFIELD_STR("cwd", cwd) << SRS_JFIELD_CONT |
| 306 | << SRS_JFIELD_STR("file", file) << SRS_JFIELD_CONT | 307 | << SRS_JFIELD_STR("file", file) << SRS_JFIELD_CONT |
| 307 | << SRS_JFIELD_ORG("seq_no", sn) | 308 | << SRS_JFIELD_ORG("seq_no", sn) |
| @@ -102,8 +102,9 @@ public: | @@ -102,8 +102,9 @@ public: | ||
| 102 | * ignore if empty. | 102 | * ignore if empty. |
| 103 | * @param file the ts file path, can be relative or absolute path. | 103 | * @param file the ts file path, can be relative or absolute path. |
| 104 | * @param sn the seq_no, the sequence number of ts in hls/m3u8. | 104 | * @param sn the seq_no, the sequence number of ts in hls/m3u8. |
| 105 | + * @param duration the segment duration in seconds. | ||
| 105 | */ | 106 | */ |
| 106 | - static int on_hls(std::string url, SrsRequest* req, std::string file, int sn); | 107 | + static int on_hls(std::string url, SrsRequest* req, std::string file, int sn, double duration); |
| 107 | private: | 108 | private: |
| 108 | static int do_post(std::string url, std::string req, int& code, std::string& res); | 109 | static int do_post(std::string url, std::string req, int& code, std::string& res); |
| 109 | }; | 110 | }; |
-
请 注册 或 登录 后发表评论