lib.rs 3.16 KB
Newer Older
Sebastian Dröge's avatar
Sebastian Dröge committed
1 2 3 4 5 6 7 8
// 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.

9
#![recursion_limit = "256"]
Sebastian Dröge's avatar
Sebastian Dröge committed
10 11 12
#[macro_use]
extern crate bitflags;
extern crate libc;
13 14
#[macro_use]
extern crate lazy_static;
Sebastian Dröge's avatar
Sebastian Dröge committed
15 16 17 18 19 20 21 22

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;

Sebastian Dröge's avatar
Sebastian Dröge committed
23 24
extern crate num_rational;

25 26
use glib::translate::{from_glib, from_glib_full};

Sebastian Dröge's avatar
Sebastian Dröge committed
27 28 29 30 31 32
macro_rules! callback_guard {
    () => (
        let _guard = ::glib::CallbackGuard::new();
    )
}

33 34 35 36 37 38 39 40 41 42 43
macro_rules! assert_initialized_main_thread {
    () => (
        assert_eq!(unsafe {ffi::gst_is_initialized()}, ::glib_ffi::GTRUE)
    )
}

macro_rules! skip_assert_initialized {
    () => (
    )
}

44
pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue, Value};
Sebastian Dröge's avatar
Sebastian Dröge committed
45

46 47 48 49
#[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))]
Sebastian Dröge's avatar
Sebastian Dröge committed
50
mod auto;
51
pub use auto::*;
52
pub use auto::traits::*;
53
pub use auto::functions::{parse_bin_from_description, parse_launch};
Sebastian Dröge's avatar
Sebastian Dröge committed
54

55 56 57
pub mod miniobject;
pub use miniobject::GstRc;
pub mod message;
Sebastian Dröge's avatar
Sebastian Dröge committed
58
pub use message::{Message, MessageRef, MessageView};
59
pub mod structure;
Sebastian Dröge's avatar
Sebastian Dröge committed
60
pub use structure::{Structure, StructureRef};
Sebastian Dröge's avatar
Sebastian Dröge committed
61
pub mod caps;
Sebastian Dröge's avatar
Sebastian Dröge committed
62
pub use caps::{Caps, CapsRef};
Sebastian Dröge's avatar
Sebastian Dröge committed
63 64
pub mod tags;
pub use tags::*;
65
pub mod buffer;
66 67
pub use buffer::{Buffer, BufferRef, ReadBufferMap, ReadMappedBuffer, ReadWriteBufferMap,
                 ReadWriteMappedBuffer};
Sebastian Dröge's avatar
Sebastian Dröge committed
68 69
pub mod sample;
pub use sample::{Sample, SampleRef};
Sebastian Dröge's avatar
Sebastian Dröge committed
70 71
pub mod bufferlist;
pub use bufferlist::{BufferList, BufferListRef};
Sebastian Dröge's avatar
Sebastian Dröge committed
72 73
pub mod query;
pub use query::{Query, QueryRef, QueryView};
Sebastian Dröge's avatar
Sebastian Dröge committed
74 75
pub mod event;
pub use event::{Event, EventRef, EventView};
Sebastian Dröge's avatar
Sebastian Dröge committed
76 77
pub mod context;
pub use context::{Context, ContextRef};
78

79 80
mod element;
mod bin;
81
mod bus;
82
mod pad;
83
mod gobject;
Sebastian Dröge's avatar
Sebastian Dröge committed
84 85
mod proxy_pad;
mod ghost_pad;
Sebastian Dröge's avatar
Sebastian Dröge committed
86
mod child_proxy;
87 88
mod tag_setter;
mod iterator;
89
pub use element::ElementExtManual;
90
pub use bin::BinExtManual;
91
pub use pad::{PadExtManual, PadProbeData, PadProbeId, PadProbeInfo, PAD_PROBE_ID_INVALID};
92
pub use gobject::GObjectExtManualGst;
Sebastian Dröge's avatar
Sebastian Dröge committed
93
pub use child_proxy::ChildProxyExtManual;
94
pub use tag_setter::TagSetterExtManual;
Sebastian Dröge's avatar
Sebastian Dröge committed
95
pub use self::iterator::Iterator;
96

Sebastian Dröge's avatar
Sebastian Dröge committed
97 98 99
mod value;
pub use value::*;

100 101 102
mod segment;
pub use segment::*;

103 104 105
pub mod toc;
pub use toc::{Toc, TocEntry, TocEntryRef, TocRef};

Sebastian Dröge's avatar
Sebastian Dröge committed
106 107
use std::ptr;

108
pub fn init() -> Result<(), glib::Error> {
Sebastian Dröge's avatar
Sebastian Dröge committed
109
    unsafe {
110
        let mut error = ptr::null_mut();
111 112 113 114 115
        if from_glib(ffi::gst_init_check(
            ptr::null_mut(),
            ptr::null_mut(),
            &mut error,
        )) {
116 117 118 119
            Ok(())
        } else {
            Err(from_glib_full(error))
        }
Sebastian Dröge's avatar
Sebastian Dröge committed
120 121
    }
}
122 123 124

pub const BUFFER_OFFSET_NONE: u64 = ffi::GST_BUFFER_OFFSET_NONE;
pub const CLOCK_TIME_NONE: u64 = ffi::GST_CLOCK_TIME_NONE;