mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-26 03:21:03 +00:00
rtsp-server: Add bindings for RTSPThread
This commit is contained in:
parent
e0a71563ba
commit
042c1b5fd0
6 changed files with 100 additions and 8 deletions
|
@ -96,6 +96,11 @@ name = "GstRtspServer.RTSPToken"
|
||||||
status = "manual"
|
status = "manual"
|
||||||
ref_mode = "ref"
|
ref_mode = "ref"
|
||||||
|
|
||||||
|
[[object]]
|
||||||
|
name = "GstRtspServer.RTSPThread"
|
||||||
|
status = "manual"
|
||||||
|
ref_mode = "ref"
|
||||||
|
|
||||||
[[object]]
|
[[object]]
|
||||||
name = "Gst.ClockTime"
|
name = "Gst.ClockTime"
|
||||||
status = "manual"
|
status = "manual"
|
||||||
|
@ -246,6 +251,11 @@ status = "generate"
|
||||||
[object.function.return]
|
[object.function.return]
|
||||||
bool_return_is_error = "Failed to unprepare media"
|
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]]
|
[[object.function]]
|
||||||
name = "unsuspend"
|
name = "unsuspend"
|
||||||
[object.function.return]
|
[object.function.return]
|
||||||
|
|
|
@ -24,6 +24,7 @@ use RTSPMediaStatus;
|
||||||
use RTSPPublishClockMode;
|
use RTSPPublishClockMode;
|
||||||
use RTSPStream;
|
use RTSPStream;
|
||||||
use RTSPSuspendMode;
|
use RTSPSuspendMode;
|
||||||
|
use RTSPThread;
|
||||||
use RTSPTransportMode;
|
use RTSPTransportMode;
|
||||||
|
|
||||||
glib_wrapper! {
|
glib_wrapper! {
|
||||||
|
@ -123,7 +124,7 @@ pub trait RTSPMediaExt: 'static {
|
||||||
|
|
||||||
fn n_streams(&self) -> u32;
|
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;
|
//fn seek(&self, range: /*Ignored*/&mut gst_rtsp::RTSPTimeRange) -> bool;
|
||||||
|
|
||||||
|
@ -542,9 +543,17 @@ impl<O: IsA<RTSPMedia>> RTSPMediaExt for O {
|
||||||
unsafe { gst_rtsp_server_sys::gst_rtsp_media_n_streams(self.as_ref().to_glib_none().0) }
|
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 {
|
fn prepare(&self, thread: Option<&RTSPThread>) -> Result<(), glib::error::BoolError> {
|
||||||
// unsafe { TODO: call gst_rtsp_server_sys:gst_rtsp_media_prepare() }
|
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 {
|
//fn seek(&self, range: /*Ignored*/&mut gst_rtsp::RTSPTimeRange) -> bool {
|
||||||
// unsafe { TODO: call gst_rtsp_server_sys:gst_rtsp_media_seek() }
|
// unsafe { TODO: call gst_rtsp_server_sys:gst_rtsp_media_seek() }
|
||||||
|
|
|
@ -11,6 +11,9 @@ use glib_sys;
|
||||||
use gst_rtsp_server_sys;
|
use gst_rtsp_server_sys;
|
||||||
use std::boxed::Box as Box_;
|
use std::boxed::Box as Box_;
|
||||||
use std::mem::transmute;
|
use std::mem::transmute;
|
||||||
|
use RTSPContext;
|
||||||
|
use RTSPThread;
|
||||||
|
use RTSPThreadType;
|
||||||
|
|
||||||
glib_wrapper! {
|
glib_wrapper! {
|
||||||
pub struct RTSPThreadPool(Object<gst_rtsp_server_sys::GstRTSPThreadPool, gst_rtsp_server_sys::GstRTSPThreadPoolClass, RTSPThreadPoolClass>);
|
pub struct RTSPThreadPool(Object<gst_rtsp_server_sys::GstRTSPThreadPool, gst_rtsp_server_sys::GstRTSPThreadPoolClass, RTSPThreadPoolClass>);
|
||||||
|
@ -48,7 +51,7 @@ pub const NONE_RTSP_THREAD_POOL: Option<&RTSPThreadPool> = None;
|
||||||
pub trait RTSPThreadPoolExt: 'static {
|
pub trait RTSPThreadPoolExt: 'static {
|
||||||
fn get_max_threads(&self) -> i32;
|
fn get_max_threads(&self) -> i32;
|
||||||
|
|
||||||
//fn get_thread(&self, type_: RTSPThreadType, ctx: &RTSPContext) -> /*Ignored*/Option<RTSPThread>;
|
fn get_thread(&self, type_: RTSPThreadType, ctx: &RTSPContext) -> Option<RTSPThread>;
|
||||||
|
|
||||||
fn set_max_threads(&self, max_threads: i32);
|
fn set_max_threads(&self, max_threads: i32);
|
||||||
|
|
||||||
|
@ -67,9 +70,15 @@ impl<O: IsA<RTSPThreadPool>> RTSPThreadPoolExt for O {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//fn get_thread(&self, type_: RTSPThreadType, ctx: &RTSPContext) -> /*Ignored*/Option<RTSPThread> {
|
fn get_thread(&self, type_: RTSPThreadType, ctx: &RTSPContext) -> Option<RTSPThread> {
|
||||||
// unsafe { TODO: call gst_rtsp_server_sys:gst_rtsp_thread_pool_get_thread() }
|
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) {
|
fn set_max_threads(&self, max_threads: i32) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -56,6 +56,7 @@ mod rtsp_server;
|
||||||
mod rtsp_session_pool;
|
mod rtsp_session_pool;
|
||||||
mod rtsp_stream;
|
mod rtsp_stream;
|
||||||
mod rtsp_stream_transport;
|
mod rtsp_stream_transport;
|
||||||
|
mod rtsp_thread;
|
||||||
mod rtsp_token;
|
mod rtsp_token;
|
||||||
|
|
||||||
pub use rtsp_address_pool::RTSPAddressPoolExtManual;
|
pub use rtsp_address_pool::RTSPAddressPoolExtManual;
|
||||||
|
@ -66,6 +67,7 @@ pub use rtsp_server::RTSPServerExtManual;
|
||||||
pub use rtsp_session_pool::RTSPSessionPoolExtManual;
|
pub use rtsp_session_pool::RTSPSessionPoolExtManual;
|
||||||
pub use rtsp_stream::RTSPStreamExtManual;
|
pub use rtsp_stream::RTSPStreamExtManual;
|
||||||
pub use rtsp_stream_transport::RTSPStreamTransportExtManual;
|
pub use rtsp_stream_transport::RTSPStreamTransportExtManual;
|
||||||
|
pub use rtsp_thread::*;
|
||||||
|
|
||||||
pub use rtsp_context::*;
|
pub use rtsp_context::*;
|
||||||
pub use rtsp_token::*;
|
pub use rtsp_token::*;
|
||||||
|
|
|
@ -37,3 +37,18 @@ impl glib::translate::FromGlibPtrBorrow<*mut gst_rtsp_server_sys::GstRTSPContext
|
||||||
RTSPContext(ptr::NonNull::new_unchecked(ptr))
|
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!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
47
gstreamer-rtsp-server/src/rtsp_thread.rs
Normal file
47
gstreamer-rtsp-server/src/rtsp_thread.rs
Normal file
|
@ -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<Self> {
|
||||||
|
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_) }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue