1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
// Take a look at the license at the top of the repository in the LICENSE file.

#![cfg_attr(docsrs, feature(doc_cfg))]
#![recursion_limit = "256"]
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::manual_range_contains)]
#![doc = include_str!("../README.md")]

// Re-exported for the subclass gst_plugin_define! macro
pub use ffi;
pub use glib;
pub use paste;

#[doc(hidden)]
pub static INITIALIZED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);

#[cold]
#[inline(never)]
#[track_caller]
pub fn assert_initialized() {
    #[allow(unused_unsafe)]
    if unsafe { ffi::gst_is_initialized() } != glib::ffi::GTRUE {
        panic!("GStreamer has not been initialized. Call `gst::init` first.");
    } else {
        crate::INITIALIZED.store(true, std::sync::atomic::Ordering::SeqCst);
    }
}

macro_rules! assert_initialized_main_thread {
    () => {
        if !crate::INITIALIZED.load(std::sync::atomic::Ordering::SeqCst) {
            $crate::assert_initialized();
        }
    };
}

macro_rules! skip_assert_initialized {
    () => {};
}

#[allow(clippy::needless_borrow)]
#[allow(clippy::let_unit_value)]
mod auto;
pub use crate::auto::*;

#[macro_use]
#[cfg(feature = "serde")]
mod serde_macros;

#[macro_use]
pub mod log;
pub use crate::log::{
    DebugCategory, DebugLogFunction, DebugMessage, LoggedObject, CAT_BUFFER, CAT_BUFFER_LIST,
    CAT_BUS, CAT_CALL_TRACE, CAT_CAPS, CAT_CLOCK, CAT_CONTEXT, CAT_DEFAULT, CAT_ELEMENT_PADS,
    CAT_ERROR_SYSTEM, CAT_EVENT, CAT_GST_INIT, CAT_LOCKING, CAT_MEMORY, CAT_MESSAGE, CAT_META,
    CAT_NEGOTIATION, CAT_PADS, CAT_PARAMS, CAT_PARENTAGE, CAT_PERFORMANCE, CAT_PIPELINE,
    CAT_PLUGIN_INFO, CAT_PLUGIN_LOADING, CAT_PROBE, CAT_PROPERTIES, CAT_QOS, CAT_REFCOUNTING,
    CAT_REGISTRY, CAT_RUST, CAT_SCHEDULING, CAT_SIGNAL, CAT_STATES,
};

#[cfg(target_os = "macos")]
mod macos;
#[cfg(target_os = "macos")]
pub use crate::macos::*;

#[macro_use]
mod error;
pub use crate::error::*;

#[macro_use]
pub mod miniobject;
pub use miniobject::{MiniObject, MiniObjectRef};
pub mod message;
pub use crate::message::{Message, MessageErrorDomain, MessageRef, MessageView};

mod value;
pub use crate::value::{
    Array, ArrayRef, Bitmask, Fraction, FractionRange, IntRange, List, ListRef,
};
#[cfg(feature = "serde")]
#[macro_use]
mod value_serde;

#[cfg(feature = "serde")]
mod flag_serde;

pub mod structure;
pub use crate::structure::{Structure, StructureRef};
#[cfg(feature = "serde")]
mod structure_serde;

pub mod caps;
pub use crate::caps::{Caps, CapsFilterMapAction, CapsRef};
mod caps_features;
#[cfg(feature = "serde")]
mod caps_serde;
pub use crate::caps_features::{
    CapsFeatures, CapsFeaturesRef, CAPS_FEATURES_MEMORY_SYSTEM_MEMORY,
    CAPS_FEATURE_MEMORY_SYSTEM_MEMORY,
};
#[cfg(feature = "serde")]
mod caps_features_serde;

pub mod tags;
pub use crate::tags::{
    tag_exists, tag_get_description, tag_get_flag, tag_get_nick, tag_get_type, Tag, TagList,
    TagListRef,
};
#[cfg(feature = "serde")]
mod tags_serde;

