xmpp-parsers/jingle_rtp: Add a proper constructor for PayloadType.

This commit is contained in:
Emmanuel Gil Peyrot 2020-11-30 02:04:13 +01:00
parent 923a054b81
commit 04e149ad53

View file

@ -107,7 +107,22 @@ generate_element!(
impl PayloadType { impl PayloadType {
/// Create a new RTP payload-type. /// 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 { PayloadType {
channels: Default::default(), channels: Default::default(),
clockrate: None, clockrate: None,