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