mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-03 17:27:33 +08:00
实现hls的流量汇报事件
This commit is contained in:
@@ -42,21 +42,27 @@ void HlsCookieData::addReaderCount(){
|
||||
_src = src;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HlsCookieData::~HlsCookieData() {
|
||||
if(_added){
|
||||
if (_added) {
|
||||
auto src = _src.lock();
|
||||
if(src){
|
||||
if (src) {
|
||||
src->modifyReaderCount(false);
|
||||
}
|
||||
auto duration = (_ticker.createdTime() - _ticker.elapsedTime()) / 1000;
|
||||
WarnL << "HLS播放器(" << _info._vhost << "/" << _info._app << "/" << _info._streamid << ")断开,播放时间:" << duration;
|
||||
GET_CONFIG(uint32_t, iFlowThreshold, General::kFlowThreshold);
|
||||
if (_bytes > iFlowThreshold * 1024) {
|
||||
NoticeCenter::Instance().emitEvent(Broadcast::kBroadcastFlowReport, _info, _bytes, duration, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HlsCookieData::addByteUsage(uint64_t bytes) {
|
||||
addReaderCount();
|
||||
_bytes += bytes;
|
||||
_ticker.resetTime();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#define ZLMEDIAKIT_HLSMEDIASOURCE_H
|
||||
|
||||
#include <atomic>
|
||||
#include "Util/TimeTicker.h"
|
||||
#include "Common/MediaSource.h"
|
||||
namespace mediakit{
|
||||
|
||||
@@ -43,6 +44,7 @@ private:
|
||||
MediaInfo _info;
|
||||
bool _added = false;
|
||||
weak_ptr<HlsMediaSource> _src;
|
||||
Ticker _ticker;
|
||||
};
|
||||
|
||||
class HlsMediaSource : public MediaSource {
|
||||
|
||||
Reference in New Issue
Block a user