gstreamer-rs/gstreamer-rtsp-server/src/auto/rtsp_address_pool.rs

125 lines
3.3 KiB
Rust
Raw Normal View History

2018-04-23 17:34:22 +00:00
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
// DO NOT EDIT
2020-11-22 10:40:56 +00:00
use crate::RTSPAddress;
use crate::RTSPAddressFlags;
use glib::object::IsA;
use glib::translate::*;
2020-12-17 22:34:53 +00:00
glib::wrapper! {
2020-11-22 10:40:56 +00:00
pub struct RTSPAddressPool(Object<ffi::GstRTSPAddressPool, ffi::GstRTSPAddressPoolClass>);
match fn {
2020-11-22 10:40:56 +00:00
get_type => || ffi::gst_rtsp_address_pool_get_type(),
}
}
impl RTSPAddressPool {
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_rtsp_address_pool_new")]
pub fn new() -> RTSPAddressPool {
assert_initialized_main_thread!();
2020-11-22 10:40:56 +00:00
unsafe { from_glib_full(ffi::gst_rtsp_address_pool_new()) }
}
}
impl Default for RTSPAddressPool {
fn default() -> Self {
Self::new()
}
}
unsafe impl Send for RTSPAddressPool {}
unsafe impl Sync for RTSPAddressPool {}
2019-01-16 11:32:39 +00:00
pub const NONE_RTSP_ADDRESS_POOL: Option<&RTSPAddressPool> = None;
pub trait RTSPAddressPoolExt: 'static {
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_rtsp_address_pool_acquire_address")]
fn acquire_address(
&self,
flags: RTSPAddressFlags,
n_ports: i32,
) -> Result<RTSPAddress, glib::BoolError>;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_rtsp_address_pool_add_range")]
fn add_range(
&self,
min_address: &str,
max_address: &str,
min_port: u16,
max_port: u16,
ttl: u8,
) -> Result<(), glib::error::BoolError>;
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_rtsp_address_pool_clear")]
fn clear(&self);
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_rtsp_address_pool_dump")]
fn dump(&self);
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_rtsp_address_pool_has_unicast_addresses")]
fn has_unicast_addresses(&self) -> bool;
}
impl<O: IsA<RTSPAddressPool>> RTSPAddressPoolExt for O {
fn acquire_address(
&self,
flags: RTSPAddressFlags,
n_ports: i32,
) -> Result<RTSPAddress, glib::BoolError> {
unsafe {
2020-11-22 10:40:56 +00:00
Option::<_>::from_glib_full(ffi::gst_rtsp_address_pool_acquire_address(
self.as_ref().to_glib_none().0,
flags.to_glib(),
n_ports,
))
2020-12-17 22:34:53 +00:00
.ok_or_else(|| glib::bool_error!("Failed to acquire address"))
}
}
fn add_range(
&self,
min_address: &str,
max_address: &str,
min_port: u16,
max_port: u16,
ttl: u8,
) -> Result<(), glib::error::BoolError> {
unsafe {
2020-12-17 22:34:53 +00:00
glib::result_from_gboolean!(
2020-11-22 10:40:56 +00:00
ffi::gst_rtsp_address_pool_add_range(
self.as_ref().to_glib_none().0,
min_address.to_glib_none().0,
max_address.to_glib_none().0,
min_port,
max_port,
ttl
),
"Failed to add address range"
)
}
}
fn clear(&self) {
unsafe {
2020-11-22 10:40:56 +00:00
ffi::gst_rtsp_address_pool_clear(self.as_ref().to_glib_none().0);
}
}
fn dump(&self) {
unsafe {
2020-11-22 10:40:56 +00:00
ffi::gst_rtsp_address_pool_dump(self.as_ref().to_glib_none().0);
}
}
fn has_unicast_addresses(&self) -> bool {
unsafe {
2020-11-22 10:40:56 +00:00
from_glib(ffi::gst_rtsp_address_pool_has_unicast_addresses(
self.as_ref().to_glib_none().0,
))
}
}
}