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