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
e31c1ee2
Commit
e31c1ee2
authored
5 years ago
by
Gemfield
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add optional customized_path parameter for startRecord
parent
84de9720
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
29 行增加
和
18 行删除
+29
-18
api/include/mk_recorder.h
+1
-1
api/source/mk_recorder.cpp
+2
-2
server/WebApi.cpp
+2
-0
src/Common/MultiMediaSourceMuxer.h
+2
-2
src/Record/HlsMakerImp.cpp
+3
-2
src/Record/Recorder.cpp
+18
-10
src/Record/Recorder.h
+1
-1
没有找到文件。
api/include/mk_recorder.h
查看文件 @
e31c1ee2
...
...
@@ -83,7 +83,7 @@ API_EXPORT int API_CALL mk_recorder_status(int type, const char *vhost, const ch
* @param continue_record 流注销时是否继续等待录制还是立即停止录制
* @return 0代表成功,负数代表失败
*/
API_EXPORT
int
API_CALL
mk_recorder_start
(
int
type
,
const
char
*
vhost
,
const
char
*
app
,
const
char
*
stream
,
int
wait_for_record
,
int
continue_record
);
API_EXPORT
int
API_CALL
mk_recorder_start
(
int
type
,
const
char
*
vhost
,
const
char
*
app
,
const
char
*
stream
,
const
char
*
customized_path
,
int
wait_for_record
,
int
continue_record
);
/**
* 停止录制
...
...
This diff is collapsed.
Click to expand it.
api/source/mk_recorder.cpp
查看文件 @
e31c1ee2
...
...
@@ -57,9 +57,9 @@ API_EXPORT int API_CALL mk_recorder_status(int type, const char *vhost, const ch
return
Recorder
::
getRecordStatus
((
Recorder
::
type
)
type
,
vhost
,
app
,
stream
);
}
API_EXPORT
int
API_CALL
mk_recorder_start
(
int
type
,
const
char
*
vhost
,
const
char
*
app
,
const
char
*
stream
,
int
wait_for_record
,
int
continue_record
){
API_EXPORT
int
API_CALL
mk_recorder_start
(
int
type
,
const
char
*
vhost
,
const
char
*
app
,
const
char
*
stream
,
const
char
*
customized_path
,
int
wait_for_record
,
int
continue_record
){
assert
(
vhost
&&
app
&&
stream
);
return
Recorder
::
startRecord
((
Recorder
::
type
)
type
,
vhost
,
app
,
stream
,
wait_for_record
,
continue_record
);
return
Recorder
::
startRecord
((
Recorder
::
type
)
type
,
vhost
,
app
,
stream
,
customized_path
,
wait_for_record
,
continue_record
);
}
API_EXPORT
int
API_CALL
mk_recorder_stop
(
int
type
,
const
char
*
vhost
,
const
char
*
app
,
const
char
*
stream
){
...
...
This diff is collapsed.
Click to expand it.
server/WebApi.cpp
查看文件 @
e31c1ee2
...
...
@@ -745,10 +745,12 @@ void installWebApi() {
API_REGIST
(
api
,
startRecord
,{
CHECK_SECRET
();
CHECK_ARGS
(
"type"
,
"vhost"
,
"app"
,
"stream"
,
"wait_for_record"
,
"continue_record"
);
int
result
=
Recorder
::
startRecord
((
Recorder
::
type
)
allArgs
[
"type"
].
as
<
int
>
(),
allArgs
[
"vhost"
],
allArgs
[
"app"
],
allArgs
[
"stream"
],
allArgs
[
"customized_path"
],
allArgs
[
"wait_for_record"
],
allArgs
[
"continue_record"
]);
val
[
"result"
]
=
result
;
...
...
This diff is collapsed.
Click to expand it.
src/Common/MultiMediaSourceMuxer.h
查看文件 @
e31c1ee2
...
...
@@ -53,11 +53,11 @@ public:
}
if
(
enable_hls
){
Recorder
::
startRecord
(
Recorder
::
type_hls
,
vhost
,
app
,
stream
,
true
,
false
);
Recorder
::
startRecord
(
Recorder
::
type_hls
,
vhost
,
app
,
stream
,
""
,
true
,
false
);
}
if
(
enable_mp4
){
Recorder
::
startRecord
(
Recorder
::
type_mp4
,
vhost
,
app
,
stream
,
true
,
false
);
Recorder
::
startRecord
(
Recorder
::
type_mp4
,
vhost
,
app
,
stream
,
""
,
true
,
false
);
}
_get_hls_media_source
=
[
vhost
,
app
,
stream
](){
...
...
This diff is collapsed.
Click to expand it.
src/Record/HlsMakerImp.cpp
查看文件 @
e31c1ee2
...
...
@@ -58,8 +58,9 @@ string HlsMakerImp::onOpenSegment(int index) {
string
segment_name
,
segment_path
;
{
auto
strDate
=
getTimeStr
(
"%Y-%m-%d"
);
auto
strTime
=
getTimeStr
(
"%H-%M-%S"
);
segment_name
=
StrPrinter
<<
strDate
+
"/"
+
strTime
<<
"_"
<<
index
<<
".ts"
;
auto
strHour
=
getTimeStr
(
"%H"
);
auto
strTime
=
getTimeStr
(
"%M-%S"
);
segment_name
=
StrPrinter
<<
strDate
+
"/"
+
strHour
+
"/"
+
strTime
<<
"_"
<<
index
<<
".ts"
;
segment_path
=
_path_prefix
+
"/"
+
segment_name
;
if
(
isLive
()){
_segment_file_paths
.
emplace
(
index
,
segment_path
);
...
...
This diff is collapsed.
Click to expand it.
src/Record/Recorder.cpp
查看文件 @
e31c1ee2
...
...
@@ -34,7 +34,7 @@ using namespace toolkit;
namespace
mediakit
{
MediaSinkInterface
*
createHlsRecorder
(
const
string
&
strVhost_tmp
,
const
string
&
strApp
,
const
string
&
strId
)
{
MediaSinkInterface
*
createHlsRecorder
(
const
string
&
strVhost_tmp
,
const
string
&
strApp
,
const
string
&
strId
,
const
string
&
customized_path
)
{
#if defined(ENABLE_HLS)
GET_CONFIG
(
bool
,
enableVhost
,
General
::
kEnableVhost
);
GET_CONFIG
(
string
,
hlsPath
,
Hls
::
kFilePath
);
...
...
@@ -53,6 +53,10 @@ MediaSinkInterface *createHlsRecorder(const string &strVhost_tmp, const string &
}
else
{
m3u8FilePath
=
strApp
+
"/"
+
strId
+
"/hls.m3u8"
;
}
//Here we use the customized file path.
if
(
!
customized_path
.
empty
()){
m3u8FilePath
=
customized_path
+
"/hls.m3u8"
;
}
m3u8FilePath
=
File
::
absolutePath
(
m3u8FilePath
,
hlsPath
);
auto
ret
=
new
HlsRecorder
(
m3u8FilePath
,
params
);
ret
->
setMediaSource
(
strVhost
,
strApp
,
strId
);
...
...
@@ -62,7 +66,7 @@ MediaSinkInterface *createHlsRecorder(const string &strVhost_tmp, const string &
#endif //defined(ENABLE_HLS)
}
MediaSinkInterface
*
createMP4Recorder
(
const
string
&
strVhost_tmp
,
const
string
&
strApp
,
const
string
&
strId
)
{
MediaSinkInterface
*
createMP4Recorder
(
const
string
&
strVhost_tmp
,
const
string
&
strApp
,
const
string
&
strId
,
const
string
&
customized_path
)
{
#if defined(ENABLE_MP4RECORD)
GET_CONFIG
(
bool
,
enableVhost
,
General
::
kEnableVhost
);
GET_CONFIG
(
string
,
recordPath
,
Record
::
kFilePath
);
...
...
@@ -80,6 +84,10 @@ MediaSinkInterface *createMP4Recorder(const string &strVhost_tmp, const string &
}
else
{
mp4FilePath
=
recordAppName
+
"/"
+
strApp
+
"/"
+
strId
+
"/"
;
}
//Here we use the customized file path.
if
(
!
customized_path
.
empty
()){
mp4FilePath
=
customized_path
+
"/"
;
}
mp4FilePath
=
File
::
absolutePath
(
mp4FilePath
,
recordPath
);
return
new
MP4Recorder
(
mp4FilePath
,
strVhost
,
strApp
,
strId
);
#else
...
...
@@ -193,7 +201,7 @@ public:
return
it
->
second
->
getRecorder
();
}
int
startRecord
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
bool
waitForRecord
,
bool
continueRecord
)
{
int
startRecord
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
const
string
&
customized_path
,
bool
waitForRecord
,
bool
continueRecord
)
{
auto
key
=
getRecorderKey
(
vhost
,
app
,
stream_id
);
lock_guard
<
decltype
(
_recorder_mtx
)
>
lck
(
_recorder_mtx
);
if
(
getRecordStatus_l
(
key
)
!=
Recorder
::
status_not_record
)
{
...
...
@@ -207,7 +215,7 @@ public:
return
-
1
;
}
auto
recorder
=
MediaSinkInterface
::
Ptr
(
createRecorder
(
vhost
,
app
,
stream_id
));
auto
recorder
=
MediaSinkInterface
::
Ptr
(
createRecorder
(
vhost
,
app
,
stream_id
,
customized_path
));
if
(
!
recorder
)
{
// 创建录制器失败
return
-
2
;
...
...
@@ -326,14 +334,14 @@ private:
return
vhost
+
"/"
+
app
+
"/"
+
stream_id
;
}
MediaSinkInterface
*
createRecorder
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
)
{
MediaSinkInterface
*
createRecorder
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
const
string
&
customized_path
)
{
MediaSinkInterface
*
ret
=
nullptr
;
switch
(
type
)
{
case
Recorder
:
:
type_hls
:
ret
=
createHlsRecorder
(
vhost
,
app
,
stream_id
);
ret
=
createHlsRecorder
(
vhost
,
app
,
stream_id
,
customized_path
);
break
;
case
Recorder
:
:
type_mp4
:
ret
=
createMP4Recorder
(
vhost
,
app
,
stream_id
);
ret
=
createMP4Recorder
(
vhost
,
app
,
stream_id
,
customized_path
);
break
;
default
:
break
;
...
...
@@ -385,12 +393,12 @@ std::shared_ptr<MediaSinkInterface> Recorder::getRecorder(type type, const strin
}
int
Recorder
::
startRecord
(
Recorder
::
type
type
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
bool
waitForRecord
,
bool
continueRecord
)
{
int
Recorder
::
startRecord
(
Recorder
::
type
type
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
const
string
&
customized_path
,
bool
waitForRecord
,
bool
continueRecord
)
{
switch
(
type
){
case
type_mp4
:
return
MediaSourceWatcher
<
type_mp4
>::
Instance
().
startRecord
(
vhost
,
app
,
stream_id
,
waitForRecord
,
continueRecord
);
return
MediaSourceWatcher
<
type_mp4
>::
Instance
().
startRecord
(
vhost
,
app
,
stream_id
,
customized_path
,
waitForRecord
,
continueRecord
);
case
type_hls
:
return
MediaSourceWatcher
<
type_hls
>::
Instance
().
startRecord
(
vhost
,
app
,
stream_id
,
waitForRecord
,
continueRecord
);
return
MediaSourceWatcher
<
type_hls
>::
Instance
().
startRecord
(
vhost
,
app
,
stream_id
,
customized_path
,
waitForRecord
,
continueRecord
);
}
WarnL
<<
"unknown record type: "
<<
type
;
return
-
3
;
...
...
This diff is collapsed.
Click to expand it.
src/Record/Recorder.h
查看文件 @
e31c1ee2
...
...
@@ -73,7 +73,7 @@ public:
* @param continueRecord 流注销时是否继续等待录制还是立即停止录制
* @return 0代表成功,负数代表失败
*/
static
int
startRecord
(
type
type
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
bool
waitForRecord
,
bool
continueRecord
);
static
int
startRecord
(
type
type
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
const
string
&
customized_path
,
bool
waitForRecord
,
bool
continueRecord
);
/**
* 停止录制
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论