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
f6b4eb41
Commit
f6b4eb41
authored
Jun 11, 2022
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化录制相关代码
parent
09af12a1
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
31 行增加
和
58 行删除
+31
-58
api/source/mk_recorder.cpp
+31
-3
src/Record/Recorder.cpp
+0
-25
src/Record/Recorder.h
+0
-30
没有找到文件。
api/source/mk_recorder.cpp
查看文件 @
f6b4eb41
...
@@ -11,6 +11,8 @@
...
@@ -11,6 +11,8 @@
#include "mk_recorder.h"
#include "mk_recorder.h"
#include "Rtmp/FlvMuxer.h"
#include "Rtmp/FlvMuxer.h"
#include "Record/Recorder.h"
#include "Record/Recorder.h"
using
namespace
std
;
using
namespace
toolkit
;
using
namespace
toolkit
;
using
namespace
mediakit
;
using
namespace
mediakit
;
...
@@ -36,17 +38,43 @@ API_EXPORT int API_CALL mk_flv_recorder_start(mk_flv_recorder ctx, const char *v
...
@@ -36,17 +38,43 @@ API_EXPORT int API_CALL mk_flv_recorder_start(mk_flv_recorder ctx, const char *v
}
}
///////////////////////////////////////////hls/mp4录制/////////////////////////////////////////////
///////////////////////////////////////////hls/mp4录制/////////////////////////////////////////////
static
inline
bool
isRecording
(
Recorder
::
type
type
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
){
auto
src
=
MediaSource
::
find
(
vhost
,
app
,
stream_id
);
if
(
!
src
){
return
false
;
}
return
src
->
isRecording
(
type
);
}
static
inline
bool
startRecord
(
Recorder
::
type
type
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
const
string
&
customized_path
,
size_t
max_second
){
auto
src
=
MediaSource
::
find
(
vhost
,
app
,
stream_id
);
if
(
!
src
)
{
WarnL
<<
"未找到相关的MediaSource,startRecord失败:"
<<
vhost
<<
"/"
<<
app
<<
"/"
<<
stream_id
;
return
false
;
}
return
src
->
setupRecord
(
type
,
true
,
customized_path
,
max_second
);
}
static
inline
bool
stopRecord
(
Recorder
::
type
type
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
){
auto
src
=
MediaSource
::
find
(
vhost
,
app
,
stream_id
);
if
(
!
src
){
return
false
;
}
return
src
->
setupRecord
(
type
,
false
,
""
,
0
);
}
API_EXPORT
int
API_CALL
mk_recorder_is_recording
(
int
type
,
const
char
*
vhost
,
const
char
*
app
,
const
char
*
stream
){
API_EXPORT
int
API_CALL
mk_recorder_is_recording
(
int
type
,
const
char
*
vhost
,
const
char
*
app
,
const
char
*
stream
){
assert
(
vhost
&&
app
&&
stream
);
assert
(
vhost
&&
app
&&
stream
);
return
Recorder
::
isRecording
((
Recorder
::
type
)
type
,
vhost
,
app
,
stream
);
return
isRecording
((
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
,
const
char
*
customized_path
,
size_t
max_second
){
API_EXPORT
int
API_CALL
mk_recorder_start
(
int
type
,
const
char
*
vhost
,
const
char
*
app
,
const
char
*
stream
,
const
char
*
customized_path
,
size_t
max_second
){
assert
(
vhost
&&
app
&&
stream
);
assert
(
vhost
&&
app
&&
stream
);
return
Recorder
::
startRecord
((
Recorder
::
type
)
type
,
vhost
,
app
,
stream
,
customized_path
?
customized_path
:
""
,
max_second
);
return
startRecord
((
Recorder
::
type
)
type
,
vhost
,
app
,
stream
,
customized_path
?
customized_path
:
""
,
max_second
);
}
}
API_EXPORT
int
API_CALL
mk_recorder_stop
(
int
type
,
const
char
*
vhost
,
const
char
*
app
,
const
char
*
stream
){
API_EXPORT
int
API_CALL
mk_recorder_stop
(
int
type
,
const
char
*
vhost
,
const
char
*
app
,
const
char
*
stream
){
assert
(
vhost
&&
app
&&
stream
);
assert
(
vhost
&&
app
&&
stream
);
return
Recorder
::
stopRecord
((
Recorder
::
type
)
type
,
vhost
,
app
,
stream
);
return
stopRecord
((
Recorder
::
type
)
type
,
vhost
,
app
,
stream
);
}
}
src/Record/Recorder.cpp
查看文件 @
f6b4eb41
...
@@ -83,29 +83,4 @@ std::shared_ptr<MediaSinkInterface> Recorder::createRecorder(type type, const st
...
@@ -83,29 +83,4 @@ std::shared_ptr<MediaSinkInterface> Recorder::createRecorder(type type, const st
}
}
}
}
bool
Recorder
::
isRecording
(
type
type
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
){
auto
src
=
MediaSource
::
find
(
vhost
,
app
,
stream_id
);
if
(
!
src
){
return
false
;
}
return
src
->
isRecording
(
type
);
}
bool
Recorder
::
startRecord
(
type
type
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
,
const
string
&
customized_path
,
size_t
max_second
){
auto
src
=
MediaSource
::
find
(
vhost
,
app
,
stream_id
);
if
(
!
src
)
{
WarnL
<<
"未找到相关的MediaSource,startRecord失败:"
<<
vhost
<<
"/"
<<
app
<<
"/"
<<
stream_id
;
return
false
;
}
return
src
->
setupRecord
(
type
,
true
,
customized_path
,
max_second
);
}
bool
Recorder
::
stopRecord
(
type
type
,
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream_id
){
auto
src
=
MediaSource
::
find
(
vhost
,
app
,
stream_id
);
if
(
!
src
){
return
false
;
}
return
src
->
setupRecord
(
type
,
false
,
""
,
0
);
}
}
/* namespace mediakit */
}
/* namespace mediakit */
src/Record/Recorder.h
查看文件 @
f6b4eb41
...
@@ -62,36 +62,6 @@ public:
...
@@ -62,36 +62,6 @@ public:
*/
*/
static
std
::
shared_ptr
<
MediaSinkInterface
>
createRecorder
(
type
type
,
const
std
::
string
&
vhost
,
const
std
::
string
&
app
,
const
std
::
string
&
stream_id
,
const
std
::
string
&
customized_path
=
""
,
size_t
max_second
=
0
);
static
std
::
shared_ptr
<
MediaSinkInterface
>
createRecorder
(
type
type
,
const
std
::
string
&
vhost
,
const
std
::
string
&
app
,
const
std
::
string
&
stream_id
,
const
std
::
string
&
customized_path
=
""
,
size_t
max_second
=
0
);
/**
* 获取录制状态
* @param type hls还是MP4录制
* @param vhost 虚拟主机
* @param app 应用名
* @param stream_id 流id
* @return 是否真正录制
*/
static
bool
isRecording
(
type
type
,
const
std
::
string
&
vhost
,
const
std
::
string
&
app
,
const
std
::
string
&
stream_id
);
/**
* 开始录制
* @param type hls还是MP4录制
* @param vhost 虚拟主机
* @param app 应用名
* @param stream_id 流id
* @param customized_path 录像文件保存自定义根目录,为空则采用配置文件设置
* @return 成功与否
*/
static
bool
startRecord
(
type
type
,
const
std
::
string
&
vhost
,
const
std
::
string
&
app
,
const
std
::
string
&
stream_id
,
const
std
::
string
&
customized_path
,
size_t
max_second
);
/**
* 停止录制
* @param type hls还是MP4录制
* @param vhost 虚拟主机
* @param app 应用名
* @param stream_id 流id
*/
static
bool
stopRecord
(
type
type
,
const
std
::
string
&
vhost
,
const
std
::
string
&
app
,
const
std
::
string
&
stream_id
);
private
:
private
:
Recorder
()
=
delete
;
Recorder
()
=
delete
;
~
Recorder
()
=
delete
;
~
Recorder
()
=
delete
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论