Skip to main content

gstreamer_rtsp_server/
rtsp_address_pool.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::ptr;
4
5use glib::{prelude::*, translate::*};
6
7use crate::{RTSPAddress, RTSPAddressPool, RTSPAddressPoolResult, ffi};
8
9pub trait RTSPAddressPoolExtManual: IsA<RTSPAddressPool> + 'static {
10    ///  0, `address`
11    /// should be a valid multicast address.
12    /// ## `ip_address`
13    /// The IP address to reserve
14    /// ## `port`
15    /// The first port to reserve
16    /// ## `n_ports`
17    /// The number of ports
18    /// ## `ttl`
19    /// The requested ttl
20    ///
21    /// # Returns
22    ///
23    /// [`RTSPAddressPoolResult::Ok`][crate::RTSPAddressPoolResult::Ok] if an address was reserved. The address
24    /// is returned in `address` and should be freed with gst_rtsp_address_free
25    /// after use.
26    ///
27    /// ## `address`
28    /// storage for a [`RTSPAddress`][crate::RTSPAddress]
29    #[doc(alias = "gst_rtsp_address_pool_reserve_address")]
30    fn reserve_address(
31        &self,
32        ip_address: &str,
33        port: u32,
34        n_ports: u32,
35        ttl: u32,
36    ) -> Result<RTSPAddress, RTSPAddressPoolResult> {
37        unsafe {
38            let mut address = ptr::null_mut();
39            let ret = from_glib(ffi::gst_rtsp_address_pool_reserve_address(
40                self.as_ref().to_glib_none().0,
41                ip_address.to_glib_none().0,
42                port,
43                n_ports,
44                ttl,
45                &mut address,
46            ));
47            match ret {
48                RTSPAddressPoolResult::Ok => Ok(from_glib_full(address)),
49                _ => Err(ret),
50            }
51        }
52    }
53}
54
55impl<O: IsA<RTSPAddressPool>> RTSPAddressPoolExtManual for O {}