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)
2018-02-09 02:30:08 +00:00
// DO NOT EDIT
2019-02-22 09:54:27 +00:00
use RTSPFilterResult ;
2018-02-09 02:30:08 +00:00
use RTSPSession ;
use glib ;
2019-01-16 11:32:39 +00:00
use glib ::object ::Cast ;
2018-02-09 02:30:08 +00:00
use glib ::object ::IsA ;
use glib ::signal ::SignalHandlerId ;
2018-12-08 09:05:20 +00:00
use glib ::signal ::connect_raw ;
2018-02-09 02:30:08 +00:00
use glib ::translate ::* ;
2019-03-19 07:40:05 +00:00
use glib_sys ;
use gst_rtsp_server_sys ;
2018-02-09 02:30:08 +00:00
use std ::boxed ::Box as Box_ ;
use std ::mem ::transmute ;
glib_wrapper! {
2019-03-19 07:40:05 +00:00
pub struct RTSPSessionPool ( Object < gst_rtsp_server_sys ::GstRTSPSessionPool , gst_rtsp_server_sys ::GstRTSPSessionPoolClass , RTSPSessionPoolClass > ) ;
2018-02-09 02:30:08 +00:00
match fn {
2019-03-19 07:40:05 +00:00
get_type = > | | gst_rtsp_server_sys ::gst_rtsp_session_pool_get_type ( ) ,
2018-02-09 02:30:08 +00:00
}
}
impl RTSPSessionPool {
pub fn new ( ) -> RTSPSessionPool {
assert_initialized_main_thread! ( ) ;
unsafe {
2019-03-19 07:40:05 +00:00
from_glib_full ( gst_rtsp_server_sys ::gst_rtsp_session_pool_new ( ) )
2018-02-09 02:30:08 +00:00
}
}
}
impl Default for RTSPSessionPool {
fn default ( ) -> Self {
Self ::new ( )
}
}
unsafe impl Send for RTSPSessionPool { }
unsafe impl Sync for RTSPSessionPool { }
2019-01-16 11:32:39 +00:00
pub const NONE_RTSP_SESSION_POOL : Option < & RTSPSessionPool > = None ;
2018-12-08 09:05:20 +00:00
pub trait RTSPSessionPoolExt : 'static {
2018-02-09 02:30:08 +00:00
fn cleanup ( & self ) -> u32 ;
fn create ( & self ) -> Option < RTSPSession > ;
2019-02-22 09:54:27 +00:00
fn filter ( & self , func : Option < & mut dyn ( FnMut ( & RTSPSessionPool , & RTSPSession ) -> RTSPFilterResult ) > ) -> Vec < RTSPSession > ;
2018-02-09 02:30:08 +00:00
fn find ( & self , sessionid : & str ) -> Option < RTSPSession > ;
fn get_max_sessions ( & self ) -> u32 ;
fn get_n_sessions ( & self ) -> u32 ;
2019-01-16 11:32:39 +00:00
fn remove < P : IsA < RTSPSession > > ( & self , sess : & P ) -> Result < ( ) , glib ::error ::BoolError > ;
2018-02-09 02:30:08 +00:00
fn set_max_sessions ( & self , max : u32 ) ;
fn connect_session_removed < F : Fn ( & Self , & RTSPSession ) + Send + Sync + 'static > ( & self , f : F ) -> SignalHandlerId ;
fn connect_property_max_sessions_notify < F : Fn ( & Self ) + Send + Sync + 'static > ( & self , f : F ) -> SignalHandlerId ;
}
2018-12-08 09:05:20 +00:00
impl < O : IsA < RTSPSessionPool > > RTSPSessionPoolExt for O {
2018-02-09 02:30:08 +00:00
fn cleanup ( & self ) -> u32 {
unsafe {
2019-03-19 07:40:05 +00:00
gst_rtsp_server_sys ::gst_rtsp_session_pool_cleanup ( self . as_ref ( ) . to_glib_none ( ) . 0 )
2018-02-09 02:30:08 +00:00
}
}
fn create ( & self ) -> Option < RTSPSession > {
unsafe {
2019-03-19 07:40:05 +00:00
from_glib_full ( gst_rtsp_server_sys ::gst_rtsp_session_pool_create ( self . as_ref ( ) . to_glib_none ( ) . 0 ) )
2018-02-09 02:30:08 +00:00
}
}
2019-02-22 09:54:27 +00:00
fn filter ( & self , func : Option < & mut dyn ( FnMut ( & RTSPSessionPool , & RTSPSession ) -> RTSPFilterResult ) > ) -> Vec < RTSPSession > {
let func_data : Option < & mut dyn ( FnMut ( & RTSPSessionPool , & RTSPSession ) -> RTSPFilterResult ) > = func ;
2019-03-19 07:40:05 +00:00
unsafe extern " C " fn func_func ( pool : * mut gst_rtsp_server_sys ::GstRTSPSessionPool , session : * mut gst_rtsp_server_sys ::GstRTSPSession , user_data : glib_sys ::gpointer ) -> gst_rtsp_server_sys ::GstRTSPFilterResult {
2019-02-22 09:54:27 +00:00
let pool = from_glib_borrow ( pool ) ;
let session = from_glib_borrow ( session ) ;
let callback : * mut Option < & mut dyn ( FnMut ( & RTSPSessionPool , & RTSPSession ) -> RTSPFilterResult ) > = user_data as * const _ as usize as * mut Option < & mut dyn ( FnMut ( & RTSPSessionPool , & RTSPSession ) -> RTSPFilterResult ) > ;
let res = if let Some ( ref mut callback ) = * callback {
callback ( & pool , & session )
} else {
panic! ( " cannot get closure... " )
} ;
res . to_glib ( )
}
2019-03-19 07:40:05 +00:00
let func = if func_data . is_some ( ) { Some ( func_func as _ ) } else { None } ;
2019-02-22 09:54:27 +00:00
let super_callback0 : & Option < & mut dyn ( FnMut ( & RTSPSessionPool , & RTSPSession ) -> RTSPFilterResult ) > = & func_data ;
unsafe {
2019-03-19 07:40:05 +00:00
FromGlibPtrContainer ::from_glib_full ( gst_rtsp_server_sys ::gst_rtsp_session_pool_filter ( self . as_ref ( ) . to_glib_none ( ) . 0 , func , super_callback0 as * const _ as usize as * mut _ ) )
2019-02-22 09:54:27 +00:00
}
}
2018-02-09 02:30:08 +00:00
fn find ( & self , sessionid : & str ) -> Option < RTSPSession > {
unsafe {
2019-03-19 07:40:05 +00:00
from_glib_full ( gst_rtsp_server_sys ::gst_rtsp_session_pool_find ( self . as_ref ( ) . to_glib_none ( ) . 0 , sessionid . to_glib_none ( ) . 0 ) )
2018-02-09 02:30:08 +00:00
}
}
fn get_max_sessions ( & self ) -> u32 {
unsafe {
2019-03-19 07:40:05 +00:00
gst_rtsp_server_sys ::gst_rtsp_session_pool_get_max_sessions ( self . as_ref ( ) . to_glib_none ( ) . 0 )
2018-02-09 02:30:08 +00:00
}
}
fn get_n_sessions ( & self ) -> u32 {
unsafe {
2019-03-19 07:40:05 +00:00
gst_rtsp_server_sys ::gst_rtsp_session_pool_get_n_sessions ( self . as_ref ( ) . to_glib_none ( ) . 0 )
2018-02-09 02:30:08 +00:00
}
}
2019-01-16 11:32:39 +00:00
fn remove < P : IsA < RTSPSession > > ( & self , sess : & P ) -> Result < ( ) , glib ::error ::BoolError > {
2018-02-09 02:30:08 +00:00
unsafe {
2019-03-19 07:40:05 +00:00
glib_result_from_gboolean! ( gst_rtsp_server_sys ::gst_rtsp_session_pool_remove ( self . as_ref ( ) . to_glib_none ( ) . 0 , sess . as_ref ( ) . to_glib_none ( ) . 0 ) , " Failed to remove session from pool " )
2018-02-09 02:30:08 +00:00
}
}
fn set_max_sessions ( & self , max : u32 ) {
unsafe {
2019-03-19 07:40:05 +00:00
gst_rtsp_server_sys ::gst_rtsp_session_pool_set_max_sessions ( self . as_ref ( ) . to_glib_none ( ) . 0 , max ) ;
2018-02-09 02:30:08 +00:00
}
}
fn connect_session_removed < F : Fn ( & Self , & RTSPSession ) + Send + Sync + 'static > ( & self , f : F ) -> SignalHandlerId {
unsafe {
2019-01-29 13:53:44 +00:00
let f : Box_ < F > = Box_ ::new ( f ) ;
2019-01-16 11:32:39 +00:00
connect_raw ( self . as_ptr ( ) as * mut _ , b " session-removed \0 " . as_ptr ( ) as * const _ ,
2019-01-29 13:53:44 +00:00
Some ( transmute ( session_removed_trampoline ::< Self , F > as usize ) ) , Box_ ::into_raw ( f ) )
2018-02-09 02:30:08 +00:00
}
}
fn connect_property_max_sessions_notify < F : Fn ( & Self ) + Send + Sync + 'static > ( & self , f : F ) -> SignalHandlerId {
unsafe {
2019-01-29 13:53:44 +00:00
let f : Box_ < F > = Box_ ::new ( f ) ;
2019-01-16 11:32:39 +00:00
connect_raw ( self . as_ptr ( ) as * mut _ , b " notify::max-sessions \0 " . as_ptr ( ) as * const _ ,
2019-01-29 13:53:44 +00:00
Some ( transmute ( notify_max_sessions_trampoline ::< Self , F > as usize ) ) , Box_ ::into_raw ( f ) )
2018-02-09 02:30:08 +00:00
}
}
}
2019-03-19 07:40:05 +00:00
unsafe extern " C " fn session_removed_trampoline < P , F : Fn ( & P , & RTSPSession ) + Send + Sync + 'static > ( this : * mut gst_rtsp_server_sys ::GstRTSPSessionPool , object : * mut gst_rtsp_server_sys ::GstRTSPSession , f : glib_sys ::gpointer )
2018-02-09 02:30:08 +00:00
where P : IsA < RTSPSessionPool > {
2019-02-22 09:51:17 +00:00
let f : & F = & * ( f as * const F ) ;
2019-01-16 11:32:39 +00:00
f ( & RTSPSessionPool ::from_glib_borrow ( this ) . unsafe_cast ( ) , & from_glib_borrow ( object ) )
2018-02-09 02:30:08 +00:00
}
2019-03-19 07:40:05 +00:00
unsafe extern " C " fn notify_max_sessions_trampoline < P , F : Fn ( & P ) + Send + Sync + 'static > ( this : * mut gst_rtsp_server_sys ::GstRTSPSessionPool , _param_spec : glib_sys ::gpointer , f : glib_sys ::gpointer )
2018-02-09 02:30:08 +00:00
where P : IsA < RTSPSessionPool > {
2019-02-22 09:51:17 +00:00
let f : & F = & * ( f as * const F ) ;
2019-01-16 11:32:39 +00:00
f ( & RTSPSessionPool ::from_glib_borrow ( this ) . unsafe_cast ( ) )
2018-02-09 02:30:08 +00:00
}