jingle_rtcp_fb.rs

 1// Copyright (c) 2019 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
 2//
 3// This Source Code Form is subject to the terms of the Mozilla Public
 4// License, v. 2.0. If a copy of the MPL was not distributed with this
 5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
 6
 7generate_element!(
 8    /// Wrapper element for a rtcp-fb.
 9    RtcpFb, "rtcp-fb", JINGLE_RTCP_FB,
10    attributes: [
11        /// Type of this rtcp-fb.
12        type_: Required<String> = "type",
13
14        /// Subtype of this rtcp-fb, if relevant.
15        subtype: Option<String> = "subtype",
16    ]
17);
18
19#[cfg(test)]
20mod tests {
21    use super::*;
22    use crate::Element;
23    use std::convert::TryFrom;
24
25    #[cfg(target_pointer_width = "32")]
26    #[test]
27    fn test_size() {
28        assert_size!(RtcpFb, 24);
29    }
30
31    #[cfg(target_pointer_width = "64")]
32    #[test]
33    fn test_size() {
34        assert_size!(RtcpFb, 48);
35    }
36
37    #[test]
38    fn parse_simple() {
39        let elem: Element =
40            "<rtcp-fb xmlns='urn:xmpp:jingle:apps:rtp:rtcp-fb:0' type='nack' subtype='sli'/>"
41                .parse()
42                .unwrap();
43        let rtcp_fb = RtcpFb::try_from(elem).unwrap();
44        assert_eq!(rtcp_fb.type_, "nack");
45        assert_eq!(rtcp_fb.subtype.unwrap(), "sli");
46    }
47}