mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-30 06:42:22 +08:00
Header refactor (#2115)
* 优化MultiMediaSourceMuxer头文件包含 * 将MediaSinkDelegate和Demux移到MediaSink中 * MediaSource头文件重构, 独立出PacketCache.h 精简Frame和Track的头文件 * Rtmp头文件重构 * Rtsp头文件重构 * webrtc头文件重构 * 规范.h头文件包含,并将其移到.cpp中: - 尽量不包含Common\config.h - Util\File.h - Rtsp/RtspPlayer.h - Rtmp/RtmpPlayer.h * 删除多余的Stamp.h和Base64包含
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
#include "HlsMediaSource.h"
|
||||
#include "Common/config.h"
|
||||
|
||||
using namespace toolkit;
|
||||
|
||||
@@ -64,4 +65,40 @@ HlsMediaSource::Ptr HlsCookieData::getMediaSource() const {
|
||||
return _src.lock();
|
||||
}
|
||||
|
||||
void HlsMediaSource::setIndexFile(std::string index_file)
|
||||
{
|
||||
if (!_ring) {
|
||||
std::weak_ptr<HlsMediaSource> weakSelf = std::dynamic_pointer_cast<HlsMediaSource>(shared_from_this());
|
||||
auto lam = [weakSelf](int size) {
|
||||
auto strongSelf = weakSelf.lock();
|
||||
if (!strongSelf) {
|
||||
return;
|
||||
}
|
||||
strongSelf->onReaderChanged(size);
|
||||
};
|
||||
_ring = std::make_shared<RingType>(0, std::move(lam));
|
||||
regist();
|
||||
}
|
||||
|
||||
//赋值m3u8索引文件内容
|
||||
std::lock_guard<std::mutex> lck(_mtx_index);
|
||||
_index_file = std::move(index_file);
|
||||
|
||||
if (!_index_file.empty()) {
|
||||
_list_cb.for_each([&](const std::function<void(const std::string& str)>& cb) { cb(_index_file); });
|
||||
_list_cb.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void HlsMediaSource::getIndexFile(std::function<void(const std::string& str)> cb)
|
||||
{
|
||||
std::lock_guard<std::mutex> lck(_mtx_index);
|
||||
if (!_index_file.empty()) {
|
||||
cb(_index_file);
|
||||
return;
|
||||
}
|
||||
//等待生成m3u8文件
|
||||
_list_cb.emplace_back(std::move(cb));
|
||||
}
|
||||
|
||||
} // namespace mediakit
|
||||
|
||||
Reference in New Issue
Block a user