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 | |
6 | use crate::VideoCodecFrame; |
7 | use glib::{ |
8 | prelude::*, |
9 | signal::{connect_raw, SignalHandlerId}, |
10 | translate::*, |
11 | }; |
12 | use std::{boxed::Box as Box_, mem::transmute}; |
13 | |
14 | glib::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 | |
23 | impl VideoEncoder { |
24 | pub const NONE: Option<&'static VideoEncoder> = None; |
25 | } |
26 | |
27 | unsafe impl Send for VideoEncoder {} |
28 | unsafe impl Sync for VideoEncoder {} |
29 | |
30 | mod sealed { |
31 | pub trait Sealed {} |
32 | impl<T: super::IsA<super::VideoEncoder>> Sealed for T {} |
33 | } |
34 | |
35 | pub 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 | #[doc (alias = "gst_video_encoder_finish_frame" )] |
47 | fn finish_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> { |
48 | unsafe { |
49 | try_from_glib(ffi::gst_video_encoder_finish_frame( |
50 | self.as_ref().to_glib_none().0, |
51 | frame.into_glib_ptr(), |
52 | )) |
53 | } |
54 | } |
55 | |
56 | #[doc (alias = "gst_video_encoder_get_max_encode_time" )] |
57 | #[doc (alias = "get_max_encode_time" )] |
58 | fn max_encode_time(&self, frame: &VideoCodecFrame) -> gst::ClockTimeDiff { |
59 | unsafe { |
60 | ffi::gst_video_encoder_get_max_encode_time( |
61 | self.as_ref().to_glib_none().0, |
62 | frame.to_glib_none().0, |
63 | ) |
64 | } |
65 | } |
66 | |
67 | #[cfg (feature = "v1_18" )] |
68 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_18" )))] |
69 | #[doc (alias = "gst_video_encoder_get_min_force_key_unit_interval" )] |
70 | #[doc (alias = "get_min_force_key_unit_interval" )] |
71 | fn min_force_key_unit_interval(&self) -> Option<gst::ClockTime> { |
72 | unsafe { |
73 | from_glib(ffi::gst_video_encoder_get_min_force_key_unit_interval( |
74 | self.as_ref().to_glib_none().0, |
75 | )) |
76 | } |
77 | } |
78 | |
79 | #[doc (alias = "gst_video_encoder_is_qos_enabled" )] |
80 | fn is_qos_enabled(&self) -> bool { |
81 | unsafe { |
82 | from_glib(ffi::gst_video_encoder_is_qos_enabled( |
83 | self.as_ref().to_glib_none().0, |
84 | )) |
85 | } |
86 | } |
87 | |
88 | #[doc (alias = "gst_video_encoder_merge_tags" )] |
89 | fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode) { |
90 | unsafe { |
91 | ffi::gst_video_encoder_merge_tags( |
92 | self.as_ref().to_glib_none().0, |
93 | tags.to_glib_none().0, |
94 | mode.into_glib(), |
95 | ); |
96 | } |
97 | } |
98 | |
99 | #[doc (alias = "gst_video_encoder_proxy_getcaps" )] |
100 | fn proxy_getcaps(&self, caps: Option<&gst::Caps>, filter: Option<&gst::Caps>) -> gst::Caps { |
101 | unsafe { |
102 | from_glib_full(ffi::gst_video_encoder_proxy_getcaps( |
103 | self.as_ref().to_glib_none().0, |
104 | caps.to_glib_none().0, |
105 | filter.to_glib_none().0, |
106 | )) |
107 | } |
108 | } |
109 | |
110 | #[cfg (feature = "v1_18" )] |
111 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_18" )))] |
112 | #[doc (alias = "gst_video_encoder_set_min_force_key_unit_interval" )] |
113 | fn set_min_force_key_unit_interval(&self, interval: impl Into<Option<gst::ClockTime>>) { |
114 | unsafe { |
115 | ffi::gst_video_encoder_set_min_force_key_unit_interval( |
116 | self.as_ref().to_glib_none().0, |
117 | interval.into().into_glib(), |
118 | ); |
119 | } |
120 | } |
121 | |
122 | #[doc (alias = "gst_video_encoder_set_min_pts" )] |
123 | fn set_min_pts(&self, min_pts: impl Into<Option<gst::ClockTime>>) { |
124 | unsafe { |
125 | ffi::gst_video_encoder_set_min_pts( |
126 | self.as_ref().to_glib_none().0, |
127 | min_pts.into().into_glib(), |
128 | ); |
129 | } |
130 | } |
131 | |
132 | #[doc (alias = "gst_video_encoder_set_qos_enabled" )] |
133 | fn set_qos_enabled(&self, enabled: bool) { |
134 | unsafe { |
135 | ffi::gst_video_encoder_set_qos_enabled( |
136 | self.as_ref().to_glib_none().0, |
137 | enabled.into_glib(), |
138 | ); |
139 | } |
140 | } |
141 | |
142 | fn is_qos(&self) -> bool { |
143 | ObjectExt::property(self.as_ref(), "qos" ) |
144 | } |
145 | |
146 | fn set_qos(&self, qos: bool) { |
147 | ObjectExt::set_property(self.as_ref(), "qos" , qos) |
148 | } |
149 | |
150 | #[cfg (feature = "v1_18" )] |
151 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_18" )))] |
152 | #[doc (alias = "min-force-key-unit-interval" )] |
153 | fn connect_min_force_key_unit_interval_notify<F: Fn(&Self) + Send + Sync + 'static>( |
154 | &self, |
155 | f: F, |
156 | ) -> SignalHandlerId { |
157 | unsafe extern "C" fn notify_min_force_key_unit_interval_trampoline< |
158 | P: IsA<VideoEncoder>, |
159 | F: Fn(&P) + Send + Sync + 'static, |
160 | >( |
161 | this: *mut ffi::GstVideoEncoder, |
162 | _param_spec: glib::ffi::gpointer, |
163 | f: glib::ffi::gpointer, |
164 | ) { |
165 | let f: &F = &*(f as *const F); |
166 | f(VideoEncoder::from_glib_borrow(this).unsafe_cast_ref()) |
167 | } |
168 | unsafe { |
169 | let f: Box_<F> = Box_::new(f); |
170 | connect_raw( |
171 | self.as_ptr() as *mut _, |
172 | b"notify::min-force-key-unit-interval \0" .as_ptr() as *const _, |
173 | Some(transmute::<_, unsafe extern "C" fn()>( |
174 | notify_min_force_key_unit_interval_trampoline::<Self, F> as *const (), |
175 | )), |
176 | Box_::into_raw(f), |
177 | ) |
178 | } |
179 | } |
180 | |
181 | #[doc (alias = "qos" )] |
182 | fn connect_qos_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId { |
183 | unsafe extern "C" fn notify_qos_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::qos \0" .as_ptr() as *const _, |
199 | Some(transmute::<_, unsafe extern "C" fn()>( |
200 | notify_qos_trampoline::<Self, F> as *const (), |
201 | )), |
202 | Box_::into_raw(f), |
203 | ) |
204 | } |
205 | } |
206 | } |
207 | |
208 | impl<O: IsA<VideoEncoder>> VideoEncoderExt for O {} |
209 | |