2018-03-06 09:38:27 +00:00
|
|
|
// Copyright (C) 2018 Sebastian Dröge <sebastian@centricular.com>
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Library General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Library General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Library General Public
|
|
|
|
// License along with this library; if not, write to the
|
|
|
|
// Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
|
|
|
|
// Boston, MA 02110-1335, USA.
|
|
|
|
|
|
|
|
#![crate_type = "cdylib"]
|
|
|
|
|
2018-11-30 17:38:25 +00:00
|
|
|
extern crate libc;
|
|
|
|
|
2018-11-13 12:13:23 +00:00
|
|
|
extern crate gio_sys as gio_ffi;
|
2018-04-05 10:36:58 +00:00
|
|
|
extern crate glib_sys as glib_ffi;
|
2018-11-13 12:13:23 +00:00
|
|
|
extern crate gobject_sys as gobject_ffi;
|
2018-04-05 10:36:58 +00:00
|
|
|
extern crate gstreamer_sys as gst_ffi;
|
|
|
|
|
2018-11-13 12:13:23 +00:00
|
|
|
extern crate gio;
|
2018-11-29 19:01:02 +00:00
|
|
|
#[macro_use]
|
2018-03-06 09:38:27 +00:00
|
|
|
extern crate glib;
|
2018-05-01 15:47:36 +00:00
|
|
|
extern crate gobject_subclass;
|
2018-03-06 09:38:27 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate gst_plugin;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate gstreamer as gst;
|
|
|
|
|
2018-03-08 20:26:34 +00:00
|
|
|
extern crate futures;
|
|
|
|
extern crate tokio;
|
2018-07-24 10:40:58 +00:00
|
|
|
extern crate tokio_current_thread;
|
2018-03-12 10:24:37 +00:00
|
|
|
extern crate tokio_executor;
|
2018-03-08 20:26:34 +00:00
|
|
|
extern crate tokio_reactor;
|
2018-04-03 16:14:00 +00:00
|
|
|
extern crate tokio_timer;
|
2018-03-08 20:26:34 +00:00
|
|
|
|
2018-03-12 13:47:33 +00:00
|
|
|
extern crate either;
|
|
|
|
|
2018-03-16 17:11:53 +00:00
|
|
|
extern crate rand;
|
|
|
|
|
2018-03-08 20:26:34 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate lazy_static;
|
|
|
|
|
2018-05-23 07:32:06 +00:00
|
|
|
extern crate net2;
|
|
|
|
|
2018-11-30 17:38:25 +00:00
|
|
|
#[cfg(windows)]
|
|
|
|
extern crate winapi;
|
|
|
|
|
2018-03-15 18:52:38 +00:00
|
|
|
mod iocontext;
|
2018-03-19 14:47:56 +00:00
|
|
|
|
2018-07-06 07:26:23 +00:00
|
|
|
mod socket;
|
2018-07-06 07:32:24 +00:00
|
|
|
mod tcpclientsrc;
|
2018-03-06 09:38:27 +00:00
|
|
|
mod udpsrc;
|
|
|
|
|
2018-04-03 16:14:00 +00:00
|
|
|
mod appsrc;
|
2018-03-26 15:30:44 +00:00
|
|
|
mod dataqueue;
|
2018-03-27 17:06:25 +00:00
|
|
|
mod proxy;
|
2018-04-03 16:14:00 +00:00
|
|
|
mod queue;
|
2018-03-19 14:47:56 +00:00
|
|
|
|
2018-11-05 11:43:11 +00:00
|
|
|
fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
|
|
|
|
udpsrc::register(plugin)?;
|
|
|
|
tcpclientsrc::register(plugin)?;
|
|
|
|
queue::register(plugin)?;
|
|
|
|
proxy::register(plugin)?;
|
|
|
|
appsrc::register(plugin)?;
|
|
|
|
|
|
|
|
Ok(())
|
2018-03-06 09:38:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
plugin_define!(
|
|
|
|
b"threadshare\0",
|
|
|
|
b"Threadshare Plugin\0",
|
|
|
|
plugin_init,
|
|
|
|
b"0.1.0\0",
|
|
|
|
b"LGPL\0",
|
|
|
|
b"threadshare\0",
|
|
|
|
b"threadshare\0",
|
2018-11-26 10:52:09 +00:00
|
|
|
b"https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs\0",
|
2018-03-06 09:38:27 +00:00
|
|
|
b"2018-03-01\0"
|
|
|
|
);
|
2018-04-05 10:36:58 +00:00
|
|
|
|
|
|
|
pub fn set_element_flags<T: glib::IsA<gst::Object> + glib::IsA<gst::Element>>(
|
|
|
|
element: &T,
|
|
|
|
flags: gst::ElementFlags,
|
|
|
|
) {
|
|
|
|
unsafe {
|
|
|
|
use glib::translate::ToGlib;
|
|
|
|
use gst_ffi;
|
|
|
|
|
|
|
|
let ptr: *mut gst_ffi::GstObject = element.to_glib_none().0;
|
|
|
|
let _guard = MutexGuard::lock(&(*ptr).lock);
|
|
|
|
(*ptr).flags |= flags.to_glib();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct MutexGuard<'a>(&'a glib_ffi::GMutex);
|
|
|
|
|
|
|
|
impl<'a> MutexGuard<'a> {
|
|
|
|
pub fn lock(mutex: &'a glib_ffi::GMutex) -> Self {
|
|
|
|
use glib::translate::mut_override;
|
|
|
|
unsafe {
|
|
|
|
glib_ffi::g_mutex_lock(mut_override(mutex));
|
|
|
|
}
|
|
|
|
MutexGuard(mutex)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'a> Drop for MutexGuard<'a> {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
use glib::translate::mut_override;
|
|
|
|
unsafe {
|
|
|
|
glib_ffi::g_mutex_unlock(mut_override(self.0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|