rtsp_server/media: Implement take_pipeline() manually

Because of floating reference problems in the API that have to be worked
around.
This commit is contained in:
Sebastian Dröge 2020-02-23 10:00:05 +02:00
parent 38071f1897
commit aa86c804bd
4 changed files with 36 additions and 11 deletions

View file

@ -261,6 +261,10 @@ status = "generate"
[object.function.return]
bool_return_is_error = "Failed to unsuspend media"
[[object.function]]
name = "take_pipeline"
ignore = true
[[object]]
name = "GstRtspServer.RTSPMediaFactory"
status = "generate"

View file

@ -183,8 +183,6 @@ pub trait RTSPMediaExt: 'static {
fn suspend(&self) -> Result<(), glib::error::BoolError>;
fn take_pipeline<P: IsA<gst::Pipeline>>(&self, pipeline: &P);
fn unprepare(&self) -> Result<(), glib::error::BoolError>;
fn unsuspend(&self) -> Result<(), glib::error::BoolError>;
@ -764,15 +762,6 @@ impl<O: IsA<RTSPMedia>> RTSPMediaExt for O {
}
}
fn take_pipeline<P: IsA<gst::Pipeline>>(&self, pipeline: &P) {
unsafe {
gst_rtsp_server_sys::gst_rtsp_media_take_pipeline(
self.as_ref().to_glib_none().0,
pipeline.as_ref().to_glib_full(),
);
}
}
fn unprepare(&self) -> Result<(), glib::error::BoolError> {
unsafe {
glib_result_from_gboolean!(

View file

@ -52,6 +52,7 @@ mod rtsp_address_pool;
mod rtsp_auth;
mod rtsp_client;
mod rtsp_context;
mod rtsp_media;
mod rtsp_media_factory;
mod rtsp_server;
mod rtsp_session_pool;
@ -60,9 +61,12 @@ mod rtsp_stream_transport;
mod rtsp_thread;
mod rtsp_token;
pub mod subclass;
pub use rtsp_address_pool::RTSPAddressPoolExtManual;
pub use rtsp_auth::RTSPAuthExtManual;
pub use rtsp_client::RTSPClientExtManual;
pub use rtsp_media::RTSPMediaExtManual;
pub use rtsp_media_factory::RTSPMediaFactoryExtManual;
pub use rtsp_server::RTSPServerExtManual;
pub use rtsp_session_pool::RTSPSessionPoolExtManual;
@ -142,6 +146,7 @@ pub mod prelude {
pub use rtsp_address_pool::RTSPAddressPoolExtManual;
pub use rtsp_auth::RTSPAuthExtManual;
pub use rtsp_client::RTSPClientExtManual;
pub use rtsp_media::RTSPMediaExtManual;
pub use rtsp_media_factory::RTSPMediaFactoryExtManual;
pub use rtsp_server::RTSPServerExtManual;
pub use rtsp_session_pool::RTSPSessionPoolExtManual;

View file

@ -0,0 +1,27 @@
use glib::object::IsA;
use glib::translate::*;
use gst;
use gst_rtsp_server_sys;
use RTSPMedia;
pub trait RTSPMediaExtManual: 'static {
fn take_pipeline<P: IsA<gst::Pipeline>>(&self, pipeline: &P);
}
impl<O: IsA<RTSPMedia>> RTSPMediaExtManual for O {
fn take_pipeline<P: IsA<gst::Pipeline>>(&self, pipeline: &P) {
unsafe {
let pipeline = pipeline.as_ref().to_glib_full();
// See https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/merge_requests/109
gobject_sys::g_object_force_floating(pipeline as *mut _);
gst_rtsp_server_sys::gst_rtsp_media_take_pipeline(
self.as_ref().to_glib_none().0,
pipeline,
);
if gobject_sys::g_object_is_floating(pipeline as *mut _) != glib_sys::GFALSE {
gobject_sys::g_object_ref_sink(pipeline as *mut _);
}
}
}
}