From 04e149ad53fc6fc201bedf31562e06e3a1a7f570 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Mon, 30 Nov 2020 02:04:13 +0100 Subject: [PATCH] xmpp-parsers/jingle_rtp: Add a proper constructor for PayloadType. --- xmpp-parsers/src/jingle_rtp.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/xmpp-parsers/src/jingle_rtp.rs b/xmpp-parsers/src/jingle_rtp.rs index f2c36e0f..5f380dc3 100644 --- a/xmpp-parsers/src/jingle_rtp.rs +++ b/xmpp-parsers/src/jingle_rtp.rs @@ -107,7 +107,22 @@ generate_element!( impl PayloadType { /// Create a new RTP payload-type. - pub fn new(id: u8, name: String) -> PayloadType { + pub fn new(id: u8, name: String, clockrate: u32, channels: u8) -> PayloadType { + PayloadType { + channels: Channels(channels), + clockrate: Some(clockrate), + id, + maxptime: None, + name: Some(name), + ptime: None, + parameters: Vec::new(), + rtcp_fbs: Vec::new(), + } + } + + /// Create a new RTP payload-type without a clockrate. Warning: this is invalid as per + /// RFC 4566! + pub fn without_clockrate(id: u8, name: String) -> PayloadType { PayloadType { channels: Default::default(), clockrate: None,