Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
5c7ce6c3
Unverified
提交
5c7ce6c3
authored
1月 01, 2024
作者:
Iñaki Baz Castillo
提交者:
GitHub
1月 01, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rust: expose DataChannel string message as binary (#1289)
上级
bf501b2c
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
43 行增加
和
29 行删除
+43
-29
CHANGELOG.md
rust/CHANGELOG.md
+4
-0
data_structures.rs
rust/src/data_structures.rs
+6
-8
direct_transport.rs
rust/tests/integration/direct_transport.rs
+33
-21
没有找到文件。
rust/CHANGELOG.md
浏览文件 @
5c7ce6c3
# Changelog
# NEXT
*
Expose DataChannel string message as binary (PR #1289).
# 0.14.0
*
Updates from mediasoup TypeScript
`3.13.8..=3.13.12`
.
...
...
rust/src/data_structures.rs
浏览文件 @
5c7ce6c3
...
...
@@ -1047,7 +1047,7 @@ impl TraceEventDirection {
#[derive(Debug,
Clone)]
pub
enum
WebRtcMessage
<
'a
>
{
/// String
String
(
String
),
String
(
Cow
<
'a
,
[
u8
]
>
),
/// Binary
Binary
(
Cow
<
'a
,
[
u8
]
>
),
/// EmptyString
...
...
@@ -1070,9 +1070,7 @@ impl<'a> WebRtcMessage<'a> {
pub
(
crate
)
fn
new
(
ppid
:
u32
,
payload
:
Cow
<
'a
,
[
u8
]
>
)
->
Result
<
Self
,
u32
>
{
match
ppid
{
51
=>
Ok
(
WebRtcMessage
::
String
(
String
::
from_utf8
(
payload
.to_vec
())
.unwrap
(),
)),
51
=>
Ok
(
WebRtcMessage
::
String
(
payload
)),
53
=>
Ok
(
WebRtcMessage
::
Binary
(
payload
)),
56
=>
Ok
(
WebRtcMessage
::
EmptyString
),
57
=>
Ok
(
WebRtcMessage
::
EmptyBinary
),
...
...
@@ -1082,9 +1080,9 @@ impl<'a> WebRtcMessage<'a> {
pub
(
crate
)
fn
into_ppid_and_payload
(
self
)
->
(
u32
,
Cow
<
'a
,
[
u8
]
>
)
{
match
self
{
WebRtcMessage
::
String
(
string
)
=>
(
51
_u32
,
Cow
::
from
(
string
.into_bytes
())
),
WebRtcMessage
::
String
(
binary
)
=>
(
51
_u32
,
binary
),
WebRtcMessage
::
Binary
(
binary
)
=>
(
53
_u32
,
binary
),
WebRtcMessage
::
EmptyString
=>
(
56
_u32
,
Cow
::
from
(
b
" "
.as_ref
()
)),
WebRtcMessage
::
EmptyString
=>
(
56
_u32
,
Cow
::
from
(
vec!
[
0
_u8
]
)),
WebRtcMessage
::
EmptyBinary
=>
(
57
_u32
,
Cow
::
from
(
vec!
[
0
_u8
])),
}
}
...
...
@@ -1092,7 +1090,7 @@ impl<'a> WebRtcMessage<'a> {
/// Convert to owned message
pub
fn
into_owned
(
self
)
->
OwnedWebRtcMessage
{
match
self
{
WebRtcMessage
::
String
(
string
)
=>
OwnedWebRtcMessage
::
String
(
string
),
WebRtcMessage
::
String
(
binary
)
=>
OwnedWebRtcMessage
::
String
(
binary
.into_owned
()
),
WebRtcMessage
::
Binary
(
binary
)
=>
OwnedWebRtcMessage
::
Binary
(
binary
.into_owned
()),
WebRtcMessage
::
EmptyString
=>
OwnedWebRtcMessage
::
EmptyString
,
WebRtcMessage
::
EmptyBinary
=>
OwnedWebRtcMessage
::
EmptyBinary
,
...
...
@@ -1105,7 +1103,7 @@ impl<'a> WebRtcMessage<'a> {
#[derive(Debug,
Clone)]
pub
enum
OwnedWebRtcMessage
{
/// String
String
(
String
),
String
(
Vec
<
u8
>
),
/// Binary
Binary
(
Vec
<
u8
>
),
/// EmptyString
...
...
rust/tests/integration/direct_transport.rs
浏览文件 @
5c7ce6c3
...
...
@@ -202,19 +202,19 @@ fn send_succeeds() {
move
|
message
|
{
let
id
:
usize
=
match
message
{
WebRtcMessage
::
String
(
string
)
=>
{
recv_message_bytes
.fetch_add
(
string
.as_bytes
()
.len
(),
Ordering
::
SeqCst
);
string
.parse
()
.unwrap
()
WebRtcMessage
::
String
(
binary
)
=>
{
recv_message_bytes
.fetch_add
(
binary
.len
(),
Ordering
::
SeqCst
);
String
::
from_utf8
(
binary
.to_vec
())
.unwrap
()
.parse
()
.unwrap
()
}
WebRtcMessage
::
Binary
(
binary
)
=>
{
recv_message_bytes
.fetch_add
(
binary
.len
(),
Ordering
::
SeqCst
);
String
::
from_utf8
(
binary
.to_vec
())
.unwrap
()
.parse
()
.unwrap
()
}
WebRtcMessage
::
EmptyString
=>
{
panic!
(
"Unexpected empty message
s
!"
);
panic!
(
"Unexpected empty message!"
);
}
WebRtcMessage
::
EmptyBinary
=>
{
panic!
(
"Unexpected empty message
s
!"
);
panic!
(
"Unexpected empty message!"
);
}
};
...
...
@@ -266,14 +266,14 @@ fn send_succeeds() {
}
let
message
=
if
id
<
num_messages
/
2
{
let
content
=
id
.to_string
();
let
content
=
id
.to_string
()
.into_bytes
()
;
sent_message_bytes
+=
content
.len
();
if
!
data_producer
.paused
()
&&
!
data_consumer
.paused
()
{
effectively_sent_message_bytes
+=
content
.len
();
}
WebRtcMessage
::
String
(
content
)
WebRtcMessage
::
String
(
Cow
::
from
(
content
)
)
}
else
{
let
content
=
id
.to_string
()
.into_bytes
();
sent_message_bytes
+=
content
.len
();
...
...
@@ -388,9 +388,9 @@ fn send_with_subchannels_succeeds() {
move
|
message
|
{
let
text
:
String
=
match
message
{
WebRtcMessage
::
String
(
string
)
=>
string
.parse
(
)
.unwrap
(),
WebRtcMessage
::
String
(
binary
)
=>
String
::
from_utf8
(
binary
.to_vec
()
)
.unwrap
(),
_
=>
{
panic!
(
"Unexpected empty message
s
!"
);
panic!
(
"Unexpected empty message!"
);
}
};
...
...
@@ -409,9 +409,9 @@ fn send_with_subchannels_succeeds() {
move
|
message
|
{
let
text
:
String
=
match
message
{
WebRtcMessage
::
String
(
string
)
=>
string
.parse
(
)
.unwrap
(),
WebRtcMessage
::
String
(
binary
)
=>
String
::
from_utf8
(
binary
.to_vec
()
)
.unwrap
(),
_
=>
{
panic!
(
"Unexpected empty message
s
!"
);
panic!
(
"Unexpected empty message!"
);
}
};
...
...
@@ -444,13 +444,17 @@ fn send_with_subchannels_succeeds() {
// Must be received by dataConsumer1 and dataConsumer2.
direct_data_producer
.send
(
WebRtcMessage
::
String
(
both
.to_string
()),
None
,
None
)
.send
(
WebRtcMessage
::
String
(
Cow
::
Borrowed
(
both
.as_bytes
())),
None
,
None
,
)
.expect
(
"Failed to send message"
);
// Must be received by dataConsumer1 and dataConsumer2.
direct_data_producer
.send
(
WebRtcMessage
::
String
(
both
.to_string
(
)),
WebRtcMessage
::
String
(
Cow
::
Borrowed
(
both
.as_bytes
()
)),
Some
(
vec!
[
1
,
2
]),
None
,
)
...
...
@@ -459,7 +463,7 @@ fn send_with_subchannels_succeeds() {
// Must be received by dataConsumer1 and dataConsumer2.
direct_data_producer
.send
(
WebRtcMessage
::
String
(
both
.to_string
(
)),
WebRtcMessage
::
String
(
Cow
::
Borrowed
(
both
.as_bytes
()
)),
Some
(
vec!
[
11
,
22
,
33
]),
Some
(
666
),
)
...
...
@@ -468,7 +472,7 @@ fn send_with_subchannels_succeeds() {
// Must not be received by neither dataConsumer1 nor dataConsumer2.
direct_data_producer
.send
(
WebRtcMessage
::
String
(
none
.to_string
(
)),
WebRtcMessage
::
String
(
Cow
::
Borrowed
(
none
.as_bytes
()
)),
Some
(
vec!
[
3
]),
Some
(
666
),
)
...
...
@@ -477,7 +481,7 @@ fn send_with_subchannels_succeeds() {
// Must not be received by neither dataConsumer1 nor dataConsumer2.
direct_data_producer
.send
(
WebRtcMessage
::
String
(
none
.to_string
(
)),
WebRtcMessage
::
String
(
Cow
::
Borrowed
(
none
.as_bytes
()
)),
Some
(
vec!
[
666
]),
Some
(
3
),
)
...
...
@@ -485,18 +489,26 @@ fn send_with_subchannels_succeeds() {
// Must be received by dataConsumer1.
direct_data_producer
.send
(
WebRtcMessage
::
String
(
dc1
.to_string
()),
Some
(
vec!
[
1
]),
None
)
.send
(
WebRtcMessage
::
String
(
Cow
::
Borrowed
(
dc1
.as_bytes
())),
Some
(
vec!
[
1
]),
None
,
)
.expect
(
"Failed to send message"
);
// Must be received by dataConsumer1.
direct_data_producer
.send
(
WebRtcMessage
::
String
(
dc1
.to_string
()),
Some
(
vec!
[
11
]),
None
)
.send
(
WebRtcMessage
::
String
(
Cow
::
Borrowed
(
dc1
.as_bytes
())),
Some
(
vec!
[
11
]),
None
,
)
.expect
(
"Failed to send message"
);
// Must be received by dataConsumer1.
direct_data_producer
.send
(
WebRtcMessage
::
String
(
dc1
.to_string
(
)),
WebRtcMessage
::
String
(
Cow
::
Borrowed
(
dc1
.as_bytes
()
)),
Some
(
vec!
[
666
]),
Some
(
11
),
)
...
...
@@ -505,7 +517,7 @@ fn send_with_subchannels_succeeds() {
// Must be received by dataConsumer2.
direct_data_producer
.send
(
WebRtcMessage
::
String
(
dc2
.to_string
(
)),
WebRtcMessage
::
String
(
Cow
::
Borrowed
(
dc2
.as_bytes
()
)),
Some
(
vec!
[
666
]),
Some
(
2
),
)
...
...
@@ -522,7 +534,7 @@ fn send_with_subchannels_succeeds() {
// Must be received by dataConsumer2.
direct_data_producer
.send
(
WebRtcMessage
::
String
(
both
.to_string
(
)),
WebRtcMessage
::
String
(
Cow
::
Borrowed
(
both
.as_bytes
()
)),
Some
(
vec!
[
1
]),
Some
(
666
),
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论