Skip to main content

media_pp\elements/
rtsp.rs

1/// Lower transport used for RTP packets negotiated through RTSP.
2#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
3pub enum RtspTransport {
4    /// RTP-over-TCP, interleaved in the RTSP control connection. This is
5    /// the default because it crosses NAT and firewalls more reliably.
6    #[default]
7    Tcp,
8    /// RTP-over-UDP. This can reduce latency on a controlled network but
9    /// requires the RTP/RTCP UDP ports negotiated with the server to work.
10    Udp,
11}
12
13impl RtspTransport {
14    pub(crate) fn as_ffmpeg_option(self) -> &'static str {
15        match self {
16            Self::Tcp => "tcp",
17            Self::Udp => "udp",
18        }
19    }
20}
21
22#[cfg(test)]
23mod tests {
24    use super::RtspTransport;
25
26    #[test]
27    fn maps_transports_to_ffmpeg_options() {
28        assert_eq!(RtspTransport::Tcp.as_ffmpeg_option(), "tcp");
29        assert_eq!(RtspTransport::Udp.as_ffmpeg_option(), "udp");
30    }
31}