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    /// Set `pipeline` as the [`gst::Pipeline`][crate::gst::Pipeline] for `self`. Ownership is
9    /// taken of `pipeline`.
10    /// ## `pipeline`
11    /// a [`gst::Pipeline`][crate::gst::Pipeline]
12    #[doc(alias = "gst_rtsp_media_take_pipeline")]
13    fn take_pipeline(&self, pipeline: &impl IsA<gst::Pipeline>) {
14        unsafe {
15            #[cfg(feature = "v1_18")]
16            {
17                ffi::gst_rtsp_media_take_pipeline(
18                    self.as_ref().to_glib_none().0,
19                    pipeline.upcast_ref().to_glib_none().0,
20                );
21            }
22            #[cfg(not(feature = "v1_18"))]
23            {
24                let pipeline = pipeline.upcast_ref().to_glib_full();
25                // See https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/merge_requests/109
26                glib::gobject_ffi::g_object_force_floating(pipeline as *mut _);
27                ffi::gst_rtsp_media_take_pipeline(self.as_ref().to_glib_none().0, pipeline);
28                if glib::gobject_ffi::g_object_is_floating(pipeline as *mut _) != glib::ffi::GFALSE
29                {
30                    glib::gobject_ffi::g_object_ref_sink(pipeline as *mut _);
31                }
32            }
33        }
34    }
35}
36
37impl<O: IsA<RTSPMedia>> RTSPMediaExtManual for O {}