From 34cd7b25861df0d57bf0311307300a646f15bf15 Mon Sep 17 00:00:00 2001 From: winlin Date: Thu, 23 Sep 2021 22:35:52 +0800 Subject: [PATCH] Squash: Merge SRS 4.0 --- trunk/src/app/srs_app_http_static.cpp | 85 ++++++++++++++------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/trunk/src/app/srs_app_http_static.cpp b/trunk/src/app/srs_app_http_static.cpp index dd8b4e969..bae3b7872 100644 --- a/trunk/src/app/srs_app_http_static.cpp +++ b/trunk/src/app/srs_app_http_static.cpp @@ -36,6 +36,7 @@ using namespace std; #include #include #include +#include #define SRS_CONTEXT_IN_HLS "hls_ctx" @@ -53,7 +54,7 @@ SrsVodStream::~SrsVodStream() } map_ctx_info_.clear(); } - + srs_error_t SrsVodStream::serve_flv_stream(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, string fullpath, int offset) { srs_error_t err = srs_success; @@ -183,10 +184,10 @@ srs_error_t SrsVodStream::serve_mp4_stream(ISrsHttpResponseWriter* w, ISrsHttpMe } return err; -} - -srs_error_t SrsVodStream::serve_m3u8_ctx(ISrsHttpResponseWriter * w, ISrsHttpMessage * r, std::string fullpath) -{ +} + +srs_error_t SrsVodStream::serve_m3u8_ctx(ISrsHttpResponseWriter * w, ISrsHttpMessage * r, std::string fullpath) +{ srs_error_t err = srs_success; SrsHttpMessage* hr = dynamic_cast(r); @@ -195,7 +196,7 @@ srs_error_t SrsVodStream::serve_m3u8_ctx(ISrsHttpResponseWriter * w, ISrsHttpMes SrsRequest* req = hr->to_request(hr->host())->as_http(); SrsAutoFree(SrsRequest, req); - string ctx = hr->query_get(SRS_CONTEXT_IN_HLS); + string ctx = hr->query_get(SRS_CONTEXT_IN_HLS); if (!ctx.empty() && ctx_is_exist(ctx)) { alive(ctx, NULL); return SrsHttpFileServer::serve_m3u8_ctx(w, r, fullpath); @@ -244,29 +245,29 @@ srs_error_t SrsVodStream::serve_m3u8_ctx(ISrsHttpResponseWriter * w, ISrsHttpMes return srs_error_wrap(err, "stat on client"); } - return err; -} - -bool SrsVodStream::ctx_is_exist(std::string ctx) -{ - return (map_ctx_info_.find(ctx) != map_ctx_info_.end()); -} - -void SrsVodStream::alive(std::string ctx, SrsRequest* req) -{ - std::map::iterator it; + return err; +} + +bool SrsVodStream::ctx_is_exist(std::string ctx) +{ + return (map_ctx_info_.find(ctx) != map_ctx_info_.end()); +} + +void SrsVodStream::alive(std::string ctx, SrsRequest* req) +{ + std::map::iterator it; if ((it = map_ctx_info_.find(ctx)) != map_ctx_info_.end()) { it->second.request_time = srs_get_system_time(); - } else { - SrsM3u8CtxInfo info; - info.req = req; - info.request_time = srs_get_system_time(); - map_ctx_info_.insert(make_pair(ctx, info)); - } + } else { + SrsM3u8CtxInfo info; + info.req = req; + info.request_time = srs_get_system_time(); + map_ctx_info_.insert(make_pair(ctx, info)); + } } - -srs_error_t SrsVodStream::http_hooks_on_play(SrsRequest* req) -{ + +srs_error_t SrsVodStream::http_hooks_on_play(SrsRequest* req) +{ srs_error_t err = srs_success; if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) { @@ -295,11 +296,11 @@ srs_error_t SrsVodStream::http_hooks_on_play(SrsRequest* req) } } - return err; -} - -void SrsVodStream::http_hooks_on_stop(SrsRequest* req) -{ + return err; +} + +void SrsVodStream::http_hooks_on_stop(SrsRequest* req) +{ if (!_srs_config->get_vhost_http_hooks_enabled(req->vhost)) { return; } @@ -325,14 +326,14 @@ void SrsVodStream::http_hooks_on_stop(SrsRequest* req) SrsHttpHooks::on_stop(url, req); } - return; -} - -srs_error_t SrsVodStream::on_timer(srs_utime_t interval) -{ - srs_error_t err = srs_success; - - std::map::iterator it; + return; +} + +srs_error_t SrsVodStream::on_timer(srs_utime_t interval) +{ + srs_error_t err = srs_success; + + std::map::iterator it; for (it = map_ctx_info_.begin(); it != map_ctx_info_.end(); ++it) { string ctx = it->first; SrsRequest* req = it->second.req; @@ -347,9 +348,9 @@ srs_error_t SrsVodStream::on_timer(srs_utime_t interval) break; } - } - - return err; + } + + return err; } SrsHttpStaticServer::SrsHttpStaticServer(SrsServer* svr)