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

Merge branch '2.0release' into develop

This commit is contained in:
winlin 2015-04-03 14:36:09 +08:00
commit 90cd16aae4
11 changed files with 75 additions and 22 deletions

View file

@ -3414,7 +3414,7 @@ bool SrsConfig::get_hls_cleanup(string vhost)
SrsConfDirective* conf = hls->get("hls_cleanup");
if (!conf && conf->arg0() != "off") {
if (conf && conf->arg0() != "off") {
return SRS_CONF_DEFAULT_HLS_CLEANUP;
}

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;
}
@ -581,7 +582,7 @@ int SrsHlsMuxer::segment_close(string log_desc)
}
// use async to call the http hooks, for it will cause thread switch.
if ((ret = async->call(new SrsDvrAsyncCallOnHls(req, current->full_path, current->sequence_no))) != ERROR_SUCCESS) {
if ((ret = async->call(new SrsDvrAsyncCallOnHls(req, current->full_path, current->sequence_no, current->duration))) != ERROR_SUCCESS) {
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);
};

View file

@ -347,10 +347,6 @@ int SrsMpegtsOverUdp::on_ts_video(SrsTsMessage* msg, SrsStream* avs)
// ts tbn to flv tbn.
u_int32_t dts = msg->dts / 90;
u_int32_t pts = msg->dts / 90;
// the whole ts pes video packet must be a flv frame packet.
char* ibpframe = avs->data() + avs->pos();
int ibpframe_size = avs->size() - avs->pos();
// send each frame.
while (!avs->empty()) {
@ -388,8 +384,6 @@ int SrsMpegtsOverUdp::on_ts_video(SrsTsMessage* msg, SrsStream* avs)
// for pps
if (avc->is_pps(frame, frame_size)) {
got_sps_pps = true;
std::string pps;
if ((ret = avc->pps_demux(frame, frame_size, pps)) != ERROR_SUCCESS) {
return ret;

View file

@ -1018,8 +1018,9 @@ int SrsServer::listen_stream_caster()
srs_error("invalid stream caster port %d. ret=%d", port, ret);
return ret;
}
if ((ret = listener->listen(port)) != ERROR_SUCCESS) {
// TODO: support listen at <[ip:]port>
if ((ret = listener->listen("0.0.0.0", port)) != ERROR_SUCCESS) {
srs_error("StreamCaster listen at port %d failed. ret=%d", port, ret);
return ret;
}

View file

@ -1356,7 +1356,7 @@ VOID TEST(ConfigMainTest, ParseMinConf)
MockSrsConfig conf;
EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF));
vector<string> listens = conf.get_listen();
vector<string> listens = conf.get_listens();
EXPECT_EQ(1, (int)listens.size());
EXPECT_STREQ("1935", listens.at(0).c_str());
}
@ -1379,7 +1379,7 @@ VOID TEST(ConfigMainTest, ParseFullConf)
MockSrsConfig conf;
EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_full_conf));
vector<string> listens = conf.get_listen();
vector<string> listens = conf.get_listens();
EXPECT_EQ(1, (int)listens.size());
EXPECT_STREQ("1935", listens.at(0).c_str());
@ -1403,10 +1403,10 @@ VOID TEST(ConfigMainTest, ParseFullConf)
EXPECT_EQ(4, (int)conf.get_stats_disk_device()->args.size());
EXPECT_TRUE(conf.get_http_api_enabled());
EXPECT_EQ(1985, conf.get_http_api_listen());
EXPECT_STREQ("1985", conf.get_http_api_listen().c_str());
EXPECT_TRUE(conf.get_http_stream_enabled());
EXPECT_EQ(8080, conf.get_http_stream_listen());
EXPECT_STREQ("8080", conf.get_http_stream_listen().c_str());
EXPECT_STREQ("./objs/nginx/html", conf.get_http_stream_dir().c_str());
EXPECT_EQ(10000, conf.get_pithy_print_ms());