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
b96a2291
Commit
b96a2291
authored
Nov 09, 2021
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MediaPusher: 整理代码风格
parent
b4207240
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
19 行增加
和
27 行删除
+19
-27
src/Pusher/MediaPusher.cpp
+2
-2
src/Pusher/PusherBase.h
+17
-25
没有找到文件。
src/Pusher/MediaPusher.cpp
查看文件 @
b96a2291
...
...
@@ -44,8 +44,8 @@ void MediaPusher::publish(const string &url) {
_delegate
=
PusherBase
::
createPusher
(
_poller
,
_src
.
lock
(),
url
);
assert
(
_delegate
);
setOnCreateSocket_l
(
_delegate
,
_on_create_socket
);
_delegate
->
setOnShutdown
(
_
shutdownCB
);
_delegate
->
setOnPublished
(
_
publishCB
);
_delegate
->
setOnShutdown
(
_
on_shutdown
);
_delegate
->
setOnPublished
(
_
on_publish
);
_delegate
->
mINI
::
operator
=
(
*
this
);
_delegate
->
publish
(
url
);
}
...
...
src/Pusher/PusherBase.h
查看文件 @
b96a2291
...
...
@@ -22,18 +22,17 @@ using namespace toolkit;
namespace
mediakit
{
class
PusherBase
:
public
mINI
{
class
PusherBase
:
public
mINI
{
public
:
typedef
std
::
shared_ptr
<
PusherBase
>
Ptr
;
typedef
std
::
function
<
void
(
const
SockException
&
ex
)
>
Event
;
using
Ptr
=
std
::
shared_ptr
<
PusherBase
>
;
using
Event
=
std
::
function
<
void
(
const
SockException
&
ex
)
>
;
static
Ptr
createPusher
(
const
EventPoller
::
Ptr
&
poller
,
const
MediaSource
::
Ptr
&
src
,
const
string
&
strUrl
);
PusherBase
();
virtual
~
PusherBase
()
{}
virtual
~
PusherBase
()
=
default
;
/**
* 开始推流
...
...
@@ -48,32 +47,29 @@ public:
/**
* 摄像推流结果回调
* @param onPublished
*/
virtual
void
setOnPublished
(
const
Event
&
cb
)
=
0
;
/**
* 设置断开回调
* @param onShutdown
*/
virtual
void
setOnShutdown
(
const
Event
&
cb
)
=
0
;
};
template
<
typename
Parent
,
typename
Delegate
>
template
<
typename
Parent
,
typename
Delegate
>
class
PusherImp
:
public
Parent
{
public
:
typedef
std
::
shared_ptr
<
PusherImp
>
Ptr
;
using
Ptr
=
std
::
shared_ptr
<
PusherImp
>
;
template
<
typename
...
ArgsType
>
PusherImp
(
ArgsType
&&
...
args
)
:
Parent
(
std
::
forward
<
ArgsType
>
(
args
)...){}
virtual
~
PusherImp
(){}
PusherImp
(
ArgsType
&&
...
args
)
:
Parent
(
std
::
forward
<
ArgsType
>
(
args
)...)
{}
~
PusherImp
()
override
=
default
;
/**
* 开始推流
* @param strUrl 推流url,支持rtsp/rtmp
*/
void
publish
(
const
string
&
strUrl
)
override
{
void
publish
(
const
string
&
strUrl
)
override
{
if
(
_delegate
)
{
_delegate
->
publish
(
strUrl
);
}
...
...
@@ -82,7 +78,7 @@ public:
/**
* 中断推流
*/
void
teardown
()
override
{
void
teardown
()
override
{
if
(
_delegate
)
{
_delegate
->
teardown
();
}
...
...
@@ -90,37 +86,33 @@ public:
/**
* 摄像推流结果回调
* @param onPublished
*/
void
setOnPublished
(
const
PusherBase
::
Event
&
cb
)
override
{
void
setOnPublished
(
const
PusherBase
::
Event
&
cb
)
override
{
if
(
_delegate
)
{
_delegate
->
setOnPublished
(
cb
);
}
_
publishCB
=
cb
;
_
on_publish
=
cb
;
}
/**
* 设置断开回调
* @param onShutdown
*/
void
setOnShutdown
(
const
PusherBase
::
Event
&
cb
)
override
{
void
setOnShutdown
(
const
PusherBase
::
Event
&
cb
)
override
{
if
(
_delegate
)
{
_delegate
->
setOnShutdown
(
cb
);
}
_
shutdownCB
=
cb
;
_
on_shutdown
=
cb
;
}
std
::
shared_ptr
<
SockInfo
>
getSockInfo
()
const
{
std
::
shared_ptr
<
SockInfo
>
getSockInfo
()
const
{
return
dynamic_pointer_cast
<
SockInfo
>
(
_delegate
);
}
protected
:
PusherBase
::
Event
_
shutdownCB
;
PusherBase
::
Event
_
publishCB
;
PusherBase
::
Event
_
on_shutdown
;
PusherBase
::
Event
_
on_publish
;
std
::
shared_ptr
<
Delegate
>
_delegate
;
};
}
/* namespace mediakit */
#endif
/* SRC_PUSHER_PUSHERBASE_H_ */
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论