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
f2e82fc2
Commit
f2e82fc2
authored
Mar 27, 2018
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
解决hls iPhone无法播放的问题
parent
412424b2
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
12 行增加
和
51 行删除
+12
-51
src/Common/config.cpp
+0
-10
src/Common/config.h
+0
-4
src/MediaFile/HLSMaker.cpp
+7
-5
src/MediaFile/HLSMaker.h
+0
-2
src/MediaFile/MediaRecorder.cpp
+5
-30
没有找到文件。
src/Common/config.cpp
查看文件 @
f2e82fc2
...
...
@@ -287,21 +287,11 @@ const char kFileBufSize[] = HLS_FIELD"fileBufSize";
#define HLS_FILE_PATH (HTTP_ROOT_PATH)
const
char
kFilePath
[]
=
HLS_FIELD
"filePath"
;
//HTTP访问url前缀
#define HTTP_PREFIX (StrPrinter << "http://${" << VHOST_KEY << "}:" << HTTP_PORT << endl)
const
char
kHttpPrefix
[]
=
HLS_FIELD
"httpPrefix"
;
#define HTTP_PREFIX_DEFAULT_VHOST (StrPrinter << "http://" << SockUtil::get_local_ip() << ":" << HTTP_PORT << endl)
const
char
kHttpPrefixDefaultVhost
[]
=
HLS_FIELD
"httpPrefixDefaultVhost"
;
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
()[
kHttpPrefix
]
=
HTTP_PREFIX
;
mINI
::
Instance
()[
kHttpPrefixDefaultVhost
]
=
HTTP_PREFIX_DEFAULT_VHOST
;
},
nullptr
);
}
//namespace Hls
...
...
src/Common/config.h
查看文件 @
f2e82fc2
...
...
@@ -232,10 +232,6 @@ extern const char kSegmentNum[];
extern
const
char
kFileBufSize
[];
//录制文件路径
extern
const
char
kFilePath
[];
//HTTP访问url前缀
extern
const
char
kHttpPrefix
[];
//HTTP默认vhost访问url前缀
extern
const
char
kHttpPrefixDefaultVhost
[];
}
//namespace Hls
}
// namespace Config
...
...
src/MediaFile/HLSMaker.cpp
查看文件 @
f2e82fc2
...
...
@@ -33,8 +33,10 @@ using namespace ZL::Util;
namespace
ZL
{
namespace
MediaFile
{
HLSMaker
::
HLSMaker
(
const
string
&
strM3u8File
,
const
string
&
strHttpUrl
,
uint32_t
ui32BufSize
,
uint32_t
ui32Duration
,
uint32_t
ui32Num
)
{
HLSMaker
::
HLSMaker
(
const
string
&
strM3u8File
,
uint32_t
ui32BufSize
,
uint32_t
ui32Duration
,
uint32_t
ui32Num
)
{
if
(
ui32BufSize
<
16
*
1024
)
{
ui32BufSize
=
16
*
1024
;
}
...
...
@@ -44,7 +46,6 @@ HLSMaker::HLSMaker(const string& strM3u8File, const string& strHttpUrl,
m_ui32BufSize
=
ui32BufSize
;
m_ui64TsCnt
=
0
;
m_strM3u8File
=
strM3u8File
;
m_strHttpUrl
=
strHttpUrl
.
substr
(
0
,
strHttpUrl
.
find_last_of
(
'/'
)
+
1
);
m_ui32NumSegments
=
ui32Num
;
m_ui32SegmentDuration
=
ui32Duration
;
...
...
@@ -85,6 +86,7 @@ bool HLSMaker::write_index_file(int iFirstSegment, unsigned int uiLastSegment, i
snprintf
(
acWriteBuf
,
sizeof
(
acWriteBuf
),
"#EXTM3U
\n
"
"#EXT-X-VERSION:3
\n
"
"#EXT-X-TARGETDURATION:%u
\n
"
"#EXT-X-MEDIA-SEQUENCE:%u
\n
"
,
maxSegmentDuration
,
...
...
@@ -93,6 +95,7 @@ bool HLSMaker::write_index_file(int iFirstSegment, unsigned int uiLastSegment, i
snprintf
(
acWriteBuf
,
sizeof
(
acWriteBuf
),
"#EXTM3U
\n
"
"#EXT-X-VERSION:3
\n
"
"#EXT-X-TARGETDURATION:%u
\n
"
,
maxSegmentDuration
);
}
...
...
@@ -104,9 +107,8 @@ bool HLSMaker::write_index_file(int iFirstSegment, unsigned int uiLastSegment, i
for
(
unsigned
int
i
=
iFirstSegment
;
i
<
uiLastSegment
;
i
++
)
{
snprintf
(
acWriteBuf
,
sizeof
(
acWriteBuf
),
"#EXTINF:%.3f,
\n
%s
%s
-%u.ts
\n
"
,
"#EXTINF:%.3f,
\n
%s-%u.ts
\n
"
,
m_iDurations
[
i
-
iFirstSegment
]
/
1000.0
,
m_strHttpUrl
.
c_str
(),
m_strFileName
.
c_str
(),
i
);
if
(
fwrite
(
acWriteBuf
,
strlen
(
acWriteBuf
),
1
,
pM3u8File
.
get
())
!=
1
)
{
...
...
src/MediaFile/HLSMaker.h
查看文件 @
f2e82fc2
...
...
@@ -43,7 +43,6 @@ namespace MediaFile {
class
HLSMaker
{
public
:
HLSMaker
(
const
string
&
strM3u8File
,
const
string
&
strHttpUrl
,
uint32_t
ui32BufSize
=
64
*
1024
,
uint32_t
ui32Duration
=
5
,
uint32_t
ui32Num
=
3
);
...
...
@@ -63,7 +62,6 @@ public:
private
:
TSMaker
m_ts
;
string
m_strM3u8File
;
string
m_strHttpUrl
;
string
m_strFileName
;
string
m_strOutputPrefix
;
uint32_t
m_ui32SegmentDuration
;
...
...
src/MediaFile/MediaRecorder.cpp
查看文件 @
f2e82fc2
...
...
@@ -44,8 +44,6 @@ MediaRecorder::MediaRecorder(const string &strVhost_tmp,
bool
enableHls
,
bool
enableMp4
)
{
GET_CONFIG_AND_REGISTER
(
string
,
hlsPrefix
,
Config
::
Hls
::
kHttpPrefix
);
GET_CONFIG_AND_REGISTER
(
string
,
hlsPrefixDefaultVhost
,
Config
::
Hls
::
kHttpPrefixDefaultVhost
);
GET_CONFIG_AND_REGISTER
(
string
,
hlsPath
,
Config
::
Hls
::
kFilePath
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
hlsBufSize
,
Config
::
Hls
::
kFileBufSize
);
GET_CONFIG_AND_REGISTER
(
uint32_t
,
hlsDuration
,
Config
::
Hls
::
kSegmentDuration
);
...
...
@@ -58,40 +56,17 @@ MediaRecorder::MediaRecorder(const string &strVhost_tmp,
}
if
(
enableHls
)
{
string
hlsPrefixVhost
=
hlsPrefix
;
do
{
//生成hls http前缀
if
(
strVhost
==
DEFAULT_VHOST
)
{
hlsPrefixVhost
=
hlsPrefixDefaultVhost
;
break
;
}
auto
pos_start
=
hlsPrefixVhost
.
find
(
"${"
);
auto
pos_end
=
hlsPrefixVhost
.
find
(
"}"
);
if
(
pos_start
!=
string
::
npos
&&
pos_end
!=
string
::
npos
&&
pos_end
-
pos_start
-
2
>
0
)
{
auto
key
=
hlsPrefixVhost
.
substr
(
pos_start
+
2
,
pos_end
-
pos_start
-
2
);
trim
(
key
);
if
(
key
==
VHOST_KEY
)
{
hlsPrefixVhost
.
replace
(
pos_start
,
pos_end
-
pos_start
+
1
,
strVhost
);
}
else
{
//不识别的环境变量
break
;
}
}
else
{
//没有更多环境变量了
break
;
}
}
while
(
true
);
m_hlsMaker
.
reset
(
new
HLSMaker
(
hlsPath
+
"/"
+
strVhost
+
"/"
+
strApp
+
"/"
+
strId
+
"/hls.m3u8"
,
hlsPrefixVhost
+
"/"
+
strApp
+
"/"
+
strId
+
"/"
,
hlsBufSize
,
hlsDuration
,
hlsNum
));
auto
m3u8FilePath
=
hlsPath
+
"/"
+
strVhost
+
"/"
+
strApp
+
"/"
+
strId
+
"/hls.m3u8"
;
m_hlsMaker
.
reset
(
new
HLSMaker
(
m3u8FilePath
,
hlsBufSize
,
hlsDuration
,
hlsNum
));
}
#ifdef ENABLE_MP4V2
GET_CONFIG_AND_REGISTER
(
string
,
recordPath
,
Config
::
Record
::
kFilePath
);
GET_CONFIG_AND_REGISTER
(
string
,
recordAppName
,
Config
::
Record
::
kAppName
);
if
(
enableMp4
){
m_mp4Maker
.
reset
(
new
Mp4Maker
(
recordPath
+
"/"
+
strVhost
+
"/"
+
recordAppName
+
"/"
+
strApp
+
"/"
+
strId
+
"/"
,
strVhost
,
strApp
,
strId
,
pPlayer
));
auto
mp4FilePath
=
recordPath
+
"/"
+
strVhost
+
"/"
+
recordAppName
+
"/"
+
strApp
+
"/"
+
strId
+
"/"
;
m_mp4Maker
.
reset
(
new
Mp4Maker
(
mp4FilePath
,
strVhost
,
strApp
,
strId
,
pPlayer
));
}
#endif //ENABLE_MP4V2
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论