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