From 5b5df16ac9e9fe9679dbd232acc034364cc7fa72 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Wed, 24 Jul 2024 18:00:25 +0200 Subject: [PATCH] xmpp-parsers: Convert jingle_rtp_hdrext to xso --- parsers/src/jingle_rtp_hdrext.rs | 34 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/parsers/src/jingle_rtp_hdrext.rs b/parsers/src/jingle_rtp_hdrext.rs index 5a0ec107..34b170bc 100644 --- a/parsers/src/jingle_rtp_hdrext.rs +++ b/parsers/src/jingle_rtp_hdrext.rs @@ -4,6 +4,10 @@ // 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/. +use xso::{AsXml, FromXml}; + +use crate::ns; + generate_attribute!( /// Which party is allowed to send the negotiated RTP Header Extensions. Senders, "senders", { @@ -18,22 +22,24 @@ generate_attribute!( }, Default = Both ); -generate_element!( - /// Header extensions to be used in a RTP description. - RtpHdrext, "rtp-hdrext", JINGLE_RTP_HDREXT, - attributes: [ - /// The ID of the extensions. The allowed values are only in the 1-256, 4096-4351 ranges, - /// this isn’t enforced by xmpp-parsers yet! - // TODO: make it so. - id: Required = "id", +/// Header extensions to be used in a RTP description. +#[derive(FromXml, AsXml, PartialEq, Debug, Clone)] +#[xml(namespace = ns::JINGLE_RTP_HDREXT, name = "rtp-hdrext")] +pub struct RtpHdrext { + /// The ID of the extensions. The allowed values are only in the 1-256, 4096-4351 ranges, + /// this isn’t enforced by xmpp-parsers yet! + // TODO: make it so. + #[xml(attribute)] + pub id: u16, - /// The URI that defines the extension. - uri: Required = "uri", + /// The URI that defines the extension. + #[xml(attribute)] + pub uri: String, - /// Which party is allowed to send the negotiated RTP Header Extensions. - senders: Default = "senders", - ] -); + /// Which party is allowed to send the negotiated RTP Header Extensions. + #[xml(attribute(default))] + pub senders: Senders, +} impl RtpHdrext { /// Create a new RTP header extension element.