Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
7a7b9bbb
提交
7a7b9bbb
authored
4月 27, 2019
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Producer: allow RTP parameters with MID and single encoding without RID and SSRC
上级
8b7715a6
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
137 行增加
和
9 行删除
+137
-9
test-Producer.js
test/test-Producer.js
+48
-7
Producer.cpp
worker/src/RTC/Producer.cpp
+89
-2
没有找到文件。
test/test-Producer.js
浏览文件 @
7a7b9bbb
...
@@ -99,7 +99,8 @@ test('webRtcTransport.produce() succeeds', async () =>
...
@@ -99,7 +99,8 @@ test('webRtcTransport.produce() succeeds', async () =>
id
:
12
id
:
12
}
}
],
],
encodings
:
[
{
ssrc
:
11111111
,
dtx
:
true
}
],
// Single encoding without ssrc and rid on purpose.
encodings
:
[
{
dtx
:
true
}
],
rtcp
:
rtcp
:
{
{
cname
:
'audio-1'
cname
:
'audio-1'
...
@@ -398,7 +399,7 @@ test('webRtcTransport.produce() with unsupported codecs rejects with Unsupported
...
@@ -398,7 +399,7 @@ test('webRtcTransport.produce() with unsupported codecs rejects with Unsupported
.
toThrow
(
UnsupportedError
);
.
toThrow
(
UnsupportedError
);
},
2000
);
},
2000
);
test
(
'
webRtcT
ransport.produce() with already used MID or SSRC rejects with Error'
,
async
()
=>
test
(
'
t
ransport.produce() with already used MID or SSRC rejects with Error'
,
async
()
=>
{
{
await
expect
(
webRtcTransport
.
produce
(
await
expect
(
webRtcTransport
.
produce
(
{
{
...
@@ -426,12 +427,53 @@ test('webRtcTransport.produce() with already used MID or SSRC rejects with Error
...
@@ -426,12 +427,53 @@ test('webRtcTransport.produce() with already used MID or SSRC rejects with Error
.
rejects
.
rejects
.
toThrow
(
Error
);
.
toThrow
(
Error
);
await
expect
(
plainRtpTransport
.
produce
(
{
kind
:
'video'
,
rtpParameters
:
{
mid
:
'VIDEO2'
,
codecs
:
[
{
mimeType
:
'video/h264'
,
payloadType
:
112
,
clockRate
:
90000
,
parameters
:
{
'packetization-mode'
:
1
,
'profile-level-id'
:
'4d0032'
}
}
],
headerExtensions
:
[
{
uri
:
'urn:ietf:params:rtp-hdrext:sdes:mid'
,
id
:
10
}
],
encodings
:
[
{
ssrc
:
22222222
}
],
rtcp
:
{
cname
:
'video-1'
}
}
}))
.
rejects
.
toThrow
(
Error
);
},
2000
);
test
(
'transport.produce() with no MID and with single encoding without RID or SSRC rejects with Error'
,
async
()
=>
{
await
expect
(
webRtcTransport
.
produce
(
await
expect
(
webRtcTransport
.
produce
(
{
{
kind
:
'audio'
,
kind
:
'audio'
,
rtpParameters
:
rtpParameters
:
{
{
mid
:
'AUDIO-2'
,
codecs
:
codecs
:
[
[
{
{
...
@@ -441,9 +483,8 @@ test('webRtcTransport.produce() with already used MID or SSRC rejects with Error
...
@@ -441,9 +483,8 @@ test('webRtcTransport.produce() with already used MID or SSRC rejects with Error
channels
:
2
channels
:
2
}
}
],
],
headerExtensions
:
[],
encodings
:
[
{
dtx
:
true
}
],
encodings
:
[
{
ssrc
:
11111111
}
],
rtcp
:
rtcp
:
{
{
cname
:
'audio-2'
cname
:
'audio-2'
}
}
...
@@ -498,7 +539,7 @@ test('producer.dump() succeeds', async () =>
...
@@ -498,7 +539,7 @@ test('producer.dump() succeeds', async () =>
expect
(
data
.
rtpParameters
.
encodings
.
length
).
toBe
(
1
);
expect
(
data
.
rtpParameters
.
encodings
.
length
).
toBe
(
1
);
expect
(
data
.
rtpParameters
.
encodings
).
toEqual
(
expect
(
data
.
rtpParameters
.
encodings
).
toEqual
(
[
[
{
codecPayloadType
:
111
,
ssrc
:
11111111
,
dtx
:
true
}
{
codecPayloadType
:
111
,
dtx
:
true
}
]);
]);
expect
(
data
.
type
).
toBe
(
'simple'
);
expect
(
data
.
type
).
toBe
(
'simple'
);
...
...
worker/src/RTC/Producer.cpp
浏览文件 @
7a7b9bbb
...
@@ -58,12 +58,16 @@ namespace RTC
...
@@ -58,12 +58,16 @@ namespace RTC
auto
jsonPayloadTypeIt
=
codec
.
find
(
"payloadType"
);
auto
jsonPayloadTypeIt
=
codec
.
find
(
"payloadType"
);
if
(
jsonPayloadTypeIt
==
codec
.
end
()
||
!
jsonPayloadTypeIt
->
is_number_unsigned
())
if
(
jsonPayloadTypeIt
==
codec
.
end
()
||
!
jsonPayloadTypeIt
->
is_number_unsigned
())
{
MS_THROW_TYPE_ERROR
(
"wrong entry in rtpMapping.codecs (missing payloadType)"
);
MS_THROW_TYPE_ERROR
(
"wrong entry in rtpMapping.codecs (missing payloadType)"
);
}
auto
jsonMappedPayloadTypeIt
=
codec
.
find
(
"mappedPayloadType"
);
auto
jsonMappedPayloadTypeIt
=
codec
.
find
(
"mappedPayloadType"
);
if
(
jsonMappedPayloadTypeIt
==
codec
.
end
()
||
!
jsonMappedPayloadTypeIt
->
is_number_unsigned
())
if
(
jsonMappedPayloadTypeIt
==
codec
.
end
()
||
!
jsonMappedPayloadTypeIt
->
is_number_unsigned
())
{
MS_THROW_TYPE_ERROR
(
"wrong entry in rtpMapping.codecs (missing mappedPayloadType)"
);
MS_THROW_TYPE_ERROR
(
"wrong entry in rtpMapping.codecs (missing mappedPayloadType)"
);
}
this
->
rtpMapping
.
codecs
[
jsonPayloadTypeIt
->
get
<
uint8_t
>
()]
=
this
->
rtpMapping
.
codecs
[
jsonPayloadTypeIt
->
get
<
uint8_t
>
()]
=
jsonMappedPayloadTypeIt
->
get
<
uint8_t
>
();
jsonMappedPayloadTypeIt
->
get
<
uint8_t
>
();
...
@@ -72,7 +76,9 @@ namespace RTC
...
@@ -72,7 +76,9 @@ namespace RTC
auto
jsonEncodingsIt
=
jsonRtpMappingIt
->
find
(
"encodings"
);
auto
jsonEncodingsIt
=
jsonRtpMappingIt
->
find
(
"encodings"
);
if
(
jsonEncodingsIt
==
jsonRtpMappingIt
->
end
()
||
!
jsonEncodingsIt
->
is_array
())
if
(
jsonEncodingsIt
==
jsonRtpMappingIt
->
end
()
||
!
jsonEncodingsIt
->
is_array
())
{
MS_THROW_TYPE_ERROR
(
"missing rtpMapping.encodings"
);
MS_THROW_TYPE_ERROR
(
"missing rtpMapping.encodings"
);
}
this
->
rtpMapping
.
encodings
.
reserve
(
jsonEncodingsIt
->
size
());
this
->
rtpMapping
.
encodings
.
reserve
(
jsonEncodingsIt
->
size
());
...
@@ -97,9 +103,25 @@ namespace RTC
...
@@ -97,9 +103,25 @@ namespace RTC
if
(
jsonRidIt
!=
encoding
.
end
()
&&
jsonRidIt
->
is_string
())
if
(
jsonRidIt
!=
encoding
.
end
()
&&
jsonRidIt
->
is_string
())
encodingMapping
.
rid
=
jsonRidIt
->
get
<
std
::
string
>
();
encodingMapping
.
rid
=
jsonRidIt
->
get
<
std
::
string
>
();
// However ssrc or rid must be present.
// However ssrc or rid must be present (if more than 1 encoding).
if
(
jsonSsrcIt
==
encoding
.
end
()
&&
jsonRidIt
==
encoding
.
end
())
if
(
jsonEncodingsIt
->
size
()
>
1
&&
jsonSsrcIt
==
encoding
.
end
()
&&
jsonRidIt
==
encoding
.
end
())
{
MS_THROW_TYPE_ERROR
(
"wrong entry in rtpMapping.encodings (missing ssrc or rid)"
);
MS_THROW_TYPE_ERROR
(
"wrong entry in rtpMapping.encodings (missing ssrc or rid)"
);
}
// If there is no mid and a single encoding, ssrc or rid must be present.
// clang-format off
if
(
this
->
rtpParameters
.
mid
.
empty
()
&&
jsonEncodingsIt
->
size
()
==
1
&&
jsonSsrcIt
==
encoding
.
end
()
&&
jsonRidIt
==
encoding
.
end
()
)
// clang-format on
{
MS_THROW_TYPE_ERROR
(
"wrong entry in rtpMapping.encodings (missing ssrc or rid, or rtpParameters.mid)"
);
}
// mappedSsrc is mandatory.
// mappedSsrc is mandatory.
auto
jsonMappedSsrcIt
=
encoding
.
find
(
"mappedSsrc"
);
auto
jsonMappedSsrcIt
=
encoding
.
find
(
"mappedSsrc"
);
...
@@ -727,6 +749,71 @@ namespace RTC
...
@@ -727,6 +749,71 @@ namespace RTC
return
nullptr
;
return
nullptr
;
}
}
// If not found, and there is a single encoding, this may be a media or RTX
// stream and the single encoding does not signal nor SSRC nor RID.
//
// clang-format off
if
(
this
->
rtpParameters
.
encodings
.
size
()
==
1
&&
this
->
mapSsrcRtpStream
.
size
()
<=
1
)
// clang-format on
{
auto
&
encoding
=
this
->
rtpParameters
.
encodings
[
0
];
auto
*
mediaCodec
=
this
->
rtpParameters
.
GetCodecForEncoding
(
encoding
);
auto
*
rtxCodec
=
this
->
rtpParameters
.
GetRtxCodecForEncoding
(
encoding
);
bool
isMediaPacket
=
(
mediaCodec
->
payloadType
==
payloadType
);
bool
isRtxPacket
=
(
rtxCodec
&&
rtxCodec
->
payloadType
==
payloadType
);
if
(
isMediaPacket
)
{
// Ensure there is no other RTP stream already.
if
(
!
this
->
mapSsrcRtpStream
.
empty
())
{
MS_WARN_TAG
(
rtp
,
"ignoring packet with unknown ssrc not matching the already existing stream (single RtpStream lookup)"
);
return
nullptr
;
}
auto
*
rtpStream
=
CreateRtpStream
(
packet
,
*
mediaCodec
,
0
);
return
rtpStream
;
}
else
if
(
isRtxPacket
)
{
// There must be already a media RTP stream.
auto
it
=
this
->
mapSsrcRtpStream
.
begin
();
if
(
it
==
this
->
mapSsrcRtpStream
.
end
())
{
MS_DEBUG_2TAGS
(
rtp
,
rtx
,
"ignoring RTX packet for not yet created RtpStream (single stream lookup)"
);
return
nullptr
;
}
auto
*
rtpStream
=
it
->
second
;
// Ensure no RTX SSRC was previously detected.
if
(
rtpStream
->
HasRtx
())
{
MS_DEBUG_2TAGS
(
rtp
,
rtx
,
"ignoring RTX packet with new SSRC (single stream lookup)"
);
return
nullptr
;
}
// Update the stream RTX data.
rtpStream
->
SetRtx
(
payloadType
,
ssrc
);
// Insert the new RTX SSRC into the map.
this
->
mapRtxSsrcRtpStream
[
ssrc
]
=
rtpStream
;
return
rtpStream
;
}
}
return
nullptr
;
return
nullptr
;
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论