jingle_rtp: Add constructors.

Emmanuel Gil Peyrot created

Change summary

src/jingle_rtp.rs | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)

Detailed changes

src/jingle_rtp.rs 🔗

@@ -24,6 +24,17 @@ generate_element!(
     ]
 );
 
+impl Description {
+    /// Create a new RTP description.
+    pub fn new(media: String) -> Description {
+        Description {
+            media,
+            ssrc: None,
+            payload_types: Vec::new(),
+        }
+    }
+}
+
 generate_attribute!(
     /// The number of channels.
     Channels, "channels", u8, Default = 1
@@ -59,6 +70,21 @@ generate_element!(
     ]
 );
 
+impl PayloadType {
+    /// Create a new RTP payload-type.
+    pub fn new(id: u8, name: String) -> PayloadType {
+        PayloadType {
+            channels: Default::default(),
+            clockrate: None,
+            id,
+            maxptime: None,
+            name: Some(name),
+            ptime: None,
+            parameters: Vec::new(),
+        }
+    }
+}
+
 generate_element!(
     /// Parameter related to a payload.
     Parameter, "parameter", JINGLE_RTP,