gstreamer_rtsp_server/auto/rtsp_address_pool.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::{ffi, RTSPAddress, RTSPAddressFlags};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10 /// An address pool, all member are private
11 ///
12 /// # Implements
13 ///
14 /// [`RTSPAddressPoolExt`][trait@crate::prelude::RTSPAddressPoolExt], [`trait@glib::ObjectExt`], [`RTSPAddressPoolExtManual`][trait@crate::prelude::RTSPAddressPoolExtManual]
15 #[doc(alias = "GstRTSPAddressPool")]
16 pub struct RTSPAddressPool(Object<ffi::GstRTSPAddressPool, ffi::GstRTSPAddressPoolClass>);
17
18 match fn {
19 type_ => || ffi::gst_rtsp_address_pool_get_type(),
20 }
21}
22
23impl RTSPAddressPool {
24 pub const NONE: Option<&'static RTSPAddressPool> = None;
25
26 /// Make a new [`RTSPAddressPool`][crate::RTSPAddressPool].
27 ///
28 /// # Returns
29 ///
30 /// a new [`RTSPAddressPool`][crate::RTSPAddressPool]
31 #[doc(alias = "gst_rtsp_address_pool_new")]
32 pub fn new() -> RTSPAddressPool {
33 assert_initialized_main_thread!();
34 unsafe { from_glib_full(ffi::gst_rtsp_address_pool_new()) }
35 }
36}
37
38impl Default for RTSPAddressPool {
39 fn default() -> Self {
40 Self::new()
41 }
42}
43
44unsafe impl Send for RTSPAddressPool {}
45unsafe impl Sync for RTSPAddressPool {}
46
47/// Trait containing all [`struct@RTSPAddressPool`] methods.
48///
49/// # Implementors
50///
51/// [`RTSPAddressPool`][struct@crate::RTSPAddressPool]
52pub trait RTSPAddressPoolExt: IsA<RTSPAddressPool> + 'static {
53 /// Take an address and ports from `self`. `flags` can be used to control the
54 /// allocation. `n_ports` consecutive ports will be allocated of which the first
55 /// one can be found in `port`.
56 /// ## `flags`
57 /// flags
58 /// ## `n_ports`
59 /// the amount of ports
60 ///
61 /// # Returns
62 ///
63 /// a [`RTSPAddress`][crate::RTSPAddress] that should be freed with
64 /// gst_rtsp_address_free after use or [`None`] when no address could be
65 /// acquired.
66 #[doc(alias = "gst_rtsp_address_pool_acquire_address")]
67 fn acquire_address(
68 &self,
69 flags: RTSPAddressFlags,
70 n_ports: i32,
71 ) -> Result<RTSPAddress, glib::BoolError> {
72 unsafe {
73 Option::<_>::from_glib_full(ffi::gst_rtsp_address_pool_acquire_address(
74 self.as_ref().to_glib_none().0,
75 flags.into_glib(),
76 n_ports,
77 ))
78 .ok_or_else(|| glib::bool_error!("Failed to acquire address"))
79 }
80 }
81
82 /// Adds the addresses from `min_addess` to `max_address` (inclusive)
83 /// to `self`. The valid port range for the addresses will be from `min_port` to
84 /// `max_port` inclusive.
85 ///
86 /// When `ttl` is 0, `min_address` and `max_address` should be unicast addresses.
87 /// `min_address` and `max_address` can be set to
88 /// `GST_RTSP_ADDRESS_POOL_ANY_IPV4` or `GST_RTSP_ADDRESS_POOL_ANY_IPV6` to bind
89 /// to all available IPv4 or IPv6 addresses.
90 ///
91 /// When `ttl` > 0, `min_address` and `max_address` should be multicast addresses.
92 /// ## `min_address`
93 /// a minimum address to add
94 /// ## `max_address`
95 /// a maximum address to add
96 /// ## `min_port`
97 /// the minimum port
98 /// ## `max_port`
99 /// the maximum port
100 /// ## `ttl`
101 /// a TTL or 0 for unicast addresses
102 ///
103 /// # Returns
104 ///
105 /// [`true`] if the addresses could be added.
106 #[doc(alias = "gst_rtsp_address_pool_add_range")]
107 fn add_range(
108 &self,
109 min_address: &str,
110 max_address: &str,
111 min_port: u16,
112 max_port: u16,
113 ttl: u8,
114 ) -> Result<(), glib::error::BoolError> {
115 unsafe {
116 glib::result_from_gboolean!(
117 ffi::gst_rtsp_address_pool_add_range(
118 self.as_ref().to_glib_none().0,
119 min_address.to_glib_none().0,
120 max_address.to_glib_none().0,
121 min_port,
122 max_port,
123 ttl
124 ),
125 "Failed to add address range"
126 )
127 }
128 }
129
130 /// Clear all addresses in `self`. There should be no outstanding
131 /// allocations.
132 #[doc(alias = "gst_rtsp_address_pool_clear")]
133 fn clear(&self) {
134 unsafe {
135 ffi::gst_rtsp_address_pool_clear(self.as_ref().to_glib_none().0);
136 }
137 }
138
139 /// Dump the free and allocated addresses to stdout.
140 #[doc(alias = "gst_rtsp_address_pool_dump")]
141 fn dump(&self) {
142 unsafe {
143 ffi::gst_rtsp_address_pool_dump(self.as_ref().to_glib_none().0);
144 }
145 }
146
147 /// Used to know if the pool includes any unicast addresses.
148 ///
149 /// # Returns
150 ///
151 /// [`true`] if the pool includes any unicast addresses, [`false`] otherwise
152 #[doc(alias = "gst_rtsp_address_pool_has_unicast_addresses")]
153 fn has_unicast_addresses(&self) -> bool {
154 unsafe {
155 from_glib(ffi::gst_rtsp_address_pool_has_unicast_addresses(
156 self.as_ref().to_glib_none().0,
157 ))
158 }
159 }
160}
161
162impl<O: IsA<RTSPAddressPool>> RTSPAddressPoolExt for O {}