Commit c3302eec by xiongziliang

优化hls播放器计数

parent 97ad062d
...@@ -39,6 +39,7 @@ void HlsCookieData::addReaderCount(){ ...@@ -39,6 +39,7 @@ void HlsCookieData::addReaderCount(){
if(src){ if(src){
src->modifyReaderCount(true); src->modifyReaderCount(true);
_added = true; _added = true;
_src = src;
} }
} }
...@@ -46,7 +47,7 @@ void HlsCookieData::addReaderCount(){ ...@@ -46,7 +47,7 @@ void HlsCookieData::addReaderCount(){
HlsCookieData::~HlsCookieData() { HlsCookieData::~HlsCookieData() {
if(_added){ if(_added){
auto src = dynamic_pointer_cast<HlsMediaSource>(MediaSource::find(HLS_SCHEMA,_info._vhost,_info._app,_info._streamid)); auto src = _src.lock();
if(src){ if(src){
src->modifyReaderCount(false); src->modifyReaderCount(false);
} }
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "Common/MediaSource.h" #include "Common/MediaSource.h"
namespace mediakit{ namespace mediakit{
class HlsMediaSource;
class HlsCookieData{ class HlsCookieData{
public: public:
HlsCookieData(const MediaInfo &info); HlsCookieData(const MediaInfo &info);
...@@ -41,6 +42,7 @@ private: ...@@ -41,6 +42,7 @@ private:
uint64_t _bytes = 0; uint64_t _bytes = 0;
MediaInfo _info; MediaInfo _info;
bool _added = false; bool _added = false;
weak_ptr<HlsMediaSource> _src;
}; };
class HlsMediaSource : public MediaSource { class HlsMediaSource : public MediaSource {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论