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

Refine HTTP-FLV latency, support realtime mode. 2.0.252

This commit is contained in:
winlin 2018-08-05 20:23:17 +08:00
parent ee43fc92ae
commit c45f72ef7b
3 changed files with 15 additions and 5 deletions

View file

@ -58,6 +58,8 @@ using namespace std;
#endif
#include <srs_app_config.hpp>
#ifdef SRS_AUTO_HTTP_SERVER
SrsStreamCache::SrsStreamCache(SrsSource* s, SrsRequest* r)
@ -484,7 +486,12 @@ int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
if (srs_string_ends_with(entry->pattern, ".flv")) {
w->header()->set_content_type("video/x-flv");
#ifdef SRS_PERF_FAST_FLV_ENCODER
enc = new SrsFastFlvStreamEncoder();
bool realtime = _srs_config->get_realtime_enabled(req->vhost);
if (realtime) {
enc = new SrsFlvStreamEncoder();
} else {
enc = new SrsFastFlvStreamEncoder();
}
#else
enc = new SrsFlvStreamEncoder();
#endif
@ -542,6 +549,8 @@ int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
SrsHttpMessage* hr = dynamic_cast<SrsHttpMessage*>(r);
SrsResponseOnlyHttpConn* hc = dynamic_cast<SrsResponseOnlyHttpConn*>(hr->connection());
int mw_sleep = _srs_config->get_mw_sleep_ms(req->vhost);
SrsHttpRecvThread* trd = new SrsHttpRecvThread(hc);
SrsAutoFree(SrsHttpRecvThread, trd);
@ -570,15 +579,15 @@ int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
if (count <= 0) {
srs_info("http: sleep %dms for no msg", SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
// directly use sleep, donot use consumer wait.
st_usleep(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
st_usleep(mw_sleep);
// ignore when nothing got.
continue;
}
if (pprint->can_print()) {
srs_info("-> "SRS_CONSTS_LOG_HTTP_STREAM" http: got %d msgs, age=%d, min=%d, mw=%d",
count, pprint->age(), SRS_PERF_MW_MIN_MSGS, SRS_CONSTS_RTMP_PULSE_TIMEOUT_US / 1000);
srs_trace("-> "SRS_CONSTS_LOG_HTTP_STREAM" http: got %d msgs, age=%d, min=%d, mw=%d",
count, pprint->age(), SRS_PERF_MW_MIN_MSGS, mw_sleep);
}
// sendout all messages.