gstreamer_rtsp_server/
rtsp_media.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Take a look at the license at the top of the repository in the LICENSE file.

use glib::{prelude::*, translate::*};

use crate::{ffi, RTSPMedia};

pub trait RTSPMediaExtManual: IsA<RTSPMedia> + 'static {
    /// Set `pipeline` as the [`gst::Pipeline`][crate::gst::Pipeline] for `self`. Ownership is
    /// taken of `pipeline`.
    /// ## `pipeline`
    /// a [`gst::Pipeline`][crate::gst::Pipeline]
    #[doc(alias = "gst_rtsp_media_take_pipeline")]
    fn take_pipeline(&self, pipeline: &impl IsA<gst::Pipeline>) {
        unsafe {
            #[cfg(feature = "v1_18")]
            {
                ffi::gst_rtsp_media_take_pipeline(
                    self.as_ref().to_glib_none().0,
                    pipeline.upcast_ref().to_glib_none().0,
                );
            }
            #[cfg(not(feature = "v1_18"))]
            {
                let pipeline = pipeline.upcast_ref().to_glib_full();
                // See https://gitlab.freedesktop.org/gstreamer/gst-rtsp-server/merge_requests/109
                glib::gobject_ffi::g_object_force_floating(pipeline as *mut _);
                ffi::gst_rtsp_media_take_pipeline(self.as_ref().to_glib_none().0, pipeline);
                if glib::gobject_ffi::g_object_is_floating(pipeline as *mut _) != glib::ffi::GFALSE
                {
                    glib::gobject_ffi::g_object_ref_sink(pipeline as *mut _);
                }
            }
        }
    }
}

impl<O: IsA<RTSPMedia>> RTSPMediaExtManual for O {}