gstreamer-rs/gstreamer/src/lib.rs

285 lines
7.6 KiB
Rust
Raw Normal View History

2017-07-07 11:47:28 +00:00
// Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![recursion_limit = "256"]
#[macro_use]
extern crate bitflags;
#[cfg(any(feature = "v1_14", feature = "dox"))]
#[macro_use]
extern crate cfg_if;
2017-07-30 22:11:57 +00:00
#[macro_use]
extern crate lazy_static;
extern crate libc;
extern crate glib_sys as glib_ffi;
extern crate gobject_sys as gobject_ffi;
extern crate gstreamer_sys as ffi;
#[macro_use]
extern crate glib;
2017-07-12 10:25:11 +00:00
extern crate num_rational;
#[cfg(any(feature = "futures", feature = "dox"))]
2018-04-23 14:55:31 +00:00
extern crate futures_core;
extern crate muldiv;
2018-06-20 19:38:49 +00:00
#[cfg(feature = "ser_de")]
extern crate serde;
#[cfg(feature = "ser_de")]
2018-07-05 18:42:28 +00:00
extern crate serde_bytes;
#[cfg(feature = "ser_de")]
2018-06-20 19:38:49 +00:00
#[macro_use]
extern crate serde_derive;
use glib::translate::{from_glib, from_glib_full};
macro_rules! assert_initialized_main_thread {
2018-04-01 08:30:03 +00:00
() => {
if unsafe { ::ffi::gst_is_initialized() } != ::glib_ffi::GTRUE {
panic!("GStreamer has not been initialized. Call `gst::init` first.");
}
2018-04-01 08:30:03 +00:00
};
}
macro_rules! skip_assert_initialized {
2018-04-01 08:30:03 +00:00
() => {};
}
2017-07-10 21:33:24 +00:00
pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue, Value};
#[cfg_attr(feature = "cargo-clippy", allow(unreadable_literal))]
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
mod auto;
2017-08-17 12:31:00 +00:00
pub use auto::functions::*;
2018-04-01 08:30:03 +00:00
pub use auto::*;
#[macro_use]
mod log;
pub use log::*;
#[macro_use]
mod error;
pub use error::*;
pub mod miniobject;
pub use miniobject::{GstRc, MiniObject};
pub mod message;
pub use message::{Message, MessageErrorDomain, MessageRef, MessageView};
2018-06-21 18:44:51 +00:00
#[macro_use]
mod value;
pub use value::*;
2017-07-07 13:04:54 +00:00
pub mod structure;
2017-07-24 22:17:50 +00:00
pub use structure::{Structure, StructureRef};
2017-07-10 21:02:08 +00:00
pub mod caps;
2017-07-24 22:17:50 +00:00
pub use caps::{Caps, CapsRef};
2017-07-12 07:27:43 +00:00
pub mod tags;
pub use tags::{Tag, TagList, TagListRef};
2017-07-25 12:01:24 +00:00
pub mod buffer;
2018-07-27 10:36:40 +00:00
pub use buffer::{
Buffer, BufferMap, BufferRef, MappedBuffer, BUFFER_COPY_ALL, BUFFER_COPY_METADATA,
};
2017-07-28 17:04:15 +00:00
pub mod sample;
pub use sample::{Sample, SampleRef};
2017-07-28 17:20:11 +00:00
pub mod bufferlist;
pub use bufferlist::{BufferList, BufferListRef};
2017-07-29 11:58:54 +00:00
pub mod query;
pub use query::{Query, QueryRef, QueryView};
pub mod event;
pub use event::{Event, EventRef, EventView, GroupId, Seqnum, GROUP_ID_INVALID, SEQNUM_INVALID};
2017-08-02 17:34:37 +00:00
pub mod context;
pub use context::{Context, ContextRef};
mod static_caps;
pub use static_caps::*;
mod static_pad_template;
pub use static_pad_template::*;
2018-03-15 09:43:35 +00:00
#[cfg(any(feature = "v1_14", feature = "dox"))]
mod promise;
#[cfg(any(feature = "v1_14", feature = "dox"))]
pub use promise::*;
mod bin;
mod bus;
2018-04-01 08:30:03 +00:00
mod element;
// OS dependent Bus extensions (also import the other plateform mod for doc)
#[cfg(any(feature = "v1_14", feature = "dox"))]
cfg_if! {
if #[cfg(unix)] {
mod bus_unix;
#[cfg(feature = "dox")]
mod bus_windows;
} else {
mod bus_windows;
#[cfg(feature = "dox")]
mod bus_unix;
}
}
2017-07-29 14:10:10 +00:00
mod child_proxy;
mod clock_time;
mod date_time;
mod device_monitor;
2018-04-01 08:30:03 +00:00
mod device_provider;
mod enums;
mod ghost_pad;
mod gobject;
mod iterator;
mod object;
mod pad;
mod parse_context;
mod proxy_pad;
mod tag_setter;
pub use bin::BinExtManual;
2018-04-25 08:10:06 +00:00
pub use element::{ElementExtManual, ElementMessageType, NotifyWatchId};
2018-07-27 10:36:40 +00:00
pub use element::{
ELEMENT_METADATA_AUTHOR, ELEMENT_METADATA_DESCRIPTION, ELEMENT_METADATA_DOC_URI,
ELEMENT_METADATA_ICON_NAME, ELEMENT_METADATA_KLASS, ELEMENT_METADATA_LONGNAME,
};
2018-04-01 08:30:03 +00:00
pub use object::GstObjectExtManual;
// OS dependent Bus extensions (also import the other plateform trait for doc)
#[cfg(any(feature = "v1_14", feature = "dox"))]
cfg_if! {
if #[cfg(unix)] {
pub use bus_unix::UnixBusExtManual;
#[cfg(feature = "dox")]
pub use bus_windows::WindowsBusExtManual;
} else {
pub use bus_windows::WindowsBusExtManual;
#[cfg(feature = "dox")]
pub use bus_unix::UnixBusExtManual;
}
}
2017-09-17 15:51:45 +00:00
pub use self::iterator::{Iterator, IteratorError, IteratorImpl};
#[cfg(any(feature = "futures", feature = "dox"))]
pub use bus::BusStream;
2018-04-01 08:30:03 +00:00
pub use child_proxy::ChildProxyExtManual;
pub use clock_time::ClockTime;
pub use device_provider::DeviceProviderExtManual;
2018-07-27 10:36:40 +00:00
pub use enums::{
ClockError, ClockSuccess, FlowError, FlowSuccess, PadLinkError, PadLinkSuccess,
StateChangeError, StateChangeSuccess, TagError,
};
2018-04-01 08:30:03 +00:00
pub use gobject::GObjectExtManualGst;
pub use pad::{PadExtManual, PadProbeData, PadProbeId, PadProbeInfo};
pub use parse_context::ParseContext;
pub use tag_setter::TagSetterExtManual;
mod plugin;
2017-12-20 16:54:56 +00:00
#[cfg(any(feature = "v1_10", feature = "dox"))]
mod stream;
2018-07-27 10:36:40 +00:00
#[cfg(any(feature = "v1_10", feature = "dox"))]
pub mod stream_collection;
mod typefind;
pub use typefind::*;
pub mod format;
pub use format::{FormattedValue, GenericFormattedValue, SpecificFormattedValue};
mod segment;
pub use segment::*;
pub mod toc;
pub use toc::{Toc, TocEntry, TocEntryRef, TocRef};
mod clock;
pub use clock::{ClockExtManual, ClockId};
2018-03-07 09:07:30 +00:00
mod buffer_pool;
pub use buffer_pool::*;
2018-03-15 08:46:49 +00:00
mod pad_template;
pub mod functions;
pub use functions::*;
use std::ptr;
pub fn init() -> Result<(), glib::Error> {
unsafe {
let mut error = ptr::null_mut();
2017-07-10 21:33:24 +00:00
if from_glib(ffi::gst_init_check(
ptr::null_mut(),
ptr::null_mut(),
&mut error,
)) {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
pub const BUFFER_OFFSET_NONE: u64 = ffi::GST_BUFFER_OFFSET_NONE;
pub const CLOCK_TIME_NONE: ClockTime = ClockTime(None);
pub const SECOND: ClockTime = ClockTime(Some(1_000_000_000));
pub const MSECOND: ClockTime = ClockTime(Some(1_000_000));
pub const USECOND: ClockTime = ClockTime(Some(1_000));
pub const NSECOND: ClockTime = ClockTime(Some(1));
2017-11-11 12:00:50 +00:00
pub const SECOND_VAL: u64 = 1_000_000_000;
pub const MSECOND_VAL: u64 = 1_000_000;
pub const USECOND_VAL: u64 = 1_000;
pub const NSECOND_VAL: u64 = 1;
pub const FORMAT_PERCENT_MAX: u32 = ffi::GST_FORMAT_PERCENT_MAX as u32;
pub const FORMAT_PERCENT_SCALE: u32 = ffi::GST_FORMAT_PERCENT_SCALE as u32;
// Re-export all the traits in a prelude module, so that applications
// can always "use gst::prelude::*" without getting conflicts
pub mod prelude {
pub use glib::prelude::*;
pub use auto::traits::*;
pub use bin::BinExtManual;
2018-04-01 08:30:03 +00:00
pub use element::ElementExtManual;
// OS dependent Bus extensions (also import the other plateform trait for doc)
#[cfg(any(feature = "v1_14", feature = "dox"))]
cfg_if! {
if #[cfg(unix)] {
pub use bus_unix::UnixBusExtManual;
#[cfg(feature = "dox")]
pub use bus_windows::WindowsBusExtManual;
} else {
pub use bus_windows::WindowsBusExtManual;
#[cfg(feature = "dox")]
pub use bus_unix::UnixBusExtManual;
}
}
2018-04-01 08:30:03 +00:00
pub use buffer_pool::BufferPoolExtManual;
pub use child_proxy::ChildProxyExtManual;
pub use clock::ClockExtManual;
2018-04-01 08:30:03 +00:00
pub use device_provider::DeviceProviderExtManual;
pub use gobject::GObjectExtManualGst;
pub use object::GstObjectExtManual;
pub use pad::PadExtManual;
pub use tag_setter::TagSetterExtManual;
pub use value::GstValueExt;
pub use miniobject::MiniObject;
2018-04-01 08:30:03 +00:00
pub use tags::Tag;
pub use muldiv::MulDiv;
pub use format::{FormattedValue, SpecificFormattedValue};
}
mod utils;