pub mod meta;
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
pub use crate::meta::MetaSeqnum;
pub use crate::meta::{
    Meta, MetaAPI, MetaAPIExt, MetaRef, MetaRefMut, ParentBufferMeta, ProtectionMeta,
    ReferenceTimestampMeta,
};
pub mod buffer;
pub use crate::buffer::{
    Buffer, BufferMap, BufferRef, MappedBuffer, BUFFER_COPY_ALL, BUFFER_COPY_METADATA,
};
mod buffer_cursor;
pub use crate::buffer_cursor::{BufferCursor, BufferRefCursor};
pub mod memory;
mod memory_wrapped;
pub use crate::memory::{MappedMemory, Memory, MemoryMap, MemoryRef};
#[cfg(feature = "serde")]
mod buffer_serde;
pub mod slice;

pub mod sample;
pub use crate::sample::{Sample, SampleRef};
#[cfg(feature = "serde")]
mod sample_serde;

pub mod bufferlist;
pub use crate::bufferlist::{BufferList, BufferListRef};
#[cfg(feature = "serde")]
mod bufferlist_serde;

pub mod query;
pub use crate::query::{Query, QueryRef, QueryView, QueryViewMut};
pub mod event;
pub use crate::event::{Event, EventRef, EventView, GroupId, Seqnum};
pub mod context;
pub use crate::context::{Context, ContextRef};
mod rank;
pub use crate::rank::Rank;
mod static_caps;
pub use crate::static_caps::*;
mod static_pad_template;
pub use crate::static_pad_template::*;

pub mod promise;
pub use promise::{Promise, PromiseError};

pub mod bus;
mod element;
pub mod element_factory;

mod bin;
pub use bin::BinBuilder;

mod pipeline;
pub use pipeline::PipelineBuilder;

mod allocation_params;
pub use self::allocation_params::AllocationParams;
mod allocator;

mod element_factory_type;
pub use element_factory_type::*;

mod tracer;
mod tracer_factory;

// OS dependent Bus extensions (also import the other platform mod for doc)
#[cfg(any(unix, docsrs))]
mod bus_unix;
#[cfg(any(windows, docsrs))]
mod bus_windows;

mod child_proxy;
mod date_time;
#[cfg(feature = "serde")]
mod date_time_serde;
mod device_monitor;
mod device_provider;
mod device_provider_factory;
mod enums;
mod ghost_pad;
mod gobject;
mod iterator;
mod object;
mod pad;
pub use pad::{
    EventForeachAction, PadBuilder, PadGetRangeSuccess, PadProbeData, PadProbeId, PadProbeInfo,
    StreamLock,
};
mod control_binding;
mod control_source;
mod parse_context;
mod proxy_pad;
mod registry;
mod tag_setter;
pub mod task;
pub use task::{TaskLock, TaskLockGuard};
mod task_pool;
pub use self::iterator::{Iterator, IteratorError, IteratorImpl, StdIterator};
pub use crate::{
    device_monitor::DeviceMonitorFilterId,
    element::{
        ElementMessageType, NotifyWatchId, ELEMENT_METADATA_AUTHOR, ELEMENT_METADATA_DESCRIPTION,
        ELEMENT_METADATA_DOC_URI, ELEMENT_METADATA_ICON_NAME, ELEMENT_METADATA_KLASS,
        ELEMENT_METADATA_LONGNAME,
    },
    enums::{
        ClockError, ClockSuccess, FlowError, FlowReturn, FlowSuccess, MessageType, PadLinkError,
        PadLinkReturn, PadLinkSuccess, StateChangeError, StateChangeSuccess, TagError,
    },
    parse_context::ParseContext,
    task_pool::{TaskHandle, TaskPoolTaskHandle},
};
mod plugin_feature;

mod plugin;
pub mod stream;
pub mod stream_collection;

mod typefind;
pub use crate::typefind::*;
mod typefind_factory;

pub mod format;
pub use crate::format::{ClockTime, GenericFormattedValue, GenericSignedFormattedValue, Signed};

mod segment;
pub use crate::segment::*;
#[cfg(feature = "serde")]
mod segment_serde;

pub mod toc;
pub use crate::toc::{Toc, TocEntry, TocEntryRef, TocRef};
#[cfg(feature = "serde")]
mod toc_serde;

mod clock;
pub use crate::clock::{AtomicClockReturn, ClockId, PeriodicClockId, SingleShotClockId};

