修复hls播放器流量统计不准确的bug

This commit is contained in:
xiongziliang 2020-09-12 20:52:53 +08:00
parent 1e1b3794da
commit d26b751273
2 changed files with 6 additions and 3 deletions

View File

@ -48,8 +48,9 @@ HlsCookieData::~HlsCookieData() {
<< ")断开,耗时(s):" << duration; << ")断开,耗时(s):" << duration;
GET_CONFIG(uint32_t, iFlowThreshold, General::kFlowThreshold); GET_CONFIG(uint32_t, iFlowThreshold, General::kFlowThreshold);
if (_bytes > iFlowThreshold * 1024) { uint64_t bytes = _bytes.load();
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastFlowReport, _info, _bytes, duration, true, static_cast<SockInfo&>(*_sock_info)); if (bytes > iFlowThreshold * 1024) {
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastFlowReport, _info, bytes, duration, true, static_cast<SockInfo&>(*_sock_info));
} }
} }
} }

View File

@ -103,10 +103,12 @@ public:
HlsCookieData(const MediaInfo &info, const std::shared_ptr<SockInfo> &sock_info); HlsCookieData(const MediaInfo &info, const std::shared_ptr<SockInfo> &sock_info);
~HlsCookieData(); ~HlsCookieData();
void addByteUsage(uint64_t bytes); void addByteUsage(uint64_t bytes);
private: private:
void addReaderCount(); void addReaderCount();
private: private:
uint64_t _bytes = 0; atomic<uint64_t> _bytes {0};
MediaInfo _info; MediaInfo _info;
std::shared_ptr<bool> _added; std::shared_ptr<bool> _added;
weak_ptr<HlsMediaSource> _src; weak_ptr<HlsMediaSource> _src;