正在显示
5 个修改的文件
包含
28 行增加
和
9 行删除
@@ -780,7 +780,10 @@ vhost hooks.callback.srs.com { | @@ -780,7 +780,10 @@ vhost hooks.callback.srs.com { | ||
780 | # "stream": "livestream", | 780 | # "stream": "livestream", |
781 | # "duration": 9.36, // in seconds | 781 | # "duration": 9.36, // in seconds |
782 | # "cwd": "/usr/local/srs", | 782 | # "cwd": "/usr/local/srs", |
783 | - # "file": "./objs/nginx/html/live/livestream.1420254068776-100.ts", | 783 | + # "file": "./objs/nginx/html/live/livestream/2015-04-23/01/476584165.ts", |
784 | + # "url": "live/livestream/2015-04-23/01/476584165.ts", | ||
785 | + # "m3u8": "./objs/nginx/html/live/livestream/live.m3u8", | ||
786 | + # "m3u8_url": "live/livestream/live.m3u8", | ||
784 | # "seq_no": 100 | 787 | # "seq_no": 100 |
785 | # } | 788 | # } |
786 | # if valid, the hook must return HTTP code 200(Stauts OK) and response | 789 | # if valid, the hook must return HTTP code 200(Stauts OK) and response |
@@ -170,10 +170,13 @@ void SrsHlsSegment::update_duration(int64_t current_frame_dts) | @@ -170,10 +170,13 @@ 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, double d) | 173 | +SrsDvrAsyncCallOnHls::SrsDvrAsyncCallOnHls(SrsRequest* r, string p, string t, string m, string mu, int s, double d) |
174 | { | 174 | { |
175 | req = r; | 175 | req = r; |
176 | path = p; | 176 | path = p; |
177 | + ts_url = t; | ||
178 | + m3u8 = m; | ||
179 | + m3u8_url = mu; | ||
177 | seq_no = s; | 180 | seq_no = s; |
178 | duration = d; | 181 | duration = d; |
179 | } | 182 | } |
@@ -200,7 +203,7 @@ int SrsDvrAsyncCallOnHls::call() | @@ -200,7 +203,7 @@ int SrsDvrAsyncCallOnHls::call() | ||
200 | int sn = seq_no; | 203 | int sn = seq_no; |
201 | for (int i = 0; i < (int)on_hls->args.size(); i++) { | 204 | for (int i = 0; i < (int)on_hls->args.size(); i++) { |
202 | std::string url = on_hls->args.at(i); | 205 | std::string url = on_hls->args.at(i); |
203 | - if ((ret = SrsHttpHooks::on_hls(url, req, file, sn, duration)) != ERROR_SUCCESS) { | 206 | + if ((ret = SrsHttpHooks::on_hls(url, req, file, ts_url, m3u8, m3u8_url, sn, duration)) != ERROR_SUCCESS) { |
204 | srs_error("hook client on_hls failed. url=%s, ret=%d", url.c_str(), ret); | 207 | srs_error("hook client on_hls failed. url=%s, ret=%d", url.c_str(), ret); |
205 | return ret; | 208 | return ret; |
206 | } | 209 | } |
@@ -361,8 +364,8 @@ int SrsHlsMuxer::update_config(SrsRequest* r, string entry_prefix, | @@ -361,8 +364,8 @@ int SrsHlsMuxer::update_config(SrsRequest* r, string entry_prefix, | ||
361 | deviation_ts = 0; | 364 | deviation_ts = 0; |
362 | 365 | ||
363 | // generate the m3u8 dir and path. | 366 | // generate the m3u8 dir and path. |
364 | - m3u8 = path + "/" + m3u8_file; | ||
365 | - m3u8 = srs_path_build_stream(m3u8, req->vhost, req->app, req->stream); | 367 | + m3u8_url = srs_path_build_stream(m3u8_file, req->vhost, req->app, req->stream); |
368 | + m3u8 = path + "/" + m3u8_url; | ||
366 | 369 | ||
367 | // we always keep the target duration increasing. | 370 | // we always keep the target duration increasing. |
368 | int max_td = srs_max(target_duration, (int)(fragment * _srs_config->get_hls_td_ratio(r->vhost))); | 371 | int max_td = srs_max(target_duration, (int)(fragment * _srs_config->get_hls_td_ratio(r->vhost))); |
@@ -664,7 +667,10 @@ int SrsHlsMuxer::segment_close(string log_desc) | @@ -664,7 +667,10 @@ int SrsHlsMuxer::segment_close(string log_desc) | ||
664 | segments.push_back(current); | 667 | segments.push_back(current); |
665 | 668 | ||
666 | // use async to call the http hooks, for it will cause thread switch. | 669 | // use async to call the http hooks, for it will cause thread switch. |
667 | - if ((ret = async->call(new SrsDvrAsyncCallOnHls(req, current->full_path, current->sequence_no, current->duration))) != ERROR_SUCCESS) { | 670 | + if ((ret = async->call(new SrsDvrAsyncCallOnHls(req, |
671 | + current->full_path, current->uri, m3u8, m3u8_url, | ||
672 | + current->sequence_no, current->duration))) != ERROR_SUCCESS) | ||
673 | + { | ||
668 | return ret; | 674 | return ret; |
669 | } | 675 | } |
670 | 676 |
@@ -163,11 +163,14 @@ class SrsDvrAsyncCallOnHls : public ISrsDvrAsyncCall | @@ -163,11 +163,14 @@ class SrsDvrAsyncCallOnHls : public ISrsDvrAsyncCall | ||
163 | { | 163 | { |
164 | private: | 164 | private: |
165 | std::string path; | 165 | std::string path; |
166 | + std::string ts_url; | ||
167 | + std::string m3u8; | ||
168 | + std::string m3u8_url; | ||
166 | int seq_no; | 169 | int seq_no; |
167 | SrsRequest* req; | 170 | SrsRequest* req; |
168 | double duration; | 171 | double duration; |
169 | public: | 172 | public: |
170 | - SrsDvrAsyncCallOnHls(SrsRequest* r, std::string p, int s, double d); | 173 | + SrsDvrAsyncCallOnHls(SrsRequest* r, std::string p, std::string t, std::string m, std::string mu, int s, double d); |
171 | virtual ~SrsDvrAsyncCallOnHls(); | 174 | virtual ~SrsDvrAsyncCallOnHls(); |
172 | public: | 175 | public: |
173 | virtual int call(); | 176 | virtual int call(); |
@@ -227,6 +230,7 @@ private: | @@ -227,6 +230,7 @@ private: | ||
227 | int _sequence_no; | 230 | int _sequence_no; |
228 | int target_duration; | 231 | int target_duration; |
229 | std::string m3u8; | 232 | std::string m3u8; |
233 | + std::string m3u8_url; | ||
230 | private: | 234 | private: |
231 | ISrsHlsHandler* handler; | 235 | ISrsHlsHandler* handler; |
232 | // TODO: FIXME: supports reload. | 236 | // TODO: FIXME: supports reload. |
@@ -292,7 +292,7 @@ int SrsHttpHooks::on_dvr(string url, SrsRequest* req, string file) | @@ -292,7 +292,7 @@ int SrsHttpHooks::on_dvr(string url, SrsRequest* req, string file) | ||
292 | return ret; | 292 | return ret; |
293 | } | 293 | } |
294 | 294 | ||
295 | -int SrsHttpHooks::on_hls(string url, SrsRequest* req, string file, int sn, double duration) | 295 | +int SrsHttpHooks::on_hls(string url, SrsRequest* req, string file, string ts_url, string m3u8, string m3u8_url, int sn, double duration) |
296 | { | 296 | { |
297 | int ret = ERROR_SUCCESS; | 297 | int ret = ERROR_SUCCESS; |
298 | 298 | ||
@@ -310,6 +310,9 @@ int SrsHttpHooks::on_hls(string url, SrsRequest* req, string file, int sn, doubl | @@ -310,6 +310,9 @@ int SrsHttpHooks::on_hls(string url, SrsRequest* req, string file, int sn, doubl | ||
310 | << SRS_JFIELD_ORG("duration", duration) << SRS_JFIELD_CONT | 310 | << SRS_JFIELD_ORG("duration", duration) << SRS_JFIELD_CONT |
311 | << SRS_JFIELD_STR("cwd", cwd) << SRS_JFIELD_CONT | 311 | << SRS_JFIELD_STR("cwd", cwd) << SRS_JFIELD_CONT |
312 | << SRS_JFIELD_STR("file", file) << SRS_JFIELD_CONT | 312 | << SRS_JFIELD_STR("file", file) << SRS_JFIELD_CONT |
313 | + << SRS_JFIELD_STR("url", ts_url) << SRS_JFIELD_CONT | ||
314 | + << SRS_JFIELD_STR("m3u8", m3u8) << SRS_JFIELD_CONT | ||
315 | + << SRS_JFIELD_STR("m3u8_url", m3u8_url) << SRS_JFIELD_CONT | ||
313 | << SRS_JFIELD_ORG("seq_no", sn) | 316 | << SRS_JFIELD_ORG("seq_no", sn) |
314 | << SRS_JOBJECT_END; | 317 | << SRS_JOBJECT_END; |
315 | 318 |
@@ -101,10 +101,13 @@ public: | @@ -101,10 +101,13 @@ public: | ||
101 | * @param url the api server url, to process the event. | 101 | * @param url the api server url, to process the event. |
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 ts_url the ts url, which used for m3u8. | ||
105 | + * @param m3u8 the m3u8 file path, can be relative or absolute path. | ||
106 | + * @param m3u8_url the m3u8 url, which is used for the http mount path. | ||
104 | * @param sn the seq_no, the sequence number of ts in hls/m3u8. | 107 | * @param sn the seq_no, the sequence number of ts in hls/m3u8. |
105 | * @param duration the segment duration in seconds. | 108 | * @param duration the segment duration in seconds. |
106 | */ | 109 | */ |
107 | - static int on_hls(std::string url, SrsRequest* req, std::string file, int sn, double duration); | 110 | + static int on_hls(std::string url, SrsRequest* req, std::string file, std::string ts_url, std::string m3u8, std::string m3u8_url, int sn, double duration); |
108 | /** | 111 | /** |
109 | * when hls reap segment, callback. | 112 | * when hls reap segment, callback. |
110 | * @param url the api server url, to process the event. | 113 | * @param url the api server url, to process the event. |
-
请 注册 或 登录 后发表评论