mod buffer_pool;
pub use crate::buffer_pool::{BufferPoolAcquireParams, BufferPoolConfig, BufferPoolConfigRef};

mod pad_template;
pub use pad_template::PadTemplateBuilder;

pub mod param_spec;
pub use crate::param_spec::{ParamSpecArray, ParamSpecFraction};

mod functions;
pub use crate::functions::*;

mod utils;
pub use crate::utils::ObjectLockGuard;

pub mod parse;

#[cfg(feature = "v1_18")]
mod gtype;

use std::ptr;

#[doc(alias = "gst_init_check")]
pub fn init() -> Result<(), glib::Error> {
    unsafe {
        use glib::translate::*;

        let mut error = ptr::null_mut();
        if from_glib(ffi::gst_init_check(
            ptr::null_mut(),
            ptr::null_mut(),
            &mut error,
        )) {
            crate::INITIALIZED.store(true, std::sync::atomic::Ordering::SeqCst);
            Ok(())
        } else {
            Err(from_glib_full(error))
        }
    }
}

// rustdoc-stripper-ignore-next
/// Deinitialize GStreamer
///
/// # Safety
///
/// This must only be called once during the lifetime of the process, once no GStreamer threads
/// are running anymore and all GStreamer resources are released.
pub unsafe fn deinit() {
    crate::INITIALIZED.store(false, std::sync::atomic::Ordering::SeqCst);
    ffi::gst_deinit();
}

pub const PARAM_FLAG_CONTROLLABLE: glib::ParamFlags = glib::ParamFlags::USER_1;
pub const PARAM_FLAG_MUTABLE_READY: glib::ParamFlags = glib::ParamFlags::USER_2;
pub const PARAM_FLAG_MUTABLE_PAUSED: glib::ParamFlags = glib::ParamFlags::USER_3;
pub const PARAM_FLAG_MUTABLE_PLAYING: glib::ParamFlags = glib::ParamFlags::USER_4;
#[cfg(feature = "v1_18")]
pub const PARAM_FLAG_DOC_SHOW_DEFAULT: glib::ParamFlags = glib::ParamFlags::USER_5;
#[cfg(feature = "v1_18")]
pub const PARAM_FLAG_CONDITIONALLY_AVAILABLE: glib::ParamFlags = glib::ParamFlags::USER_6;

// Re-export all the traits in a prelude module, so that applications
// can always "use gst::prelude::*" without getting conflicts
pub mod prelude {
    #[doc(hidden)]
    pub use glib::prelude::*;
    pub use muldiv::MulDiv;
    pub use opt_ops::prelude::*;

    // OS dependent Bus extensions (also import the other platform trait for doc)
    #[cfg(any(unix, docsrs))]
    pub use crate::bus_unix::UnixBusExtManual;
    #[cfg(any(windows, docsrs))]
    pub use crate::bus_windows::WindowsBusExtManual;
    #[cfg(feature = "v1_18")]
    pub use crate::gtype::PluginApiExt;
    pub use crate::{
        auto::traits::*,
        bin::GstBinExtManual,
        buffer_pool::BufferPoolExtManual,
        child_proxy::ChildProxyExtManual,
        clock::ClockExtManual,
        control_binding::ControlBindingExtManual,
        control_source::ControlSourceExtManual,
        device_monitor::DeviceMonitorExtManual,
        device_provider::{DeviceProviderClassExt, DeviceProviderExtManual},
        element::{ElementClassExt, ElementExtManual},
        format::prelude::*,
        gobject::GObjectExtManualGst,
        memory::MemoryType,
        message::MessageErrorDomain,
        meta::{MetaAPI, MetaAPIExt},
        miniobject::IsMiniObject,
        object::GstObjectExtManual,
        pad::PadExtManual,
        param_spec::GstParamSpecBuilderExt,
        pipeline::GstPipelineExtManual,
        plugin_feature::PluginFeatureExtManual,
        slice::Dump,
        tag_setter::TagSetterExtManual,
        tags::{CustomTag, Tag},
        task_pool::{TaskHandle, TaskPoolExtManual},
        typefind::TypeFindImpl,
        utils::Displayable,
        value::GstValueExt,
    };
}

#[macro_use]
pub mod subclass;