diff --git a/Gir_GstRtspServer.toml b/Gir_GstRtspServer.toml index 56661b6c4..0b9b4765d 100644 --- a/Gir_GstRtspServer.toml +++ b/Gir_GstRtspServer.toml @@ -96,6 +96,11 @@ name = "GstRtspServer.RTSPToken" status = "manual" ref_mode = "ref" +[[object]] +name = "GstRtspServer.RTSPThread" +status = "manual" +ref_mode = "ref" + [[object]] name = "Gst.ClockTime" status = "manual" @@ -246,6 +251,11 @@ status = "generate" [object.function.return] bool_return_is_error = "Failed to unprepare media" + [[object.function]] + name = "prepare" + [object.function.return] + bool_return_is_error = "Failed to prepare media" + [[object.function]] name = "unsuspend" [object.function.return] diff --git a/gstreamer-rtsp-server/src/auto/rtsp_media.rs b/gstreamer-rtsp-server/src/auto/rtsp_media.rs index af6e7bb3b..c7cd118ca 100644 --- a/gstreamer-rtsp-server/src/auto/rtsp_media.rs +++ b/gstreamer-rtsp-server/src/auto/rtsp_media.rs @@ -24,6 +24,7 @@ use RTSPMediaStatus; use RTSPPublishClockMode; use RTSPStream; use RTSPSuspendMode; +use RTSPThread; use RTSPTransportMode; glib_wrapper! { @@ -123,7 +124,7 @@ pub trait RTSPMediaExt: 'static { fn n_streams(&self) -> u32; - //fn prepare(&self, thread: /*Ignored*/Option<&mut RTSPThread>) -> bool; + fn prepare(&self, thread: Option<&RTSPThread>) -> Result<(), glib::error::BoolError>; //fn seek(&self, range: /*Ignored*/&mut gst_rtsp::RTSPTimeRange) -> bool; @@ -542,9 +543,17 @@ impl> RTSPMediaExt for O { unsafe { gst_rtsp_server_sys::gst_rtsp_media_n_streams(self.as_ref().to_glib_none().0) } } - //fn prepare(&self, thread: /*Ignored*/Option<&mut RTSPThread>) -> bool { - // unsafe { TODO: call gst_rtsp_server_sys:gst_rtsp_media_prepare() } - //} + fn prepare(&self, thread: Option<&RTSPThread>) -> Result<(), glib::error::BoolError> { + unsafe { + glib_result_from_gboolean!( + gst_rtsp_server_sys::gst_rtsp_media_prepare( + self.as_ref().to_glib_none().0, + thread.to_glib_full() + ), + "Failed to prepare media" + ) + } + } //fn seek(&self, range: /*Ignored*/&mut gst_rtsp::RTSPTimeRange) -> bool { // unsafe { TODO: call gst_rtsp_server_sys:gst_rtsp_media_seek() } diff --git a/gstreamer-rtsp-server/src/auto/rtsp_thread_pool.rs b/gstreamer-rtsp-server/src/auto/rtsp_thread_pool.rs index f281287b3..84d12a30c 100644 --- a/gstreamer-rtsp-server/src/auto/rtsp_thread_pool.rs +++ b/gstreamer-rtsp-server/src/auto/rtsp_thread_pool.rs @@ -11,6 +11,9 @@ use glib_sys; use gst_rtsp_server_sys; use std::boxed::Box as Box_; use std::mem::transmute; +use RTSPContext; +use RTSPThread; +use RTSPThreadType; glib_wrapper! { pub struct RTSPThreadPool(Object); @@ -48,7 +51,7 @@ pub const NONE_RTSP_THREAD_POOL: Option<&RTSPThreadPool> = None; pub trait RTSPThreadPoolExt: 'static { fn get_max_threads(&self) -> i32; - //fn get_thread(&self, type_: RTSPThreadType, ctx: &RTSPContext) -> /*Ignored*/Option; + fn get_thread(&self, type_: RTSPThreadType, ctx: &RTSPContext) -> Option; fn set_max_threads(&self, max_threads: i32); @@ -67,9 +70,15 @@ impl> RTSPThreadPoolExt for O { } } - //fn get_thread(&self, type_: RTSPThreadType, ctx: &RTSPContext) -> /*Ignored*/Option { - // unsafe { TODO: call gst_rtsp_server_sys:gst_rtsp_thread_pool_get_thread() } - //} + fn get_thread(&self, type_: RTSPThreadType, ctx: &RTSPContext) -> Option { + unsafe { + from_glib_full(gst_rtsp_server_sys::gst_rtsp_thread_pool_get_thread( + self.as_ref().to_glib_none().0, + type_.to_glib(), + ctx.to_glib_none().0, + )) + } + } fn set_max_threads(&self, max_threads: i32) { unsafe { diff --git a/gstreamer-rtsp-server/src/lib.rs b/gstreamer-rtsp-server/src/lib.rs index 8889661d7..2a5552dab 100644 --- a/gstreamer-rtsp-server/src/lib.rs +++ b/gstreamer-rtsp-server/src/lib.rs @@ -56,6 +56,7 @@ mod rtsp_server; mod rtsp_session_pool; mod rtsp_stream; mod rtsp_stream_transport; +mod rtsp_thread; mod rtsp_token; pub use rtsp_address_pool::RTSPAddressPoolExtManual; @@ -66,6 +67,7 @@ pub use rtsp_server::RTSPServerExtManual; pub use rtsp_session_pool::RTSPSessionPoolExtManual; pub use rtsp_stream::RTSPStreamExtManual; pub use rtsp_stream_transport::RTSPStreamTransportExtManual; +pub use rtsp_thread::*; pub use rtsp_context::*; pub use rtsp_token::*; diff --git a/gstreamer-rtsp-server/src/rtsp_context.rs b/gstreamer-rtsp-server/src/rtsp_context.rs index 8e18ee896..8622172e0 100644 --- a/gstreamer-rtsp-server/src/rtsp_context.rs +++ b/gstreamer-rtsp-server/src/rtsp_context.rs @@ -37,3 +37,18 @@ impl glib::translate::FromGlibPtrBorrow<*mut gst_rtsp_server_sys::GstRTSPContext RTSPContext(ptr::NonNull::new_unchecked(ptr)) } } + +#[doc(hidden)] +impl<'a> glib::translate::ToGlibPtr<'a, *mut gst_rtsp_server_sys::GstRTSPContext> for RTSPContext { + type Storage = &'a RTSPContext; + + fn to_glib_none( + &'a self, + ) -> glib::translate::Stash<'a, *mut gst_rtsp_server_sys::GstRTSPContext, Self> { + glib::translate::Stash(self.0.as_ptr(), self) + } + + fn to_glib_full(&self) -> *mut gst_rtsp_server_sys::GstRTSPContext { + unimplemented!() + } +} diff --git a/gstreamer-rtsp-server/src/rtsp_thread.rs b/gstreamer-rtsp-server/src/rtsp_thread.rs new file mode 100644 index 000000000..be21cab4f --- /dev/null +++ b/gstreamer-rtsp-server/src/rtsp_thread.rs @@ -0,0 +1,47 @@ +use glib; +use glib::translate::*; +use gst_rtsp_server_sys; + +use gst::prelude::*; + +gst_define_mini_object_wrapper!( + RTSPThread, + RTSPThreadRef, + gst_rtsp_server_sys::GstRTSPThread, + [], + || gst_rtsp_server_sys::gst_rtsp_thread_get_type() +); + +impl RTSPThread { + pub fn new(type_: ::RTSPThreadType) -> Option { + unsafe { from_glib_full(gst_rtsp_server_sys::gst_rtsp_thread_new(type_.to_glib())) } + } +} + +impl RTSPThreadRef { + pub fn reuse(&self) -> bool { + unsafe { + from_glib(gst_rtsp_server_sys::gst_rtsp_thread_reuse( + self.as_mut_ptr(), + )) + } + } + + pub fn stop(&self) { + unsafe { + gst_rtsp_server_sys::gst_rtsp_thread_stop(self.as_mut_ptr()); + } + } + + pub fn type_(&self) -> ::RTSPThreadType { + unsafe { from_glib((*self.as_ptr()).type_) } + } + + pub fn context(&self) -> glib::MainContext { + unsafe { from_glib_none((*self.as_ptr()).context) } + } + + pub fn loop_(&self) -> glib::MainLoop { + unsafe { from_glib_none((*self.as_ptr()).loop_) } + } +}