1 | // Take a look at the license at the top of the repository in the LICENSE file. |
2 | |
3 | #![cfg_attr (docsrs, feature(doc_cfg))] |
4 | #![recursion_limit = "256" ] |
5 | #![allow (clippy::missing_safety_doc)] |
6 | #![allow (clippy::manual_range_contains)] |
7 | #![doc = include_str!("../README.md" )] |
8 | |
9 | // Re-exported for the subclass gst_plugin_define! macro |
10 | pub use ffi; |
11 | pub use glib; |
12 | pub use paste; |
13 | |
14 | #[doc (hidden)] |
15 | pub static INITIALIZED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false); |
16 | |
17 | #[cold ] |
18 | #[inline (never)] |
19 | #[track_caller ] |
20 | pub fn assert_initialized() { |
21 | #[allow (unused_unsafe)] |
22 | if unsafe { ffi::gst_is_initialized() } != glib::ffi::GTRUE { |
23 | panic!("GStreamer has not been initialized. Call `gst::init` first." ); |
24 | } else { |
25 | crate::INITIALIZED.store(val:true, order:std::sync::atomic::Ordering::SeqCst); |
26 | } |
27 | } |
28 | |
29 | macro_rules! assert_initialized_main_thread { |
30 | () => { |
31 | if !crate::INITIALIZED.load(std::sync::atomic::Ordering::SeqCst) { |
32 | $crate::assert_initialized(); |
33 | } |
34 | }; |
35 | } |
36 | |
37 | macro_rules! skip_assert_initialized { |
38 | () => {}; |
39 | } |
40 | |
41 | #[allow (clippy::needless_borrow)] |
42 | #[allow (clippy::let_unit_value)] |
43 | mod auto; |
44 | pub use crate::auto::{functions::*, *}; |
45 | |
46 | #[macro_use ] |
47 | #[cfg (feature = "serde" )] |
48 | mod serde_macros; |
49 | #[cfg (feature = "serde" )] |
50 | pub use crate::serde_macros::*; |
51 | |
52 | #[macro_use ] |
53 | mod log; |
54 | pub use crate::log::*; |
55 | |
56 | #[macro_use ] |
57 | mod error; |
58 | pub use crate::error::*; |
59 | |
60 | #[macro_use ] |
61 | pub mod miniobject; |
62 | pub use miniobject::{MiniObject, MiniObjectRef}; |
63 | pub mod message; |
64 | pub use crate::message::{Message, MessageErrorDomain, MessageRef, MessageView}; |
65 | |
66 | mod value; |
67 | pub use crate::value::{ |
68 | Array, ArrayRef, Bitmask, Fraction, FractionRange, IntRange, List, ListRef, |
69 | }; |
70 | #[cfg (feature = "serde" )] |
71 | #[macro_use ] |
72 | mod value_serde; |
73 | |
74 | #[cfg (feature = "serde" )] |
75 | mod flag_serde; |
76 | |
77 | pub mod structure; |
78 | pub use crate::structure::{Structure, StructureRef}; |
79 | #[cfg (feature = "serde" )] |
80 | mod structure_serde; |
81 | |
82 | pub mod caps; |
83 | pub use crate::caps::{Caps, CapsFilterMapAction, CapsRef}; |
84 | mod caps_features; |
85 | #[cfg (feature = "serde" )] |
86 | mod caps_serde; |
87 | pub use crate::caps_features::{ |
88 | CapsFeatures, CapsFeaturesRef, CAPS_FEATURES_MEMORY_SYSTEM_MEMORY, |
89 | CAPS_FEATURE_MEMORY_SYSTEM_MEMORY, |
90 | }; |
91 | #[cfg (feature = "serde" )] |
92 | mod caps_features_serde; |
93 | |
94 | pub mod tags; |
95 | pub use crate::tags::{ |
96 | tag_exists, tag_get_description, tag_get_flag, tag_get_nick, tag_get_type, Tag, TagList, |
97 | TagListRef, |
98 | }; |
99 | #[cfg (feature = "serde" )] |
100 | mod tags_serde; |
101 | |
102 | pub mod meta; |
103 | #[cfg (feature = "v1_16" )] |
104 | #[cfg_attr (docsrs, doc(cfg(feature = "v1_16" )))] |
105 | pub use crate::meta::MetaSeqnum; |
106 | pub use crate::meta::{ |
107 | Meta, MetaAPI, MetaAPIExt, MetaRef, MetaRefMut, ParentBufferMeta, ProtectionMeta, |
108 | ReferenceTimestampMeta, |
109 | }; |
110 | pub mod buffer; |
111 | pub use crate::buffer::{ |
112 | Buffer, BufferMap, BufferRef, MappedBuffer, BUFFER_COPY_ALL, BUFFER_COPY_METADATA, |
113 | }; |
114 | mod buffer_cursor; |
115 | pub use crate::buffer_cursor::{BufferCursor, BufferRefCursor}; |
116 | pub mod memory; |
117 | pub use crate::memory::{MappedMemory, Memory, MemoryMap, MemoryRef}; |
118 | #[cfg (feature = "serde" )] |
119 | mod buffer_serde; |
120 | |
121 | pub mod sample; |
122 | pub use crate::sample::{Sample, SampleRef}; |
123 | #[cfg (feature = "serde" )] |
124 | mod sample_serde; |
125 | |
126 | pub mod bufferlist; |
127 | pub use crate::bufferlist::{BufferList, BufferListRef}; |
128 | #[cfg (feature = "serde" )] |
129 | mod bufferlist_serde; |
130 | |
131 | pub mod query; |
132 | pub use crate::query::{Query, QueryRef, QueryView, QueryViewMut}; |
133 | pub mod event; |
134 | pub use crate::event::{Event, EventRef, EventView, GroupId, Seqnum}; |
135 | pub mod context; |
136 | pub use crate::context::{Context, ContextRef}; |
137 | mod static_caps; |
138 | pub use crate::static_caps::*; |
139 | mod static_pad_template; |
140 | pub use crate::static_pad_template::*; |
141 | |
142 | pub mod promise; |
143 | pub use promise::{Promise, PromiseError}; |
144 | |
145 | pub mod bus; |
146 | mod element; |
147 | pub mod element_factory; |
148 | |
149 | mod bin; |
150 | pub use bin::BinBuilder; |
151 | |
152 | mod pipeline; |
153 | pub use pipeline::PipelineBuilder; |
154 | |
155 | mod allocation_params; |
156 | pub use self::allocation_params::AllocationParams; |
157 | mod allocator; |
158 | |
159 | mod element_factory_type; |
160 | pub use element_factory_type::*; |
161 | |
162 | mod tracer; |
163 | mod tracer_factory; |
164 | |
165 | // OS dependent Bus extensions (also import the other platform mod for doc) |
166 | #[cfg (any(unix, docsrs))] |
167 | mod bus_unix; |
168 | #[cfg (any(windows, docsrs))] |
169 | mod bus_windows; |
170 | |
171 | mod child_proxy; |
172 | mod date_time; |
173 | #[cfg (feature = "serde" )] |
174 | mod date_time_serde; |
175 | mod device_monitor; |
176 | mod device_provider; |
177 | mod device_provider_factory; |
178 | mod enums; |
179 | mod ghost_pad; |
180 | mod gobject; |
181 | mod iterator; |
182 | mod object; |
183 | mod pad; |
184 | pub use pad::{ |
185 | EventForeachAction, PadBuilder, PadGetRangeSuccess, PadProbeData, PadProbeId, PadProbeInfo, |
186 | StreamLock, |
187 | }; |
188 | mod control_binding; |
189 | mod control_source; |
190 | mod parse_context; |
191 | mod proxy_pad; |
192 | mod registry; |
193 | mod tag_setter; |
194 | pub mod task; |
195 | pub use task::{TaskLock, TaskLockGuard}; |
196 | mod task_pool; |
197 | pub use self::iterator::{Iterator, IteratorError, IteratorImpl, StdIterator}; |
198 | pub use crate::{ |
199 | device_monitor::DeviceMonitorFilterId, |
200 | element::{ |
201 | ElementMessageType, NotifyWatchId, ELEMENT_METADATA_AUTHOR, ELEMENT_METADATA_DESCRIPTION, |
202 | ELEMENT_METADATA_DOC_URI, ELEMENT_METADATA_ICON_NAME, ELEMENT_METADATA_KLASS, |
203 | ELEMENT_METADATA_LONGNAME, |
204 | }, |
205 | enums::{ |
206 | ClockError, ClockSuccess, FlowError, FlowReturn, FlowSuccess, MessageType, PadLinkError, |
207 | PadLinkReturn, PadLinkSuccess, StateChangeError, StateChangeSuccess, TagError, |
208 | }, |
209 | parse_context::ParseContext, |
210 | task_pool::{TaskHandle, TaskPoolTaskHandle}, |
211 | }; |
212 | mod plugin_feature; |
213 | |
214 | mod plugin; |
215 | pub mod stream; |
216 | pub mod stream_collection; |
217 | |
218 | mod typefind; |
219 | pub use crate::typefind::*; |
220 | mod typefind_factory; |
221 | |
222 | pub mod format; |
223 | pub use crate::format::{ClockTime, GenericFormattedValue, GenericSignedFormattedValue, Signed}; |
224 | |
225 | mod segment; |
226 | pub use crate::segment::*; |
227 | #[cfg (feature = "serde" )] |
228 | mod segment_serde; |
229 | |
230 | pub mod toc; |
231 | pub use crate::toc::{Toc, TocEntry, TocEntryRef, TocRef}; |
232 | #[cfg (feature = "serde" )] |
233 | mod toc_serde; |
234 | |
235 | mod clock; |
236 | pub use crate::clock::{AtomicClockReturn, ClockId, PeriodicClockId, SingleShotClockId}; |
237 | |
238 | mod buffer_pool; |
239 | pub use crate::buffer_pool::{BufferPoolAcquireParams, BufferPoolConfig, BufferPoolConfigRef}; |
240 | |
241 | mod pad_template; |
242 | pub use pad_template::PadTemplateBuilder; |
243 | |
244 | pub mod param_spec; |
245 | pub use crate::param_spec::{ParamSpecArray, ParamSpecFraction}; |
246 | |
247 | pub mod functions; |
248 | pub use crate::functions::*; |
249 | |
250 | mod utils; |
251 | pub use crate::utils::ObjectLockGuard; |
252 | |
253 | #[cfg (feature = "v1_18" )] |
254 | mod gtype; |
255 | |
256 | use std::ptr; |
257 | |
258 | #[doc (alias = "gst_init_check" )] |
259 | pub fn init() -> Result<(), glib::Error> { |
260 | unsafe { |
261 | use glib::translate::*; |
262 | |
263 | let mut error: *mut GError = ptr::null_mut(); |
264 | if from_glib(val:ffi::gst_init_check( |
265 | argc:ptr::null_mut(), |
266 | argv:ptr::null_mut(), |
267 | &mut error, |
268 | )) { |
269 | crate::INITIALIZED.store(val:true, order:std::sync::atomic::Ordering::SeqCst); |
270 | Ok(()) |
271 | } else { |
272 | Err(from_glib_full(ptr:error)) |
273 | } |
274 | } |
275 | } |
276 | |
277 | // rustdoc-stripper-ignore-next |
278 | /// Deinitialize GStreamer |
279 | /// |
280 | /// # Safety |
281 | /// |
282 | /// This must only be called once during the lifetime of the process, once no GStreamer threads |
283 | /// are running anymore and all GStreamer resources are released. |
284 | pub unsafe fn deinit() { |
285 | crate::INITIALIZED.store(val:false, order:std::sync::atomic::Ordering::SeqCst); |
286 | ffi::gst_deinit(); |
287 | } |
288 | |
289 | pub const PARAM_FLAG_CONTROLLABLE: glib::ParamFlags = glib::ParamFlags::USER_1; |
290 | pub const PARAM_FLAG_MUTABLE_READY: glib::ParamFlags = glib::ParamFlags::USER_2; |
291 | pub const PARAM_FLAG_MUTABLE_PAUSED: glib::ParamFlags = glib::ParamFlags::USER_3; |
292 | pub const PARAM_FLAG_MUTABLE_PLAYING: glib::ParamFlags = glib::ParamFlags::USER_4; |
293 | #[cfg (feature = "v1_18" )] |
294 | pub const PARAM_FLAG_DOC_SHOW_DEFAULT: glib::ParamFlags = glib::ParamFlags::USER_5; |
295 | #[cfg (feature = "v1_18" )] |
296 | pub const PARAM_FLAG_CONDITIONALLY_AVAILABLE: glib::ParamFlags = glib::ParamFlags::USER_6; |
297 | |
298 | // Re-export all the traits in a prelude module, so that applications |
299 | // can always "use gst::prelude::*" without getting conflicts |
300 | pub mod prelude { |
301 | #[doc (hidden)] |
302 | pub use glib::prelude::*; |
303 | pub use muldiv::MulDiv; |
304 | pub use opt_ops::prelude::*; |
305 | |
306 | // OS dependent Bus extensions (also import the other platform trait for doc) |
307 | #[cfg (any(unix, docsrs))] |
308 | pub use crate::bus_unix::UnixBusExtManual; |
309 | #[cfg (any(windows, docsrs))] |
310 | pub use crate::bus_windows::WindowsBusExtManual; |
311 | #[cfg (feature = "v1_18" )] |
312 | pub use crate::gtype::PluginApiExt; |
313 | pub use crate::{ |
314 | auto::traits::*, |
315 | bin::GstBinExtManual, |
316 | buffer_pool::BufferPoolExtManual, |
317 | child_proxy::ChildProxyExtManual, |
318 | clock::ClockExtManual, |
319 | device_monitor::DeviceMonitorExtManual, |
320 | device_provider::{DeviceProviderClassExt, DeviceProviderExtManual}, |
321 | element::{ElementClassExt, ElementExtManual}, |
322 | format::prelude::*, |
323 | gobject::GObjectExtManualGst, |
324 | memory::MemoryType, |
325 | message::MessageErrorDomain, |
326 | meta::{MetaAPI, MetaAPIExt}, |
327 | miniobject::IsMiniObject, |
328 | object::GstObjectExtManual, |
329 | pad::PadExtManual, |
330 | param_spec::GstParamSpecBuilderExt, |
331 | pipeline::GstPipelineExtManual, |
332 | plugin_feature::PluginFeatureExtManual, |
333 | tag_setter::TagSetterExtManual, |
334 | tags::{CustomTag, Tag}, |
335 | task_pool::{TaskHandle, TaskPoolExtManual}, |
336 | typefind::TypeFindImpl, |
337 | utils::Displayable, |
338 | value::GstValueExt, |
339 | }; |
340 | } |
341 | |
342 | #[macro_use ] |
343 | pub mod subclass; |
344 | |