Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
ZLMediaKit
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
张翔宇
ZLMediaKit
Commits
6c0fea4c
Commit
6c0fea4c
authored
Apr 07, 2022
by
xiongziliang
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://gitee.com/xia-chu/ZLMediaKit
parents
8da23da3
75b17b3a
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
34 行增加
和
17 行删除
+34
-17
src/Http/HlsPlayer.cpp
+16
-1
src/Http/HlsPlayer.h
+2
-0
src/Http/HttpChunkedSplitter.cpp
+12
-10
src/Http/HttpChunkedSplitter.h
+3
-5
src/Record/HlsMaker.cpp
+1
-1
没有找到文件。
src/Http/HlsPlayer.cpp
查看文件 @
6c0fea4c
...
@@ -42,7 +42,22 @@ void HlsPlayer::teardown_l(const SockException &ex) {
...
@@ -42,7 +42,22 @@ void HlsPlayer::teardown_l(const SockException &ex) {
_play_result
=
true
;
_play_result
=
true
;
onPlayResult
(
ex
);
onPlayResult
(
ex
);
}
else
{
}
else
{
onShutdown
(
ex
);
//如果不是主动关闭的,则重新拉取索引文件
if
(
ex
.
getErrCode
()
!=
Err_shutdown
)
{
// 当切片列表已空, 且没有正在下载的切片并且重试次数已经达到最大次数时, 则认为失败关闭播放器
if
(
_ts_list
.
empty
()
&&
!
(
_http_ts_player
&&
_http_ts_player
->
waitResponse
())
&&
_try_fetch_index_times
>=
MAX_TRY_FETCH_INDEX_TIMES
)
{
onShutdown
(
ex
);
}
else
{
_try_fetch_index_times
+=
1
;
shutdown
(
ex
);
WarnL
<<
"重新尝试拉取索引文件["
<<
_try_fetch_index_times
<<
"]:"
<<
_play_url
;
fetchIndexFile
();
return
;
}
}
else
{
onShutdown
(
ex
);
}
}
}
_timer
.
reset
();
_timer
.
reset
();
_timer_ts
.
reset
();
_timer_ts
.
reset
();
...
...
src/Http/HlsPlayer.h
查看文件 @
6c0fea4c
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#define MIN_TIMEOUT_MULTIPLE 2
#define MIN_TIMEOUT_MULTIPLE 2
#define MAX_TIMEOUT_MULTIPLE 5
#define MAX_TIMEOUT_MULTIPLE 5
#define MAX_TRY_FETCH_INDEX_TIMES 5
namespace
mediakit
{
namespace
mediakit
{
...
@@ -105,6 +106,7 @@ private:
...
@@ -105,6 +106,7 @@ private:
std
::
set
<
std
::
string
,
UrlComp
>
_ts_url_cache
;
std
::
set
<
std
::
string
,
UrlComp
>
_ts_url_cache
;
HttpTSPlayer
::
Ptr
_http_ts_player
;
HttpTSPlayer
::
Ptr
_http_ts_player
;
int
_timeout_multiple
=
MIN_TIMEOUT_MULTIPLE
;
int
_timeout_multiple
=
MIN_TIMEOUT_MULTIPLE
;
int
_try_fetch_index_times
=
0
;
};
};
class
HlsPlayerImp
:
public
PlayerImp
<
HlsPlayer
,
PlayerBase
>
,
private
TrackListener
{
class
HlsPlayerImp
:
public
PlayerImp
<
HlsPlayer
,
PlayerBase
>
,
private
TrackListener
{
...
...
src/Http/HttpChunkedSplitter.cpp
查看文件 @
6c0fea4c
...
@@ -9,29 +9,32 @@
...
@@ -9,29 +9,32 @@
*/
*/
#include <string.h>
#include <string.h>
#include "Common/macros.h"
#include "HttpChunkedSplitter.h"
#include "HttpChunkedSplitter.h"
using
namespace
std
;
using
namespace
std
;
//[chunk size][\r\n][chunk data][\r\n][chunk size][\r\n][chunk data][\r\n][chunk size = 0][\r\n][\r\n]
namespace
mediakit
{
namespace
mediakit
{
const
char
*
HttpChunkedSplitter
::
onSearchPacketTail
(
const
char
*
data
,
size_t
len
)
{
const
char
*
HttpChunkedSplitter
::
onSearchPacketTail
(
const
char
*
data
,
size_t
len
)
{
auto
pos
=
strstr
(
data
,
"
\r\n
"
);
auto
pos
=
strstr
(
data
,
"
\r\n
"
);
if
(
!
pos
)
{
if
(
!
pos
)
{
return
nullptr
;
return
nullptr
;
}
}
return
pos
+
2
;
return
pos
+
2
;
}
}
void
HttpChunkedSplitter
::
onRecvContent
(
const
char
*
data
,
size_t
len
)
{
void
HttpChunkedSplitter
::
onRecvContent
(
const
char
*
data
,
size_t
len
)
{
onRecvChunk
(
data
,
len
-
2
);
onRecvChunk
(
data
,
len
-
2
);
}
}
ssize_t
HttpChunkedSplitter
::
onRecvHeader
(
const
char
*
data
,
size_t
len
)
{
ssize_t
HttpChunkedSplitter
::
onRecvHeader
(
const
char
*
data
,
size_t
len
)
{
string
str
(
data
,
len
-
2
)
;
int
size
;
int
ret
;
CHECK
(
sscanf
(
data
,
"%X"
,
&
size
)
==
1
&&
size
>=
0
)
;
sscanf
(
str
.
data
(),
"%X"
,
&
ret
);
//包括后面\r\n两个字节
return
ret
+
2
;
return
size
+
2
;
}
}
}
//
namespace
mediakit
}
//namespace mediakit
\ No newline at end of file
src/Http/HttpChunkedSplitter.h
查看文件 @
6c0fea4c
...
@@ -21,12 +21,10 @@ public:
...
@@ -21,12 +21,10 @@ public:
/**
/**
* len == 0时代表结束
* len == 0时代表结束
*/
*/
typedef
std
::
function
<
void
(
const
char
*
data
,
size_t
len
)
>
onChunkData
;
using
onChunkData
=
std
::
function
<
void
(
const
char
*
data
,
size_t
len
)
>
;
HttpChunkedSplitter
(
const
onChunkData
&
cb
){
HttpChunkedSplitter
(
const
onChunkData
&
cb
)
{
_onChunkData
=
cb
;
};
_onChunkData
=
cb
;
~
HttpChunkedSplitter
()
override
{
_onChunkData
=
nullptr
;
};
};
~
HttpChunkedSplitter
()
override
{}
;
protected
:
protected
:
ssize_t
onRecvHeader
(
const
char
*
data
,
size_t
len
)
override
;
ssize_t
onRecvHeader
(
const
char
*
data
,
size_t
len
)
override
;
...
...
src/Record/HlsMaker.cpp
查看文件 @
6c0fea4c
...
@@ -137,7 +137,7 @@ void HlsMaker::flushLastSegment(bool eof){
...
@@ -137,7 +137,7 @@ void HlsMaker::flushLastSegment(bool eof){
if
(
seg_dur
<=
0
)
{
if
(
seg_dur
<=
0
)
{
seg_dur
=
100
;
seg_dur
=
100
;
}
}
_seg_dur_list
.
push_back
(
std
::
make_tuple
(
seg_dur
,
std
::
move
(
_last_file_name
)
));
_seg_dur_list
.
emplace_back
(
seg_dur
,
std
::
move
(
_last_file_name
));
delOldSegment
();
delOldSegment
();
//先flush ts切片,否则可能存在ts文件未写入完毕就被访问的情况
//先flush ts切片,否则可能存在ts文件未写入完毕就被访问的情况
onFlushLastSegment
(
seg_dur
);
onFlushLastSegment
(
seg_dur
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论