Skip to main content

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