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
37d842e4
Commit
37d842e4
authored
5 years ago
by
xiongziliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复rtsp组播相关的bug
parent
b43df8be
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
11 行增加
和
11 行删除
+11
-11
src/Rtsp/RtpBroadCaster.cpp
+7
-7
src/Rtsp/RtpBroadCaster.h
+3
-3
src/Rtsp/RtspSession.cpp
+1
-1
没有找到文件。
src/Rtsp/RtpBroadCaster.cpp
查看文件 @
37d842e4
...
...
@@ -97,7 +97,7 @@ RtpBroadCaster::~RtpBroadCaster() {
_pReader
->
setDetachCB
(
nullptr
);
DebugL
;
}
RtpBroadCaster
::
RtpBroadCaster
(
const
string
&
strLocalIp
,
const
string
&
strVhost
,
const
string
&
strApp
,
const
string
&
strStream
)
{
RtpBroadCaster
::
RtpBroadCaster
(
const
EventPoller
::
Ptr
&
poller
,
const
string
&
strLocalIp
,
const
string
&
strVhost
,
const
string
&
strApp
,
const
string
&
strStream
)
{
auto
src
=
dynamic_pointer_cast
<
RtspMediaSource
>
(
MediaSource
::
find
(
RTSP_SCHEMA
,
strVhost
,
strApp
,
strStream
));
if
(
!
src
){
auto
strErr
=
StrPrinter
<<
"未找到媒体源:"
<<
strVhost
<<
" "
<<
strApp
<<
" "
<<
strStream
<<
endl
;
...
...
@@ -124,7 +124,7 @@ RtpBroadCaster::RtpBroadCaster(const string &strLocalIp,const string &strVhost,c
bzero
(
&
(
peerAddr
.
sin_zero
),
sizeof
peerAddr
.
sin_zero
);
_apUdpSock
[
i
]
->
setSendPeerAddr
((
struct
sockaddr
*
)
&
peerAddr
);
}
_pReader
=
src
->
getRing
()
->
attach
(
EventPollerPool
::
Instance
().
getPoller
()
);
_pReader
=
src
->
getRing
()
->
attach
(
poller
);
_pReader
->
setReadCB
([
this
](
const
RtpPacket
::
Ptr
&
pkt
){
int
i
=
(
int
)(
pkt
->
type
);
auto
&
pSock
=
_apUdpSock
[
i
];
...
...
@@ -154,9 +154,9 @@ uint16_t RtpBroadCaster::getPort(TrackType trackType){
string
RtpBroadCaster
::
getIP
(){
return
inet_ntoa
(
_aPeerUdpAddr
[
0
].
sin_addr
);
}
RtpBroadCaster
::
Ptr
RtpBroadCaster
::
make
(
const
string
&
strLocalIp
,
const
string
&
strVhost
,
const
string
&
strApp
,
const
string
&
strStream
){
RtpBroadCaster
::
Ptr
RtpBroadCaster
::
make
(
const
EventPoller
::
Ptr
&
poller
,
const
string
&
strLocalIp
,
const
string
&
strVhost
,
const
string
&
strApp
,
const
string
&
strStream
){
try
{
auto
ret
=
Ptr
(
new
RtpBroadCaster
(
strLocalIp
,
strVhost
,
strApp
,
strStream
));
auto
ret
=
Ptr
(
new
RtpBroadCaster
(
poller
,
strLocalIp
,
strVhost
,
strApp
,
strStream
));
lock_guard
<
recursive_mutex
>
lck
(
g_mtx
);
string
strKey
=
StrPrinter
<<
strLocalIp
<<
" "
<<
strVhost
<<
" "
<<
strApp
<<
" "
<<
strStream
<<
endl
;
weak_ptr
<
RtpBroadCaster
>
weakPtr
=
ret
;
...
...
@@ -168,17 +168,17 @@ RtpBroadCaster::Ptr RtpBroadCaster::make(const string &strLocalIp,const string &
}
}
RtpBroadCaster
::
Ptr
RtpBroadCaster
::
get
(
const
string
&
strLocalIp
,
const
string
&
strVhost
,
const
string
&
strApp
,
const
string
&
strStream
)
{
RtpBroadCaster
::
Ptr
RtpBroadCaster
::
get
(
const
EventPoller
::
Ptr
&
poller
,
const
string
&
strLocalIp
,
const
string
&
strVhost
,
const
string
&
strApp
,
const
string
&
strStream
)
{
string
strKey
=
StrPrinter
<<
strLocalIp
<<
" "
<<
strVhost
<<
" "
<<
strApp
<<
" "
<<
strStream
<<
endl
;
lock_guard
<
recursive_mutex
>
lck
(
g_mtx
);
auto
it
=
g_mapBroadCaster
.
find
(
strKey
);
if
(
it
==
g_mapBroadCaster
.
end
())
{
return
make
(
strLocalIp
,
strVhost
,
strApp
,
strStream
);
return
make
(
poller
,
strLocalIp
,
strVhost
,
strApp
,
strStream
);
}
auto
ret
=
it
->
second
.
lock
();
if
(
!
ret
)
{
g_mapBroadCaster
.
erase
(
it
);
return
make
(
strLocalIp
,
strVhost
,
strApp
,
strStream
);
return
make
(
poller
,
strLocalIp
,
strVhost
,
strApp
,
strStream
);
}
return
ret
;
}
...
...
This diff is collapsed.
Click to expand it.
src/Rtsp/RtpBroadCaster.h
查看文件 @
37d842e4
...
...
@@ -71,14 +71,14 @@ public:
typedef
std
::
shared_ptr
<
RtpBroadCaster
>
Ptr
;
typedef
function
<
void
()
>
onDetach
;
virtual
~
RtpBroadCaster
();
static
Ptr
get
(
const
string
&
strLocalIp
,
const
string
&
strVhost
,
const
string
&
strApp
,
const
string
&
strStream
);
static
Ptr
get
(
const
EventPoller
::
Ptr
&
poller
,
const
string
&
strLocalIp
,
const
string
&
strVhost
,
const
string
&
strApp
,
const
string
&
strStream
);
void
setDetachCB
(
void
*
listener
,
const
onDetach
&
cb
);
uint16_t
getPort
(
TrackType
trackType
);
string
getIP
();
private
:
static
recursive_mutex
g_mtx
;
static
unordered_map
<
string
,
weak_ptr
<
RtpBroadCaster
>
>
g_mapBroadCaster
;
static
Ptr
make
(
const
string
&
strLocalIp
,
const
string
&
strVhost
,
const
string
&
strApp
,
const
string
&
strStream
);
static
Ptr
make
(
const
EventPoller
::
Ptr
&
poller
,
const
string
&
strLocalIp
,
const
string
&
strVhost
,
const
string
&
strApp
,
const
string
&
strStream
);
std
::
shared_ptr
<
uint32_t
>
_multiAddr
;
recursive_mutex
_mtx
;
...
...
@@ -87,7 +87,7 @@ private:
Socket
::
Ptr
_apUdpSock
[
2
];
struct
sockaddr_in
_aPeerUdpAddr
[
2
];
RtpBroadCaster
(
const
string
&
strLocalIp
,
const
string
&
strVhost
,
const
string
&
strApp
,
const
string
&
strStream
);
RtpBroadCaster
(
const
EventPoller
::
Ptr
&
poller
,
const
string
&
strLocalIp
,
const
string
&
strVhost
,
const
string
&
strApp
,
const
string
&
strStream
);
};
...
...
This diff is collapsed.
Click to expand it.
src/Rtsp/RtspSession.cpp
查看文件 @
37d842e4
...
...
@@ -637,7 +637,7 @@ bool RtspSession::handleReq_Setup(const Parser &parser) {
break
;
case
Rtsp
:
:
RTP_MULTICAST
:
{
if
(
!
_pBrdcaster
){
_pBrdcaster
=
RtpBroadCaster
::
get
(
get_local_ip
(),
_mediaInfo
.
_vhost
,
_mediaInfo
.
_app
,
_mediaInfo
.
_streamid
);
_pBrdcaster
=
RtpBroadCaster
::
get
(
get
Poller
(),
get
_local_ip
(),
_mediaInfo
.
_vhost
,
_mediaInfo
.
_app
,
_mediaInfo
.
_streamid
);
if
(
!
_pBrdcaster
)
{
send_NotAcceptable
();
return
false
;
...
...
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论