mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
7b87985f74
@ -110,7 +110,7 @@ segRetain=5
|
|||||||
#是否广播 ts 切片完成通知
|
#是否广播 ts 切片完成通知
|
||||||
broadcastRecordTs=0
|
broadcastRecordTs=0
|
||||||
#直播hls文件删除延时,单位秒,issue: #913
|
#直播hls文件删除延时,单位秒,issue: #913
|
||||||
deleteDelaySec=0
|
deleteDelaySec=10
|
||||||
#是否保留hls文件,此功能部分等效于segNum=0的情况
|
#是否保留hls文件,此功能部分等效于segNum=0的情况
|
||||||
#不同的是这个保留不会在m3u8文件中体现
|
#不同的是这个保留不会在m3u8文件中体现
|
||||||
#0为不保留,不起作用
|
#0为不保留,不起作用
|
||||||
|
@ -280,7 +280,7 @@ static onceToken token([]() {
|
|||||||
mINI::Instance()[kFileBufSize] = 64 * 1024;
|
mINI::Instance()[kFileBufSize] = 64 * 1024;
|
||||||
mINI::Instance()[kFilePath] = "./www";
|
mINI::Instance()[kFilePath] = "./www";
|
||||||
mINI::Instance()[kBroadcastRecordTs] = false;
|
mINI::Instance()[kBroadcastRecordTs] = false;
|
||||||
mINI::Instance()[kDeleteDelaySec] = 0;
|
mINI::Instance()[kDeleteDelaySec] = 10;
|
||||||
});
|
});
|
||||||
} // namespace Hls
|
} // namespace Hls
|
||||||
|
|
||||||
|
@ -91,8 +91,8 @@ public:
|
|||||||
* 获取附加数据
|
* 获取附加数据
|
||||||
*/
|
*/
|
||||||
template <class T>
|
template <class T>
|
||||||
const T& getAttach() const {
|
T& getAttach() {
|
||||||
return *static_cast<const T *>(_attach.get());
|
return *static_cast<T *>(_attach.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -33,8 +33,9 @@ static int kHlsCookieSecond = 60;
|
|||||||
static const string kCookieName = "ZL_COOKIE";
|
static const string kCookieName = "ZL_COOKIE";
|
||||||
static const string kHlsSuffix = "/hls.m3u8";
|
static const string kHlsSuffix = "/hls.m3u8";
|
||||||
|
|
||||||
class HttpCookieAttachment {
|
struct HttpCookieAttachment {
|
||||||
public:
|
//是否已经查找到过MediaSource
|
||||||
|
bool _find_src = false;
|
||||||
//cookie生效作用域,本cookie只对该目录下的文件生效
|
//cookie生效作用域,本cookie只对该目录下的文件生效
|
||||||
string _path;
|
string _path;
|
||||||
//上次鉴权失败信息,为空则上次鉴权成功
|
//上次鉴权失败信息,为空则上次鉴权成功
|
||||||
@ -425,6 +426,11 @@ static void accessFile(TcpSession &sender, const Parser &parser, const MediaInfo
|
|||||||
response_file(cookie, cb, file_path, parser, src->getIndexFile());
|
response_file(cookie, cb, file_path, parser, src->getIndexFile());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (cookie->getAttach<HttpCookieAttachment>()._find_src) {
|
||||||
|
//查找过MediaSource,但是流已经注销了,不用再查找
|
||||||
|
response_file(cookie, cb, file_path, parser);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//hls流可能未注册,MediaSource::findAsync可以触发not_found事件,然后再按需推拉流
|
//hls流可能未注册,MediaSource::findAsync可以触发not_found事件,然后再按需推拉流
|
||||||
MediaSource::findAsync(media_info, strongSession, [response_file, cookie, cb, file_path, parser](const MediaSource::Ptr &src) {
|
MediaSource::findAsync(media_info, strongSession, [response_file, cookie, cb, file_path, parser](const MediaSource::Ptr &src) {
|
||||||
@ -439,6 +445,8 @@ static void accessFile(TcpSession &sender, const Parser &parser, const MediaInfo
|
|||||||
attach._hls_data->setMediaSource(hls);
|
attach._hls_data->setMediaSource(hls);
|
||||||
//添加HlsMediaSource的观看人数(HLS是按需生成的,这样可以触发HLS文件的生成)
|
//添加HlsMediaSource的观看人数(HLS是按需生成的,这样可以触发HLS文件的生成)
|
||||||
attach._hls_data->addByteUsage(0);
|
attach._hls_data->addByteUsage(0);
|
||||||
|
//标记找到MediaSource
|
||||||
|
attach._find_src = true;
|
||||||
|
|
||||||
// m3u8文件可能不存在, 等待m3u8索引文件按需生成
|
// m3u8文件可能不存在, 等待m3u8索引文件按需生成
|
||||||
hls->getIndexFile([response_file, file_path, cookie, cb, parser](const string &file) {
|
hls->getIndexFile([response_file, file_path, cookie, cb, parser](const string &file) {
|
||||||
|
Loading…
Reference in New Issue
Block a user