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
5fe5dd9d
Commit
5fe5dd9d
authored
Dec 12, 2019
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hls保存ts文件时根据日期、时间保存
parent
ee66d945
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
22 行增加
和
33 行删除
+22
-33
3rdpart/ZLToolKit
+1
-1
src/Record/HlsMakerImp.cpp
+18
-11
src/Record/HlsMakerImp.h
+1
-1
src/Record/MP4Recorder.cpp
+2
-20
没有找到文件。
ZLToolKit
@
ecb38246
Subproject commit
628d3b2527f63b54a5eb38b9e9973254d4a2192b
Subproject commit
ecb382460ffa2f6f5cdf1e11b394797e3396b2d0
src/Record/HlsMakerImp.cpp
查看文件 @
5fe5dd9d
...
...
@@ -56,21 +56,31 @@ HlsMakerImp::~HlsMakerImp() {
}
string
HlsMakerImp
::
onOpenSegment
(
int
index
)
{
auto
full_path
=
fullPath
(
index
);
_file
=
makeFile
(
full_path
,
true
);
string
segment_name
,
segment_path
;
{
auto
strDate
=
getTimeStr
(
"%Y-%m-%d"
);
auto
strTime
=
getTimeStr
(
"%H-%M-%S"
);
segment_name
=
StrPrinter
<<
strDate
+
"/"
+
strTime
<<
"_"
<<
index
<<
".ts"
;
segment_path
=
_path_prefix
+
"/"
+
segment_name
;
_segment_file_paths
.
emplace
(
index
,
segment_path
);
}
_file
=
makeFile
(
segment_path
,
true
);
if
(
!
_file
){
WarnL
<<
"create file falied,"
<<
full
_path
<<
" "
<<
get_uv_errmsg
();
WarnL
<<
"create file falied,"
<<
segment
_path
<<
" "
<<
get_uv_errmsg
();
}
//DebugL << index << " " << full_path;
if
(
_params
.
empty
()){
return
StrPrinter
<<
index
<<
".ts"
;
return
std
::
move
(
segment_name
)
;
}
return
StrPrinter
<<
index
<<
".ts"
<<
"?"
<<
_params
;
return
std
::
move
(
segment_name
+
"?"
+
_params
)
;
}
void
HlsMakerImp
::
onDelSegment
(
int
index
)
{
//WarnL << index;
File
::
delete_file
(
fullPath
(
index
).
data
());
auto
it
=
_segment_file_paths
.
find
(
index
);
if
(
it
==
_segment_file_paths
.
end
()){
return
;
}
File
::
delete_file
(
it
->
second
.
data
());
_segment_file_paths
.
erase
(
it
);
}
void
HlsMakerImp
::
onWriteSegment
(
const
char
*
data
,
int
len
)
{
...
...
@@ -90,9 +100,6 @@ void HlsMakerImp::onWriteHls(const char *data, int len) {
//DebugL << "\r\n" << string(data,len);
}
string
HlsMakerImp
::
fullPath
(
int
index
)
{
return
StrPrinter
<<
_path_prefix
<<
"/"
<<
index
<<
".ts"
;
}
std
::
shared_ptr
<
FILE
>
HlsMakerImp
::
makeFile
(
const
string
&
file
,
bool
setbuf
)
{
auto
ret
=
shared_ptr
<
FILE
>
(
File
::
createfile_file
(
file
.
data
(),
"wb"
),
[](
FILE
*
fp
)
{
...
...
src/Record/HlsMakerImp.h
查看文件 @
5fe5dd9d
...
...
@@ -49,9 +49,9 @@ protected:
void
onWriteSegment
(
const
char
*
data
,
int
len
)
override
;
void
onWriteHls
(
const
char
*
data
,
int
len
)
override
;
private
:
string
fullPath
(
int
index
);
std
::
shared_ptr
<
FILE
>
makeFile
(
const
string
&
file
,
bool
setbuf
=
false
);
private
:
map
<
int
/*index*/
,
string
/*file_path*/
>
_segment_file_paths
;
std
::
shared_ptr
<
FILE
>
_file
;
std
::
shared_ptr
<
char
>
_file_buf
;
string
_path_prefix
;
...
...
src/Record/MP4Recorder.cpp
查看文件 @
5fe5dd9d
...
...
@@ -29,30 +29,12 @@
#include <sys/stat.h>
#include "Common/config.h"
#include "MP4Recorder.h"
#include "Util/util.h"
#include "Util/NoticeCenter.h"
#include "Thread/WorkThreadPool.h"
using
namespace
toolkit
;
namespace
mediakit
{
string
timeStr
(
const
char
*
fmt
)
{
std
::
tm
tm_snapshot
;
auto
time
=
::
time
(
NULL
);
#if defined(_WIN32)
localtime_s
(
&
tm_snapshot
,
&
time
);
// thread-safe
#else
localtime_r
(
&
time
,
&
tm_snapshot
);
// POSIX
#endif
const
size_t
size
=
1024
;
char
buffer
[
size
];
auto
success
=
std
::
strftime
(
buffer
,
size
,
fmt
,
&
tm_snapshot
);
if
(
0
==
success
)
return
string
(
fmt
);
return
buffer
;
}
MP4Recorder
::
MP4Recorder
(
const
string
&
strPath
,
const
string
&
strVhost
,
const
string
&
strApp
,
...
...
@@ -70,8 +52,8 @@ MP4Recorder::~MP4Recorder() {
void
MP4Recorder
::
createFile
()
{
closeFile
();
auto
strDate
=
t
imeStr
(
"%Y-%m-%d"
);
auto
strTime
=
t
imeStr
(
"%H-%M-%S"
);
auto
strDate
=
getT
imeStr
(
"%Y-%m-%d"
);
auto
strTime
=
getT
imeStr
(
"%H-%M-%S"
);
auto
strFileTmp
=
_strPath
+
strDate
+
"/."
+
strTime
+
".mp4"
;
auto
strFile
=
_strPath
+
strDate
+
"/"
+
strTime
+
".mp4"
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论