Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
e549e5bc
提交
e549e5bc
authored
9月 11, 2017
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
RtpListener: remove payload type based table
上级
38a3161f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
6 行增加
和
120 行删除
+6
-120
RtpListener.hpp
worker/include/RTC/RtpListener.hpp
+1
-21
RtpListener.cpp
worker/src/RTC/RtpListener.cpp
+5
-99
没有找到文件。
worker/include/RTC/RtpListener.hpp
浏览文件 @
e549e5bc
...
@@ -19,7 +19,6 @@ namespace RTC
...
@@ -19,7 +19,6 @@ namespace RTC
Json
::
Value
ToJson
()
const
;
Json
::
Value
ToJson
()
const
;
bool
HasSsrc
(
uint32_t
ssrc
,
const
RTC
::
Producer
*
producer
)
const
;
bool
HasSsrc
(
uint32_t
ssrc
,
const
RTC
::
Producer
*
producer
)
const
;
bool
HasMuxId
(
const
std
::
string
&
muxId
,
const
RTC
::
Producer
*
producer
)
const
;
bool
HasMuxId
(
const
std
::
string
&
muxId
,
const
RTC
::
Producer
*
producer
)
const
;
bool
HasPayloadType
(
uint8_t
payloadType
,
const
RTC
::
Producer
*
producer
)
const
;
void
AddProducer
(
RTC
::
Producer
*
producer
);
void
AddProducer
(
RTC
::
Producer
*
producer
);
void
RemoveProducer
(
const
RTC
::
Producer
*
producer
);
void
RemoveProducer
(
const
RTC
::
Producer
*
producer
);
RTC
::
Producer
*
GetProducer
(
RTC
::
RtpPacket
*
packet
);
RTC
::
Producer
*
GetProducer
(
RTC
::
RtpPacket
*
packet
);
...
@@ -27,18 +26,13 @@ namespace RTC
...
@@ -27,18 +26,13 @@ namespace RTC
private
:
private
:
void
RollbackProducer
(
void
RollbackProducer
(
RTC
::
Producer
*
producer
,
RTC
::
Producer
*
producer
,
std
::
vector
<
uint32_t
>&
previousSsrcs
,
std
::
string
&
previousMuxId
);
std
::
vector
<
uint32_t
>&
previousSsrcs
,
std
::
string
&
previousMuxId
,
std
::
vector
<
uint8_t
>&
previousPayloadTypes
);
public
:
public
:
// Table of SSRC / Producer pairs.
// Table of SSRC / Producer pairs.
std
::
unordered_map
<
uint32_t
,
RTC
::
Producer
*>
ssrcTable
;
std
::
unordered_map
<
uint32_t
,
RTC
::
Producer
*>
ssrcTable
;
// Table of MID RTP header extension / Producer pairs.
// Table of MID RTP header extension / Producer pairs.
std
::
unordered_map
<
std
::
string
,
const
RTC
::
Producer
*>
muxIdTable
;
std
::
unordered_map
<
std
::
string
,
const
RTC
::
Producer
*>
muxIdTable
;
// Table of RTP payload type / Producer pairs.
std
::
unordered_map
<
uint8_t
,
RTC
::
Producer
*>
ptTable
;
};
};
/* Inline instance methods. */
/* Inline instance methods. */
...
@@ -70,20 +64,6 @@ namespace RTC
...
@@ -70,20 +64,6 @@ namespace RTC
return
(
it
->
second
!=
producer
);
return
(
it
->
second
!=
producer
);
}
}
}
}
inline
bool
RtpListener
::
HasPayloadType
(
uint8_t
payloadType
,
const
RTC
::
Producer
*
producer
)
const
{
auto
it
=
this
->
ptTable
.
find
(
payloadType
);
if
(
it
==
this
->
ptTable
.
end
())
{
return
false
;
}
else
{
return
(
it
->
second
!=
producer
);
}
}
}
// namespace RTC
}
// namespace RTC
#endif
#endif
worker/src/RTC/RtpListener.cpp
浏览文件 @
e549e5bc
...
@@ -16,12 +16,10 @@ namespace RTC
...
@@ -16,12 +16,10 @@ namespace RTC
static
const
Json
::
StaticString
JsonStringSsrcTable
{
"ssrcTable"
};
static
const
Json
::
StaticString
JsonStringSsrcTable
{
"ssrcTable"
};
static
const
Json
::
StaticString
JsonStringMuxIdTable
{
"muxIdTable"
};
static
const
Json
::
StaticString
JsonStringMuxIdTable
{
"muxIdTable"
};
static
const
Json
::
StaticString
JsonStringPtTable
{
"ptTable"
};
Json
::
Value
json
(
Json
::
objectValue
);
Json
::
Value
json
(
Json
::
objectValue
);
Json
::
Value
jsonSsrcTable
(
Json
::
objectValue
);
Json
::
Value
jsonSsrcTable
(
Json
::
objectValue
);
Json
::
Value
jsonMuxIdTable
(
Json
::
objectValue
);
Json
::
Value
jsonMuxIdTable
(
Json
::
objectValue
);
Json
::
Value
jsonPtTable
(
Json
::
objectValue
);
// Add ssrcTable.
// Add ssrcTable.
for
(
auto
&
kv
:
this
->
ssrcTable
)
for
(
auto
&
kv
:
this
->
ssrcTable
)
...
@@ -43,16 +41,6 @@ namespace RTC
...
@@ -43,16 +41,6 @@ namespace RTC
}
}
json
[
JsonStringMuxIdTable
]
=
jsonMuxIdTable
;
json
[
JsonStringMuxIdTable
]
=
jsonMuxIdTable
;
// Add ptTable.
for
(
auto
&
kv
:
this
->
ptTable
)
{
auto
payloadType
=
kv
.
first
;
auto
producer
=
kv
.
second
;
jsonPtTable
[
std
::
to_string
(
payloadType
)]
=
std
::
to_string
(
producer
->
producerId
);
}
json
[
JsonStringPtTable
]
=
jsonPtTable
;
return
json
;
return
json
;
}
}
...
@@ -66,7 +54,6 @@ namespace RTC
...
@@ -66,7 +54,6 @@ namespace RTC
std
::
vector
<
uint32_t
>
previousSsrcs
;
std
::
vector
<
uint32_t
>
previousSsrcs
;
std
::
string
previousMuxId
;
std
::
string
previousMuxId
;
std
::
vector
<
uint8_t
>
previousPayloadTypes
;
for
(
auto
&
kv
:
this
->
ssrcTable
)
for
(
auto
&
kv
:
this
->
ssrcTable
)
{
{
...
@@ -89,15 +76,6 @@ namespace RTC
...
@@ -89,15 +76,6 @@ namespace RTC
}
}
}
}
for
(
auto
&
kv
:
this
->
ptTable
)
{
auto
payloadType
=
kv
.
first
;
auto
&
existingProducer
=
kv
.
second
;
if
(
existingProducer
==
producer
)
previousPayloadTypes
.
push_back
(
payloadType
);
}
// First remove from the listener tables all the entries pointing to
// First remove from the listener tables all the entries pointing to
// the given Producer.
// the given Producer.
RemoveProducer
(
producer
);
RemoveProducer
(
producer
);
...
@@ -121,7 +99,7 @@ namespace RTC
...
@@ -121,7 +99,7 @@ namespace RTC
else
else
{
{
RemoveProducer
(
producer
);
RemoveProducer
(
producer
);
RollbackProducer
(
producer
,
previousSsrcs
,
previousMuxId
,
previousPayloadTypes
);
RollbackProducer
(
producer
,
previousSsrcs
,
previousMuxId
);
MS_THROW_ERROR
(
"ssrc already exists in RTP listener [ssrc:%"
PRIu32
"]"
,
ssrc
);
MS_THROW_ERROR
(
"ssrc already exists in RTP listener [ssrc:%"
PRIu32
"]"
,
ssrc
);
}
}
...
@@ -140,7 +118,7 @@ namespace RTC
...
@@ -140,7 +118,7 @@ namespace RTC
else
else
{
{
RemoveProducer
(
producer
);
RemoveProducer
(
producer
);
RollbackProducer
(
producer
,
previousSsrcs
,
previousMuxId
,
previousPayloadTypes
);
RollbackProducer
(
producer
,
previousSsrcs
,
previousMuxId
);
MS_THROW_ERROR
(
"ssrc already exists in RTP listener [ssrc:%"
PRIu32
"]"
,
ssrc
);
MS_THROW_ERROR
(
"ssrc already exists in RTP listener [ssrc:%"
PRIu32
"]"
,
ssrc
);
}
}
...
@@ -159,7 +137,7 @@ namespace RTC
...
@@ -159,7 +137,7 @@ namespace RTC
else
else
{
{
RemoveProducer
(
producer
);
RemoveProducer
(
producer
);
RollbackProducer
(
producer
,
previousSsrcs
,
previousMuxId
,
previousPayloadTypes
);
RollbackProducer
(
producer
,
previousSsrcs
,
previousMuxId
);
MS_THROW_ERROR
(
"ssrc already exists in RTP listener [ssrc:%"
PRIu32
"]"
,
ssrc
);
MS_THROW_ERROR
(
"ssrc already exists in RTP listener [ssrc:%"
PRIu32
"]"
,
ssrc
);
}
}
...
@@ -180,53 +158,12 @@ namespace RTC
...
@@ -180,53 +158,12 @@ namespace RTC
else
else
{
{
RemoveProducer
(
producer
);
RemoveProducer
(
producer
);
RollbackProducer
(
producer
,
previousSsrcs
,
previousMuxId
,
previousPayloadTypes
);
RollbackProducer
(
producer
,
previousSsrcs
,
previousMuxId
);
MS_THROW_ERROR
(
"muxId already exists in RTP listener [muxId:'%s']"
,
muxId
.
c_str
());
MS_THROW_ERROR
(
"muxId already exists in RTP listener [muxId:'%s']"
,
muxId
.
c_str
());
}
}
}
}
}
}
// Add entries into ptTable just if:
// - Not all the encoding.ssrc are given, or
// - Not all the encoding.rtx.ssrc are given, or
// - Not all the encoding.fec.ssrc are given.
{
auto
it
=
rtpParameters
.
encodings
.
begin
();
for
(;
it
!=
rtpParameters
.
encodings
.
end
();
++
it
)
{
auto
&
encoding
=
*
it
;
if
(
(
encoding
.
ssrc
==
0u
)
||
(
encoding
.
hasRtx
&&
(
encoding
.
rtx
.
ssrc
==
0u
))
||
(
encoding
.
hasFec
&&
(
encoding
.
fec
.
ssrc
==
0u
)))
{
break
;
}
}
if
(
it
!=
rtpParameters
.
encodings
.
end
())
{
for
(
auto
&
codec
:
rtpParameters
.
codecs
)
{
uint8_t
payloadType
=
codec
.
payloadType
;
if
(
!
this
->
HasPayloadType
(
payloadType
,
producer
))
{
this
->
ptTable
[
payloadType
]
=
producer
;
}
else
{
RemoveProducer
(
producer
);
RollbackProducer
(
producer
,
previousSsrcs
,
previousMuxId
,
previousPayloadTypes
);
MS_THROW_ERROR
(
"payloadType already exists in RTP listener [payloadType:%"
PRIu8
"]"
,
payloadType
);
}
}
}
}
}
}
void
RtpListener
::
RemoveProducer
(
const
RTC
::
Producer
*
producer
)
void
RtpListener
::
RemoveProducer
(
const
RTC
::
Producer
*
producer
)
...
@@ -251,14 +188,6 @@ namespace RTC
...
@@ -251,14 +188,6 @@ namespace RTC
else
else
++
it
;
++
it
;
}
}
for
(
auto
it
=
this
->
ptTable
.
begin
();
it
!=
this
->
ptTable
.
end
();)
{
if
(
it
->
second
==
producer
)
it
=
this
->
ptTable
.
erase
(
it
);
else
++
it
;
}
}
}
RTC
::
Producer
*
RtpListener
::
GetProducer
(
RTC
::
RtpPacket
*
packet
)
RTC
::
Producer
*
RtpListener
::
GetProducer
(
RTC
::
RtpPacket
*
packet
)
...
@@ -295,21 +224,6 @@ namespace RTC
...
@@ -295,21 +224,6 @@ namespace RTC
// Otherwise lookup into the muxId table.
// Otherwise lookup into the muxId table.
// TODO: do it.
// TODO: do it.
// Otherwise lookup into the PT table.
{
auto
it
=
this
->
ptTable
.
find
(
packet
->
GetPayloadType
());
if
(
it
!=
this
->
ptTable
.
end
())
{
auto
producer
=
it
->
second
;
// Update SSRC table.
this
->
ssrcTable
[
packet
->
GetSsrc
()]
=
producer
;
return
producer
;
}
}
// TODO: We may emit "unhandledrtp" event.
// TODO: We may emit "unhandledrtp" event.
return
nullptr
;
return
nullptr
;
}
}
...
@@ -330,10 +244,7 @@ namespace RTC
...
@@ -330,10 +244,7 @@ namespace RTC
}
}
void
RtpListener
::
RollbackProducer
(
void
RtpListener
::
RollbackProducer
(
RTC
::
Producer
*
producer
,
RTC
::
Producer
*
producer
,
std
::
vector
<
uint32_t
>&
previousSsrcs
,
std
::
string
&
previousMuxId
)
std
::
vector
<
uint32_t
>&
previousSsrcs
,
std
::
string
&
previousMuxId
,
std
::
vector
<
uint8_t
>&
previousPayloadTypes
)
{
{
MS_TRACE
();
MS_TRACE
();
...
@@ -344,10 +255,5 @@ namespace RTC
...
@@ -344,10 +255,5 @@ namespace RTC
if
(
!
previousMuxId
.
empty
())
if
(
!
previousMuxId
.
empty
())
this
->
muxIdTable
[
previousMuxId
]
=
producer
;
this
->
muxIdTable
[
previousMuxId
]
=
producer
;
for
(
auto
payloadType
:
previousPayloadTypes
)
{
this
->
ptTable
[
payloadType
]
=
producer
;
}
}
}
}
// namespace RTC
}
// namespace RTC
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论