Skip to content

Commit c45f72e

Browse files
committed
Refine HTTP-FLV latency, support realtime mode. 2.0.252
1 parent ee43fc9 commit c45f72e

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ Remark:
333333

334334
## History
335335

336+
* v2.0, 2018-08-05, Refine HTTP-FLV latency, support realtime mode. 2.0.252
336337
* v2.0, 2018-08-04, For [#1110][bug #1110], Support params in http callback. 2.0.251
337338
* v2.0, 2018-08-02, For [#1031][bug #1031], SRS edge support douyu.com. 2.0.250
338339
* v2.0, 2018-07-21, Merge [#1119][bug #1119], fix memory leak. 2.0.249

trunk/src/app/srs_app_http_stream.cpp

+13-4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ using namespace std;
5858

5959
#endif
6060

61+
#include <srs_app_config.hpp>
62+
6163
#ifdef SRS_AUTO_HTTP_SERVER
6264

6365
SrsStreamCache::SrsStreamCache(SrsSource* s, SrsRequest* r)
@@ -484,7 +486,12 @@ int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
484486
if (srs_string_ends_with(entry->pattern, ".flv")) {
485487
w->header()->set_content_type("video/x-flv");
486488
#ifdef SRS_PERF_FAST_FLV_ENCODER
487-
enc = new SrsFastFlvStreamEncoder();
489+
bool realtime = _srs_config->get_realtime_enabled(req->vhost);
490+
if (realtime) {
491+
enc = new SrsFlvStreamEncoder();
492+
} else {
493+
enc = new SrsFastFlvStreamEncoder();
494+
}
488495
#else
489496
enc = new SrsFlvStreamEncoder();
490497
#endif
@@ -542,6 +549,8 @@ int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
542549
SrsHttpMessage* hr = dynamic_cast<SrsHttpMessage*>(r);
543550
SrsResponseOnlyHttpConn* hc = dynamic_cast<SrsResponseOnlyHttpConn*>(hr->connection());
544551

552+
int mw_sleep = _srs_config->get_mw_sleep_ms(req->vhost);
553+
545554
SrsHttpRecvThread* trd = new SrsHttpRecvThread(hc);
546555
SrsAutoFree(SrsHttpRecvThread, trd);
547556

@@ -570,15 +579,15 @@ int SrsLiveStream::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
570579
if (count <= 0) {
571580
srs_info("http: sleep %dms for no msg", SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
572581
// directly use sleep, donot use consumer wait.
573-
st_usleep(SRS_CONSTS_RTMP_PULSE_TIMEOUT_US);
582+
st_usleep(mw_sleep);
574583

575584
// ignore when nothing got.
576585
continue;
577586
}
578587

579588
if (pprint->can_print()) {
580-
srs_info("-> "SRS_CONSTS_LOG_HTTP_STREAM" http: got %d msgs, age=%d, min=%d, mw=%d",
581-
count, pprint->age(), SRS_PERF_MW_MIN_MSGS, SRS_CONSTS_RTMP_PULSE_TIMEOUT_US / 1000);
589+
srs_trace("-> "SRS_CONSTS_LOG_HTTP_STREAM" http: got %d msgs, age=%d, min=%d, mw=%d",
590+
count, pprint->age(), SRS_PERF_MW_MIN_MSGS, mw_sleep);
582591
}
583592

584593
// sendout all messages.

trunk/src/core/srs_core.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3131
// current release version
3232
#define VERSION_MAJOR 2
3333
#define VERSION_MINOR 0
34-
#define VERSION_REVISION 251
34+
#define VERSION_REVISION 252
3535

3636
// generated by configure, only macros.
3737
#include <srs_auto_headers.hpp>

0 commit comments

Comments
 (0)