Skip to content

Commit 1cbfaa8

Browse files
authored
Move RtcRtpEncodingParameters into submodule in medea-flutter-webrtc-native crate (#223, #210)
1 parent e4cf6fa commit 1cbfaa8

File tree

8 files changed

+163
-151
lines changed

8 files changed

+163
-151
lines changed

crates/native/src/api/mod.rs

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
pub mod capability;
44
pub mod media_info;
55
pub mod media_stream_track;
6+
pub mod rtc_rtp_encoding_parameters;
67
pub mod stats;
78

89
use std::{
@@ -33,6 +34,7 @@ pub use self::{
3334
set_audio_level_observer_enabled, set_track_enabled, track_height,
3435
track_state, track_width, update_audio_processing,
3536
},
37+
rtc_rtp_encoding_parameters::RtcRtpEncodingParameters,
3638
stats::{
3739
CandidateType, IceCandidateStats, IceRole, Protocol,
3840
RtcIceCandidateStats, RtcInboundRtpStreamMediaType,
@@ -597,48 +599,6 @@ pub struct AudioProcessingConstraints {
597599
pub echo_cancellation: Option<bool>,
598600
}
599601

600-
/// Representation of [RTCRtpEncodingParameters][0].
601-
///
602-
/// [0]: https://w3.org/TR/webrtc#rtcrtpencodingparameters
603-
pub struct RtcRtpEncodingParameters {
604-
/// [RTP stream ID (RID)][0] to be sent using the RID header extension.
605-
///
606-
/// [0]: https://w3.org/TR/webrtc#dom-rtcrtpcodingparameters-rid
607-
pub rid: String,
608-
609-
/// Indicator whether the described [`RtcRtpEncodingParameters`] are
610-
/// currently actively being used.
611-
pub active: bool,
612-
613-
/// Maximum number of bits per second to allow for these
614-
/// [`RtcRtpEncodingParameters`].
615-
pub max_bitrate: Option<i32>,
616-
617-
/// Maximum number of frames per second to allow for these
618-
/// [`RtcRtpEncodingParameters`].
619-
pub max_framerate: Option<f64>,
620-
621-
/// Factor for scaling down the video with these
622-
/// [`RtcRtpEncodingParameters`].
623-
pub scale_resolution_down_by: Option<f64>,
624-
625-
/// Scalability mode describing layers within the media stream.
626-
pub scalability_mode: Option<String>,
627-
}
628-
629-
impl From<&sys::RtpEncodingParameters> for RtcRtpEncodingParameters {
630-
fn from(sys: &sys::RtpEncodingParameters) -> Self {
631-
Self {
632-
rid: sys.rid(),
633-
active: sys.active(),
634-
max_bitrate: sys.max_bitrate(),
635-
max_framerate: sys.max_framerate(),
636-
scale_resolution_down_by: sys.scale_resolution_down_by(),
637-
scalability_mode: sys.scalability_mode(),
638-
}
639-
}
640-
}
641-
642602
/// Representation of an [RTCRtpTransceiverInit][0].
643603
///
644604
/// [0]: https://w3.org/TR/webrtc#dom-rtcrtptransceiverinit
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//! [RTCRtpEncodingParameters][0] definitions.
2+
//!
3+
//! [0]: https://w3.org/TR/webrtc#rtcrtpencodingparameters
4+
5+
use libwebrtc_sys as sys;
6+
7+
/// Representation of [RTCRtpEncodingParameters][0].
8+
///
9+
/// [0]: https://w3.org/TR/webrtc#rtcrtpencodingparameters
10+
pub struct RtcRtpEncodingParameters {
11+
/// [RTP stream ID (RID)][0] to be sent using the RID header extension.
12+
///
13+
/// [0]: https://w3.org/TR/webrtc#dom-rtcrtpcodingparameters-rid
14+
pub rid: String,
15+
16+
/// Indicator whether the described [`RtcRtpEncodingParameters`] are
17+
/// currently actively being used.
18+
pub active: bool,
19+
20+
/// Maximum number of bits per second to allow for these
21+
/// [`RtcRtpEncodingParameters`].
22+
pub max_bitrate: Option<i32>,
23+
24+
/// Maximum number of frames per second to allow for these
25+
/// [`RtcRtpEncodingParameters`].
26+
pub max_framerate: Option<f64>,
27+
28+
/// Factor for scaling down the video with these
29+
/// [`RtcRtpEncodingParameters`].
30+
pub scale_resolution_down_by: Option<f64>,
31+
32+
/// Scalability mode describing layers within the media stream.
33+
pub scalability_mode: Option<String>,
34+
}
35+
36+
impl From<&sys::RtpEncodingParameters> for RtcRtpEncodingParameters {
37+
fn from(sys: &sys::RtpEncodingParameters) -> Self {
38+
Self {
39+
rid: sys.rid(),
40+
active: sys.active(),
41+
max_bitrate: sys.max_bitrate(),
42+
max_framerate: sys.max_framerate(),
43+
scale_resolution_down_by: sys.scale_resolution_down_by(),
44+
scalability_mode: sys.scalability_mode(),
45+
}
46+
}
47+
}

crates/native/src/frb_generated.rs

Lines changed: 40 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ impl SseDecode for Vec<u8> {
13121312

13131313
impl SseDecode
13141314
for Vec<(
1315-
crate::api::RtcRtpEncodingParameters,
1315+
crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters,
13161316
RustOpaqueMoi<Arc<RtpEncodingParameters>>,
13171317
)>
13181318
{
@@ -1323,10 +1323,7 @@ impl SseDecode
13231323
let mut len_ = <i32>::sse_decode(deserializer);
13241324
let mut ans_ = vec![];
13251325
for idx_ in 0..len_ {
1326-
ans_.push(<(
1327-
crate::api::RtcRtpEncodingParameters,
1328-
RustOpaqueMoi<Arc<RtpEncodingParameters>>,
1329-
)>::sse_decode(deserializer));
1326+
ans_.push(<(crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters,RustOpaqueMoi<Arc < RtpEncodingParameters >>,)>::sse_decode(deserializer));
13301327
}
13311328
return ans_;
13321329
}
@@ -1360,17 +1357,17 @@ impl SseDecode for Vec<crate::api::RtcIceServer> {
13601357
}
13611358
}
13621359

1363-
impl SseDecode for Vec<crate::api::RtcRtpEncodingParameters> {
1360+
impl SseDecode
1361+
for Vec<crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters>
1362+
{
13641363
// Codec=Sse (Serialization based), see doc to use other codecs
13651364
fn sse_decode(
13661365
deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer,
13671366
) -> Self {
13681367
let mut len_ = <i32>::sse_decode(deserializer);
13691368
let mut ans_ = vec![];
13701369
for idx_ in 0..len_ {
1371-
ans_.push(<crate::api::RtcRtpEncodingParameters>::sse_decode(
1372-
deserializer,
1373-
));
1370+
ans_.push(<crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters>::sse_decode(deserializer));
13741371
}
13751372
return ans_;
13761373
}
@@ -1885,16 +1882,15 @@ impl SseDecode for crate::api::stats::rtc_ice_candidate_stats::Protocol {
18851882

18861883
impl SseDecode
18871884
for (
1888-
crate::api::RtcRtpEncodingParameters,
1885+
crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters,
18891886
RustOpaqueMoi<Arc<RtpEncodingParameters>>,
18901887
)
18911888
{
18921889
// Codec=Sse (Serialization based), see doc to use other codecs
18931890
fn sse_decode(
18941891
deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer,
18951892
) -> Self {
1896-
let mut var_field0 =
1897-
<crate::api::RtcRtpEncodingParameters>::sse_decode(deserializer);
1893+
let mut var_field0 = <crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters>::sse_decode(deserializer);
18981894
let mut var_field1 =
18991895
<RustOpaqueMoi<Arc<RtpEncodingParameters>>>::sse_decode(
19001896
deserializer,
@@ -2029,7 +2025,9 @@ return crate::api::stats::rtc_outbound_rtp_stream_media_type::RtcOutboundRtpStre
20292025
_ => { unimplemented!(""); }}}
20302026
}
20312027

2032-
impl SseDecode for crate::api::RtcRtpEncodingParameters {
2028+
impl SseDecode
2029+
for crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters
2030+
{
20332031
// Codec=Sse (Serialization based), see doc to use other codecs
20342032
fn sse_decode(
20352033
deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer,
@@ -2042,14 +2040,7 @@ impl SseDecode for crate::api::RtcRtpEncodingParameters {
20422040
<Option<f64>>::sse_decode(deserializer);
20432041
let mut var_scalabilityMode =
20442042
<Option<String>>::sse_decode(deserializer);
2045-
return crate::api::RtcRtpEncodingParameters {
2046-
rid: var_rid,
2047-
active: var_active,
2048-
max_bitrate: var_maxBitrate,
2049-
max_framerate: var_maxFramerate,
2050-
scale_resolution_down_by: var_scaleResolutionDownBy,
2051-
scalability_mode: var_scalabilityMode,
2052-
};
2043+
return crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters{rid: var_rid, active: var_active, max_bitrate: var_maxBitrate, max_framerate: var_maxFramerate, scale_resolution_down_by: var_scaleResolutionDownBy, scalability_mode: var_scalabilityMode};
20532044
}
20542045
}
20552046

@@ -2059,7 +2050,7 @@ impl SseDecode for crate::api::RtcRtpSendParameters {
20592050
deserializer: &mut flutter_rust_bridge::for_generated::SseDeserializer,
20602051
) -> Self {
20612052
let mut var_encodings = <Vec<(
2062-
crate::api::RtcRtpEncodingParameters,
2053+
crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters,
20632054
RustOpaqueMoi<Arc<RtpEncodingParameters>>,
20642055
)>>::sse_decode(deserializer);
20652056
let mut var_inner =
@@ -2402,10 +2393,9 @@ impl SseDecode for crate::api::RtpTransceiverInit {
24022393
) -> Self {
24032394
let mut var_direction =
24042395
<crate::api::RtpTransceiverDirection>::sse_decode(deserializer);
2405-
let mut var_sendEncodings =
2406-
<Vec<crate::api::RtcRtpEncodingParameters>>::sse_decode(
2407-
deserializer,
2408-
);
2396+
let mut var_sendEncodings = <Vec<
2397+
crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters,
2398+
>>::sse_decode(deserializer);
24092399
return crate::api::RtpTransceiverInit {
24102400
direction: var_direction,
24112401
send_encodings: var_sendEncodings,
@@ -3470,7 +3460,9 @@ impl flutter_rust_bridge::IntoIntoDart<crate::api::stats::rtc_outbound_rtp_strea
34703460
}
34713461
}
34723462
// Codec=Dco (DartCObject based), see doc to use other codecs
3473-
impl flutter_rust_bridge::IntoDart for crate::api::RtcRtpEncodingParameters {
3463+
impl flutter_rust_bridge::IntoDart
3464+
for crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters
3465+
{
34743466
fn into_dart(self) -> flutter_rust_bridge::for_generated::DartAbi {
34753467
[
34763468
self.rid.into_into_dart().into_dart(),
@@ -3484,13 +3476,17 @@ impl flutter_rust_bridge::IntoDart for crate::api::RtcRtpEncodingParameters {
34843476
}
34853477
}
34863478
impl flutter_rust_bridge::for_generated::IntoDartExceptPrimitive
3487-
for crate::api::RtcRtpEncodingParameters
3479+
for crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters
34883480
{
34893481
}
3490-
impl flutter_rust_bridge::IntoIntoDart<crate::api::RtcRtpEncodingParameters>
3491-
for crate::api::RtcRtpEncodingParameters
3482+
impl
3483+
flutter_rust_bridge::IntoIntoDart<
3484+
crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters,
3485+
> for crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters
34923486
{
3493-
fn into_into_dart(self) -> crate::api::RtcRtpEncodingParameters {
3487+
fn into_into_dart(
3488+
self,
3489+
) -> crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters {
34943490
self
34953491
}
34963492
}
@@ -4611,7 +4607,7 @@ impl SseEncode for Vec<u8> {
46114607

46124608
impl SseEncode
46134609
for Vec<(
4614-
crate::api::RtcRtpEncodingParameters,
4610+
crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters,
46154611
RustOpaqueMoi<Arc<RtpEncodingParameters>>,
46164612
)>
46174613
{
@@ -4622,10 +4618,7 @@ impl SseEncode
46224618
) {
46234619
<i32>::sse_encode(self.len() as _, serializer);
46244620
for item in self {
4625-
<(
4626-
crate::api::RtcRtpEncodingParameters,
4627-
RustOpaqueMoi<Arc<RtpEncodingParameters>>,
4628-
)>::sse_encode(item, serializer);
4621+
<(crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters,RustOpaqueMoi<Arc < RtpEncodingParameters >>,)>::sse_encode(item, serializer);
46294622
}
46304623
}
46314624
}
@@ -4656,17 +4649,17 @@ impl SseEncode for Vec<crate::api::RtcIceServer> {
46564649
}
46574650
}
46584651

4659-
impl SseEncode for Vec<crate::api::RtcRtpEncodingParameters> {
4652+
impl SseEncode
4653+
for Vec<crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters>
4654+
{
46604655
// Codec=Sse (Serialization based), see doc to use other codecs
46614656
fn sse_encode(
46624657
self,
46634658
serializer: &mut flutter_rust_bridge::for_generated::SseSerializer,
46644659
) {
46654660
<i32>::sse_encode(self.len() as _, serializer);
46664661
for item in self {
4667-
<crate::api::RtcRtpEncodingParameters>::sse_encode(
4668-
item, serializer,
4669-
);
4662+
<crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters>::sse_encode(item, serializer);
46704663
}
46714664
}
46724665
}
@@ -5154,7 +5147,7 @@ impl SseEncode for crate::api::stats::rtc_ice_candidate_stats::Protocol {
51545147

51555148
impl SseEncode
51565149
for (
5157-
crate::api::RtcRtpEncodingParameters,
5150+
crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters,
51585151
RustOpaqueMoi<Arc<RtpEncodingParameters>>,
51595152
)
51605153
{
@@ -5163,7 +5156,7 @@ impl SseEncode
51635156
self,
51645157
serializer: &mut flutter_rust_bridge::for_generated::SseSerializer,
51655158
) {
5166-
<crate::api::RtcRtpEncodingParameters>::sse_encode(self.0, serializer);
5159+
<crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters>::sse_encode(self.0, serializer);
51675160
<RustOpaqueMoi<Arc<RtpEncodingParameters>>>::sse_encode(
51685161
self.1, serializer,
51695162
);
@@ -5280,7 +5273,9 @@ crate::api::stats::rtc_outbound_rtp_stream_media_type::RtcOutboundRtpStreamStats
52805273
_ => { unimplemented!(""); }}}
52815274
}
52825275

5283-
impl SseEncode for crate::api::RtcRtpEncodingParameters {
5276+
impl SseEncode
5277+
for crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters
5278+
{
52845279
// Codec=Sse (Serialization based), see doc to use other codecs
52855280
fn sse_encode(
52865281
self,
@@ -5302,7 +5297,7 @@ impl SseEncode for crate::api::RtcRtpSendParameters {
53025297
serializer: &mut flutter_rust_bridge::for_generated::SseSerializer,
53035298
) {
53045299
<Vec<(
5305-
crate::api::RtcRtpEncodingParameters,
5300+
crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters,
53065301
RustOpaqueMoi<Arc<RtpEncodingParameters>>,
53075302
)>>::sse_encode(self.encodings, serializer);
53085303
<RustOpaqueMoi<Arc<RtpParameters>>>::sse_encode(self.inner, serializer);
@@ -5542,10 +5537,7 @@ impl SseEncode for crate::api::RtpTransceiverInit {
55425537
self.direction,
55435538
serializer,
55445539
);
5545-
<Vec<crate::api::RtcRtpEncodingParameters>>::sse_encode(
5546-
self.send_encodings,
5547-
serializer,
5548-
);
5540+
<Vec<crate::api::rtc_rtp_encoding_parameters::RtcRtpEncodingParameters>>::sse_encode(self.send_encodings, serializer);
55495541
}
55505542
}
55515543

0 commit comments

Comments
 (0)