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