Skip to content

Commit

Permalink
rename secret
Browse files Browse the repository at this point in the history
  • Loading branch information
Haibo Chen committed Sep 15, 2021
1 parent 1789f54 commit a00554a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions trunk/src/app/srs_app_http_static.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, SrsM3u8CtxInfo>::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));
}
}

Expand Down Expand Up @@ -334,15 +334,15 @@ srs_error_t SrsVodStream::on_timer(srs_utime_t interval)

std::map<std::string, SrsM3u8CtxInfo>::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()) {
http_hooks_on_stop(req);
srs_freep(req);

SrsStatistic* stat = SrsStatistic::instance();
stat->on_disconnect(secret);
stat->on_disconnect(ctx);
map_ctx_info_.erase(it);

break;
Expand Down
6 changes: 3 additions & 3 deletions trunk/src/app/srs_app_http_static.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string, SrsM3u8CtxInfo> map_ctx_info_;
public:
SrsVodStream(std::string root_dir);
Expand All @@ -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
Expand Down

0 comments on commit a00554a

Please sign in to comment.