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
10pub use ffi;
11pub use glib;
12pub use paste;
13
14#[doc(hidden)]
15pub static INITIALIZED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
16
17#[cold]
18#[inline(never)]
19#[track_caller]
20pub 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
29macro_rules! assert_initialized_main_thread {
30 () => {
31 if !crate::INITIALIZED.load(std::sync::atomic::Ordering::SeqCst) {
32 $crate::assert_initialized();
33 }
34 };
35}
36
37macro_rules! skip_assert_initialized {
38 () => {};
39}
40
41#[allow(clippy::needless_borrow)]
42#[allow(clippy::let_unit_value)]
43mod auto;
44pub use crate::auto::{functions::*, *};
45
46#[macro_use]
47#[cfg(feature = "serde")]
48mod serde_macros;
49#[cfg(feature = "serde")]
50pub use crate::serde_macros::*;
51
52#[macro_use]
53mod log;
54pub use crate::log::*;
55
56#[macro_use]
57mod error;
58pub use crate::error::*;
59
60#[macro_use]
61pub mod miniobject;
62pub use miniobject::{MiniObject, MiniObjectRef};
63pub mod message;
64pub use crate::message::{Message, MessageErrorDomain, MessageRef, MessageView};
65
66mod value;
67pub use crate::value::{
68 Array, ArrayRef, Bitmask, Fraction, FractionRange, IntRange, List, ListRef,
69};
70#[cfg(feature = "serde")]
71#[macro_use]
72mod value_serde;
73
74#[cfg(feature = "serde")]
75mod flag_serde;
76
77pub mod structure;
78pub use crate::structure::{Structure, StructureRef};
79#[cfg(feature = "serde")]
80mod structure_serde;
81
82pub mod caps;
83pub use crate::caps::{Caps, CapsFilterMapAction, CapsRef};
84mod caps_features;
85#[cfg(feature = "serde")]
86mod caps_serde;
87pub use crate::caps_features::{
88 CapsFeatures, CapsFeaturesRef, CAPS_FEATURES_MEMORY_SYSTEM_MEMORY,
89 CAPS_FEATURE_MEMORY_SYSTEM_MEMORY,
90};
91#[cfg(feature = "serde")]
92mod caps_features_serde;
93
94pub mod tags;
95pub 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")]
100mod tags_serde;
101
102pub mod meta;
103#[cfg(feature = "v1_16")]
104#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
105pub use crate::meta::MetaSeqnum;
106pub use crate::meta::{
107 Meta, MetaAPI, MetaAPIExt, MetaRef, MetaRefMut, ParentBufferMeta, ProtectionMeta,
108 ReferenceTimestampMeta,
109};
110pub mod buffer;
111pub use crate::buffer::{
112 Buffer, BufferMap, BufferRef, MappedBuffer, BUFFER_COPY_ALL, BUFFER_COPY_METADATA,
113};
114mod buffer_cursor;
115pub use crate::buffer_cursor::{BufferCursor, BufferRefCursor};
116pub mod memory;
117pub use crate::memory::{MappedMemory, Memory, MemoryMap, MemoryRef};
118#[cfg(feature = "serde")]
119mod buffer_serde;
120
121pub mod sample;
122pub use crate::sample::{Sample, SampleRef};
123#[cfg(feature = "serde")]
124mod sample_serde;
125
126pub mod bufferlist;
127pub use crate::bufferlist::{BufferList, BufferListRef};
128#[cfg(feature = "serde")]
129mod bufferlist_serde;
130
131pub mod query;
132pub use crate::query::{Query, QueryRef, QueryView, QueryViewMut};
133pub mod event;
134pub use crate::event::{Event, EventRef, EventView, GroupId, Seqnum};
135pub mod context;
136pub use crate::context::{Context, ContextRef};
137mod static_caps;
138pub use crate::static_caps::*;
139mod static_pad_template;
140pub use crate::static_pad_template::*;
141
142pub mod promise;
143pub use promise::{Promise, PromiseError};
144
145pub mod bus;
146mod element;
147pub mod element_factory;
148
149mod bin;
150pub use bin::BinBuilder;
151
152mod pipeline;
153pub use pipeline::PipelineBuilder;
154
155mod allocation_params;
156pub use self::allocation_params::AllocationParams;
157mod allocator;
158
159mod element_factory_type;
160pub use element_factory_type::*;
161
162mod tracer;
163mod tracer_factory;
164
165// OS dependent Bus extensions (also import the other platform mod for doc)
166#[cfg(any(unix, docsrs))]
167mod bus_unix;
168#[cfg(any(windows, docsrs))]
169mod bus_windows;
170
171mod child_proxy;
172mod date_time;
173#[cfg(feature = "serde")]
174mod date_time_serde;
175mod device_monitor;
176mod device_provider;
177mod device_provider_factory;
178mod enums;
179mod ghost_pad;
180mod gobject;
181mod iterator;
182mod object;
183mod pad;
184pub use pad::{
185 EventForeachAction, PadBuilder, PadGetRangeSuccess, PadProbeData, PadProbeId, PadProbeInfo,
186 StreamLock,
187};
188mod control_binding;
189mod control_source;
190mod parse_context;
191mod proxy_pad;
192mod registry;
193mod tag_setter;
194pub mod task;
195pub use task::{TaskLock, TaskLockGuard};
196mod task_pool;
197pub use self::iterator::{Iterator, IteratorError, IteratorImpl, StdIterator};
198pub 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};
212mod plugin_feature;
213
214mod plugin;
215pub mod stream;
216pub mod stream_collection;
217
218mod typefind;
219pub use crate::typefind::*;
220mod typefind_factory;
221
222pub mod format;
223pub use crate::format::{ClockTime, GenericFormattedValue, GenericSignedFormattedValue, Signed};
224
225mod segment;
226pub use crate::segment::*;
227#[cfg(feature = "serde")]
228mod segment_serde;
229
230pub mod toc;
231pub use crate::toc::{Toc, TocEntry, TocEntryRef, TocRef};
232#[cfg(feature = "serde")]
233mod toc_serde;
234
235mod clock;
236pub use crate::clock::{AtomicClockReturn, ClockId, PeriodicClockId, SingleShotClockId};
237
238mod buffer_pool;
239pub use crate::buffer_pool::{BufferPoolAcquireParams, BufferPoolConfig, BufferPoolConfigRef};
240
241mod pad_template;
242pub use pad_template::PadTemplateBuilder;
243
244pub mod param_spec;
245pub use crate::param_spec::{ParamSpecArray, ParamSpecFraction};
246
247pub mod functions;
248pub use crate::functions::*;
249
250mod utils;
251pub use crate::utils::ObjectLockGuard;
252
253#[cfg(feature = "v1_18")]
254mod gtype;
255
256use std::ptr;
257
258#[doc(alias = "gst_init_check")]
259pub 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.
284pub unsafe fn deinit() {
285 crate::INITIALIZED.store(val:false, order:std::sync::atomic::Ordering::SeqCst);
286 ffi::gst_deinit();
287}
288
289pub const PARAM_FLAG_CONTROLLABLE: glib::ParamFlags = glib::ParamFlags::USER_1;
290pub const PARAM_FLAG_MUTABLE_READY: glib::ParamFlags = glib::ParamFlags::USER_2;
291pub const PARAM_FLAG_MUTABLE_PAUSED: glib::ParamFlags = glib::ParamFlags::USER_3;
292pub const PARAM_FLAG_MUTABLE_PLAYING: glib::ParamFlags = glib::ParamFlags::USER_4;
293#[cfg(feature = "v1_18")]
294pub const PARAM_FLAG_DOC_SHOW_DEFAULT: glib::ParamFlags = glib::ParamFlags::USER_5;
295#[cfg(feature = "v1_18")]
296pub 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
300pub 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]
343pub mod subclass;
344