2019-10-12 17:10:50 +00:00
|
|
|
// Copyright (c) 2019 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
|
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2024-07-09 15:01:42 +00:00
|
|
|
use xso::{AsXml, FromXml};
|
2024-06-29 14:34:27 +00:00
|
|
|
|
|
|
|
use crate::ns;
|
|
|
|
|
|
|
|
/// Wrapper element for a rtcp-fb.
|
2024-07-09 15:01:42 +00:00
|
|
|
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
2024-06-29 14:34:27 +00:00
|
|
|
#[xml(namespace = ns::JINGLE_RTCP_FB, name = "rtcp-fb")]
|
|
|
|
pub struct RtcpFb {
|
|
|
|
/// Type of this rtcp-fb.
|
|
|
|
#[xml(attribute = "type")]
|
|
|
|
pub type_: String,
|
|
|
|
|
|
|
|
/// Subtype of this rtcp-fb, if relevant.
|
|
|
|
#[xml(attribute(default))]
|
|
|
|
pub subtype: Option<String>,
|
|
|
|
}
|
2019-10-12 17:10:50 +00:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
2024-07-24 18:28:22 +00:00
|
|
|
use minidom::Element;
|
2019-10-12 17:10:50 +00:00
|
|
|
|
|
|
|
#[cfg(target_pointer_width = "32")]
|
|
|
|
#[test]
|
|
|
|
fn test_size() {
|
|
|
|
assert_size!(RtcpFb, 24);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(target_pointer_width = "64")]
|
|
|
|
#[test]
|
|
|
|
fn test_size() {
|
|
|
|
assert_size!(RtcpFb, 48);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn parse_simple() {
|
2019-10-22 23:32:41 +00:00
|
|
|
let elem: Element =
|
|
|
|
"<rtcp-fb xmlns='urn:xmpp:jingle:apps:rtp:rtcp-fb:0' type='nack' subtype='sli'/>"
|
2019-10-12 17:10:50 +00:00
|
|
|
.parse()
|
|
|
|
.unwrap();
|
|
|
|
let rtcp_fb = RtcpFb::try_from(elem).unwrap();
|
|
|
|
assert_eq!(rtcp_fb.type_, "nack");
|
|
|
|
assert_eq!(rtcp_fb.subtype.unwrap(), "sli");
|
|
|
|
}
|
|
|
|
}
|