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::{ffi, RTSPAddress, RTSPAddressPool, RTSPAddressPoolResult};
8
9pub trait RTSPAddressPoolExtManual: IsA<RTSPAddressPool> + 'static {
10    #[doc(alias = "gst_rtsp_address_pool_reserve_address")]
11    fn reserve_address(
12        &self,
13        ip_address: &str,
14        port: u32,
15        n_ports: u32,
16        ttl: u32,
17    ) -> Result<RTSPAddress, RTSPAddressPoolResult> {
18        unsafe {
19            let mut address = ptr::null_mut();
20            let ret = from_glib(ffi::gst_rtsp_address_pool_reserve_address(
21                self.as_ref().to_glib_none().0,
22                ip_address.to_glib_none().0,
23                port,
24                n_ports,
25                ttl,
26                &mut address,
27            ));
28            match ret {
29                RTSPAddressPoolResult::Ok => Ok(from_glib_full(address)),
30                _ => Err(ret),
31            }
32        }
33    }
34}
35
36impl<O: IsA<RTSPAddressPool>> RTSPAddressPoolExtManual for O {}