Commit d15588e6 authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

rtsp-server: Generate the various filter functions

parent 8754e422
......@@ -32,7 +32,8 @@ generate = [
"GstRtspServer.RTSPSuspendMode",
"GstRtspServer.RTSPThreadPool",
"GstRtspServer.RTSPThreadType",
"GstRtspServer.RTSPTransportMode"
"GstRtspServer.RTSPTransportMode",
"GstRtspServer.RTSPFilterResult"
]
manual = [
......
......@@ -55,6 +55,43 @@ impl FromGlib<ffi::GstRTSPAddressPoolResult> for RTSPAddressPoolResult {
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
pub enum RTSPFilterResult {
Remove,
Keep,
Ref,
#[doc(hidden)]
__Unknown(i32),
}
#[doc(hidden)]
impl ToGlib for RTSPFilterResult {
type GlibType = ffi::GstRTSPFilterResult;
fn to_glib(&self) -> ffi::GstRTSPFilterResult {
match *self {
RTSPFilterResult::Remove => ffi::GST_RTSP_FILTER_REMOVE,
RTSPFilterResult::Keep => ffi::GST_RTSP_FILTER_KEEP,
RTSPFilterResult::Ref => ffi::GST_RTSP_FILTER_REF,
RTSPFilterResult::__Unknown(value) => value
}
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstRTSPFilterResult> for RTSPFilterResult {
fn from_glib(value: ffi::GstRTSPFilterResult) -> Self {
skip_assert_initialized!();
match value {
0 => RTSPFilterResult::Remove,
1 => RTSPFilterResult::Keep,
2 => RTSPFilterResult::Ref,
value => RTSPFilterResult::__Unknown(value),
}
}
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Clone, Copy)]
pub enum RTSPMediaStatus {
......
......@@ -63,6 +63,7 @@ pub use self::rtsp_address::RTSPAddress;
mod enums;
pub use self::enums::RTSPAddressPoolResult;
pub use self::enums::RTSPFilterResult;
pub use self::enums::RTSPMediaStatus;
pub use self::enums::RTSPPublishClockMode;
pub use self::enums::RTSPSuspendMode;
......
......@@ -4,6 +4,7 @@
use RTSPAuth;
use RTSPContext;
use RTSPFilterResult;
use RTSPMountPoints;
use RTSPSession;
use RTSPSessionPool;
......@@ -70,7 +71,7 @@ pub trait RTSPClientExt: 'static {
//fn send_message<'a, P: IsA<RTSPSession> + 'a, Q: Into<Option<&'a P>>>(&self, session: Q, message: /*Ignored*/&mut gst_rtsp::RTSPMessage) -> gst_rtsp::RTSPResult;
//fn session_filter(&self, func: /*Unimplemented*/FnMut(&RTSPClient, &RTSPSession) -> /*Ignored*/RTSPFilterResult, user_data: /*Unimplemented*/Option<Fundamental: Pointer>) -> Vec<RTSPSession>;
fn session_filter(&self, func: Option<&mut dyn (FnMut(&RTSPClient, &RTSPSession) -> RTSPFilterResult)>) -> Vec<RTSPSession>;
fn set_auth<'a, P: IsA<RTSPAuth> + 'a, Q: Into<Option<&'a P>>>(&self, auth: Q);
......@@ -198,9 +199,25 @@ impl<O: IsA<RTSPClient>> RTSPClientExt for O {
// unsafe { TODO: call ffi::gst_rtsp_client_send_message() }
//}
//fn session_filter(&self, func: /*Unimplemented*/FnMut(&RTSPClient, &RTSPSession) -> /*Ignored*/RTSPFilterResult, user_data: /*Unimplemented*/Option<Fundamental: Pointer>) -> Vec<RTSPSession> {
// unsafe { TODO: call ffi::gst_rtsp_client_session_filter() }
//}
fn session_filter(&self, func: Option<&mut dyn (FnMut(&RTSPClient, &RTSPSession) -> RTSPFilterResult)>) -> Vec<RTSPSession> {
let func_data: Option<&mut dyn (FnMut(&RTSPClient, &RTSPSession) -> RTSPFilterResult)> = func;
unsafe extern "C" fn func_func(client: *mut ffi::GstRTSPClient, sess: *mut ffi::GstRTSPSession, user_data: glib_ffi::gpointer) -> ffi::GstRTSPFilterResult {
let client = from_glib_borrow(client);
let sess = from_glib_borrow(sess);
let callback: *mut Option<&mut dyn (FnMut(&RTSPClient, &RTSPSession) -> RTSPFilterResult)> = user_data as *const _ as usize as *mut Option<&mut dyn (FnMut(&RTSPClient, &RTSPSession) -> RTSPFilterResult)>;
let res = if let Some(ref mut callback) = *callback {
callback(&client, &sess)
} else {
panic!("cannot get closure...")
};
res.to_glib()
}
let func = Some(func_func as _);
let super_callback0: &Option<&mut dyn (FnMut(&RTSPClient, &RTSPSession) -> RTSPFilterResult)> = &func_data;
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::gst_rtsp_client_session_filter(self.as_ref().to_glib_none().0, func, super_callback0 as *const _ as usize as *mut _))
}
}
fn set_auth<'a, P: IsA<RTSPAuth> + 'a, Q: Into<Option<&'a P>>>(&self, auth: Q) {
let auth = auth.into();
......
......@@ -5,6 +5,7 @@
use Error;
use RTSPAuth;
use RTSPClient;
use RTSPFilterResult;
use RTSPMountPoints;
use RTSPSessionPool;
use RTSPThreadPool;
......@@ -58,7 +59,7 @@ unsafe impl Sync for RTSPServer {}
pub const NONE_RTSP_SERVER: Option<&RTSPServer> = None;
pub trait RTSPServerExt: 'static {
//fn client_filter(&self, func: /*Unimplemented*/FnMut(&RTSPServer, &RTSPClient) -> /*Ignored*/RTSPFilterResult, user_data: /*Unimplemented*/Option<Fundamental: Pointer>) -> Vec<RTSPClient>;
fn client_filter(&self, func: Option<&mut dyn (FnMut(&RTSPServer, &RTSPClient) -> RTSPFilterResult)>) -> Vec<RTSPClient>;
fn create_socket<'a, P: IsA<gio::Cancellable> + 'a, Q: Into<Option<&'a P>>>(&self, cancellable: Q) -> Result<gio::Socket, Error>;
......@@ -112,9 +113,25 @@ pub trait RTSPServerExt: 'static {
}
impl<O: IsA<RTSPServer>> RTSPServerExt for O {
//fn client_filter(&self, func: /*Unimplemented*/FnMut(&RTSPServer, &RTSPClient) -> /*Ignored*/RTSPFilterResult, user_data: /*Unimplemented*/Option<Fundamental: Pointer>) -> Vec<RTSPClient> {
// unsafe { TODO: call ffi::gst_rtsp_server_client_filter() }
//}
fn client_filter(&self, func: Option<&mut dyn (FnMut(&RTSPServer, &RTSPClient) -> RTSPFilterResult)>) -> Vec<RTSPClient> {
let func_data: Option<&mut dyn (FnMut(&RTSPServer, &RTSPClient) -> RTSPFilterResult)> = func;
unsafe extern "C" fn func_func(server: *mut ffi::GstRTSPServer, client: *mut ffi::GstRTSPClient, user_data: glib_ffi::gpointer) -> ffi::GstRTSPFilterResult {
let server = from_glib_borrow(server);
let client = from_glib_borrow(client);
let callback: *mut Option<&mut dyn (FnMut(&RTSPServer, &RTSPClient) -> RTSPFilterResult)> = user_data as *const _ as usize as *mut Option<&mut dyn (FnMut(&RTSPServer, &RTSPClient) -> RTSPFilterResult)>;
let res = if let Some(ref mut callback) = *callback {
callback(&server, &client)
} else {
panic!("cannot get closure...")
};
res.to_glib()
}
let func = Some(func_func as _);
let super_callback0: &Option<&mut dyn (FnMut(&RTSPServer, &RTSPClient) -> RTSPFilterResult)> = &func_data;
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::gst_rtsp_server_client_filter(self.as_ref().to_glib_none().0, func, super_callback0 as *const _ as usize as *mut _))
}
}
fn create_socket<'a, P: IsA<gio::Cancellable> + 'a, Q: Into<Option<&'a P>>>(&self, cancellable: Q) -> Result<gio::Socket, Error> {
let cancellable = cancellable.into();
......
......@@ -2,6 +2,7 @@
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use RTSPFilterResult;
use RTSPMedia;
use RTSPSessionMedia;
use ffi;
......@@ -44,7 +45,7 @@ pub const NONE_RTSP_SESSION: Option<&RTSPSession> = None;
pub trait RTSPSessionExt: 'static {
fn allow_expire(&self);
//fn filter(&self, func: /*Unimplemented*/FnMut(&RTSPSession, &RTSPSessionMedia) -> /*Ignored*/RTSPFilterResult, user_data: /*Unimplemented*/Option<Fundamental: Pointer>) -> Vec<RTSPSessionMedia>;
fn filter(&self, func: Option<&mut dyn (FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult)>) -> Vec<RTSPSessionMedia>;
fn get_header(&self) -> Option<GString>;
......@@ -88,9 +89,25 @@ impl<O: IsA<RTSPSession>> RTSPSessionExt for O {
}
}
//fn filter(&self, func: /*Unimplemented*/FnMut(&RTSPSession, &RTSPSessionMedia) -> /*Ignored*/RTSPFilterResult, user_data: /*Unimplemented*/Option<Fundamental: Pointer>) -> Vec<RTSPSessionMedia> {
// unsafe { TODO: call ffi::gst_rtsp_session_filter() }
//}
fn filter(&self, func: Option<&mut dyn (FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult)>) -> Vec<RTSPSessionMedia> {
let func_data: Option<&mut dyn (FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult)> = func;
unsafe extern "C" fn func_func(sess: *mut ffi::GstRTSPSession, media: *mut ffi::GstRTSPSessionMedia, user_data: glib_ffi::gpointer) -> ffi::GstRTSPFilterResult {
let sess = from_glib_borrow(sess);
let media = from_glib_borrow(media);
let callback: *mut Option<&mut dyn (FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult)> = user_data as *const _ as usize as *mut Option<&mut dyn (FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult)>;
let res = if let Some(ref mut callback) = *callback {
callback(&sess, &media)
} else {
panic!("cannot get closure...")
};
res.to_glib()
}
let func = Some(func_func as _);
let super_callback0: &Option<&mut dyn (FnMut(&RTSPSession, &RTSPSessionMedia) -> RTSPFilterResult)> = &func_data;
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::gst_rtsp_session_filter(self.as_ref().to_glib_none().0, func, super_callback0 as *const _ as usize as *mut _))
}
}
fn get_header(&self) -> Option<GString> {
unsafe {
......
......@@ -2,6 +2,7 @@
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use RTSPFilterResult;
use RTSPSession;
use ffi;
use glib;
......@@ -47,7 +48,7 @@ pub trait RTSPSessionPoolExt: 'static {
fn create(&self) -> Option<RTSPSession>;
//fn filter(&self, func: /*Unimplemented*/FnMut(&RTSPSessionPool, &RTSPSession) -> /*Ignored*/RTSPFilterResult, user_data: /*Unimplemented*/Option<Fundamental: Pointer>) -> Vec<RTSPSession>;
fn filter(&self, func: Option<&mut dyn (FnMut(&RTSPSessionPool, &RTSPSession) -> RTSPFilterResult)>) -> Vec<RTSPSession>;
fn find(&self, sessionid: &str) -> Option<RTSPSession>;
......@@ -77,9 +78,25 @@ impl<O: IsA<RTSPSessionPool>> RTSPSessionPoolExt for O {
}
}
//fn filter(&self, func: /*Unimplemented*/FnMut(&RTSPSessionPool, &RTSPSession) -> /*Ignored*/RTSPFilterResult, user_data: /*Unimplemented*/Option<Fundamental: Pointer>) -> Vec<RTSPSession> {
// unsafe { TODO: call ffi::gst_rtsp_session_pool_filter() }
//}
fn filter(&self, func: Option<&mut dyn (FnMut(&RTSPSessionPool, &RTSPSession) -> RTSPFilterResult)>) -> Vec<RTSPSession> {
let func_data: Option<&mut dyn (FnMut(&RTSPSessionPool, &RTSPSession) -> RTSPFilterResult)> = func;
unsafe extern "C" fn func_func(pool: *mut ffi::GstRTSPSessionPool, session: *mut ffi::GstRTSPSession, user_data: glib_ffi::gpointer) -> ffi::GstRTSPFilterResult {
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()
}
let func = Some(func_func as _);
let super_callback0: &Option<&mut dyn (FnMut(&RTSPSessionPool, &RTSPSession) -> RTSPFilterResult)> = &func_data;
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::gst_rtsp_session_pool_filter(self.as_ref().to_glib_none().0, func, super_callback0 as *const _ as usize as *mut _))
}
}
fn find(&self, sessionid: &str) -> Option<RTSPSession> {
unsafe {
......
......@@ -4,6 +4,7 @@
use RTSPAddress;
use RTSPAddressPool;
use RTSPFilterResult;
use RTSPPublishClockMode;
use RTSPStreamTransport;
use ffi;
......@@ -164,7 +165,7 @@ pub trait RTSPStreamExt: 'static {
fn set_seqnum_offset(&self, seqnum: u16);
//fn transport_filter(&self, func: /*Unimplemented*/FnMut(&RTSPStream, &RTSPStreamTransport) -> /*Ignored*/RTSPFilterResult, user_data: /*Unimplemented*/Option<Fundamental: Pointer>) -> Vec<RTSPStreamTransport>;
fn transport_filter(&self, func: Option<&mut dyn (FnMut(&RTSPStream, &RTSPStreamTransport) -> RTSPFilterResult)>) -> Vec<RTSPStreamTransport>;
fn unblock_linked(&self) -> Result<(), glib::error::BoolError>;
......@@ -539,9 +540,25 @@ impl<O: IsA<RTSPStream>> RTSPStreamExt for O {
}
}
//fn transport_filter(&self, func: /*Unimplemented*/FnMut(&RTSPStream, &RTSPStreamTransport) -> /*Ignored*/RTSPFilterResult, user_data: /*Unimplemented*/Option<Fundamental: Pointer>) -> Vec<RTSPStreamTransport> {
// unsafe { TODO: call ffi::gst_rtsp_stream_transport_filter() }
//}
fn transport_filter(&self, func: Option<&mut dyn (FnMut(&RTSPStream, &RTSPStreamTransport) -> RTSPFilterResult)>) -> Vec<RTSPStreamTransport> {
let func_data: Option<&mut dyn (FnMut(&RTSPStream, &RTSPStreamTransport) -> RTSPFilterResult)> = func;
unsafe extern "C" fn func_func(stream: *mut ffi::GstRTSPStream, trans: *mut ffi::GstRTSPStreamTransport, user_data: glib_ffi::gpointer) -> ffi::GstRTSPFilterResult {
let stream = from_glib_borrow(stream);
let trans = from_glib_borrow(trans);
let callback: *mut Option<&mut dyn (FnMut(&RTSPStream, &RTSPStreamTransport) -> RTSPFilterResult)> = user_data as *const _ as usize as *mut Option<&mut dyn (FnMut(&RTSPStream, &RTSPStreamTransport) -> RTSPFilterResult)>;
let res = if let Some(ref mut callback) = *callback {
callback(&stream, &trans)
} else {
panic!("cannot get closure...")
};
res.to_glib()
}
let func = Some(func_func as _);
let super_callback0: &Option<&mut dyn (FnMut(&RTSPStream, &RTSPStreamTransport) -> RTSPFilterResult)> = &func_data;
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::gst_rtsp_stream_transport_filter(self.as_ref().to_glib_none().0, func, super_callback0 as *const _ as usize as *mut _))
}
}
fn unblock_linked(&self) -> Result<(), glib::error::BoolError> {
unsafe {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment