Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
8abc21cc
Unverified
提交
8abc21cc
authored
6月 14, 2021
作者:
Nazar Mokrynskyi
提交者:
GitHub
6月 14, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Improvements to Rust version and various general cleanups (#587)
上级
2b6021df
全部展开
显示空白字符变更
内嵌
并排
正在显示
29 个修改的文件
包含
329 行增加
和
232 行删除
+329
-232
CHANGELOG.md
CHANGELOG.md
+4
-0
CHANGELOG.md
rust/CHANGELOG.md
+8
-0
Cargo.toml
rust/Cargo.toml
+2
-2
data_structures.rs
rust/src/data_structures.rs
+77
-0
lib.rs
rust/src/lib.rs
+2
-3
messages.rs
rust/src/messages.rs
+5
-7
ortc.rs
rust/src/ortc.rs
+12
-22
tests.rs
rust/src/ortc/tests.rs
+16
-17
router.rs
rust/src/router.rs
+0
-1
audio_level_observer.rs
rust/src/router/audio_level_observer.rs
+5
-11
consumer.rs
rust/src/router/consumer.rs
+12
-18
plain_transport.rs
rust/src/router/plain_transport.rs
+0
-1
producer.rs
rust/src/router/producer.rs
+9
-23
transport.rs
rust/src/router/transport.rs
+5
-9
rtp_parameters.rs
rust/src/rtp_parameters.rs
+8
-22
scalability_modes.rs
rust/src/scalability_modes.rs
+0
-0
tests.rs
rust/src/scalability_modes/tests.rs
+112
-30
supported_rtp_capabilities.rs
rust/src/supported_rtp_capabilities.rs
+13
-14
worker.rs
rust/src/worker.rs
+1
-1
consumer.rs
rust/tests/integration/consumer.rs
+13
-15
pipe_transport.rs
rust/tests/integration/pipe_transport.rs
+3
-4
producer.rs
rust/tests/integration/producer.rs
+7
-6
smoke.rs
rust/tests/integration/smoke.rs
+0
-1
RtpObserver.ts
src/RtpObserver.ts
+4
-4
RtpParameters.ts
src/RtpParameters.ts
+2
-8
ortc.ts
src/ortc.ts
+1
-5
Cargo.toml
worker/Cargo.toml
+1
-1
Router.hpp
worker/include/RTC/Router.hpp
+1
-1
Router.cpp
worker/src/RTC/Router.cpp
+6
-6
没有找到文件。
CHANGELOG.md
浏览文件 @
8abc21cc
# Changelog
# Changelog
### Unreleased
*
`kind`
field of
`RtpHeaderExtension`
is no longer optional.
*
Refactor API inconsistency in internal RTP Observer communication with worker.
### 3.7.14
### 3.7.14
...
...
rust/CHANGELOG.md
浏览文件 @
8abc21cc
# Changelog
# Changelog
### 0.8.0
*
`NonClosingProducer`
removed (use
`PipedProducer`
instead, they were identical)
*
`RtpHeaderExtensionUri::as_str()`
now takes
`self`
instead of
`&self`
*
`kind`
field of
`RtpHeaderExtension`
is no longer optional
*
Refactor
`ScalabilityMode`
from being a string to enum, make sure layers are not zero on type system level
*
Concrete types for info field of tracing events
### 0.7.2
### 0.7.2
*
Thread and memory safety fixes in mediasoup-sys
*
Thread and memory safety fixes in mediasoup-sys
...
...
rust/Cargo.toml
浏览文件 @
8abc21cc
[package]
[package]
name
=
"mediasoup"
name
=
"mediasoup"
version
=
"0.
7.2
"
version
=
"0.
8.0
"
description
=
"Cutting Edge WebRTC Video Conferencing in Rust"
description
=
"Cutting Edge WebRTC Video Conferencing in Rust"
categories
=
[
"api-bindings"
,
"multimedia"
,
"network-programming"
]
categories
=
[
"api-bindings"
,
"multimedia"
,
"network-programming"
]
authors
=
[
"Nazar Mokrynskyi <nazar@mokrynskyi.com>"
]
authors
=
[
"Nazar Mokrynskyi <nazar@mokrynskyi.com>"
]
...
@@ -45,7 +45,7 @@ version = "0.6.5"
...
@@ -45,7 +45,7 @@ version = "0.6.5"
[dependencies.mediasoup-sys]
[dependencies.mediasoup-sys]
path
=
"../worker"
path
=
"../worker"
version
=
"0.
1.2
"
version
=
"0.
2.0
"
[dependencies.parking_lot]
[dependencies.parking_lot]
version
=
"0.11.1"
version
=
"0.11.1"
...
...
rust/src/data_structures.rs
浏览文件 @
8abc21cc
...
@@ -753,3 +753,80 @@ impl WebRtcMessage {
...
@@ -753,3 +753,80 @@ impl WebRtcMessage {
}
}
}
}
}
}
/// RTP packet info in trace event.
#[derive(Debug,
Clone,
Deserialize,
Serialize)]
#[serde(rename_all
=
"camelCase"
)]
pub
struct
RtpPacketTraceInfo
{
/// RTP payload type.
pub
payload_type
:
u8
,
/// Sequence number.
pub
sequence_number
:
u16
,
/// Timestamp.
pub
timestamp
:
u32
,
/// Whether packet has marker or not.
pub
marker
:
bool
,
/// RTP stream SSRC.
pub
ssrc
:
u32
,
/// Whether packet contains a key frame.
pub
is_key_frame
:
bool
,
/// Packet size.
pub
size
:
usize
,
/// Payload size.
pub
payload_size
:
usize
,
/// The spatial layer index (from 0 to N).
pub
spatial_layer
:
u8
,
/// The temporal layer index (from 0 to N).
pub
temporal_layer
:
u8
,
/// The MID RTP extension value as defined in the BUNDLE specification
pub
mid
:
Option
<
String
>
,
/// RTP stream RID value.
pub
rid
:
Option
<
String
>
,
/// RTP stream RRID value.
pub
rrid
:
Option
<
String
>
,
/// Transport-wide sequence number.
pub
wide_sequence_number
:
Option
<
u16
>
,
/// Whether this is an RTX packet.
#[serde(default)]
pub
is_rtx
:
bool
,
}
/// SSRC info in trace event.
#[derive(Debug,
Copy,
Clone,
Deserialize,
Serialize)]
pub
struct
SsrcTraceInfo
{
/// RTP stream SSRC.
ssrc
:
u32
,
}
/// Bandwidth estimation type.
#[derive(Debug,
Copy,
Clone,
Deserialize,
Serialize)]
pub
enum
BweType
{
/// Transport-wide Congestion Control.
#[serde(rename
=
"transport-cc"
)]
TransportCc
,
/// Receiver Estimated Maximum Bitrate.
#[serde(rename
=
"remb"
)]
Remb
,
}
/// BWE info in trace event.
#[derive(Debug,
Copy,
Clone,
Deserialize,
Serialize)]
#[serde(rename_all
=
"camelCase"
)]
pub
struct
BweTraceInfo
{
/// Bandwidth estimation type.
r
#
type
:
BweType
,
/// Desired bitrate
desired_bitrate
:
u32
,
/// Effective desired bitrate.
effective_desired_bitrate
:
u32
,
/// Min bitrate.
min_bitrate
:
u32
,
/// Max bitrate.
max_bitrate
:
u32
,
/// Start bitrate.
start_bitrate
:
u32
,
/// Max padding bitrate.
max_padding_bitrate
:
u32
,
/// Available bitrate.
available_bitrate
:
u32
,
}
rust/src/lib.rs
浏览文件 @
8abc21cc
...
@@ -51,8 +51,8 @@
...
@@ -51,8 +51,8 @@
pub
mod
data_structures
;
pub
mod
data_structures
;
mod
macros
;
mod
macros
;
mod
messages
;
mod
messages
;
// TODO: Check public items in this module
#[doc(hidden)]
mod
ortc
;
pub
mod
ortc
;
pub
mod
router
;
pub
mod
router
;
pub
mod
rtp_parameters
;
pub
mod
rtp_parameters
;
pub
mod
scalability_modes
;
pub
mod
scalability_modes
;
...
@@ -62,7 +62,6 @@ pub mod supported_rtp_capabilities;
...
@@ -62,7 +62,6 @@ pub mod supported_rtp_capabilities;
pub
mod
worker
;
pub
mod
worker
;
pub
mod
worker_manager
;
pub
mod
worker_manager
;
// TODO: The mess below is because of https://github.com/rust-lang/rust/issues/59368
pub
mod
audio_level_observer
{
pub
mod
audio_level_observer
{
//! An audio level observer monitors the volume of the selected audio producers.
//! An audio level observer monitors the volume of the selected audio producers.
...
...
rust/src/messages.rs
浏览文件 @
8abc21cc
...
@@ -917,24 +917,22 @@ request_response!(
...
@@ -917,24 +917,22 @@ request_response!(
#[derive(Debug,
Serialize)]
#[derive(Debug,
Serialize)]
#[serde(rename_all
=
"camelCase"
)]
#[serde(rename_all
=
"camelCase"
)]
pub
(
crate
)
struct
RtpObserverAddRemoveProducerRequestInternal
{
pub
(
crate
)
struct
RtpObserverAddRemoveProducerRequestData
{
pub
(
crate
)
router_id
:
RouterId
,
pub
(
crate
)
rtp_observer_id
:
RtpObserverId
,
// TODO: Inconsistency with the rest of the API, this field should have been in `data` field
// instead, but it is in `internal` for now...
pub
(
crate
)
producer_id
:
ProducerId
,
pub
(
crate
)
producer_id
:
ProducerId
,
}
}
request_response!
(
request_response!
(
"rtpObserver.addProducer"
,
"rtpObserver.addProducer"
,
RtpObserverAddProducerRequest
{
RtpObserverAddProducerRequest
{
internal
:
RtpObserverAddRemoveProducerRequestInternal
,
internal
:
RtpObserverInternal
,
data
:
RtpObserverAddRemoveProducerRequestData
,
},
},
);
);
request_response!
(
request_response!
(
"rtpObserver.removeProducer"
,
"rtpObserver.removeProducer"
,
RtpObserverRemoveProducerRequest
{
RtpObserverRemoveProducerRequest
{
internal
:
RtpObserverAddRemoveProducerRequestInternal
,
internal
:
RtpObserverInternal
,
data
:
RtpObserverAddRemoveProducerRequestData
,
},
},
);
);
rust/src/ortc.rs
浏览文件 @
8abc21cc
...
@@ -40,8 +40,8 @@ pub struct RtpMappingEncoding {
...
@@ -40,8 +40,8 @@ pub struct RtpMappingEncoding {
pub
ssrc
:
Option
<
u32
>
,
pub
ssrc
:
Option
<
u32
>
,
#[serde(skip_serializing_if
=
"Option::is_none"
)]
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
rid
:
Option
<
String
>
,
pub
rid
:
Option
<
String
>
,
#[serde(
skip_serializing_if
=
"Option
::is_none"
)]
#[serde(
default,
skip_serializing_if
=
"ScalabilityMode
::is_none"
)]
pub
scalability_mode
:
Option
<
String
>
,
pub
scalability_mode
:
ScalabilityMode
,
pub
mapped_ssrc
:
u32
,
pub
mapped_ssrc
:
u32
,
}
}
...
@@ -193,7 +193,6 @@ pub(crate) fn generate_router_rtp_capabilities(
...
@@ -193,7 +193,6 @@ pub(crate) fn generate_router_rtp_capabilities(
let
mut
caps
=
RtpCapabilitiesFinalized
{
let
mut
caps
=
RtpCapabilitiesFinalized
{
codecs
:
vec!
[],
codecs
:
vec!
[],
header_extensions
:
supported_rtp_capabilities
.header_extensions
,
header_extensions
:
supported_rtp_capabilities
.header_extensions
,
fec_mechanisms
:
vec!
[],
};
};
for
media_codec
in
&
mut
media_codecs
{
for
media_codec
in
&
mut
media_codecs
{
...
@@ -564,17 +563,9 @@ pub(crate) fn get_consumable_rtp_parameters(
...
@@ -564,17 +563,9 @@ pub(crate) fn get_consumable_rtp_parameters(
for
cap_ext
in
&
caps
.header_extensions
{
for
cap_ext
in
&
caps
.header_extensions
{
// Just take RTP header extension that can be used in Consumers.
// Just take RTP header extension that can be used in Consumers.
match
cap_ext
.kind
{
if
cap_ext
.kind
!=
kind
{
Some
(
cap_ext_kind
)
=>
{
if
cap_ext_kind
!=
kind
{
continue
;
}
}
None
=>
{
// TODO: Should this really skip "any" extensions?
continue
;
continue
;
}
}
}
if
!
matches!
(
if
!
matches!
(
cap_ext
.direction
,
cap_ext
.direction
,
RtpHeaderExtensionDirection
::
SendRecv
|
RtpHeaderExtensionDirection
::
SendOnly
RtpHeaderExtensionDirection
::
SendRecv
|
RtpHeaderExtensionDirection
::
SendOnly
...
@@ -779,20 +770,19 @@ pub(crate) fn get_consumer_rtp_parameters(
...
@@ -779,20 +770,19 @@ pub(crate) fn get_consumer_rtp_parameters(
// (assume all encodings have the same value).
// (assume all encodings have the same value).
let
mut
scalability_mode
=
consumable_params
let
mut
scalability_mode
=
consumable_params
.encodings
.encodings
.iter
()
.get
(
0
)
.find_map
(|
encoding
|
encoding
.scalability_mode
.clone
());
.map
(|
encoding
|
encoding
.scalability_mode
.clone
())
.unwrap_or_default
();
// If there is simulast, mangle spatial layers in scalabilityMode.
// If there is simul
c
ast, mangle spatial layers in scalabilityMode.
if
consumable_params
.encodings
.len
()
>
1
{
if
consumable_params
.encodings
.len
()
>
1
{
scalability_mode
=
Some
(
format!
(
scalability_mode
=
format!
(
"S{}T{}"
,
"S{}T{}"
,
consumable_params
.encodings
.len
(),
consumable_params
.encodings
.len
(),
scalability_mode
scalability_mode
.temporal_layers
()
.as_ref
()
)
.and_then
(|
s
|
s
.parse
::
<
ScalabilityMode
>
()
.ok
())
.parse
()
.unwrap_or_default
()
.unwrap
();
.temporal_layers
));
}
}
consumer_encoding
.scalability_mode
=
scalability_mode
;
consumer_encoding
.scalability_mode
=
scalability_mode
;
...
...
rust/src/ortc/tests.rs
浏览文件 @
8abc21cc
...
@@ -221,20 +221,20 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
...
@@ -221,20 +221,20 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
RtpEncodingParameters
{
RtpEncodingParameters
{
ssrc
:
Some
(
11111111
),
ssrc
:
Some
(
11111111
),
rtx
:
Some
(
RtpEncodingParametersRtx
{
ssrc
:
11111112
}),
rtx
:
Some
(
RtpEncodingParametersRtx
{
ssrc
:
11111112
}),
scalability_mode
:
S
ome
(
"L1T3"
.to_string
())
,
scalability_mode
:
S
calabilityMode
::
L1T3
,
max_bitrate
:
Some
(
111111
),
max_bitrate
:
Some
(
111111
),
..
RtpEncodingParameters
::
default
()
..
RtpEncodingParameters
::
default
()
},
},
RtpEncodingParameters
{
RtpEncodingParameters
{
ssrc
:
Some
(
21111111
),
ssrc
:
Some
(
21111111
),
rtx
:
Some
(
RtpEncodingParametersRtx
{
ssrc
:
21111112
}),
rtx
:
Some
(
RtpEncodingParametersRtx
{
ssrc
:
21111112
}),
scalability_mode
:
S
ome
(
"L1T3"
.to_string
())
,
scalability_mode
:
S
calabilityMode
::
L1T3
,
max_bitrate
:
Some
(
222222
),
max_bitrate
:
Some
(
222222
),
..
RtpEncodingParameters
::
default
()
..
RtpEncodingParameters
::
default
()
},
},
RtpEncodingParameters
{
RtpEncodingParameters
{
rid
:
Some
(
"high"
.to_string
()),
rid
:
Some
(
"high"
.to_string
()),
scalability_mode
:
S
ome
(
"L1T3"
.to_string
())
,
scalability_mode
:
S
calabilityMode
::
L1T3
,
max_bitrate
:
Some
(
333333
),
max_bitrate
:
Some
(
333333
),
..
RtpEncodingParameters
::
default
()
..
RtpEncodingParameters
::
default
()
},
},
...
@@ -328,7 +328,7 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
...
@@ -328,7 +328,7 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
.get
(
0
)
.get
(
0
)
.unwrap
()
.unwrap
()
.scalability_mode
,
.scalability_mode
,
S
ome
(
"L1T3"
.to_string
())
,
S
calabilityMode
::
L1T3
,
);
);
assert_eq!
(
assert_eq!
(
consumable_rtp_parameters
.encodings
.get
(
1
)
.unwrap
()
.ssrc
,
consumable_rtp_parameters
.encodings
.get
(
1
)
.unwrap
()
.ssrc
,
...
@@ -348,7 +348,7 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
...
@@ -348,7 +348,7 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
.get
(
1
)
.get
(
1
)
.unwrap
()
.unwrap
()
.scalability_mode
,
.scalability_mode
,
S
ome
(
"L1T3"
.to_string
())
,
S
calabilityMode
::
L1T3
,
);
);
assert_eq!
(
assert_eq!
(
consumable_rtp_parameters
.encodings
.get
(
2
)
.unwrap
()
.ssrc
,
consumable_rtp_parameters
.encodings
.get
(
2
)
.unwrap
()
.ssrc
,
...
@@ -368,7 +368,7 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
...
@@ -368,7 +368,7 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
.get
(
2
)
.get
(
2
)
.unwrap
()
.unwrap
()
.scalability_mode
,
.scalability_mode
,
S
ome
(
"L1T3"
.to_string
())
,
S
calabilityMode
::
L1T3
,
);
);
assert_eq!
(
assert_eq!
(
...
@@ -415,49 +415,48 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
...
@@ -415,49 +415,48 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
],
],
header_extensions
:
vec!
[
header_extensions
:
vec!
[
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Audio
)
,
kind
:
MediaKind
::
Audio
,
uri
:
RtpHeaderExtensionUri
::
Mid
,
uri
:
RtpHeaderExtensionUri
::
Mid
,
preferred_id
:
1
,
preferred_id
:
1
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
Mid
,
uri
:
RtpHeaderExtensionUri
::
Mid
,
preferred_id
:
1
,
preferred_id
:
1
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
RtpStreamId
,
uri
:
RtpHeaderExtensionUri
::
RtpStreamId
,
preferred_id
:
2
,
preferred_id
:
2
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Audio
)
,
kind
:
MediaKind
::
Audio
,
uri
:
RtpHeaderExtensionUri
::
AudioLevel
,
uri
:
RtpHeaderExtensionUri
::
AudioLevel
,
preferred_id
:
8
,
preferred_id
:
8
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
VideoOrientation
,
uri
:
RtpHeaderExtensionUri
::
VideoOrientation
,
preferred_id
:
11
,
preferred_id
:
11
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
TimeOffset
,
uri
:
RtpHeaderExtensionUri
::
TimeOffset
,
preferred_id
:
12
,
preferred_id
:
12
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
},
},
],
],
fec_mechanisms
:
vec!
[],
};
};
let
consumer_rtp_parameters
=
let
consumer_rtp_parameters
=
...
@@ -511,7 +510,7 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
...
@@ -511,7 +510,7 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
.get
(
0
)
.get
(
0
)
.unwrap
()
.unwrap
()
.scalability_mode
,
.scalability_mode
,
S
ome
(
"S3T3"
.to_string
())
,
S
calabilityMode
::
S3T3
,
);
);
assert_eq!
(
assert_eq!
(
consumer_rtp_parameters
consumer_rtp_parameters
...
@@ -595,7 +594,7 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
...
@@ -595,7 +594,7 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
.get
(
0
)
.get
(
0
)
.unwrap
()
.unwrap
()
.scalability_mode
,
.scalability_mode
,
S
ome
(
"L1T3"
.to_string
())
,
S
calabilityMode
::
L1T3
,
);
);
assert
!
(
pipe_consumer_rtp_parameters
assert
!
(
pipe_consumer_rtp_parameters
.encodings
.encodings
...
@@ -621,7 +620,7 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
...
@@ -621,7 +620,7 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
.get
(
1
)
.get
(
1
)
.unwrap
()
.unwrap
()
.scalability_mode
,
.scalability_mode
,
S
ome
(
"L1T3"
.to_string
())
,
S
calabilityMode
::
L1T3
,
);
);
assert
!
(
pipe_consumer_rtp_parameters
assert
!
(
pipe_consumer_rtp_parameters
.encodings
.encodings
...
@@ -647,7 +646,7 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
...
@@ -647,7 +646,7 @@ fn get_producer_rtp_parameters_mapping_get_consumable_rtp_parameters_get_consume
.get
(
2
)
.get
(
2
)
.unwrap
()
.unwrap
()
.scalability_mode
,
.scalability_mode
,
S
ome
(
"L1T3"
.to_string
())
,
S
calabilityMode
::
L1T3
,
);
);
assert_eq!
(
assert_eq!
(
...
...
rust/src/router.rs
浏览文件 @
8abc21cc
...
@@ -908,7 +908,6 @@ impl Router {
...
@@ -908,7 +908,6 @@ impl Router {
/// },
/// },
/// ],
/// ],
/// header_extensions: vec![],
/// header_extensions: vec![],
/// fec_mechanisms: vec![],
/// }
/// }
/// ))
/// ))
/// .await?;
/// .await?;
...
...
rust/src/router/audio_level_observer.rs
浏览文件 @
8abc21cc
...
@@ -3,7 +3,7 @@ mod tests;
...
@@ -3,7 +3,7 @@ mod tests;
use
crate
::
data_structures
::
AppData
;
use
crate
::
data_structures
::
AppData
;
use
crate
::
messages
::{
use
crate
::
messages
::{
RtpObserverAddProducerRequest
,
RtpObserverAddRemoveProducerRequest
Internal
,
RtpObserverAddProducerRequest
,
RtpObserverAddRemoveProducerRequest
Data
,
RtpObserverCloseRequest
,
RtpObserverInternal
,
RtpObserverPauseRequest
,
RtpObserverCloseRequest
,
RtpObserverInternal
,
RtpObserverPauseRequest
,
RtpObserverRemoveProducerRequest
,
RtpObserverResumeRequest
,
RtpObserverRemoveProducerRequest
,
RtpObserverResumeRequest
,
};
};
...
@@ -232,11 +232,8 @@ impl RtpObserver for AudioLevelObserver {
...
@@ -232,11 +232,8 @@ impl RtpObserver for AudioLevelObserver {
self
.inner
self
.inner
.channel
.channel
.request
(
RtpObserverAddProducerRequest
{
.request
(
RtpObserverAddProducerRequest
{
internal
:
RtpObserverAddRemoveProducerRequestInternal
{
internal
:
self
.get_internal
(),
router_id
:
self
.inner.router
.id
(),
data
:
RtpObserverAddRemoveProducerRequestData
{
producer_id
},
rtp_observer_id
:
self
.inner.id
,
producer_id
,
},
})
})
.await
?
;
.await
?
;
...
@@ -257,11 +254,8 @@ impl RtpObserver for AudioLevelObserver {
...
@@ -257,11 +254,8 @@ impl RtpObserver for AudioLevelObserver {
self
.inner
self
.inner
.channel
.channel
.request
(
RtpObserverRemoveProducerRequest
{
.request
(
RtpObserverRemoveProducerRequest
{
internal
:
RtpObserverAddRemoveProducerRequestInternal
{
internal
:
self
.get_internal
(),
router_id
:
self
.inner.router
.id
(),
data
:
RtpObserverAddRemoveProducerRequestData
{
producer_id
},
rtp_observer_id
:
self
.inner.id
,
producer_id
,
},
})
})
.await
?
;
.await
?
;
...
...
rust/src/router/consumer.rs
浏览文件 @
8abc21cc
#
[
cfg
(
test
)]
#
[
cfg
(
test
)]
mod
tests
;
mod
tests
;
use
crate
::
data_structures
::{
AppData
,
TraceEventDirection
};
use
crate
::
data_structures
::{
AppData
,
RtpPacketTraceInfo
,
SsrcTraceInfo
,
TraceEventDirection
};
use
crate
::
messages
::{
use
crate
::
messages
::{
ConsumerCloseRequest
,
ConsumerDumpRequest
,
ConsumerEnableTraceEventData
,
ConsumerCloseRequest
,
ConsumerDumpRequest
,
ConsumerEnableTraceEventData
,
ConsumerEnableTraceEventRequest
,
ConsumerGetStatsRequest
,
ConsumerInternal
,
ConsumerEnableTraceEventRequest
,
ConsumerGetStatsRequest
,
ConsumerInternal
,
...
@@ -10,6 +10,7 @@ use crate::messages::{
...
@@ -10,6 +10,7 @@ use crate::messages::{
};
};
use
crate
::
producer
::{
ProducerId
,
ProducerStat
,
ProducerType
};
use
crate
::
producer
::{
ProducerId
,
ProducerStat
,
ProducerType
};
use
crate
::
rtp_parameters
::{
MediaKind
,
MimeType
,
RtpCapabilities
,
RtpParameters
};
use
crate
::
rtp_parameters
::{
MediaKind
,
MimeType
,
RtpCapabilities
,
RtpParameters
};
use
crate
::
scalability_modes
::
ScalabilityMode
;
use
crate
::
transport
::
Transport
;
use
crate
::
transport
::
Transport
;
use
crate
::
uuid_based_wrapper_type
;
use
crate
::
uuid_based_wrapper_type
;
use
crate
::
worker
::{
use
crate
::
worker
::{
...
@@ -21,7 +22,6 @@ use event_listener_primitives::{Bag, BagOnce, HandlerId};
...
@@ -21,7 +22,6 @@ use event_listener_primitives::{Bag, BagOnce, HandlerId};
use
log
::{
debug
,
error
};
use
log
::{
debug
,
error
};
use
parking_lot
::
Mutex
;
use
parking_lot
::
Mutex
;
use
serde
::{
Deserialize
,
Serialize
};
use
serde
::{
Deserialize
,
Serialize
};
use
serde_json
::
Value
;
use
std
::
fmt
;
use
std
::
fmt
;
use
std
::
fmt
::
Debug
;
use
std
::
fmt
::
Debug
;
use
std
::
sync
::
atomic
::{
AtomicBool
,
Ordering
};
use
std
::
sync
::
atomic
::{
AtomicBool
,
Ordering
};
...
@@ -147,7 +147,8 @@ pub struct ConsumableRtpEncoding {
...
@@ -147,7 +147,8 @@ pub struct ConsumableRtpEncoding {
pub
max_bitrate
:
Option
<
u32
>
,
pub
max_bitrate
:
Option
<
u32
>
,
pub
max_framerate
:
Option
<
f64
>
,
pub
max_framerate
:
Option
<
f64
>
,
pub
dtx
:
Option
<
bool
>
,
pub
dtx
:
Option
<
bool
>
,
pub
scalability_mode
:
Option
<
String
>
,
#[serde(default,
skip_serializing_if
=
"ScalabilityMode::is_none"
)]
pub
scalability_mode
:
ScalabilityMode
,
pub
spatial_layers
:
Option
<
u8
>
,
pub
spatial_layers
:
Option
<
u8
>
,
pub
temporal_layers
:
Option
<
u8
>
,
pub
temporal_layers
:
Option
<
u8
>
,
pub
ksvc
:
Option
<
bool
>
,
pub
ksvc
:
Option
<
bool
>
,
...
@@ -259,9 +260,8 @@ pub enum ConsumerTraceEventData {
...
@@ -259,9 +260,8 @@ pub enum ConsumerTraceEventData {
timestamp
:
u64
,
timestamp
:
u64
,
/// Event direction.
/// Event direction.
direction
:
TraceEventDirection
,
direction
:
TraceEventDirection
,
// TODO: Clarify value structure
/// RTP packet info.
/// Per type specific information.
info
:
RtpPacketTraceInfo
,
info
:
Value
,
},
},
/// RTP video keyframe packet.
/// RTP video keyframe packet.
KeyFrame
{
KeyFrame
{
...
@@ -269,9 +269,8 @@ pub enum ConsumerTraceEventData {
...
@@ -269,9 +269,8 @@ pub enum ConsumerTraceEventData {
timestamp
:
u64
,
timestamp
:
u64
,
/// Event direction.
/// Event direction.
direction
:
TraceEventDirection
,
direction
:
TraceEventDirection
,
// TODO: Clarify value structure
/// RTP packet info.
/// Per type specific information.
info
:
RtpPacketTraceInfo
,
info
:
Value
,
},
},
/// RTCP NACK packet.
/// RTCP NACK packet.
Nack
{
Nack
{
...
@@ -279,9 +278,6 @@ pub enum ConsumerTraceEventData {
...
@@ -279,9 +278,6 @@ pub enum ConsumerTraceEventData {
timestamp
:
u64
,
timestamp
:
u64
,
/// Event direction.
/// Event direction.
direction
:
TraceEventDirection
,
direction
:
TraceEventDirection
,
// TODO: Clarify value structure
/// Per type specific information.
info
:
Value
,
},
},
/// RTCP PLI packet.
/// RTCP PLI packet.
Pli
{
Pli
{
...
@@ -289,9 +285,8 @@ pub enum ConsumerTraceEventData {
...
@@ -289,9 +285,8 @@ pub enum ConsumerTraceEventData {
timestamp
:
u64
,
timestamp
:
u64
,
/// Event direction.
/// Event direction.
direction
:
TraceEventDirection
,
direction
:
TraceEventDirection
,
// TODO: Clarify value structure
/// SSRC info.
/// Per type specific information.
info
:
SsrcTraceInfo
,
info
:
Value
,
},
},
/// RTCP FIR packet.
/// RTCP FIR packet.
Fir
{
Fir
{
...
@@ -299,9 +294,8 @@ pub enum ConsumerTraceEventData {
...
@@ -299,9 +294,8 @@ pub enum ConsumerTraceEventData {
timestamp
:
u64
,
timestamp
:
u64
,
/// Event direction.
/// Event direction.
direction
:
TraceEventDirection
,
direction
:
TraceEventDirection
,
// TODO: Clarify value structure
/// SSRC info.
/// Per type specific information.
info
:
SsrcTraceInfo
,
info
:
Value
,
},
},
}
}
...
...
rust/src/router/plain_transport.rs
浏览文件 @
8abc21cc
...
@@ -162,7 +162,6 @@ pub struct PlainTransportStat {
...
@@ -162,7 +162,6 @@ pub struct PlainTransportStat {
pub
rtcp_tuple
:
Option
<
TransportTuple
>
,
pub
rtcp_tuple
:
Option
<
TransportTuple
>
,
}
}
// TODO: Impl with methods that only allow working invariants
/// Remote parameters for plain transport.
/// Remote parameters for plain transport.
#[derive(Debug,
Clone,
Deserialize,
Serialize)]
#[derive(Debug,
Clone,
Deserialize,
Serialize)]
#[serde(rename_all
=
"camelCase"
)]
#[serde(rename_all
=
"camelCase"
)]
...
...
rust/src/router/producer.rs
浏览文件 @
8abc21cc
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
mod
tests
;
mod
tests
;
use
crate
::
consumer
::
RtpStreamParams
;
use
crate
::
consumer
::
RtpStreamParams
;
use
crate
::
data_structures
::{
AppData
,
TraceEventDirection
};
use
crate
::
data_structures
::{
AppData
,
RtpPacketTraceInfo
,
SsrcTraceInfo
,
TraceEventDirection
};
use
crate
::
messages
::{
use
crate
::
messages
::{
ProducerCloseRequest
,
ProducerDumpRequest
,
ProducerEnableTraceEventData
,
ProducerCloseRequest
,
ProducerDumpRequest
,
ProducerEnableTraceEventData
,
ProducerEnableTraceEventRequest
,
ProducerGetStatsRequest
,
ProducerInternal
,
ProducerEnableTraceEventRequest
,
ProducerGetStatsRequest
,
ProducerInternal
,
...
@@ -21,7 +21,6 @@ use event_listener_primitives::{Bag, BagOnce, HandlerId};
...
@@ -21,7 +21,6 @@ use event_listener_primitives::{Bag, BagOnce, HandlerId};
use
log
::{
debug
,
error
};
use
log
::{
debug
,
error
};
use
parking_lot
::
Mutex
;
use
parking_lot
::
Mutex
;
use
serde
::{
Deserialize
,
Serialize
};
use
serde
::{
Deserialize
,
Serialize
};
use
serde_json
::
Value
;
use
serde_repr
::{
Deserialize_repr
,
Serialize_repr
};
use
serde_repr
::{
Deserialize_repr
,
Serialize_repr
};
use
std
::
collections
::
HashMap
;
use
std
::
collections
::
HashMap
;
use
std
::
fmt
;
use
std
::
fmt
;
...
@@ -48,7 +47,6 @@ pub struct ProducerOptions {
...
@@ -48,7 +47,6 @@ pub struct ProducerOptions {
pub
(
super
)
id
:
Option
<
ProducerId
>
,
pub
(
super
)
id
:
Option
<
ProducerId
>
,
/// Media kind.
/// Media kind.
pub
kind
:
MediaKind
,
pub
kind
:
MediaKind
,
// TODO: Docs have distinction between RtpSendParameters and RtpReceiveParameters
/// RTP parameters defining what the endpoint is sending.
/// RTP parameters defining what the endpoint is sending.
pub
rtp_parameters
:
RtpParameters
,
pub
rtp_parameters
:
RtpParameters
,
/// Whether the producer must start in paused mode. Default false.
/// Whether the producer must start in paused mode. Default false.
...
@@ -217,9 +215,8 @@ pub enum ProducerTraceEventData {
...
@@ -217,9 +215,8 @@ pub enum ProducerTraceEventData {
timestamp
:
u64
,
timestamp
:
u64
,
/// Event direction.
/// Event direction.
direction
:
TraceEventDirection
,
direction
:
TraceEventDirection
,
// TODO: Clarify value structure
/// RTP packet info.
/// Per type specific information.
info
:
RtpPacketTraceInfo
,
info
:
Value
,
},
},
/// RTP video keyframe packet.
/// RTP video keyframe packet.
KeyFrame
{
KeyFrame
{
...
@@ -227,9 +224,8 @@ pub enum ProducerTraceEventData {
...
@@ -227,9 +224,8 @@ pub enum ProducerTraceEventData {
timestamp
:
u64
,
timestamp
:
u64
,
/// Event direction.
/// Event direction.
direction
:
TraceEventDirection
,
direction
:
TraceEventDirection
,
// TODO: Clarify value structure
/// RTP packet info.
/// Per type specific information.
info
:
RtpPacketTraceInfo
,
info
:
Value
,
},
},
/// RTCP NACK packet.
/// RTCP NACK packet.
Nack
{
Nack
{
...
@@ -237,9 +233,6 @@ pub enum ProducerTraceEventData {
...
@@ -237,9 +233,6 @@ pub enum ProducerTraceEventData {
timestamp
:
u64
,
timestamp
:
u64
,
/// Event direction.
/// Event direction.
direction
:
TraceEventDirection
,
direction
:
TraceEventDirection
,
// TODO: Clarify value structure
/// Per type specific information.
info
:
Value
,
},
},
/// RTCP PLI packet.
/// RTCP PLI packet.
Pli
{
Pli
{
...
@@ -247,9 +240,8 @@ pub enum ProducerTraceEventData {
...
@@ -247,9 +240,8 @@ pub enum ProducerTraceEventData {
timestamp
:
u64
,
timestamp
:
u64
,
/// Event direction.
/// Event direction.
direction
:
TraceEventDirection
,
direction
:
TraceEventDirection
,
// TODO: Clarify value structure
/// SSRC info.
/// Per type specific information.
info
:
SsrcTraceInfo
,
info
:
Value
,
},
},
/// RTCP FIR packet.
/// RTCP FIR packet.
Fir
{
Fir
{
...
@@ -257,9 +249,8 @@ pub enum ProducerTraceEventData {
...
@@ -257,9 +249,8 @@ pub enum ProducerTraceEventData {
timestamp
:
u64
,
timestamp
:
u64
,
/// Event direction.
/// Event direction.
direction
:
TraceEventDirection
,
direction
:
TraceEventDirection
,
// TODO: Clarify value structure
/// SSRC info.
/// Per type specific information.
info
:
SsrcTraceInfo
,
info
:
Value
,
},
},
}
}
...
@@ -792,11 +783,6 @@ impl DirectProducer {
...
@@ -792,11 +783,6 @@ impl DirectProducer {
}
}
}
}
// TODO: Remove with next major version
#[deprecated(note
=
"Please use `PipedProducer` instead, it is an alias to the same type"
)]
#[doc(hidden)]
pub
type
NonClosingProducer
=
PipedProducer
;
/// Same as [`Producer`], but will not be closed when dropped.
/// Same as [`Producer`], but will not be closed when dropped.
///
///
/// The idea here is that [`ProducerId`] of both original [`Producer`] and `PipedProducer` is the
/// The idea here is that [`ProducerId`] of both original [`Producer`] and `PipedProducer` is the
...
...
rust/src/router/transport.rs
浏览文件 @
8abc21cc
use
crate
::
consumer
::{
Consumer
,
ConsumerId
,
ConsumerOptions
,
ConsumerType
};
use
crate
::
consumer
::{
Consumer
,
ConsumerId
,
ConsumerOptions
,
ConsumerType
};
use
crate
::
data_consumer
::{
DataConsumer
,
DataConsumerId
,
DataConsumerOptions
,
DataConsumerType
};
use
crate
::
data_consumer
::{
DataConsumer
,
DataConsumerId
,
DataConsumerOptions
,
DataConsumerType
};
use
crate
::
data_producer
::{
DataProducer
,
DataProducerId
,
DataProducerOptions
,
DataProducerType
};
use
crate
::
data_producer
::{
DataProducer
,
DataProducerId
,
DataProducerOptions
,
DataProducerType
};
use
crate
::
data_structures
::{
AppData
,
TraceEventDirection
};
use
crate
::
data_structures
::{
AppData
,
BweTraceInfo
,
RtpPacketTraceInfo
,
TraceEventDirection
};
use
crate
::
messages
::{
use
crate
::
messages
::{
ConsumerInternal
,
DataConsumerInternal
,
DataProducerInternal
,
ProducerInternal
,
ConsumerInternal
,
DataConsumerInternal
,
DataProducerInternal
,
ProducerInternal
,
TransportConsumeData
,
TransportConsumeDataData
,
TransportConsumeDataRequest
,
TransportConsumeData
,
TransportConsumeDataData
,
TransportConsumeDataRequest
,
...
@@ -27,7 +27,6 @@ use log::{error, warn};
...
@@ -27,7 +27,6 @@ use log::{error, warn};
use
parking_lot
::
Mutex
;
use
parking_lot
::
Mutex
;
use
serde
::
de
::
DeserializeOwned
;
use
serde
::
de
::
DeserializeOwned
;
use
serde
::{
Deserialize
,
Serialize
};
use
serde
::{
Deserialize
,
Serialize
};
use
serde_json
::
Value
;
use
std
::
collections
::
HashMap
;
use
std
::
collections
::
HashMap
;
use
std
::
fmt
::
Debug
;
use
std
::
fmt
::
Debug
;
use
std
::
marker
::
PhantomData
;
use
std
::
marker
::
PhantomData
;
...
@@ -54,9 +53,8 @@ pub enum TransportTraceEventData {
...
@@ -54,9 +53,8 @@ pub enum TransportTraceEventData {
timestamp
:
u64
,
timestamp
:
u64
,
/// Event direction.
/// Event direction.
direction
:
TraceEventDirection
,
direction
:
TraceEventDirection
,
// TODO: Clarify value structure
/// RTP packet info.
/// Per type specific information.
info
:
RtpPacketTraceInfo
,
info
:
Value
,
},
},
/// Transport bandwidth estimation changed.
/// Transport bandwidth estimation changed.
Bwe
{
Bwe
{
...
@@ -64,9 +62,8 @@ pub enum TransportTraceEventData {
...
@@ -64,9 +62,8 @@ pub enum TransportTraceEventData {
timestamp
:
u64
,
timestamp
:
u64
,
/// Event direction.
/// Event direction.
direction
:
TraceEventDirection
,
direction
:
TraceEventDirection
,
// TODO: Clarify value structure
/// BWE info.
/// Per type specific information.
info
:
BweTraceInfo
,
info
:
Value
,
},
},
}
}
...
@@ -586,7 +583,6 @@ pub(super) trait TransportImpl: TransportGeneric {
...
@@ -586,7 +583,6 @@ pub(super) trait TransportImpl: TransportGeneric {
}
}
};
};
// TODO: Maybe RtpParametersFinalized would be a better fit here
let
rtp_parameters
=
if
transport_type
==
TransportType
::
Pipe
{
let
rtp_parameters
=
if
transport_type
==
TransportType
::
Pipe
{
ortc
::
get_pipe_consumer_rtp_parameters
(
producer
.consumable_rtp_parameters
(),
rtx
)
ortc
::
get_pipe_consumer_rtp_parameters
(
producer
.consumable_rtp_parameters
(),
rtx
)
}
else
{
}
else
{
...
...
rust/src/rtp_parameters.rs
浏览文件 @
8abc21cc
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#[cfg(test)]
#[cfg(test)]
mod
tests
;
mod
tests
;
use
crate
::
scalability_modes
::
ScalabilityMode
;
use
serde
::
de
::{
MapAccess
,
Visitor
};
use
serde
::
de
::{
MapAccess
,
Visitor
};
use
serde
::
ser
::
SerializeStruct
;
use
serde
::
ser
::
SerializeStruct
;
use
serde
::{
de
,
Deserialize
,
Deserializer
,
Serialize
,
Serializer
};
use
serde
::{
de
,
Deserialize
,
Deserializer
,
Serialize
,
Serializer
};
...
@@ -187,9 +188,6 @@ pub struct RtpCapabilitiesFinalized {
...
@@ -187,9 +188,6 @@ pub struct RtpCapabilitiesFinalized {
pub
codecs
:
Vec
<
RtpCodecCapabilityFinalized
>
,
pub
codecs
:
Vec
<
RtpCodecCapabilityFinalized
>
,
/// Supported RTP header extensions.
/// Supported RTP header extensions.
pub
header_extensions
:
Vec
<
RtpHeaderExtension
>
,
pub
header_extensions
:
Vec
<
RtpHeaderExtension
>
,
// TODO: Enum instead of string?
/// Supported FEC mechanisms.
pub
fec_mechanisms
:
Vec
<
String
>
,
}
}
/// Media kind
/// Media kind
...
@@ -379,10 +377,6 @@ pub struct RtpCapabilities {
...
@@ -379,10 +377,6 @@ pub struct RtpCapabilities {
pub
codecs
:
Vec
<
RtpCodecCapability
>
,
pub
codecs
:
Vec
<
RtpCodecCapability
>
,
/// Supported RTP header extensions.
/// Supported RTP header extensions.
pub
header_extensions
:
Vec
<
RtpHeaderExtension
>
,
pub
header_extensions
:
Vec
<
RtpHeaderExtension
>
,
// TODO: Enum instead of string?
/// Supported FEC mechanisms.
#[serde(default)]
pub
fec_mechanisms
:
Vec
<
String
>
,
}
}
/// Direction of RTP header extension.
/// Direction of RTP header extension.
...
@@ -444,10 +438,9 @@ pub enum RtpHeaderExtensionUri {
...
@@ -444,10 +438,9 @@ pub enum RtpHeaderExtensionUri {
}
}
impl
RtpHeaderExtensionUri
{
impl
RtpHeaderExtensionUri
{
// TODO: Replace `&self` with `self` in next major version
/// RTP header extension as a string
/// RTP header extension as a string
#[must_use]
#[must_use]
pub
fn
as_str
(
&
self
)
->
&
'static
str
{
pub
fn
as_str
(
self
)
->
&
'static
str
{
match
self
{
match
self
{
RtpHeaderExtensionUri
::
Mid
=>
"urn:ietf:params:rtp-hdrext:sdes:mid"
,
RtpHeaderExtensionUri
::
Mid
=>
"urn:ietf:params:rtp-hdrext:sdes:mid"
,
RtpHeaderExtensionUri
::
RtpStreamId
=>
"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"
,
RtpHeaderExtensionUri
::
RtpStreamId
=>
"urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id"
,
...
@@ -483,12 +476,8 @@ impl RtpHeaderExtensionUri {
...
@@ -483,12 +476,8 @@ impl RtpHeaderExtensionUri {
#[derive(Debug,
Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Hash,
Deserialize,
Serialize)]
#[derive(Debug,
Copy,
Clone,
Eq,
PartialEq,
Ord,
PartialOrd,
Hash,
Deserialize,
Serialize)]
#[serde(rename_all
=
"camelCase"
)]
#[serde(rename_all
=
"camelCase"
)]
pub
struct
RtpHeaderExtension
{
pub
struct
RtpHeaderExtension
{
// TODO: TypeScript version makes this field both optional and possible to set to "",
/// Media kind.
// check if "" is actually needed
pub
kind
:
MediaKind
,
/// Media kind. If `None`, it's valid for all kinds.
/// Default any media kind.
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
kind
:
Option
<
MediaKind
>
,
/// The URI of the RTP header extension, as defined in RFC 5285.
/// The URI of the RTP header extension, as defined in RFC 5285.
pub
uri
:
RtpHeaderExtensionUri
,
pub
uri
:
RtpHeaderExtensionUri
,
/// The preferred numeric identifier that goes in the RTP packet. Must be unique.
/// The preferred numeric identifier that goes in the RTP packet. Must be unique.
...
@@ -534,7 +523,7 @@ pub struct RtpHeaderExtension {
...
@@ -534,7 +523,7 @@ pub struct RtpHeaderExtension {
#[derive(Debug,
Default,
Clone,
PartialEq,
PartialOrd,
Deserialize,
Serialize)]
#[derive(Debug,
Default,
Clone,
PartialEq,
PartialOrd,
Deserialize,
Serialize)]
#[serde(rename_all
=
"camelCase"
)]
#[serde(rename_all
=
"camelCase"
)]
pub
struct
RtpParameters
{
pub
struct
RtpParameters
{
/// The MID RTP extension value as defined in the BUNDLE specification
/// The MID RTP extension value as defined in the BUNDLE specification
.
#[serde(skip_serializing_if
=
"Option::is_none"
)]
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
mid
:
Option
<
String
>
,
pub
mid
:
Option
<
String
>
,
/// Media and RTX codecs in use.
/// Media and RTX codecs in use.
...
@@ -812,12 +801,9 @@ pub struct RtpEncodingParameters {
...
@@ -812,12 +801,9 @@ pub struct RtpEncodingParameters {
/// Default false.
/// Default false.
#[serde(skip_serializing_if
=
"Option::is_none"
)]
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
dtx
:
Option
<
bool
>
,
pub
dtx
:
Option
<
bool
>
,
// TODO: Enum for scalability modes, they should all be defined in the spec
/// Number of spatial and temporal layers in the RTP stream.
/// Number of spatial and temporal layers in the RTP stream (e.g. `L1T3`).
#[serde(default,
skip_serializing_if
=
"ScalabilityMode::is_none"
)]
///
pub
scalability_mode
:
ScalabilityMode
,
/// See [webrtc-svc](https://w3c.github.io/webrtc-svc/).
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
scalability_mode
:
Option
<
String
>
,
/// Factor by which to reduce the size of a video track during encoding.
/// Factor by which to reduce the size of a video track during encoding.
#[serde(skip_serializing_if
=
"Option::is_none"
)]
#[serde(skip_serializing_if
=
"Option::is_none"
)]
pub
scale_resolution_down_by
:
Option
<
f64
>
,
pub
scale_resolution_down_by
:
Option
<
f64
>
,
...
...
rust/src/scalability_modes.rs
浏览文件 @
8abc21cc
差异被折叠。
点击展开。
rust/src/scalability_modes/tests.rs
浏览文件 @
8abc21cc
...
@@ -2,32 +2,38 @@ use super::*;
...
@@ -2,32 +2,38 @@ use super::*;
#[test]
#[test]
fn
parse_scalability_modes
()
{
fn
parse_scalability_modes
()
{
let
scalability_mode
:
ScalabilityMode
=
"L1T3"
.parse
()
.unwrap
();
assert_eq!
(
assert_eq!
(
"L1T3"
.parse
(),
scalability_mode
.spatial_layers
(),
Ok
(
ScalabilityMode
{
NonZeroU8
::
new
(
1
)
.unwrap
()
spatial_layers
:
1
,
temporal_layers
:
3
,
ksvc
:
false
}),
);
);
assert_eq!
(
scalability_mode
.temporal_layers
(),
NonZeroU8
::
new
(
3
)
.unwrap
()
);
assert_eq!
(
scalability_mode
.ksvc
(),
false
);
let
scalability_mode
:
ScalabilityMode
=
"L3T2_KEY"
.parse
()
.unwrap
();
assert_eq!
(
scalability_mode
.spatial_layers
(),
NonZeroU8
::
new
(
3
)
.unwrap
()
);
assert_eq!
(
assert_eq!
(
"L3T2_KEY"
.parse
(),
scalability_mode
.temporal_layers
(),
Ok
(
ScalabilityMode
{
NonZeroU8
::
new
(
2
)
.unwrap
()
spatial_layers
:
3
,
temporal_layers
:
2
,
ksvc
:
true
}),
);
);
assert_eq!
(
scalability_mode
.ksvc
(),
true
);
let
scalability_mode
:
ScalabilityMode
=
"S2T3"
.parse
()
.unwrap
();
assert_eq!
(
scalability_mode
.spatial_layers
(),
NonZeroU8
::
new
(
2
)
.unwrap
()
);
assert_eq!
(
assert_eq!
(
"S2T3"
.parse
(),
scalability_mode
.temporal_layers
(),
Ok
(
ScalabilityMode
{
NonZeroU8
::
new
(
3
)
.unwrap
()
spatial_layers
:
2
,
temporal_layers
:
3
,
ksvc
:
false
}),
);
);
assert_eq!
(
scalability_mode
.ksvc
(),
false
);
assert_eq!
(
assert_eq!
(
"foo"
.parse
::
<
ScalabilityMode
>
(),
"foo"
.parse
::
<
ScalabilityMode
>
(),
...
@@ -49,26 +55,102 @@ fn parse_scalability_modes() {
...
@@ -49,26 +55,102 @@ fn parse_scalability_modes() {
Err
(
ParseScalabilityModeError
::
InvalidInput
),
Err
(
ParseScalabilityModeError
::
InvalidInput
),
);
);
let
scalability_mode
:
ScalabilityMode
=
"L20T3"
.parse
()
.unwrap
();
assert
!
(
matches!
(
scalability_mode
,
ScalabilityMode
::
Custom
{
..
}));
assert_eq!
(
assert_eq!
(
"L20T3"
.parse
(),
scalability_mode
.spatial_layers
(),
Ok
(
ScalabilityMode
{
NonZeroU8
::
new
(
20
)
.unwrap
()
spatial_layers
:
20
,
temporal_layers
:
3
,
ksvc
:
false
}),
);
);
assert_eq!
(
scalability_mode
.temporal_layers
(),
NonZeroU8
::
new
(
3
)
.unwrap
()
);
assert_eq!
(
scalability_mode
.ksvc
(),
false
);
assert_eq!
(
assert_eq!
(
"S200T3"
.parse
::
<
ScalabilityMode
>
(),
"S200T3"
.parse
::
<
ScalabilityMode
>
(),
Err
(
ParseScalabilityModeError
::
InvalidInput
),
Err
(
ParseScalabilityModeError
::
InvalidInput
),
);
);
let
scalability_mode
:
ScalabilityMode
=
"L4T7_KEY_SHIFT"
.parse
()
.unwrap
();
assert
!
(
matches!
(
scalability_mode
,
ScalabilityMode
::
Custom
{
..
}));
assert_eq!
(
scalability_mode
.spatial_layers
(),
NonZeroU8
::
new
(
4
)
.unwrap
()
);
assert_eq!
(
scalability_mode
.temporal_layers
(),
NonZeroU8
::
new
(
7
)
.unwrap
()
);
assert_eq!
(
scalability_mode
.ksvc
(),
true
);
}
#[test]
fn
parse_json_scalability_modes
()
{
let
scalability_mode
:
ScalabilityMode
=
serde_json
::
from_str
(
"
\
"
L1T3
\
""
)
.unwrap
();
assert_eq!
(
scalability_mode
.spatial_layers
(),
NonZeroU8
::
new
(
1
)
.unwrap
()
);
assert_eq!
(
scalability_mode
.temporal_layers
(),
NonZeroU8
::
new
(
3
)
.unwrap
()
);
assert_eq!
(
scalability_mode
.ksvc
(),
false
);
let
scalability_mode
:
ScalabilityMode
=
serde_json
::
from_str
(
"
\
"
L3T2_KEY
\
""
)
.unwrap
();
assert_eq!
(
scalability_mode
.spatial_layers
(),
NonZeroU8
::
new
(
3
)
.unwrap
()
);
assert_eq!
(
scalability_mode
.temporal_layers
(),
NonZeroU8
::
new
(
2
)
.unwrap
()
);
assert_eq!
(
scalability_mode
.ksvc
(),
true
);
let
scalability_mode
:
ScalabilityMode
=
serde_json
::
from_str
(
"
\
"
S2T3
\
""
)
.unwrap
();
assert_eq!
(
scalability_mode
.spatial_layers
(),
NonZeroU8
::
new
(
2
)
.unwrap
()
);
assert_eq!
(
scalability_mode
.temporal_layers
(),
NonZeroU8
::
new
(
3
)
.unwrap
()
);
assert_eq!
(
scalability_mode
.ksvc
(),
false
);
assert
!
(
serde_json
::
from_str
::
<
ScalabilityMode
>
(
"
\
"
foo
\
""
)
.is_err
());
assert
!
(
serde_json
::
from_str
::
<
ScalabilityMode
>
(
"
\
"
ull
\
""
)
.is_err
());
assert
!
(
serde_json
::
from_str
::
<
ScalabilityMode
>
(
"
\
"
S0T3
\
""
)
.is_err
());
assert
!
(
serde_json
::
from_str
::
<
ScalabilityMode
>
(
"
\
"
S1T0
\
""
)
.is_err
());
let
scalability_mode
:
ScalabilityMode
=
"L20T3"
.parse
()
.unwrap
();
assert
!
(
matches!
(
scalability_mode
,
ScalabilityMode
::
Custom
{
..
}));
assert_eq!
(
scalability_mode
.spatial_layers
(),
NonZeroU8
::
new
(
20
)
.unwrap
()
);
assert_eq!
(
scalability_mode
.temporal_layers
(),
NonZeroU8
::
new
(
3
)
.unwrap
()
);
assert_eq!
(
scalability_mode
.ksvc
(),
false
);
assert
!
(
serde_json
::
from_str
::
<
ScalabilityMode
>
(
"
\
"
S200T3
\
""
)
.is_err
());
let
scalability_mode
:
ScalabilityMode
=
serde_json
::
from_str
(
"
\
"
L4T7_KEY_SHIFT
\
""
)
.unwrap
();
assert
!
(
matches!
(
scalability_mode
,
ScalabilityMode
::
Custom
{
..
}));
assert_eq!
(
scalability_mode
.spatial_layers
(),
NonZeroU8
::
new
(
4
)
.unwrap
()
);
assert_eq!
(
assert_eq!
(
"L4T7_KEY_SHIFT"
.parse
(),
scalability_mode
.temporal_layers
(),
Ok
(
ScalabilityMode
{
NonZeroU8
::
new
(
7
)
.unwrap
()
spatial_layers
:
4
,
temporal_layers
:
7
,
ksvc
:
true
}),
);
);
assert_eq!
(
scalability_mode
.ksvc
(),
true
);
}
}
rust/src/supported_rtp_capabilities.rs
浏览文件 @
8abc21cc
...
@@ -257,42 +257,42 @@ pub fn get_supported_rtp_capabilities() -> RtpCapabilities {
...
@@ -257,42 +257,42 @@ pub fn get_supported_rtp_capabilities() -> RtpCapabilities {
],
],
header_extensions
:
vec!
[
header_extensions
:
vec!
[
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Audio
)
,
kind
:
MediaKind
::
Audio
,
uri
:
RtpHeaderExtensionUri
::
Mid
,
uri
:
RtpHeaderExtensionUri
::
Mid
,
preferred_id
:
1
,
preferred_id
:
1
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
Mid
,
uri
:
RtpHeaderExtensionUri
::
Mid
,
preferred_id
:
1
,
preferred_id
:
1
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
RtpStreamId
,
uri
:
RtpHeaderExtensionUri
::
RtpStreamId
,
preferred_id
:
2
,
preferred_id
:
2
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
RecvOnly
,
direction
:
RtpHeaderExtensionDirection
::
RecvOnly
,
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
RepairRtpStreamId
,
uri
:
RtpHeaderExtensionUri
::
RepairRtpStreamId
,
preferred_id
:
3
,
preferred_id
:
3
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
RecvOnly
,
direction
:
RtpHeaderExtensionDirection
::
RecvOnly
,
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Audio
)
,
kind
:
MediaKind
::
Audio
,
uri
:
RtpHeaderExtensionUri
::
AbsSendTime
,
uri
:
RtpHeaderExtensionUri
::
AbsSendTime
,
preferred_id
:
4
,
preferred_id
:
4
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
AbsSendTime
,
uri
:
RtpHeaderExtensionUri
::
AbsSendTime
,
preferred_id
:
4
,
preferred_id
:
4
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
...
@@ -300,14 +300,14 @@ pub fn get_supported_rtp_capabilities() -> RtpCapabilities {
...
@@ -300,14 +300,14 @@ pub fn get_supported_rtp_capabilities() -> RtpCapabilities {
},
},
// NOTE: For audio we just enable transport-wide-cc-01 when receiving media.
// NOTE: For audio we just enable transport-wide-cc-01 when receiving media.
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Audio
)
,
kind
:
MediaKind
::
Audio
,
uri
:
RtpHeaderExtensionUri
::
TransportWideCcDraft01
,
uri
:
RtpHeaderExtensionUri
::
TransportWideCcDraft01
,
preferred_id
:
5
,
preferred_id
:
5
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
RecvOnly
,
direction
:
RtpHeaderExtensionDirection
::
RecvOnly
,
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
TransportWideCcDraft01
,
uri
:
RtpHeaderExtensionUri
::
TransportWideCcDraft01
,
preferred_id
:
5
,
preferred_id
:
5
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
...
@@ -315,41 +315,40 @@ pub fn get_supported_rtp_capabilities() -> RtpCapabilities {
...
@@ -315,41 +315,40 @@ pub fn get_supported_rtp_capabilities() -> RtpCapabilities {
},
},
// NOTE: Remove this once framemarking draft becomes RFC.
// NOTE: Remove this once framemarking draft becomes RFC.
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
FrameMarkingDraft07
,
uri
:
RtpHeaderExtensionUri
::
FrameMarkingDraft07
,
preferred_id
:
6
,
preferred_id
:
6
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
FrameMarking
,
uri
:
RtpHeaderExtensionUri
::
FrameMarking
,
preferred_id
:
7
,
preferred_id
:
7
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Audio
)
,
kind
:
MediaKind
::
Audio
,
uri
:
RtpHeaderExtensionUri
::
AudioLevel
,
uri
:
RtpHeaderExtensionUri
::
AudioLevel
,
preferred_id
:
10
,
preferred_id
:
10
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
VideoOrientation
,
uri
:
RtpHeaderExtensionUri
::
VideoOrientation
,
preferred_id
:
11
,
preferred_id
:
11
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
TimeOffset
,
uri
:
RtpHeaderExtensionUri
::
TimeOffset
,
preferred_id
:
12
,
preferred_id
:
12
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
},
},
],
],
fec_mechanisms
:
vec!
[],
}
}
}
}
rust/src/worker.rs
浏览文件 @
8abc21cc
...
@@ -12,7 +12,7 @@ use crate::messages::{
...
@@ -12,7 +12,7 @@ use crate::messages::{
RouterInternal
,
WorkerCloseRequest
,
WorkerCreateRouterRequest
,
WorkerDumpRequest
,
RouterInternal
,
WorkerCloseRequest
,
WorkerCreateRouterRequest
,
WorkerDumpRequest
,
WorkerUpdateSettingsRequest
,
WorkerUpdateSettingsRequest
,
};
};
use
crate
::
ortc
::
RtpCapabilitiesError
;
pub
use
crate
::
ortc
::
RtpCapabilitiesError
;
use
crate
::
router
::{
Router
,
RouterId
,
RouterOptions
};
use
crate
::
router
::{
Router
,
RouterId
,
RouterOptions
};
use
crate
::
worker
::
channel
::
BufferMessagesGuard
;
use
crate
::
worker
::
channel
::
BufferMessagesGuard
;
pub
use
crate
::
worker
::
utils
::
ExitError
;
pub
use
crate
::
worker
::
utils
::
ExitError
;
...
...
rust/tests/integration/consumer.rs
浏览文件 @
8abc21cc
...
@@ -14,6 +14,7 @@ use mediasoup::rtp_parameters::{
...
@@ -14,6 +14,7 @@ use mediasoup::rtp_parameters::{
RtpHeaderExtensionDirection
,
RtpHeaderExtensionParameters
,
RtpHeaderExtensionUri
,
RtpHeaderExtensionDirection
,
RtpHeaderExtensionParameters
,
RtpHeaderExtensionUri
,
RtpParameters
,
RtpParameters
,
};
};
use
mediasoup
::
scalability_modes
::
ScalabilityMode
;
use
mediasoup
::
transport
::{
ConsumeError
,
Transport
,
TransportGeneric
};
use
mediasoup
::
transport
::{
ConsumeError
,
Transport
,
TransportGeneric
};
use
mediasoup
::
webrtc_transport
::{
TransportListenIps
,
WebRtcTransport
,
WebRtcTransportOptions
};
use
mediasoup
::
webrtc_transport
::{
TransportListenIps
,
WebRtcTransport
,
WebRtcTransportOptions
};
use
mediasoup
::
worker
::{
Worker
,
WorkerSettings
};
use
mediasoup
::
worker
::{
Worker
,
WorkerSettings
};
...
@@ -224,63 +225,62 @@ fn consumer_device_capabilities() -> RtpCapabilities {
...
@@ -224,63 +225,62 @@ fn consumer_device_capabilities() -> RtpCapabilities {
],
],
header_extensions
:
vec!
[
header_extensions
:
vec!
[
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Audio
)
,
kind
:
MediaKind
::
Audio
,
uri
:
RtpHeaderExtensionUri
::
Mid
,
uri
:
RtpHeaderExtensionUri
::
Mid
,
preferred_id
:
1
,
preferred_id
:
1
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
default
(),
direction
:
RtpHeaderExtensionDirection
::
default
(),
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
Mid
,
uri
:
RtpHeaderExtensionUri
::
Mid
,
preferred_id
:
1
,
preferred_id
:
1
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
default
(),
direction
:
RtpHeaderExtensionDirection
::
default
(),
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
RtpStreamId
,
uri
:
RtpHeaderExtensionUri
::
RtpStreamId
,
preferred_id
:
2
,
preferred_id
:
2
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
default
(),
direction
:
RtpHeaderExtensionDirection
::
default
(),
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Audio
)
,
kind
:
MediaKind
::
Audio
,
uri
:
RtpHeaderExtensionUri
::
AbsSendTime
,
uri
:
RtpHeaderExtensionUri
::
AbsSendTime
,
preferred_id
:
4
,
preferred_id
:
4
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
default
(),
direction
:
RtpHeaderExtensionDirection
::
default
(),
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
AbsSendTime
,
uri
:
RtpHeaderExtensionUri
::
AbsSendTime
,
preferred_id
:
4
,
preferred_id
:
4
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
default
(),
direction
:
RtpHeaderExtensionDirection
::
default
(),
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Audio
)
,
kind
:
MediaKind
::
Audio
,
uri
:
RtpHeaderExtensionUri
::
AudioLevel
,
uri
:
RtpHeaderExtensionUri
::
AudioLevel
,
preferred_id
:
10
,
preferred_id
:
10
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
default
(),
direction
:
RtpHeaderExtensionDirection
::
default
(),
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
VideoOrientation
,
uri
:
RtpHeaderExtensionUri
::
VideoOrientation
,
preferred_id
:
11
,
preferred_id
:
11
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
default
(),
direction
:
RtpHeaderExtensionDirection
::
default
(),
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
TimeOffset
,
uri
:
RtpHeaderExtensionUri
::
TimeOffset
,
preferred_id
:
12
,
preferred_id
:
12
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
default
(),
direction
:
RtpHeaderExtensionDirection
::
default
(),
},
},
],
],
fec_mechanisms
:
vec!
[],
}
}
}
}
...
@@ -705,7 +705,6 @@ fn consume_incompatible_rtp_capabilities() {
...
@@ -705,7 +705,6 @@ fn consume_incompatible_rtp_capabilities() {
rtcp_feedback
:
vec!
[],
rtcp_feedback
:
vec!
[],
}],
}],
header_extensions
:
vec!
[],
header_extensions
:
vec!
[],
fec_mechanisms
:
vec!
[],
};
};
assert_eq!
(
assert_eq!
(
...
@@ -728,7 +727,6 @@ fn consume_incompatible_rtp_capabilities() {
...
@@ -728,7 +727,6 @@ fn consume_incompatible_rtp_capabilities() {
let
invalid_device_capabilities
=
RtpCapabilities
{
let
invalid_device_capabilities
=
RtpCapabilities
{
codecs
:
vec!
[],
codecs
:
vec!
[],
header_extensions
:
vec!
[],
header_extensions
:
vec!
[],
fec_mechanisms
:
vec!
[],
};
};
assert_eq!
(
assert_eq!
(
...
@@ -830,7 +828,7 @@ fn dump_succeeds() {
...
@@ -830,7 +828,7 @@ fn dump_succeeds() {
codec_payload_type
:
Some
(
100
),
codec_payload_type
:
Some
(
100
),
rtx
:
None
,
rtx
:
None
,
dtx
:
None
,
dtx
:
None
,
scalability_mode
:
None
,
scalability_mode
:
ScalabilityMode
::
None
,
scale_resolution_down_by
:
None
,
scale_resolution_down_by
:
None
,
ssrc
:
audio_consumer
ssrc
:
audio_consumer
.rtp_parameters
()
.rtp_parameters
()
...
@@ -857,7 +855,7 @@ fn dump_succeeds() {
...
@@ -857,7 +855,7 @@ fn dump_succeeds() {
max_bitrate
:
None
,
max_bitrate
:
None
,
max_framerate
:
None
,
max_framerate
:
None
,
dtx
:
None
,
dtx
:
None
,
scalability_mode
:
None
,
scalability_mode
:
ScalabilityMode
::
None
,
spatial_layers
:
None
,
spatial_layers
:
None
,
temporal_layers
:
None
,
temporal_layers
:
None
,
ksvc
:
None
ksvc
:
None
...
@@ -958,7 +956,7 @@ fn dump_succeeds() {
...
@@ -958,7 +956,7 @@ fn dump_succeeds() {
.unwrap
()
.unwrap
()
.rtx
,
.rtx
,
dtx
:
None
,
dtx
:
None
,
scalability_mode
:
Some
(
"S4T1"
.to_string
()
),
scalability_mode
:
"S4T1"
.parse
()
.unwrap
(
),
scale_resolution_down_by
:
None
,
scale_resolution_down_by
:
None
,
rid
:
None
,
rid
:
None
,
max_bitrate
:
None
,
max_bitrate
:
None
,
...
@@ -979,7 +977,7 @@ fn dump_succeeds() {
...
@@ -979,7 +977,7 @@ fn dump_succeeds() {
max_bitrate
:
None
,
max_bitrate
:
None
,
max_framerate
:
None
,
max_framerate
:
None
,
dtx
:
None
,
dtx
:
None
,
scalability_mode
:
None
,
scalability_mode
:
ScalabilityMode
::
None
,
spatial_layers
:
None
,
spatial_layers
:
None
,
temporal_layers
:
None
,
temporal_layers
:
None
,
ksvc
:
None
,
ksvc
:
None
,
...
...
rust/tests/integration/pipe_transport.rs
浏览文件 @
8abc21cc
...
@@ -188,28 +188,27 @@ fn consumer_device_capabilities() -> RtpCapabilities {
...
@@ -188,28 +188,27 @@ fn consumer_device_capabilities() -> RtpCapabilities {
],
],
header_extensions
:
vec!
[
header_extensions
:
vec!
[
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
AbsSendTime
,
uri
:
RtpHeaderExtensionUri
::
AbsSendTime
,
preferred_id
:
4
,
preferred_id
:
4
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
direction
:
RtpHeaderExtensionDirection
::
SendRecv
,
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Video
)
,
kind
:
MediaKind
::
Video
,
uri
:
RtpHeaderExtensionUri
::
TransportWideCcDraft01
,
uri
:
RtpHeaderExtensionUri
::
TransportWideCcDraft01
,
preferred_id
:
5
,
preferred_id
:
5
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
default
(),
direction
:
RtpHeaderExtensionDirection
::
default
(),
},
},
RtpHeaderExtension
{
RtpHeaderExtension
{
kind
:
Some
(
MediaKind
::
Audio
)
,
kind
:
MediaKind
::
Audio
,
uri
:
RtpHeaderExtensionUri
::
AudioLevel
,
uri
:
RtpHeaderExtensionUri
::
AudioLevel
,
preferred_id
:
10
,
preferred_id
:
10
,
preferred_encrypt
:
false
,
preferred_encrypt
:
false
,
direction
:
RtpHeaderExtensionDirection
::
default
(),
direction
:
RtpHeaderExtensionDirection
::
default
(),
},
},
],
],
fec_mechanisms
:
vec!
[],
}
}
}
}
...
...
rust/tests/integration/producer.rs
浏览文件 @
8abc21cc
...
@@ -8,6 +8,7 @@ use mediasoup::rtp_parameters::{
...
@@ -8,6 +8,7 @@ use mediasoup::rtp_parameters::{
RtpCodecParameters
,
RtpCodecParametersParameters
,
RtpEncodingParameters
,
RtpCodecParameters
,
RtpCodecParametersParameters
,
RtpEncodingParameters
,
RtpEncodingParametersRtx
,
RtpHeaderExtensionParameters
,
RtpHeaderExtensionUri
,
RtpParameters
,
RtpEncodingParametersRtx
,
RtpHeaderExtensionParameters
,
RtpHeaderExtensionUri
,
RtpParameters
,
};
};
use
mediasoup
::
scalability_modes
::
ScalabilityMode
;
use
mediasoup
::
transport
::{
ProduceError
,
Transport
,
TransportGeneric
};
use
mediasoup
::
transport
::{
ProduceError
,
Transport
,
TransportGeneric
};
use
mediasoup
::
webrtc_transport
::{
TransportListenIps
,
WebRtcTransport
,
WebRtcTransportOptions
};
use
mediasoup
::
webrtc_transport
::{
TransportListenIps
,
WebRtcTransport
,
WebRtcTransportOptions
};
use
mediasoup
::
worker
::{
Worker
,
WorkerSettings
};
use
mediasoup
::
worker
::{
Worker
,
WorkerSettings
};
...
@@ -144,7 +145,7 @@ fn video_producer_options() -> ProducerOptions {
...
@@ -144,7 +145,7 @@ fn video_producer_options() -> ProducerOptions {
RtpEncodingParameters
{
RtpEncodingParameters
{
ssrc
:
Some
(
22222222
),
ssrc
:
Some
(
22222222
),
rtx
:
Some
(
RtpEncodingParametersRtx
{
ssrc
:
22222223
}),
rtx
:
Some
(
RtpEncodingParametersRtx
{
ssrc
:
22222223
}),
scalability_mode
:
Some
(
"L1T3"
.to_string
()
),
scalability_mode
:
"L1T3"
.parse
()
.unwrap
(
),
..
RtpEncodingParameters
::
default
()
..
RtpEncodingParameters
::
default
()
},
},
RtpEncodingParameters
{
RtpEncodingParameters
{
...
@@ -674,7 +675,7 @@ fn dump_succeeds() {
...
@@ -674,7 +675,7 @@ fn dump_succeeds() {
codec_payload_type
:
Some
(
0
),
codec_payload_type
:
Some
(
0
),
rtx
:
None
,
rtx
:
None
,
dtx
:
None
,
dtx
:
None
,
scalability_mode
:
None
,
scalability_mode
:
ScalabilityMode
::
None
,
scale_resolution_down_by
:
None
,
scale_resolution_down_by
:
None
,
max_bitrate
:
None
max_bitrate
:
None
}],
}],
...
@@ -712,7 +713,7 @@ fn dump_succeeds() {
...
@@ -712,7 +713,7 @@ fn dump_succeeds() {
codec_payload_type
:
Some
(
112
),
codec_payload_type
:
Some
(
112
),
rtx
:
Some
(
RtpEncodingParametersRtx
{
ssrc
:
22222223
}),
rtx
:
Some
(
RtpEncodingParametersRtx
{
ssrc
:
22222223
}),
dtx
:
None
,
dtx
:
None
,
scalability_mode
:
Some
(
"L1T3"
.to_string
()
),
scalability_mode
:
"L1T3"
.parse
()
.unwrap
(
),
scale_resolution_down_by
:
None
,
scale_resolution_down_by
:
None
,
max_bitrate
:
None
max_bitrate
:
None
},
},
...
@@ -722,7 +723,7 @@ fn dump_succeeds() {
...
@@ -722,7 +723,7 @@ fn dump_succeeds() {
codec_payload_type
:
Some
(
112
),
codec_payload_type
:
Some
(
112
),
rtx
:
Some
(
RtpEncodingParametersRtx
{
ssrc
:
22222225
}),
rtx
:
Some
(
RtpEncodingParametersRtx
{
ssrc
:
22222225
}),
dtx
:
None
,
dtx
:
None
,
scalability_mode
:
None
,
scalability_mode
:
ScalabilityMode
::
None
,
scale_resolution_down_by
:
None
,
scale_resolution_down_by
:
None
,
max_bitrate
:
None
max_bitrate
:
None
},
},
...
@@ -732,7 +733,7 @@ fn dump_succeeds() {
...
@@ -732,7 +733,7 @@ fn dump_succeeds() {
codec_payload_type
:
Some
(
112
),
codec_payload_type
:
Some
(
112
),
rtx
:
Some
(
RtpEncodingParametersRtx
{
ssrc
:
22222227
}),
rtx
:
Some
(
RtpEncodingParametersRtx
{
ssrc
:
22222227
}),
dtx
:
None
,
dtx
:
None
,
scalability_mode
:
None
,
scalability_mode
:
ScalabilityMode
::
None
,
scale_resolution_down_by
:
None
,
scale_resolution_down_by
:
None
,
max_bitrate
:
None
max_bitrate
:
None
},
},
...
@@ -742,7 +743,7 @@ fn dump_succeeds() {
...
@@ -742,7 +743,7 @@ fn dump_succeeds() {
codec_payload_type
:
Some
(
112
),
codec_payload_type
:
Some
(
112
),
rtx
:
Some
(
RtpEncodingParametersRtx
{
ssrc
:
22222229
}),
rtx
:
Some
(
RtpEncodingParametersRtx
{
ssrc
:
22222229
}),
dtx
:
None
,
dtx
:
None
,
scalability_mode
:
None
,
scalability_mode
:
ScalabilityMode
::
None
,
scale_resolution_down_by
:
None
,
scale_resolution_down_by
:
None
,
max_bitrate
:
None
max_bitrate
:
None
},
},
...
...
rust/tests/integration/smoke.rs
浏览文件 @
8abc21cc
...
@@ -160,7 +160,6 @@ fn smoke() {
...
@@ -160,7 +160,6 @@ fn smoke() {
rtcp_feedback
:
vec!
[],
rtcp_feedback
:
vec!
[],
}],
}],
header_extensions
:
vec!
[],
header_extensions
:
vec!
[],
fec_mechanisms
:
vec!
[],
},
},
))
))
.await
.await
...
...
src/RtpObserver.ts
浏览文件 @
8abc21cc
...
@@ -225,9 +225,9 @@ export class RtpObserver extends EnhancedEventEmitter
...
@@ -225,9 +225,9 @@ export class RtpObserver extends EnhancedEventEmitter
logger
.
debug
(
'addProducer()'
);
logger
.
debug
(
'addProducer()'
);
const
producer
=
this
.
_getProducerById
(
producerId
);
const
producer
=
this
.
_getProducerById
(
producerId
);
const
internal
=
{
...
this
.
_internal
,
producerId
};
const
reqData
=
{
producerId
};
await
this
.
_channel
.
request
(
'rtpObserver.addProducer'
,
internal
);
await
this
.
_channel
.
request
(
'rtpObserver.addProducer'
,
this
.
_internal
,
reqData
);
// Emit observer event.
// Emit observer event.
this
.
_observer
.
safeEmit
(
'addproducer'
,
producer
);
this
.
_observer
.
safeEmit
(
'addproducer'
,
producer
);
...
@@ -241,9 +241,9 @@ export class RtpObserver extends EnhancedEventEmitter
...
@@ -241,9 +241,9 @@ export class RtpObserver extends EnhancedEventEmitter
logger
.
debug
(
'removeProducer()'
);
logger
.
debug
(
'removeProducer()'
);
const
producer
=
this
.
_getProducerById
(
producerId
);
const
producer
=
this
.
_getProducerById
(
producerId
);
const
internal
=
{
...
this
.
_internal
,
producerId
};
const
reqData
=
{
producerId
};
await
this
.
_channel
.
request
(
'rtpObserver.removeProducer'
,
internal
);
await
this
.
_channel
.
request
(
'rtpObserver.removeProducer'
,
this
.
_internal
,
reqData
);
// Emit observer event.
// Emit observer event.
this
.
_observer
.
safeEmit
(
'removeproducer'
,
producer
);
this
.
_observer
.
safeEmit
(
'removeproducer'
,
producer
);
...
...
src/RtpParameters.ts
浏览文件 @
8abc21cc
...
@@ -13,11 +13,6 @@ export type RtpCapabilities =
...
@@ -13,11 +13,6 @@ export type RtpCapabilities =
* Supported RTP header extensions.
* Supported RTP header extensions.
*/
*/
headerExtensions
?:
RtpHeaderExtension
[];
headerExtensions
?:
RtpHeaderExtension
[];
/**
* Supported FEC mechanisms.
*/
fecMechanisms
?:
string
[];
}
}
/**
/**
...
@@ -101,10 +96,9 @@ export type RtpHeaderExtensionDirection = 'sendrecv' | 'sendonly' | 'recvonly' |
...
@@ -101,10 +96,9 @@ export type RtpHeaderExtensionDirection = 'sendrecv' | 'sendonly' | 'recvonly' |
export
type
RtpHeaderExtension
=
export
type
RtpHeaderExtension
=
{
{
/**
/**
* Media kind. If empty string, it's valid for all kinds.
* Media kind.
* Default any media kind.
*/
*/
kind
?:
MediaKind
|
''
;
kind
:
MediaKind
;
/*
/*
* The URI of the RTP header extension, as defined in RFC 5285.
* The URI of the RTP header extension, as defined in RFC 5285.
...
...
src/ortc.ts
浏览文件 @
8abc21cc
...
@@ -190,11 +190,7 @@ export function validateRtpHeaderExtension(ext: RtpHeaderExtension): void
...
@@ -190,11 +190,7 @@ export function validateRtpHeaderExtension(ext: RtpHeaderExtension): void
if
(
typeof
ext
!==
'object'
)
if
(
typeof
ext
!==
'object'
)
throw
new
TypeError
(
'ext is not an object'
);
throw
new
TypeError
(
'ext is not an object'
);
// kind is optional. If unset set it to an empty string.
if
(
ext
.
kind
!==
'audio'
&&
ext
.
kind
!==
'video'
)
if
(
!
ext
.
kind
||
typeof
ext
.
kind
!==
'string'
)
ext
.
kind
=
''
;
if
(
ext
.
kind
!==
''
&&
ext
.
kind
!==
'audio'
&&
ext
.
kind
!==
'video'
)
throw
new
TypeError
(
'invalid ext.kind'
);
throw
new
TypeError
(
'invalid ext.kind'
);
// uri is mandatory.
// uri is mandatory.
...
...
worker/Cargo.toml
浏览文件 @
8abc21cc
[package]
[package]
name
=
"mediasoup-sys"
name
=
"mediasoup-sys"
version
=
"0.
1.4
"
version
=
"0.
2.0
"
description
=
"FFI bindings to C++ libmediasoup-worker"
description
=
"FFI bindings to C++ libmediasoup-worker"
authors
=
[
"Nazar Mokrynskyi <nazar@mokrynskyi.com>"
]
authors
=
[
"Nazar Mokrynskyi <nazar@mokrynskyi.com>"
]
edition
=
"2018"
edition
=
"2018"
...
...
worker/include/RTC/Router.hpp
浏览文件 @
8abc21cc
...
@@ -39,7 +39,7 @@ namespace RTC
...
@@ -39,7 +39,7 @@ namespace RTC
RTC
::
Transport
*
GetTransportFromInternal
(
json
&
internal
)
const
;
RTC
::
Transport
*
GetTransportFromInternal
(
json
&
internal
)
const
;
void
SetNewRtpObserverIdFromInternal
(
json
&
internal
,
std
::
string
&
rtpObserverId
)
const
;
void
SetNewRtpObserverIdFromInternal
(
json
&
internal
,
std
::
string
&
rtpObserverId
)
const
;
RTC
::
RtpObserver
*
GetRtpObserverFromInternal
(
json
&
internal
)
const
;
RTC
::
RtpObserver
*
GetRtpObserverFromInternal
(
json
&
internal
)
const
;
RTC
::
Producer
*
GetProducerFrom
Internal
(
json
&
internal
)
const
;
RTC
::
Producer
*
GetProducerFrom
Data
(
json
&
data
)
const
;
/* Pure virtual methods inherited from RTC::Transport::Listener. */
/* Pure virtual methods inherited from RTC::Transport::Listener. */
public
:
public
:
...
...
worker/src/RTC/Router.cpp
浏览文件 @
8abc21cc
...
@@ -365,7 +365,7 @@ namespace RTC
...
@@ -365,7 +365,7 @@ namespace RTC
{
{
// This may throw.
// This may throw.
RTC
::
RtpObserver
*
rtpObserver
=
GetRtpObserverFromInternal
(
request
->
internal
);
RTC
::
RtpObserver
*
rtpObserver
=
GetRtpObserverFromInternal
(
request
->
internal
);
RTC
::
Producer
*
producer
=
GetProducerFrom
Internal
(
request
->
internal
);
RTC
::
Producer
*
producer
=
GetProducerFrom
Data
(
request
->
data
);
rtpObserver
->
AddProducer
(
producer
);
rtpObserver
->
AddProducer
(
producer
);
...
@@ -381,7 +381,7 @@ namespace RTC
...
@@ -381,7 +381,7 @@ namespace RTC
{
{
// This may throw.
// This may throw.
RTC
::
RtpObserver
*
rtpObserver
=
GetRtpObserverFromInternal
(
request
->
internal
);
RTC
::
RtpObserver
*
rtpObserver
=
GetRtpObserverFromInternal
(
request
->
internal
);
RTC
::
Producer
*
producer
=
GetProducerFrom
Internal
(
request
->
internal
);
RTC
::
Producer
*
producer
=
GetProducerFrom
Data
(
request
->
data
);
rtpObserver
->
RemoveProducer
(
producer
);
rtpObserver
->
RemoveProducer
(
producer
);
...
@@ -494,14 +494,14 @@ namespace RTC
...
@@ -494,14 +494,14 @@ namespace RTC
return
rtpObserver
;
return
rtpObserver
;
}
}
RTC
::
Producer
*
Router
::
GetProducerFrom
Internal
(
json
&
internal
)
const
RTC
::
Producer
*
Router
::
GetProducerFrom
Data
(
json
&
data
)
const
{
{
MS_TRACE
();
MS_TRACE
();
auto
jsonProducerIdIt
=
internal
.
find
(
"producerId"
);
auto
jsonProducerIdIt
=
data
.
find
(
"producerId"
);
if
(
jsonProducerIdIt
==
internal
.
end
()
||
!
jsonProducerIdIt
->
is_string
())
if
(
jsonProducerIdIt
==
data
.
end
()
||
!
jsonProducerIdIt
->
is_string
())
MS_THROW_ERROR
(
"missing
internal
.producerId"
);
MS_THROW_ERROR
(
"missing
data
.producerId"
);
auto
it
=
this
->
mapProducers
.
find
(
jsonProducerIdIt
->
get
<
std
::
string
>
());
auto
it
=
this
->
mapProducers
.
find
(
jsonProducerIdIt
->
get
<
std
::
string
>
());
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论