1use crate::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 = "GstBaseParse")]
16 pub struct BaseParse(Object<ffi::GstBaseParse, ffi::GstBaseParseClass>) @extends gst::Element, gst::Object;
17
18 match fn {
19 type_ => || ffi::gst_base_parse_get_type(),
20 }
21}
22
23impl BaseParse {
24 pub const NONE: Option<&'static BaseParse> = None;
25}
26
27unsafe impl Send for BaseParse {}
28unsafe impl Sync for BaseParse {}
29
30pub trait BaseParseExt: IsA<BaseParse> + 'static {
31 #[doc(alias = "gst_base_parse_add_index_entry")]
32 fn add_index_entry(&self, offset: u64, ts: gst::ClockTime, key: bool, force: bool) -> bool {
33 unsafe {
34 from_glib(ffi::gst_base_parse_add_index_entry(
35 self.as_ref().to_glib_none().0,
36 offset,
37 ts.into_glib(),
38 key.into_glib(),
39 force.into_glib(),
40 ))
41 }
42 }
43
44 #[doc(alias = "gst_base_parse_drain")]
45 fn drain(&self) {
46 unsafe {
47 ffi::gst_base_parse_drain(self.as_ref().to_glib_none().0);
48 }
49 }
50
51 #[doc(alias = "gst_base_parse_merge_tags")]
52 fn merge_tags(&self, tags: Option<&gst::TagList>, mode: gst::TagMergeMode) {
53 unsafe {
54 ffi::gst_base_parse_merge_tags(
55 self.as_ref().to_glib_none().0,
56 tags.to_glib_none().0,
57 mode.into_glib(),
58 );
59 }
60 }
61
62 #[cfg(feature = "v1_30")]
63 #[cfg_attr(docsrs, doc(cfg(feature = "v1_30")))]
64 #[doc(alias = "gst_base_parse_set_allow_duplicated_pts")]
65 fn set_allow_duplicated_pts(&self, allow_duplicated_pts: bool) {
66 unsafe {
67 ffi::gst_base_parse_set_allow_duplicated_pts(
68 self.as_ref().to_glib_none().0,
69 allow_duplicated_pts.into_glib(),
70 );
71 }
72 }
73
74 #[doc(alias = "gst_base_parse_set_average_bitrate")]
75 fn set_average_bitrate(&self, bitrate: u32) {
76 unsafe {
77 ffi::gst_base_parse_set_average_bitrate(self.as_ref().to_glib_none().0, bitrate);
78 }
79 }
80
81 #[doc(alias = "gst_base_parse_set_has_timing_info")]
82 fn set_has_timing_info(&self, has_timing: bool) {
83 unsafe {
84 ffi::gst_base_parse_set_has_timing_info(
85 self.as_ref().to_glib_none().0,
86 has_timing.into_glib(),
87 );
88 }
89 }
90
91 #[doc(alias = "gst_base_parse_set_infer_ts")]
92 fn set_infer_ts(&self, infer_ts: bool) {
93 unsafe {
94 ffi::gst_base_parse_set_infer_ts(self.as_ref().to_glib_none().0, infer_ts.into_glib());
95 }
96 }
97
98 #[doc(alias = "gst_base_parse_set_latency")]
99 fn set_latency(
100 &self,
101 min_latency: gst::ClockTime,
102 max_latency: impl Into<Option<gst::ClockTime>>,
103 ) {
104 unsafe {
105 ffi::gst_base_parse_set_latency(
106 self.as_ref().to_glib_none().0,
107 min_latency.into_glib(),
108 max_latency.into().into_glib(),
109 );
110 }
111 }
112
113 #[doc(alias = "gst_base_parse_set_min_frame_size")]
114 fn set_min_frame_size(&self, min_size: u32) {
115 unsafe {
116 ffi::gst_base_parse_set_min_frame_size(self.as_ref().to_glib_none().0, min_size);
117 }
118 }
119
120 #[doc(alias = "gst_base_parse_set_passthrough")]
121 fn set_passthrough(&self, passthrough: bool) {
122 unsafe {
123 ffi::gst_base_parse_set_passthrough(
124 self.as_ref().to_glib_none().0,
125 passthrough.into_glib(),
126 );
127 }
128 }
129
130 #[doc(alias = "gst_base_parse_set_pts_interpolation")]
131 fn set_pts_interpolation(&self, pts_interpolate: bool) {
132 unsafe {
133 ffi::gst_base_parse_set_pts_interpolation(
134 self.as_ref().to_glib_none().0,
135 pts_interpolate.into_glib(),
136 );
137 }
138 }
139
140 #[doc(alias = "gst_base_parse_set_syncable")]
141 fn set_syncable(&self, syncable: bool) {
142 unsafe {
143 ffi::gst_base_parse_set_syncable(self.as_ref().to_glib_none().0, syncable.into_glib());
144 }
145 }
146
147 #[doc(alias = "gst_base_parse_set_ts_at_offset")]
148 fn set_ts_at_offset(&self, offset: usize) {
149 unsafe {
150 ffi::gst_base_parse_set_ts_at_offset(self.as_ref().to_glib_none().0, offset);
151 }
152 }
153
154 #[cfg(feature = "v1_28")]
155 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
156 #[doc(alias = "disable-clip")]
157 fn is_disable_clip(&self) -> bool {
158 ObjectExt::property(self.as_ref(), "disable-clip")
159 }
160
161 #[cfg(feature = "v1_28")]
162 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
163 #[doc(alias = "disable-clip")]
164 fn set_disable_clip(&self, disable_clip: bool) {
165 ObjectExt::set_property(self.as_ref(), "disable-clip", disable_clip)
166 }
167
168 #[doc(alias = "disable-passthrough")]
169 fn is_disable_passthrough(&self) -> bool {
170 ObjectExt::property(self.as_ref(), "disable-passthrough")
171 }
172
173 #[doc(alias = "disable-passthrough")]
174 fn set_disable_passthrough(&self, disable_passthrough: bool) {
175 ObjectExt::set_property(self.as_ref(), "disable-passthrough", disable_passthrough)
176 }
177
178 #[cfg(feature = "v1_28")]
179 #[cfg_attr(docsrs, doc(cfg(feature = "v1_28")))]
180 #[doc(alias = "disable-clip")]
181 fn connect_disable_clip_notify<F: Fn(&Self) + Send + Sync + 'static>(
182 &self,
183 f: F,
184 ) -> SignalHandlerId {
185 unsafe extern "C" fn notify_disable_clip_trampoline<
186 P: IsA<BaseParse>,
187 F: Fn(&P) + Send + Sync + 'static,
188 >(
189 this: *mut ffi::GstBaseParse,
190 _param_spec: glib::ffi::gpointer,
191 f: glib::ffi::gpointer,
192 ) {
193 unsafe {
194 let f: &F = &*(f as *const F);
195 f(BaseParse::from_glib_borrow(this).unsafe_cast_ref())
196 }
197 }
198 unsafe {
199 let f: Box_<F> = Box_::new(f);
200 connect_raw(
201 self.as_ptr() as *mut _,
202 c"notify::disable-clip".as_ptr(),
203 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
204 notify_disable_clip_trampoline::<Self, F> as *const (),
205 )),
206 Box_::into_raw(f),
207 )
208 }
209 }
210
211 #[doc(alias = "disable-passthrough")]
212 fn connect_disable_passthrough_notify<F: Fn(&Self) + Send + Sync + 'static>(
213 &self,
214 f: F,
215 ) -> SignalHandlerId {
216 unsafe extern "C" fn notify_disable_passthrough_trampoline<
217 P: IsA<BaseParse>,
218 F: Fn(&P) + Send + Sync + 'static,
219 >(
220 this: *mut ffi::GstBaseParse,
221 _param_spec: glib::ffi::gpointer,
222 f: glib::ffi::gpointer,
223 ) {
224 unsafe {
225 let f: &F = &*(f as *const F);
226 f(BaseParse::from_glib_borrow(this).unsafe_cast_ref())
227 }
228 }
229 unsafe {
230 let f: Box_<F> = Box_::new(f);
231 connect_raw(
232 self.as_ptr() as *mut _,
233 c"notify::disable-passthrough".as_ptr(),
234 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
235 notify_disable_passthrough_trampoline::<Self, F> as *const (),
236 )),
237 Box_::into_raw(f),
238 )
239 }
240 }
241}
242
243impl<O: IsA<BaseParse>> BaseParseExt for O {}