gstreamer_video/auto/
video_encoder.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
4// DO NOT EDIT
5
6use crate::{ffi, VideoCodecFrame};
7use glib::{
8    prelude::*,
9    signal::{connect_raw, SignalHandlerId},
10    translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15    #[doc(alias = "GstVideoEncoder")]
16    pub struct VideoEncoder(Object<ffi::GstVideoEncoder, ffi::GstVideoEncoderClass>) @extends gst::Element, gst::Object;
17
18    match fn {
19        type_ => || ffi::gst_video_encoder_get_type(),
20    }
21}
22
23impl VideoEncoder {
24    pub const NONE: Option<&'static VideoEncoder> = None;
25}
26
27unsafe impl Send for VideoEncoder {}
28unsafe impl Sync for VideoEncoder {}
29
30mod sealed {
31    pub trait Sealed {}
32    impl<T: super::IsA<super::VideoEncoder>> Sealed for T {}
33}
34
35pub trait VideoEncoderExt: IsA<VideoEncoder> + sealed::Sealed + 'static {
36    #[doc(alias = "gst_video_encoder_allocate_output_buffer")]
37    fn allocate_output_buffer(&self, size: usize) -> gst::Buffer {
38        unsafe {
39            from_glib_full(ffi::gst_video_encoder_allocate_output_buffer(
40                self.as_ref().to_glib_none().0,
41                size,
42            ))
43        }
44    }
45
46    #[cfg(feature = "v1_26")]
47    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
48    #[doc(alias = "gst_video_encoder_drop_frame")]
49    fn drop_frame(&self, frame: VideoCodecFrame) {
50        unsafe {
51            ffi::gst_video_encoder_drop_frame(
52                self.as_ref().to_glib_none().0,
53                frame.into_glib_ptr(),
54            );
55        }
56    }
57
58    #[doc(alias = "gst_video_encoder_finish_frame")]
59    fn finish_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
60        unsafe {
61            try_from_glib(ffi::gst_video_encoder_finish_frame(
62                self.as_ref().to_glib_none().0,
63                frame.into_glib_ptr(),
64            ))
65        }
66    }
67
68    #[doc(alias = "gst_video_encoder_get_max_encode_time")]
69    #[doc(alias = "get_max_encode_time")]
70    fn max_encode_time(&self, frame: &VideoCodecFrame) -> gst::ClockTimeDiff {
71        unsafe {
72            ffi::gst_video_encoder_get_max_encode_time(
73                self.as_ref().to_glib_none().0,
74                frame.to_glib_none().0,
75            )
76        }
77    }
78
79    #[cfg(feature = "v1_18")]
80    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
81    #[doc(alias = "gst_video_encoder_get_min_force_key_unit_interval")]
82    #[doc(alias = "get_min_force_key_unit_interval")]
83    #[doc(alias = "min-force-key-unit-interval")]
84    fn min_force_key_unit_interval(&self) -> Option<gst::ClockTime> {
85        unsafe {
86            from_glib(ffi::gst_video_encoder_get_min_force_key_unit_interval(
87                self.as_ref().to_glib_none().0,
88            ))
89        }
90    }
91
92    #[doc(alias = "gst_video_encoder_is_qos_enabled")]
93    fn is_qos_enabled(&self) -> bool {
94        unsafe {
95            from_glib(ffi::gst_video_encoder_is_qos_enabled(
96                self.as_ref().to_glib_none().0,
97            ))
98        }
99    }
100
101    #[doc(alias = "gst_video_encoder_merge_tags")]
102    fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode) {
103        unsafe {
104            ffi::gst_video_encoder_merge_tags(
105                self.as_ref().to_glib_none().0,
106                tags.to_glib_none().0,
107                mode.into_glib(),
108            );
109        }
110    }
111
112    #[doc(alias = "gst_video_encoder_proxy_getcaps")]
113    fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps {
114        unsafe {
115            from_glib_full(ffi::gst_video_encoder_proxy_getcaps(
116                self.as_ref().to_glib_none().0,
117                caps.to_glib_none().0,
118                filter.to_glib_none().0,
119            ))
120        }
121    }
122
123    #[cfg(feature = "v1_26")]
124    #[cfg_attr(docsrs, doc(cfg(feature = "v1_26")))]
125    #[doc(alias = "gst_video_encoder_release_frame")]
126    fn release_frame(&self, frame: VideoCodecFrame) {
127        unsafe {
128            ffi::gst_video_encoder_release_frame(
129                self.as_ref().to_glib_none().0,
130                frame.into_glib_ptr(),
131            );
132        }
133    }
134
135    #[cfg(feature = "v1_18")]
136    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
137    #[doc(alias = "gst_video_encoder_set_min_force_key_unit_interval")]
138    #[doc(alias = "min-force-key-unit-interval")]
139    fn set_min_force_key_unit_interval(&self, interval: impl Into<Option<gst::ClockTime>>) {
140        unsafe {
141            ffi::gst_video_encoder_set_min_force_key_unit_interval(
142                self.as_ref().to_glib_none().0,
143                interval.into().into_glib(),
144            );
145        }
146    }
147
148    #[doc(alias = "gst_video_encoder_set_min_pts")]
149    fn set_min_pts(&self, min_pts: impl Into<Option<gst::ClockTime>>) {
150        unsafe {
151            ffi::gst_video_encoder_set_min_pts(
152                self.as_ref().to_glib_none().0,
153                min_pts.into().into_glib(),
154            );
155        }
156    }
157
158    #[doc(alias = "gst_video_encoder_set_qos_enabled")]
159    fn set_qos_enabled(&self, enabled: bool) {
160        unsafe {
161            ffi::gst_video_encoder_set_qos_enabled(
162                self.as_ref().to_glib_none().0,
163                enabled.into_glib(),
164            );
165        }
166    }
167
168    fn is_qos(&self) -> bool {
169        ObjectExt::property(self.as_ref(), "qos")
170    }
171
172    fn set_qos(&self, qos: bool) {
173        ObjectExt::set_property(self.as_ref(), "qos", qos)
174    }
175
176    #[cfg(feature = "v1_18")]
177    #[cfg_attr(docsrs, doc(cfg(feature = "v1_18")))]
178    #[doc(alias = "min-force-key-unit-interval")]
179    fn connect_min_force_key_unit_interval_notify<F: Fn(&Self) + Send + Sync + 'static>(
180        &self,
181        f: F,
182    ) -> SignalHandlerId {
183        unsafe extern "C" fn notify_min_force_key_unit_interval_trampoline<
184            P: IsA<VideoEncoder>,
185            F: Fn(&P) + Send + Sync + 'static,
186        >(
187            this: *mut ffi::GstVideoEncoder,
188            _param_spec: glib::ffi::gpointer,
189            f: glib::ffi::gpointer,
190        ) {
191            let f: &F = &*(f as *const F);
192            f(VideoEncoder::from_glib_borrow(this).unsafe_cast_ref())
193        }
194        unsafe {
195            let f: Box_<F> = Box_::new(f);
196            connect_raw(
197                self.as_ptr() as *mut _,
198                b"notify::min-force-key-unit-interval\0".as_ptr() as *const _,
199                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
200                    notify_min_force_key_unit_interval_trampoline::<Self, F> as *const (),
201                )),
202                Box_::into_raw(f),
203            )
204        }
205    }
206
207    #[doc(alias = "qos")]
208    fn connect_qos_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
209        unsafe extern "C" fn notify_qos_trampoline<
210            P: IsA<VideoEncoder>,
211            F: Fn(&P) + Send + Sync + 'static,
212        >(
213            this: *mut ffi::GstVideoEncoder,
214            _param_spec: glib::ffi::gpointer,
215            f: glib::ffi::gpointer,
216        ) {
217            let f: &F = &*(f as *const F);
218            f(VideoEncoder::from_glib_borrow(this).unsafe_cast_ref())
219        }
220        unsafe {
221            let f: Box_<F> = Box_::new(f);
222            connect_raw(
223                self.as_ptr() as *mut _,
224                b"notify::qos\0".as_ptr() as *const _,
225                Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
226                    notify_qos_trampoline::<Self, F> as *const (),
227                )),
228                Box_::into_raw(f),
229            )
230        }
231    }
232}
233
234impl<O: IsA<VideoEncoder>> VideoEncoderExt for O {}