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
76ebf02c
Commit
76ebf02c
authored
Jun 25, 2021
by
ziyue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
记录所有rtp的ssrc
parent
a7f75774
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
26 行增加
和
5 行删除
+26
-5
webrtc/RtpExt.cpp
+12
-1
webrtc/RtpExt.h
+7
-0
webrtc/WebRtcTransport.cpp
+7
-4
没有找到文件。
webrtc/RtpExt.cpp
查看文件 @
76ebf02c
...
@@ -624,10 +624,21 @@ void RtpExtContext::changeRtpExtId(const RtpHeader *header, bool is_recv, string
...
@@ -624,10 +624,21 @@ void RtpExtContext::changeRtpExtId(const RtpHeader *header, bool is_recv, string
}
else
{
}
else
{
//设置rid
//设置rid
if
(
_ssrc_to_rid
.
emplace
(
ssrc
,
rid
).
second
)
{
if
(
_ssrc_to_rid
.
emplace
(
ssrc
,
rid
).
second
)
{
InfoL
<<
"rid of ssrc "
<<
ssrc
<<
" is:"
<<
rid
;
onGetRtp
(
header
->
pt
,
ssrc
,
rid
)
;
}
}
}
}
if
(
rid_ptr
)
{
if
(
rid_ptr
)
{
*
rid_ptr
=
rid
;
*
rid_ptr
=
rid
;
}
}
}
}
void
RtpExtContext
::
setOnGetRtp
(
OnGetRtp
cb
)
{
_cb
=
std
::
move
(
cb
);
}
void
RtpExtContext
::
onGetRtp
(
uint8_t
pt
,
uint32_t
ssrc
,
const
string
&
rid
){
if
(
_cb
)
{
_cb
(
pt
,
ssrc
,
rid
);
}
}
webrtc/RtpExt.h
查看文件 @
76ebf02c
...
@@ -112,13 +112,20 @@ class RtcMedia;
...
@@ -112,13 +112,20 @@ class RtcMedia;
class
RtpExtContext
{
class
RtpExtContext
{
public
:
public
:
using
Ptr
=
std
::
shared_ptr
<
RtpExtContext
>
;
using
Ptr
=
std
::
shared_ptr
<
RtpExtContext
>
;
using
OnGetRtp
=
function
<
void
(
uint8_t
pt
,
uint32_t
ssrc
,
const
string
&
rid
)
>
;
RtpExtContext
(
const
RtcMedia
&
media
);
RtpExtContext
(
const
RtcMedia
&
media
);
~
RtpExtContext
()
=
default
;
~
RtpExtContext
()
=
default
;
void
setOnGetRtp
(
OnGetRtp
cb
);
string
getRid
(
uint32_t
ssrc
)
const
;
string
getRid
(
uint32_t
ssrc
)
const
;
void
changeRtpExtId
(
const
RtpHeader
*
header
,
bool
is_recv
,
string
*
rid_ptr
=
nullptr
);
void
changeRtpExtId
(
const
RtpHeader
*
header
,
bool
is_recv
,
string
*
rid_ptr
=
nullptr
);
private
:
private
:
void
onGetRtp
(
uint8_t
pt
,
uint32_t
ssrc
,
const
string
&
rid
);
private
:
OnGetRtp
_cb
;
//发送rtp时需要修改rtp ext id
//发送rtp时需要修改rtp ext id
map
<
RtpExtType
,
uint8_t
>
_rtp_ext_type_to_id
;
map
<
RtpExtType
,
uint8_t
>
_rtp_ext_type_to_id
;
//接收rtp时需要修改rtp ext id
//接收rtp时需要修改rtp ext id
...
...
webrtc/WebRtcTransport.cpp
查看文件 @
76ebf02c
...
@@ -412,9 +412,11 @@ void WebRtcTransportImp::onStartWebRTC() {
...
@@ -412,9 +412,11 @@ void WebRtcTransportImp::onStartWebRTC() {
//send ssrc --> MediaTrack
//send ssrc --> MediaTrack
_ssrc_to_track
[
info
->
answer_ssrc_rtp
]
=
info
;
_ssrc_to_track
[
info
->
answer_ssrc_rtp
]
=
info
;
_ssrc_to_track
[
info
->
answer_ssrc_rtx
]
=
info
;
//recv ssrc --> MediaTrack
//recv ssrc --> MediaTrack
_ssrc_to_track
[
info
->
offer_ssrc_rtp
]
=
info
;
_ssrc_to_track
[
info
->
offer_ssrc_rtp
]
=
info
;
_ssrc_to_track
[
info
->
offer_ssrc_rtx
]
=
info
;
//rtp pt --> MediaTrack
//rtp pt --> MediaTrack
_pt_to_track
.
emplace
(
info
->
plan_rtp
->
pt
,
std
::
make_pair
(
false
,
info
));
_pt_to_track
.
emplace
(
info
->
plan_rtp
->
pt
,
std
::
make_pair
(
false
,
info
));
...
@@ -425,6 +427,11 @@ void WebRtcTransportImp::onStartWebRTC() {
...
@@ -425,6 +427,11 @@ void WebRtcTransportImp::onStartWebRTC() {
if
(
m_offer
->
type
!=
TrackApplication
)
{
if
(
m_offer
->
type
!=
TrackApplication
)
{
//记录rtp ext类型与id的关系,方便接收或发送rtp时修改rtp ext id
//记录rtp ext类型与id的关系,方便接收或发送rtp时修改rtp ext id
info
->
rtp_ext_ctx
=
std
::
make_shared
<
RtpExtContext
>
(
*
m_offer
);
info
->
rtp_ext_ctx
=
std
::
make_shared
<
RtpExtContext
>
(
*
m_offer
);
info
->
rtp_ext_ctx
->
setOnGetRtp
([
this
,
info
](
uint8_t
pt
,
uint32_t
ssrc
,
const
string
&
rid
)
{
//ssrc --> MediaTrack
_ssrc_to_track
[
ssrc
]
=
info
;
InfoL
<<
"get rtp, pt:"
<<
(
int
)
pt
<<
", ssrc:"
<<
ssrc
<<
", rid:"
<<
rid
;
});
}
}
}
}
...
@@ -690,8 +697,6 @@ void WebRtcTransportImp::createRtpChannel(const string &rid, uint32_t ssrc, cons
...
@@ -690,8 +697,6 @@ void WebRtcTransportImp::createRtpChannel(const string &rid, uint32_t ssrc, cons
});
});
//rid --> rtp ssrc
//rid --> rtp ssrc
ref
->
rtp_ssrc
=
ssrc
;
ref
->
rtp_ssrc
=
ssrc
;
//rtp ssrc --> MediaTrack
_ssrc_to_track
[
ssrc
]
=
info
;
InfoL
<<
"create rtp receiver of ssrc:"
<<
ssrc
<<
", rid:"
<<
rid
<<
", codec:"
<<
info
->
plan_rtp
->
codec
;
InfoL
<<
"create rtp receiver of ssrc:"
<<
ssrc
<<
", rid:"
<<
rid
<<
", codec:"
<<
info
->
plan_rtp
->
codec
;
}
}
...
@@ -729,7 +734,6 @@ void WebRtcTransportImp::onRtp(const char *buf, size_t len) {
...
@@ -729,7 +734,6 @@ void WebRtcTransportImp::onRtp(const char *buf, size_t len) {
auto seq = ntohs(rtp->seq);
auto seq = ntohs(rtp->seq);
if (info->media->type == TrackVideo && seq % 100 == 0) {
if (info->media->type == TrackVideo && seq % 100 == 0) {
//此处模拟接受丢包
//此处模拟接受丢包
DebugL << "recv dropped:" << seq << ", rid:" << rid << ", ssrc:" << ssrc;
return;
return;
}
}
#endif
#endif
...
@@ -820,7 +824,6 @@ void WebRtcTransportImp::onSendRtp(const RtpPacket::Ptr &rtp, bool flush, bool r
...
@@ -820,7 +824,6 @@ void WebRtcTransportImp::onSendRtp(const RtpPacket::Ptr &rtp, bool flush, bool r
#if 0
#if 0
//此处模拟发送丢包
//此处模拟发送丢包
if (rtp->type == TrackVideo && rtp->getSeq() % 100 == 0) {
if (rtp->type == TrackVideo && rtp->getSeq() % 100 == 0) {
DebugL << "send dropped:" << rtp->getSeq();
return;
return;
}
}
#endif
#endif
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论