xmpp-parsers: Convert Jingle RTP to xso

This commit is contained in:
Emmanuel Gil Peyrot 2024-08-03 19:50:53 +02:00 committed by Jonas Schäfer
commit 57c2eeadfc

View file

@ -17,38 +17,42 @@ use crate::ns;
#[xml(namespace = ns::JINGLE_RTP, name = "rtcp-mux")] #[xml(namespace = ns::JINGLE_RTP, name = "rtcp-mux")]
pub struct RtcpMux; pub struct RtcpMux;
generate_element!( /// Wrapper element describing an RTP session.
/// Wrapper element describing an RTP session. #[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
Description, "description", JINGLE_RTP, #[xml(namespace = ns::JINGLE_RTP, name = "description")]
attributes: [ pub struct Description {
/// Namespace of the encryption scheme used. /// Namespace of the encryption scheme used.
media: Required<String> = "media", #[xml(attribute)]
pub media: String,
/// User-friendly name for the encryption scheme, should be `None` for OTR, /// User-friendly name for the encryption scheme, should be `None` for OTR,
/// legacy OpenPGP and OX. /// legacy OpenPGP and OX.
// XXX: is this a String or an u32?! Refer to RFC 3550. // XXX: is this a String or an u32?! Refer to RFC 3550.
ssrc: Option<String> = "ssrc", #[xml(attribute(default))]
], pub ssrc: Option<String>,
children: [
/// List of encodings that can be used for this RTP stream. /// List of encodings that can be used for this RTP stream.
payload_types: Vec<PayloadType> = ("payload-type", JINGLE_RTP) => PayloadType, #[xml(child(n = ..))]
pub payload_types: Vec<PayloadType>,
/// Specifies the ability to multiplex RTP Data and Control Packets on a single port as /// Specifies the ability to multiplex RTP Data and Control Packets on a single port as
/// described in RFC 5761. /// described in RFC 5761.
rtcp_mux: Option<RtcpMux> = ("rtcp-mux", JINGLE_RTP) => RtcpMux, #[xml(child(default))]
pub rtcp_mux: Option<RtcpMux>,
/// List of ssrc-group. /// List of ssrc-group.
ssrc_groups: Vec<Group> = ("ssrc-group", JINGLE_SSMA) => Group, #[xml(child(n = ..))]
pub ssrc_groups: Vec<Group>,
/// List of ssrc. /// List of ssrc.
ssrcs: Vec<Source> = ("source", JINGLE_SSMA) => Source, #[xml(child(n = ..))]
pub ssrcs: Vec<Source>,
/// List of header extensions. /// List of header extensions.
hdrexts: Vec<RtpHdrext> = ("rtp-hdrext", JINGLE_RTP_HDREXT) => RtpHdrext #[xml(child(n = ..))]
pub hdrexts: Vec<RtpHdrext>,
// TODO: Add support for <encryption/> and <bandwidth/>. // TODO: Add support for <encryption/> and <bandwidth/>.
] }
);
impl Description { impl Description {
/// Create a new RTP description. /// Create a new RTP description.
@ -73,38 +77,44 @@ generate_attribute!(
Default = 1 Default = 1
); );
generate_element!( /// An encoding that can be used for an RTP stream.
/// An encoding that can be used for an RTP stream. #[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
PayloadType, "payload-type", JINGLE_RTP, #[xml(namespace = ns::JINGLE_RTP, name = "payload-type")]
attributes: [ pub struct PayloadType {
/// The number of channels. /// The number of channels.
channels: Default<Channels> = "channels", #[xml(attribute(default))]
pub channels: Channels,
/// The sampling frequency in Hertz. /// The sampling frequency in Hertz.
clockrate: Option<u32> = "clockrate", #[xml(attribute(default))]
pub clockrate: Option<u32>,
/// The payload identifier. /// The payload identifier.
id: Required<u8> = "id", #[xml(attribute)]
pub id: u8,
/// Maximum packet time as specified in RFC 4566. /// Maximum packet time as specified in RFC 4566.
maxptime: Option<u32> = "maxptime", #[xml(attribute(default))]
pub maxptime: Option<u32>,
/// The appropriate subtype of the MIME type. /// The appropriate subtype of the MIME type.
name: Option<String> = "name", #[xml(attribute(default))]
pub name: Option<String>,
/// Packet time as specified in RFC 4566. /// Packet time as specified in RFC 4566.
ptime: Option<u32> = "ptime", #[xml(attribute(default))]
], pub ptime: Option<u32>,
children: [
/// List of parameters specifying this payload-type. /// List of parameters specifying this payload-type.
/// ///
/// Their order MUST be ignored. /// Their order MUST be ignored.
parameters: Vec<Parameter> = ("parameter", JINGLE_RTP) => Parameter, #[xml(child(n = ..))]
pub parameters: Vec<Parameter>,
/// List of rtcp-fb parameters from XEP-0293. /// List of rtcp-fb parameters from XEP-0293.
rtcp_fbs: Vec<RtcpFb> = ("rtcp-fb", JINGLE_RTCP_FB) => RtcpFb #[xml(child(n = ..))]
] pub rtcp_fbs: Vec<RtcpFb>,
); }
impl PayloadType { impl PayloadType {
/// Create a new RTP payload-type. /// Create a new RTP payload-type.