From a00554a7693a9f5ede6ae3a7d578108deb8e4149 Mon Sep 17 00:00:00 2001 From: Haibo Chen Date: Wed, 15 Sep 2021 15:16:48 +0800 Subject: [PATCH] rename secret --- trunk/src/app/srs_app_http_static.cpp | 18 +++++++++--------- trunk/src/app/srs_app_http_static.hpp | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/trunk/src/app/srs_app_http_static.cpp b/trunk/src/app/srs_app_http_static.cpp index 6c57a19be6..dd8b4e9696 100644 --- a/trunk/src/app/srs_app_http_static.cpp +++ b/trunk/src/app/srs_app_http_static.cpp @@ -236,32 +236,32 @@ srs_error_t SrsVodStream::serve_m3u8_ctx(ISrsHttpResponseWriter * w, ISrsHttpMes return srs_error_wrap(err, "final request"); } + alive(ctx, req->copy()); + // update the statistic when source disconveried. SrsStatistic* stat = SrsStatistic::instance(); if ((err = stat->on_client(ctx, req, NULL, SrsRtmpConnPlay)) != srs_success) { return srs_error_wrap(err, "stat on client"); } - alive(ctx, req->copy()); - return err; } -bool SrsVodStream::ctx_is_exist(std::string secret) +bool SrsVodStream::ctx_is_exist(std::string ctx) { - return (map_ctx_info_.find(secret) != map_ctx_info_.end()); + return (map_ctx_info_.find(ctx) != map_ctx_info_.end()); } -void SrsVodStream::alive(std::string secret, SrsRequest* req) +void SrsVodStream::alive(std::string ctx, SrsRequest* req) { std::map::iterator it; - if ((it = map_ctx_info_.find(secret)) != map_ctx_info_.end()) { + 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(secret, info)); + map_ctx_info_.insert(make_pair(ctx, info)); } } @@ -334,7 +334,7 @@ srs_error_t SrsVodStream::on_timer(srs_utime_t interval) std::map::iterator it; for (it = map_ctx_info_.begin(); it != map_ctx_info_.end(); ++it) { - string secret = it->first; + string ctx = it->first; SrsRequest* req = it->second.req; srs_utime_t hls_window = _srs_config->get_hls_window(req->vhost); if (it->second.request_time + (2 * hls_window) < srs_get_system_time()) { @@ -342,7 +342,7 @@ srs_error_t SrsVodStream::on_timer(srs_utime_t interval) srs_freep(req); SrsStatistic* stat = SrsStatistic::instance(); - stat->on_disconnect(secret); + stat->on_disconnect(ctx); map_ctx_info_.erase(it); break; diff --git a/trunk/src/app/srs_app_http_static.hpp b/trunk/src/app/srs_app_http_static.hpp index 8e0603d8d2..8af98cdaa5 100644 --- a/trunk/src/app/srs_app_http_static.hpp +++ b/trunk/src/app/srs_app_http_static.hpp @@ -24,7 +24,7 @@ struct SrsM3u8CtxInfo class SrsVodStream : public SrsHttpFileServer, public ISrsFastTimer { private: - // The period of validity of the secret + // The period of validity of the ctx std::map map_ctx_info_; public: SrsVodStream(std::string root_dir); @@ -34,8 +34,8 @@ class SrsVodStream : public SrsHttpFileServer, public ISrsFastTimer virtual srs_error_t serve_mp4_stream(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string fullpath, int start, int end); virtual srs_error_t serve_m3u8_ctx(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string fullpath); private: - virtual bool ctx_is_exist(std::string secret); - virtual void alive(std::string secret, SrsRequest* req); + virtual bool ctx_is_exist(std::string ctx); + virtual void alive(std::string ctx, SrsRequest* req); virtual srs_error_t http_hooks_on_play(SrsRequest* req); virtual void http_hooks_on_stop(SrsRequest* req); // interface ISrsFastTimer