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
00531481
Commit
00531481
authored
Nov 05, 2022
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化MultiMediaSourceMuxer相关代码
parent
7e95bd20
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
13 行增加
和
12 行删除
+13
-12
src/Common/MultiMediaSourceMuxer.cpp
+11
-10
src/Common/MultiMediaSourceMuxer.h
+2
-2
没有找到文件。
src/Common/MultiMediaSourceMuxer.cpp
查看文件 @
00531481
...
...
@@ -89,6 +89,14 @@ const std::string &MultiMediaSourceMuxer::getStreamId() const {
return
_stream_id
;
}
std
::
string
MultiMediaSourceMuxer
::
shortUrl
()
const
{
auto
ret
=
getOriginUrl
(
MediaSource
::
NullMediaSource
());
if
(
!
ret
.
empty
())
{
return
ret
;
}
return
_vhost
+
"/"
+
_app
+
"/"
+
_stream_id
;
}
MultiMediaSourceMuxer
::
MultiMediaSourceMuxer
(
const
string
&
vhost
,
const
string
&
app
,
const
string
&
stream
,
float
dur_sec
,
const
ProtocolOption
&
option
)
{
_poller
=
EventPollerPool
::
Instance
().
getPoller
();
_create_in_poller
=
_poller
->
isCurrentThread
();
...
...
@@ -96,13 +104,6 @@ MultiMediaSourceMuxer::MultiMediaSourceMuxer(const string &vhost, const string &
_app
=
app
;
_stream_id
=
stream
;
_option
=
option
;
_get_origin_url
=
[
this
,
vhost
,
app
,
stream
]()
{
auto
ret
=
getOriginUrl
(
MediaSource
::
NullMediaSource
());
if
(
!
ret
.
empty
())
{
return
ret
;
}
return
vhost
+
"/"
+
app
+
"/"
+
stream
;
};
if
(
option
.
enable_rtmp
)
{
_rtmp
=
std
::
make_shared
<
RtmpMediaSourceMuxer
>
(
vhost
,
app
,
stream
,
std
::
make_shared
<
TitleMeta
>
(
dur_sec
));
...
...
@@ -267,7 +268,7 @@ void MultiMediaSourceMuxer::startSendRtp(MediaSource &sender, const MediaSourceE
auto
ssrc
=
args
.
ssrc
;
rtp_sender
->
setOnClose
([
weak_self
,
ssrc
](
const
toolkit
::
SockException
&
ex
)
{
if
(
auto
strong_self
=
weak_self
.
lock
())
{
WarnL
<<
"stream:"
<<
strong_self
->
_get_origin_u
rl
()
<<
" stop send rtp:"
<<
ssrc
<<
", reason:"
<<
ex
.
what
();
WarnL
<<
"stream:"
<<
strong_self
->
shortU
rl
()
<<
" stop send rtp:"
<<
ssrc
<<
", reason:"
<<
ex
.
what
();
strong_self
->
_rtp_sender
.
erase
(
ssrc
);
//触发观看人数统计
strong_self
->
onReaderChanged
(
MediaSource
::
NullMediaSource
(),
strong_self
->
totalReaderCount
());
...
...
@@ -313,7 +314,7 @@ EventPoller::Ptr MultiMediaSourceMuxer::getOwnerPoller(MediaSource &sender) {
try
{
auto
ret
=
listener
->
getOwnerPoller
(
sender
);
if
(
ret
!=
_poller
)
{
WarnL
<<
"OwnerPoller changed:"
<<
_get_origin_u
rl
();
WarnL
<<
"OwnerPoller changed:"
<<
shortU
rl
();
_poller
=
ret
;
}
return
ret
;
...
...
@@ -372,7 +373,7 @@ void MultiMediaSourceMuxer::onAllTrackReady() {
if
(
listener
)
{
listener
->
onAllTrackReady
();
}
InfoL
<<
"stream: "
<<
_get_origin_u
rl
()
<<
" , codec info: "
<<
getTrackInfoStr
(
this
);
InfoL
<<
"stream: "
<<
shortU
rl
()
<<
" , codec info: "
<<
getTrackInfoStr
(
this
);
}
void
MultiMediaSourceMuxer
::
resetTracks
()
{
...
...
src/Common/MultiMediaSourceMuxer.h
查看文件 @
00531481
...
...
@@ -94,7 +94,7 @@ class MultiMediaSourceMuxer : public MediaSourceEventInterceptor, public MediaSi
public
:
typedef
std
::
shared_ptr
<
MultiMediaSourceMuxer
>
Ptr
;
class
Listener
{
class
Listener
{
public
:
Listener
()
=
default
;
virtual
~
Listener
()
=
default
;
...
...
@@ -193,6 +193,7 @@ public:
const
std
::
string
&
getVhost
()
const
;
const
std
::
string
&
getApp
()
const
;
const
std
::
string
&
getStreamId
()
const
;
std
::
string
shortUrl
()
const
;
protected
:
/////////////////////////////////MediaSink override/////////////////////////////////
...
...
@@ -225,7 +226,6 @@ private:
toolkit
::
Ticker
_last_check
;
Stamp
_stamp
[
2
];
std
::
weak_ptr
<
Listener
>
_track_listener
;
std
::
function
<
std
::
string
()
>
_get_origin_url
;
#if defined(ENABLE_RTPPROXY)
std
::
unordered_map
<
std
::
string
,
RtpSender
::
Ptr
>
_rtp_sender
;
#endif //ENABLE_RTPPROXY
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论