1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

for hls callback, add duration of ts.

This commit is contained in:
winlin 2015-04-03 13:46:44 +08:00
parent c4466a8c0c
commit 64b065e450
6 changed files with 16 additions and 8 deletions

View file

@ -170,11 +170,12 @@ void SrsHlsSegment::update_duration(int64_t current_frame_dts)
return;
}
SrsDvrAsyncCallOnHls::SrsDvrAsyncCallOnHls(SrsRequest* r, string p, int s)
SrsDvrAsyncCallOnHls::SrsDvrAsyncCallOnHls(SrsRequest* r, string p, int s, double d)
{
req = r;
path = p;
seq_no = s;
duration = d;
}
SrsDvrAsyncCallOnHls::~SrsDvrAsyncCallOnHls()
@ -199,7 +200,7 @@ int SrsDvrAsyncCallOnHls::call()
int sn = seq_no;
for (int i = 0; i < (int)on_hls->args.size(); i++) {
std::string url = on_hls->args.at(i);
if ((ret = SrsHttpHooks::on_hls(url, req, file, sn)) != ERROR_SUCCESS) {
if ((ret = SrsHttpHooks::on_hls(url, req, file, sn, duration)) != ERROR_SUCCESS) {
srs_error("hook client on_hls failed. url=%s, ret=%d", url.c_str(), ret);
return ret;
}

View file

@ -164,8 +164,9 @@ private:
std::string path;
int seq_no;
SrsRequest* req;
double duration;
public:
SrsDvrAsyncCallOnHls(SrsRequest* r, std::string p, int s);
SrsDvrAsyncCallOnHls(SrsRequest* r, std::string p, int s, double d);
virtual ~SrsDvrAsyncCallOnHls();
public:
virtual int call();

View file

@ -287,7 +287,7 @@ int SrsHttpHooks::on_dvr(string url, SrsRequest* req, string file)
return ret;
}
int SrsHttpHooks::on_hls(string url, SrsRequest* req, string file, int sn)
int SrsHttpHooks::on_hls(string url, SrsRequest* req, string file, int sn, double duration)
{
int ret = ERROR_SUCCESS;
@ -302,6 +302,7 @@ int SrsHttpHooks::on_hls(string url, SrsRequest* req, string file, int sn)
<< 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_CONT
<< SRS_JFIELD_ORG("duration", duration) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("cwd", cwd) << SRS_JFIELD_CONT
<< SRS_JFIELD_STR("file", file) << SRS_JFIELD_CONT
<< SRS_JFIELD_ORG("seq_no", sn)

View file

@ -102,8 +102,9 @@ public:
* ignore if empty.
* @param file the ts file path, can be relative or absolute path.
* @param sn the seq_no, the sequence number of ts in hls/m3u8.
* @param duration the segment duration in seconds.
*/
static int on_hls(std::string url, SrsRequest* req, std::string file, int sn);
static int on_hls(std::string url, SrsRequest* req, std::string file, int sn, double duration);
private:
static int do_post(std::string url, std::string req, int& code, std::string& res);
};