gstreamer_rtsp_server/
rtsp_media.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::{prelude::*, translate::*};
4
5use crate::{ffi, RTSPMedia};
6
7pub trait RTSPMediaExtManual: IsA<RTSPMedia> + 'static {
8    #[doc(alias = "gst_rtsp_media_take_pipeline")]
9    fn take_pipeline(&self, pipeline: &impl IsA<gst::Pipeline>) {
10        unsafe {
11            #[cfg(feature = "v1_18")]
12            {
13                ffi::gst_rtsp_media_take_pipeline(
14                    self.as_ref().to_glib_none().0,
15                    pipeline.upcast_ref().to_glib_none().0,
16                );
17            }
18            #[cfg(not(feature = "v1_18"))]
19            {
20                let pipeline = pipeline.upcast_ref().to_glib_full();
21                // See https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/merge_requests/109
22                glib::gobject_ffi::g_object_force_floating(pipeline as *mut _);
23                ffi::gst_rtsp_media_take_pipeline(self.as_ref().to_glib_none().0, pipeline);
24                if glib::gobject_ffi::g_object_is_floating(pipeline as *mut _) != glib::ffi::GFALSE
25                {
26                    glib::gobject_ffi::g_object_ref_sink(pipeline as *mut _);
27                }
28            }
29        }
30    }
31}
32
33impl<O: IsA<RTSPMedia>> RTSPMediaExtManual for O {}