1use std::fmt;
2
3use nom::{
4 IResult,
5 branch::alt,
6 combinator::map,
7 bytes::complete::tag_no_case
8};
9
10#[derive(Debug, PartialEq, Clone)]
11pub enum SdpAttributeType {
12 Rtpmap,
13 RecvOnly,
14 SendOnly,
15 SendRecv,
16 Fmtp
17}
18
19impl fmt::Display for SdpAttributeType {
20 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
21 match self {
22 SdpAttributeType::Rtpmap => write!(f, "rtpmap"),
23 SdpAttributeType::RecvOnly => write!(f, "recvonly"),
24 SdpAttributeType::SendRecv => write!(f, "sendrecv"),
25 SdpAttributeType::SendOnly => write!(f, "sendonly"),
26 SdpAttributeType::Fmtp => write!(f, "fmtp")
27 }
28 }
29}
30
31pub fn parse_attribute_type(input: &[u8]) -> IResult<&[u8], SdpAttributeType> {
32 alt((
33 map(tag_no_case("rtpmap"), |_| SdpAttributeType::Rtpmap),
34 map(tag_no_case("fmtp"), |_| SdpAttributeType::Fmtp),
35 map(tag_no_case("recvonly"), |_| SdpAttributeType::RecvOnly),
36 map(tag_no_case("sendrecv"), |_| SdpAttributeType::SendRecv),
37 map(tag_no_case("sendonly"), |_| SdpAttributeType::SendOnly)
38 ))(input)
39}