mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-29 22:55:52 +08:00
完成HLS按需生成流
This commit is contained in:
parent
4b4c4e0cec
commit
236dc46b82
@ -30,20 +30,31 @@ namespace mediakit{
|
||||
|
||||
HlsCookieData::HlsCookieData(const MediaInfo &info) {
|
||||
_info = info;
|
||||
auto src = dynamic_pointer_cast<HlsMediaSource>(MediaSource::find(HLS_SCHEMA,_info._vhost,_info._app,_info._streamid));
|
||||
if(src){
|
||||
src->modifyCount(true);
|
||||
addReaderCount();
|
||||
}
|
||||
|
||||
void HlsCookieData::addReaderCount(){
|
||||
if(!_added){
|
||||
auto src = dynamic_pointer_cast<HlsMediaSource>(MediaSource::find(HLS_SCHEMA,_info._vhost,_info._app,_info._streamid));
|
||||
if(src){
|
||||
src->modifyReaderCount(true);
|
||||
_added = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
HlsCookieData::~HlsCookieData() {
|
||||
auto src = dynamic_pointer_cast<HlsMediaSource>(MediaSource::find(HLS_SCHEMA,_info._vhost,_info._app,_info._streamid));
|
||||
if(src){
|
||||
src->modifyCount(false);
|
||||
if(_added){
|
||||
auto src = dynamic_pointer_cast<HlsMediaSource>(MediaSource::find(HLS_SCHEMA,_info._vhost,_info._app,_info._streamid));
|
||||
if(src){
|
||||
src->modifyReaderCount(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void HlsCookieData::addByteUsage(uint64_t bytes) {
|
||||
addReaderCount();
|
||||
_bytes += bytes;
|
||||
}
|
||||
|
||||
|
@ -35,9 +35,12 @@ public:
|
||||
HlsCookieData(const MediaInfo &info);
|
||||
~HlsCookieData();
|
||||
void addByteUsage(uint64_t bytes);
|
||||
private:
|
||||
void addReaderCount();
|
||||
private:
|
||||
uint64_t _bytes = 0;
|
||||
MediaInfo _info;
|
||||
bool _added = false;
|
||||
};
|
||||
|
||||
class HlsMediaSource : public MediaSource {
|
||||
@ -73,7 +76,7 @@ private:
|
||||
* 修改观看者个数
|
||||
* @param add 添加海思删除
|
||||
*/
|
||||
void modifyCount(bool add) {
|
||||
void modifyReaderCount(bool add) {
|
||||
if (add) {
|
||||
++_readerCount;
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user