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
ccbd1d4a
Commit
ccbd1d4a
authored
5 years ago
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加hls.segRetain配置项,修复hls切片等于segNum+1的问题
parent
35c4c05e
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
51 行增加
和
96 行删除
+51
-96
conf/config.ini
+3
-1
src/Common/config.cpp
+40
-90
src/Common/config.h
+3
-1
src/MediaFile/HlsMaker.cpp
+5
-4
没有找到文件。
conf/config.ini
查看文件 @
ccbd1d4a
...
...
@@ -44,10 +44,12 @@ fileBufSize=65536
#可以为相对(相对于本可执行程序目录)或绝对路径
filePath
=
./httpRoot
#hls最大切片时间
segDur
=
3
segDur
=
2
#m3u8索引中,hls保留切片个数(实际保留切片个数大2~3个)
#如果设置为0,则不删除切片,而是保存为点播
segNum
=
3
#HLS切片从m3u8文件中移除后,继续保留在磁盘上的个数
segRetain
=
5
[hook]
#在推流时,如果url参数匹对admin_params,那么可以不经过hook鉴权直接推流成功,播放时亦然
...
...
This diff is collapsed.
Click to expand it.
src/Common/config.cpp
查看文件 @
ccbd1d4a
...
...
@@ -95,57 +95,44 @@ onceToken token([](){
////////////HTTP配置///////////
namespace
Http
{
#define HTTP_FIELD "http."
//http 文件发送缓存大小
#define HTTP_SEND_BUF_SIZE (64 * 1024)
const
string
kSendBufSize
=
HTTP_FIELD
"sendBufSize"
;
//http 最大请求字节数
#define HTTP_MAX_REQ_SIZE (4*1024)
const
string
kMaxReqSize
=
HTTP_FIELD
"maxReqSize"
;
//http keep-alive秒数
#define HTTP_KEEP_ALIVE_SECOND 10
const
string
kKeepAliveSecond
=
HTTP_FIELD
"keepAliveSecond"
;
//http keep-alive最大请求数
#define HTTP_MAX_REQ_CNT 100
const
string
kMaxReqCount
=
HTTP_FIELD
"maxReqCount"
;
//http 字符编码
#if defined(_WIN32)
#define HTTP_CHAR_SET "gb2312"
#else
#define HTTP_CHAR_SET "utf-8"
#endif
const
string
kCharSet
=
HTTP_FIELD
"charSet"
;
//http 服务器根目录
#define HTTP_ROOT_PATH "./httpRoot"
const
string
kRootPath
=
HTTP_FIELD
"rootPath"
;
//http 404错误提示内容
#define HTTP_NOT_FOUND "<html>"\
"<head><title>404 Not Found</title></head>"\
"<body bgcolor=\"white\">"\
"<center><h1>您访问的资源不存在!</h1></center>"\
"<hr><center>"\
SERVER_NAME\
"</center>"\
"</body>"\
"</html>"
const
string
kNotFound
=
HTTP_FIELD
"notFound"
;
onceToken
token
([](){
mINI
::
Instance
()[
kSendBufSize
]
=
HTTP_SEND_BUF_SIZE
;
mINI
::
Instance
()[
kMaxReqSize
]
=
HTTP_MAX_REQ_SIZE
;
mINI
::
Instance
()[
kKeepAliveSecond
]
=
HTTP_KEEP_ALIVE_SECOND
;
mINI
::
Instance
()[
kMaxReqCount
]
=
HTTP_MAX_REQ_CNT
;
mINI
::
Instance
()[
kCharSet
]
=
HTTP_CHAR_SET
;
mINI
::
Instance
()[
kRootPath
]
=
HTTP_ROOT_PATH
;
mINI
::
Instance
()[
kNotFound
]
=
HTTP_NOT_FOUND
;
mINI
::
Instance
()[
kSendBufSize
]
=
64
*
1024
;
mINI
::
Instance
()[
kMaxReqSize
]
=
4
*
1024
;
mINI
::
Instance
()[
kKeepAliveSecond
]
=
15
;
mINI
::
Instance
()[
kMaxReqCount
]
=
100
;
#if defined(_WIN32)
mINI
::
Instance
()[
kCharSet
]
=
"gb2312"
;
#else
mINI
::
Instance
()[
kCharSet
]
=
"utf-8"
;
#endif
mINI
::
Instance
()[
kRootPath
]
=
"./httpRoot"
;
mINI
::
Instance
()[
kNotFound
]
=
"<html>"
"<head><title>404 Not Found</title></head>"
"<body bgcolor=
\"
white
\"
>"
"<center><h1>您访问的资源不存在!</h1></center>"
"<hr><center>"
SERVER_NAME
"</center>"
"</body>"
"</html>"
;
},
nullptr
);
}
//namespace Http
...
...
@@ -153,12 +140,10 @@ onceToken token([](){
////////////SHELL配置///////////
namespace
Shell
{
#define SHELL_FIELD "shell."
#define SHELL_MAX_REQ_SIZE 1024
const
string
kMaxReqSize
=
SHELL_FIELD
"maxReqSize"
;
onceToken
token
([](){
mINI
::
Instance
()[
kMaxReqSize
]
=
SHELL_MAX_REQ_SIZE
;
mINI
::
Instance
()[
kMaxReqSize
]
=
1024
;
},
nullptr
);
}
//namespace Shell
...
...
@@ -179,7 +164,6 @@ onceToken token([](){
mINI
::
Instance
()[
kDirectProxy
]
=
1
;
mINI
::
Instance
()[
kModifyStamp
]
=
false
;
},
nullptr
);
}
//namespace Rtsp
////////////RTMP服务器配置///////////
...
...
@@ -194,40 +178,28 @@ onceToken token([](){
mINI
::
Instance
()[
kHandshakeSecond
]
=
15
;
mINI
::
Instance
()[
kKeepAliveSecond
]
=
15
;
},
nullptr
);
}
//namespace RTMP
////////////RTP配置///////////
namespace
Rtp
{
#define RTP_FIELD "rtp."
//RTP打包最大MTU,公网情况下更小
#define RTP_VIDOE_MTU_SIZE 1400
const
string
kVideoMtuSize
=
RTP_FIELD
"videoMtuSize"
;
#define RTP_Audio_MTU_SIZE 600
const
string
kAudioMtuSize
=
RTP_FIELD
"audioMtuSize"
;
//RTP排序缓存最大个数
#define RTP_MAX_RTP_COUNT 50
const
string
kMaxRtpCount
=
RTP_FIELD
"maxRtpCount"
;
//如果RTP序列正确次数累计达到该数字就启动清空排序缓存
#define RTP_CLEAR_COUNT 10
const
string
kClearCount
=
RTP_FIELD
"clearCount"
;
//最大RTP时间为13个小时,每13小时回环一次
#define RTP_CYCLE_MS (13*60*60*1000)
const
string
kCycleMS
=
RTP_FIELD
"cycleMS"
;
onceToken
token
([](){
mINI
::
Instance
()[
kVideoMtuSize
]
=
RTP_VIDOE_MTU_SIZE
;
mINI
::
Instance
()[
kAudioMtuSize
]
=
RTP_Audio_MTU_SIZE
;
mINI
::
Instance
()[
kMaxRtpCount
]
=
RTP_MAX_RTP_COUNT
;
mINI
::
Instance
()[
kClearCount
]
=
RTP_CLEAR_COUNT
;
mINI
::
Instance
()[
kCycleMS
]
=
RTP_CYCLE_MS
;
mINI
::
Instance
()[
kVideoMtuSize
]
=
1400
;
mINI
::
Instance
()[
kAudioMtuSize
]
=
600
;
mINI
::
Instance
()[
kMaxRtpCount
]
=
50
;
mINI
::
Instance
()[
kClearCount
]
=
10
;
mINI
::
Instance
()[
kCycleMS
]
=
13
*
60
*
60
*
1000
;
},
nullptr
);
}
//namespace Rtsp
...
...
@@ -239,88 +211,67 @@ const string kAddrMin = MULTI_FIELD"addrMin";
//组播分配截止地址
const
string
kAddrMax
=
MULTI_FIELD
"addrMax"
;
//组播TTL
#define MULTI_UDP_TTL 64
const
string
kUdpTTL
=
MULTI_FIELD
"udpTTL"
;
onceToken
token
([](){
mINI
::
Instance
()[
kAddrMin
]
=
"239.0.0.0"
;
mINI
::
Instance
()[
kAddrMax
]
=
"239.255.255.255"
;
mINI
::
Instance
()[
kUdpTTL
]
=
MULTI_UDP_TTL
;
mINI
::
Instance
()[
kUdpTTL
]
=
64
;
},
nullptr
);
}
//namespace MultiCast
////////////录像配置///////////
namespace
Record
{
#define RECORD_FIELD "record."
//查看录像的应用名称
#define RECORD_APP_NAME "record"
const
string
kAppName
=
RECORD_FIELD
"appName"
;
//每次流化MP4文件的时长,单位毫秒
#define RECORD_SAMPLE_MS 500
const
string
kSampleMS
=
RECORD_FIELD
"sampleMS"
;
//MP4文件录制大小,默认一个小时
#define RECORD_FILE_SECOND (60*60)
const
string
kFileSecond
=
RECORD_FIELD
"fileSecond"
;
//录制文件路径
#define RECORD_FILE_PATH HTTP_ROOT_PATH
const
string
kFilePath
=
RECORD_FIELD
"filePath"
;
//mp4文件写缓存大小
const
string
kFileBufSize
=
RECORD_FIELD
"fileBufSize"
;
//mp4录制完成后是否进行二次关键帧索引写入头部
const
string
kFastStart
=
RECORD_FIELD
"fastStart"
;
//mp4文件是否重头循环读取
const
string
kFileRepeat
=
RECORD_FIELD
"fileRepeat"
;
onceToken
token
([](){
mINI
::
Instance
()[
kAppName
]
=
RECORD_APP_NAME
;
mINI
::
Instance
()[
kSampleMS
]
=
RECORD_SAMPLE_MS
;
mINI
::
Instance
()[
kFileSecond
]
=
RECORD_FILE_SECOND
;
mINI
::
Instance
()[
kFilePath
]
=
RECORD_FILE_PATH
;
mINI
::
Instance
()[
kAppName
]
=
"record"
;
mINI
::
Instance
()[
kSampleMS
]
=
500
;
mINI
::
Instance
()[
kFileSecond
]
=
60
*
60
;
mINI
::
Instance
()[
kFilePath
]
=
"./httpRoot"
;
mINI
::
Instance
()[
kFileBufSize
]
=
64
*
1024
;
mINI
::
Instance
()[
kFastStart
]
=
false
;
mINI
::
Instance
()[
kFileRepeat
]
=
false
;
},
nullptr
);
}
//namespace Record
////////////HLS相关配置///////////
namespace
Hls
{
#define HLS_FIELD "hls."
//HLS切片时长,单位秒
#define HLS_SEGMENT_DURATION 3
const
string
kSegmentDuration
=
HLS_FIELD
"segDur"
;
//HLS切片个数
#define HLS_SEGMENT_NUM 3
const
string
kSegmentNum
=
HLS_FIELD
"segNum"
;
//HLS切片从m3u8文件中移除后,继续保留在磁盘上的个数
const
string
kSegmentRetain
=
HLS_FIELD
"segRetain"
;
//HLS文件写缓存大小
#define HLS_FILE_BUF_SIZE (64 * 1024)
const
string
kFileBufSize
=
HLS_FIELD
"fileBufSize"
;
//录制文件路径
#define HLS_FILE_PATH (HTTP_ROOT_PATH)
const
string
kFilePath
=
HLS_FIELD
"filePath"
;
onceToken
token
([](){
mINI
::
Instance
()[
kSegmentDuration
]
=
HLS_SEGMENT_DURATION
;
mINI
::
Instance
()[
kSegmentNum
]
=
HLS_SEGMENT_NUM
;
mINI
::
Instance
()[
kFileBufSize
]
=
HLS_FILE_BUF_SIZE
;
mINI
::
Instance
()[
kFilePath
]
=
HLS_FILE_PATH
;
mINI
::
Instance
()[
kSegmentDuration
]
=
2
;
mINI
::
Instance
()[
kSegmentNum
]
=
3
;
mINI
::
Instance
()[
kSegmentRetain
]
=
5
;
mINI
::
Instance
()[
kFileBufSize
]
=
64
*
1024
;
mINI
::
Instance
()[
kFilePath
]
=
"./httpRoot"
;
},
nullptr
);
}
//namespace Hls
namespace
Client
{
const
string
kNetAdapter
=
"net_adapter"
;
const
string
kRtpType
=
"rtp_type"
;
...
...
@@ -331,7 +282,6 @@ const string kTimeoutMS = "protocol_timeout_ms";
const
string
kMediaTimeoutMS
=
"media_timeout_ms"
;
const
string
kBeatIntervalMS
=
"beat_interval_ms"
;
const
string
kMaxAnalysisMS
=
"max_analysis_ms"
;
}
}
// namespace mediakit
...
...
This diff is collapsed.
Click to expand it.
src/Common/config.h
查看文件 @
ccbd1d4a
...
...
@@ -283,8 +283,10 @@ extern const string kFileRepeat;
namespace
Hls
{
//HLS切片时长,单位秒
extern
const
string
kSegmentDuration
;
//HLS切片个数,如果设置为0,则不删除切片,而是保存为点播
//
m3u8文件中
HLS切片个数,如果设置为0,则不删除切片,而是保存为点播
extern
const
string
kSegmentNum
;
//HLS切片从m3u8文件中移除后,继续保留在磁盘上的个数
extern
const
string
kSegmentRetain
;
//HLS文件写缓存大小
extern
const
string
kFileBufSize
;
//录制文件路径
...
...
This diff is collapsed.
Click to expand it.
src/MediaFile/HlsMaker.cpp
查看文件 @
ccbd1d4a
...
...
@@ -93,13 +93,14 @@ void HlsMaker::delOldSegment() {
return
;
}
//在hls m3u8索引文件中,我们保存的切片个数跟_seg_number相关设置一致
if
(
_file_index
>
=
_seg_number
+
2
)
{
if
(
_file_index
>
_seg_number
)
{
_seg_dur_list
.
pop_front
();
}
//但是实际保存的切片个数比m3u8所述多两个,这样做的目的是防止播放器在切片删除前能下载完毕
if
(
_file_index
>=
_seg_number
+
4
)
{
onDelSegment
(
_file_index
-
_seg_number
-
4
);
GET_CONFIG
(
uint32_t
,
segRetain
,
Hls
::
kSegmentRetain
);
//但是实际保存的切片个数比m3u8所述多若干个,这样做的目的是防止播放器在切片删除前能下载完毕
if
(
_file_index
>
_seg_number
+
segRetain
)
{
onDelSegment
(
_file_index
-
_seg_number
-
segRetain
-
1
);
}
}
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论