utils: Update to 2018 edition

This commit is contained in:
Sebastian Dröge 2020-11-22 18:59:46 +02:00
parent 7dcd51e2f1
commit 767ed3afae
24 changed files with 184 additions and 236 deletions

View file

@ -10,11 +10,8 @@ description = "Fallback Switcher Plugin"
[dependencies]
libc = { version = "0.2", optional = true }
glib = { git = "https://github.com/gtk-rs/gtk-rs" }
glib-sys = { git = "https://github.com/gtk-rs/gtk-rs", optional = true }
gobject-sys = { git = "https://github.com/gtk-rs/gtk-rs", optional = true }
gst = { package = "gstreamer", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", features = ["v1_14"] }
gst-base = { package = "gstreamer-base", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", features = ["v1_16"] }
gst-sys = { package = "gstreamer-sys", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", optional = true }
gst-audio = { package = "gstreamer-audio", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", features = ["v1_14"] }
gst-video = { package = "gstreamer-video", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs", features = ["v1_14"] }
gtk = { git = "https://github.com/gtk-rs/gtk-rs", optional = true }
@ -41,5 +38,5 @@ cc = "1.0"
pkg-config = "0.3"
[features]
default = ["glib-sys", "gobject-sys", "gst-sys", "libc"]
default = ["libc"]
v1_18 = ["gst-base/v1_18"]

View file

@ -6,7 +6,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use super::gst_base_sys;
use super::ffi;
use super::Aggregator;
use glib::prelude::*;
use glib::signal::{connect_raw, SignalHandlerId};
@ -36,7 +36,7 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
unsafe {
let mut allocator = ptr::null_mut();
let mut params = mem::zeroed();
gst_base_sys::gst_aggregator_get_allocator(
ffi::gst_aggregator_get_allocator(
self.as_ref().to_glib_none().0,
&mut allocator,
&mut params,
@ -47,7 +47,7 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
fn finish_buffer(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn = unsafe {
from_glib(gst_base_sys::gst_aggregator_finish_buffer(
from_glib(ffi::gst_aggregator_finish_buffer(
self.as_ref().to_glib_none().0,
buffer.into_ptr(),
))
@ -58,8 +58,8 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
fn get_property_min_upstream_latency(&self) -> gst::ClockTime {
unsafe {
let mut value = Value::from_type(<gst::ClockTime as StaticType>::static_type());
gobject_sys::g_object_get_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
glib::gobject_ffi::g_object_get_property(
self.to_glib_none().0 as *mut glib::gobject_ffi::GObject,
b"min-upstream-latency\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
@ -72,8 +72,8 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
fn set_property_min_upstream_latency(&self, min_upstream_latency: gst::ClockTime) {
unsafe {
gobject_sys::g_object_set_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
glib::gobject_ffi::g_object_set_property(
self.to_glib_none().0 as *mut glib::gobject_ffi::GObject,
b"min-upstream-latency\0".as_ptr() as *const _,
Value::from(&min_upstream_latency).to_glib_none().0,
);
@ -99,9 +99,9 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
}
unsafe extern "C" fn notify_min_upstream_latency_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
this: *mut gst_base_sys::GstAggregator,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
this: *mut ffi::GstAggregator,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) where
P: IsA<Aggregator>,
{

View file

@ -6,7 +6,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use super::gst_base_sys;
use super::ffi;
use super::AggregatorPad;
use glib::object::IsA;
use glib::translate::*;
@ -18,9 +18,9 @@ pub trait AggregatorPadExtManual: 'static {
impl<O: IsA<AggregatorPad>> AggregatorPadExtManual for O {
fn get_segment(&self) -> gst::Segment {
unsafe {
let ptr: &gst_base_sys::GstAggregatorPad = &*(self.as_ptr() as *const _);
let ptr: &ffi::GstAggregatorPad = &*(self.as_ptr() as *const _);
let _guard = super::utils::MutexGuard::lock(&ptr.parent.object.lock);
from_glib_none(&ptr.segment as *const gst_sys::GstSegment)
from_glib_none(&ptr.segment as *const gst::ffi::GstSegment)
}
}
}

View file

@ -2,7 +2,7 @@
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use super::super::gst_base_sys;
use super::super::ffi;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
@ -13,11 +13,11 @@ use glib::Value;
use std::boxed::Box as Box_;
use std::mem::transmute;
glib_wrapper! {
pub struct Aggregator(Object<gst_base_sys::GstAggregator, gst_base_sys::GstAggregatorClass>) @extends gst::Element, gst::Object;
glib::glib_wrapper! {
pub struct Aggregator(Object<ffi::GstAggregator, ffi::GstAggregatorClass>) @extends gst::Element, gst::Object;
match fn {
get_type => || gst_base_sys::gst_aggregator_get_type(),
get_type => || ffi::gst_aggregator_get_type(),
}
}
@ -58,12 +58,12 @@ pub trait AggregatorExt: 'static {
impl<O: IsA<Aggregator>> AggregatorExt for O {
//fn get_allocator(&self, allocator: /*Ignored*/gst::Allocator, params: /*Ignored*/gst::AllocationParams) {
// unsafe { TODO: call gst_base_sys:gst_aggregator_get_allocator() }
// unsafe { TODO: call ffi:gst_aggregator_get_allocator() }
//}
fn get_buffer_pool(&self) -> Option<gst::BufferPool> {
unsafe {
from_glib_full(gst_base_sys::gst_aggregator_get_buffer_pool(
from_glib_full(ffi::gst_aggregator_get_buffer_pool(
self.as_ref().to_glib_none().0,
))
}
@ -71,7 +71,7 @@ impl<O: IsA<Aggregator>> AggregatorExt for O {
fn get_latency(&self) -> gst::ClockTime {
unsafe {
from_glib(gst_base_sys::gst_aggregator_get_latency(
from_glib(ffi::gst_aggregator_get_latency(
self.as_ref().to_glib_none().0,
))
}
@ -79,7 +79,7 @@ impl<O: IsA<Aggregator>> AggregatorExt for O {
fn set_latency(&self, min_latency: gst::ClockTime, max_latency: gst::ClockTime) {
unsafe {
gst_base_sys::gst_aggregator_set_latency(
ffi::gst_aggregator_set_latency(
self.as_ref().to_glib_none().0,
min_latency.to_glib(),
max_latency.to_glib(),
@ -89,16 +89,13 @@ impl<O: IsA<Aggregator>> AggregatorExt for O {
fn set_src_caps(&self, caps: &gst::Caps) {
unsafe {
gst_base_sys::gst_aggregator_set_src_caps(
self.as_ref().to_glib_none().0,
caps.to_glib_none().0,
);
ffi::gst_aggregator_set_src_caps(self.as_ref().to_glib_none().0, caps.to_glib_none().0);
}
}
fn simple_get_next_time(&self) -> gst::ClockTime {
unsafe {
from_glib(gst_base_sys::gst_aggregator_simple_get_next_time(
from_glib(ffi::gst_aggregator_simple_get_next_time(
self.as_ref().to_glib_none().0,
))
}
@ -107,8 +104,8 @@ impl<O: IsA<Aggregator>> AggregatorExt for O {
fn get_property_start_time(&self) -> u64 {
unsafe {
let mut value = Value::from_type(<u64 as StaticType>::static_type());
gobject_sys::g_object_get_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
glib::gobject_ffi::g_object_get_property(
self.to_glib_none().0 as *mut glib::gobject_ffi::GObject,
b"start-time\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
@ -121,8 +118,8 @@ impl<O: IsA<Aggregator>> AggregatorExt for O {
fn set_property_start_time(&self, start_time: u64) {
unsafe {
gobject_sys::g_object_set_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
glib::gobject_ffi::g_object_set_property(
self.to_glib_none().0 as *mut glib::gobject_ffi::GObject,
b"start-time\0".as_ptr() as *const _,
Value::from(&start_time).to_glib_none().0,
);
@ -134,9 +131,9 @@ impl<O: IsA<Aggregator>> AggregatorExt for O {
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_latency_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
this: *mut gst_base_sys::GstAggregator,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
this: *mut ffi::GstAggregator,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) where
P: IsA<Aggregator>,
{
@ -159,9 +156,9 @@ impl<O: IsA<Aggregator>> AggregatorExt for O {
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_start_time_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
this: *mut gst_base_sys::GstAggregator,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
this: *mut ffi::GstAggregator,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) where
P: IsA<Aggregator>,
{
@ -181,7 +178,7 @@ impl<O: IsA<Aggregator>> AggregatorExt for O {
fn negotiate(&self) -> bool {
unsafe {
from_glib(gst_base_sys::gst_aggregator_negotiate(
from_glib(ffi::gst_aggregator_negotiate(
self.as_ref().to_glib_none().0,
))
}

View file

@ -2,7 +2,7 @@
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use super::super::gst_base_sys;
use super::super::ffi;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
@ -13,11 +13,11 @@ use glib::Value;
use std::boxed::Box as Box_;
use std::mem::transmute;
glib_wrapper! {
pub struct AggregatorPad(Object<gst_base_sys::GstAggregatorPad, gst_base_sys::GstAggregatorPadClass>) @extends gst::Pad, gst::Object;
glib::glib_wrapper! {
pub struct AggregatorPad(Object<ffi::GstAggregatorPad, ffi::GstAggregatorPadClass>) @extends gst::Pad, gst::Object;
match fn {
get_type => || gst_base_sys::gst_aggregator_pad_get_type(),
get_type => || ffi::gst_aggregator_pad_get_type(),
}
}
@ -55,7 +55,7 @@ pub trait AggregatorPadExt: 'static {
impl<O: IsA<AggregatorPad>> AggregatorPadExt for O {
fn drop_buffer(&self) -> bool {
unsafe {
from_glib(gst_base_sys::gst_aggregator_pad_drop_buffer(
from_glib(ffi::gst_aggregator_pad_drop_buffer(
self.as_ref().to_glib_none().0,
))
}
@ -63,7 +63,7 @@ impl<O: IsA<AggregatorPad>> AggregatorPadExt for O {
fn has_buffer(&self) -> bool {
unsafe {
from_glib(gst_base_sys::gst_aggregator_pad_has_buffer(
from_glib(ffi::gst_aggregator_pad_has_buffer(
self.as_ref().to_glib_none().0,
))
}
@ -71,7 +71,7 @@ impl<O: IsA<AggregatorPad>> AggregatorPadExt for O {
fn is_eos(&self) -> bool {
unsafe {
from_glib(gst_base_sys::gst_aggregator_pad_is_eos(
from_glib(ffi::gst_aggregator_pad_is_eos(
self.as_ref().to_glib_none().0,
))
}
@ -79,7 +79,7 @@ impl<O: IsA<AggregatorPad>> AggregatorPadExt for O {
fn peek_buffer(&self) -> Option<gst::Buffer> {
unsafe {
from_glib_full(gst_base_sys::gst_aggregator_pad_peek_buffer(
from_glib_full(ffi::gst_aggregator_pad_peek_buffer(
self.as_ref().to_glib_none().0,
))
}
@ -87,7 +87,7 @@ impl<O: IsA<AggregatorPad>> AggregatorPadExt for O {
fn pop_buffer(&self) -> Option<gst::Buffer> {
unsafe {
from_glib_full(gst_base_sys::gst_aggregator_pad_pop_buffer(
from_glib_full(ffi::gst_aggregator_pad_pop_buffer(
self.as_ref().to_glib_none().0,
))
}
@ -96,8 +96,8 @@ impl<O: IsA<AggregatorPad>> AggregatorPadExt for O {
fn get_property_emit_signals(&self) -> bool {
unsafe {
let mut value = Value::from_type(<bool as StaticType>::static_type());
gobject_sys::g_object_get_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
glib::gobject_ffi::g_object_get_property(
self.to_glib_none().0 as *mut glib::gobject_ffi::GObject,
b"emit-signals\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
@ -110,8 +110,8 @@ impl<O: IsA<AggregatorPad>> AggregatorPadExt for O {
fn set_property_emit_signals(&self, emit_signals: bool) {
unsafe {
gobject_sys::g_object_set_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
glib::gobject_ffi::g_object_set_property(
self.to_glib_none().0 as *mut glib::gobject_ffi::GObject,
b"emit-signals\0".as_ptr() as *const _,
Value::from(&emit_signals).to_glib_none().0,
);
@ -126,9 +126,9 @@ impl<O: IsA<AggregatorPad>> AggregatorPadExt for O {
P,
F: Fn(&P, &gst::Buffer) + Send + Sync + 'static,
>(
this: *mut gst_base_sys::GstAggregatorPad,
object: *mut gst_sys::GstBuffer,
f: glib_sys::gpointer,
this: *mut ffi::GstAggregatorPad,
object: *mut gst::ffi::GstBuffer,
f: glib::ffi::gpointer,
) where
P: IsA<AggregatorPad>,
{
@ -154,9 +154,9 @@ impl<O: IsA<AggregatorPad>> AggregatorPadExt for O {
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_emit_signals_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
this: *mut gst_base_sys::GstAggregatorPad,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
this: *mut ffi::GstAggregatorPad,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) where
P: IsA<AggregatorPad>,
{

View file

@ -5,7 +5,7 @@
clippy::unreadable_literal
)]
use gst_sys as gst;
use gst::ffi as gst;
#[allow(unused_imports)]
use libc::{
@ -14,7 +14,7 @@ use libc::{
};
#[allow(unused_imports)]
use glib_sys::{gboolean, gconstpointer, gpointer, GType};
use glib::ffi::{gboolean, gconstpointer, gpointer, GType};
#[repr(C)]
#[derive(Copy, Clone)]

View file

@ -21,7 +21,6 @@ pub mod prelude {
pub mod subclass;
mod sys;
use sys as gst_base_sys;
mod ffi;
pub const AGGREGATOR_FLOW_NEED_DATA: gst::FlowError = gst::FlowError::CustomError;

View file

@ -6,13 +6,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use super::super::gst_base_sys;
use super::super::ffi;
use glib::prelude::*;
use glib::subclass::prelude::*;
use glib::translate::*;
use gst::subclass::prelude::*;
use gst::{gst_error_msg, gst_panic_to_error, gst_result_from_gboolean};
use std::ptr;
@ -245,8 +246,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
fn parent_flush(&self, aggregator: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
(*parent_class)
.flush
.map(|f| {
@ -268,8 +268,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
) -> Option<gst::Buffer> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
match (*parent_class).clip {
None => Some(buffer),
Some(ref func) => from_glib_full(func(
@ -288,8 +287,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
let f = (*parent_class)
.finish_buffer
.expect("Missing parent function `finish_buffer`");
@ -309,8 +307,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
) -> bool {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
let f = (*parent_class)
.sink_event
.expect("Missing parent function `sink_event`");
@ -330,8 +327,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
let f = (*parent_class)
.sink_event_pre_queue
.expect("Missing parent function `sink_event_pre_queue`");
@ -352,8 +348,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
) -> bool {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
let f = (*parent_class)
.sink_query
.expect("Missing parent function `sink_query`");
@ -373,8 +368,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
) -> bool {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
let f = (*parent_class)
.sink_query_pre_queue
.expect("Missing parent function `sink_query`");
@ -389,8 +383,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
fn parent_src_event(&self, aggregator: &Self::Type, event: gst::Event) -> bool {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
let f = (*parent_class)
.src_event
.expect("Missing parent function `src_event`");
@ -404,8 +397,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
fn parent_src_query(&self, aggregator: &Self::Type, query: &mut gst::QueryRef) -> bool {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
let f = (*parent_class)
.src_query
.expect("Missing parent function `src_query`");
@ -424,8 +416,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
) -> Result<(), gst::LoggableError> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
match (*parent_class).src_activate {
None => Ok(()),
Some(f) => gst_result_from_gboolean!(
@ -448,8 +439,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
let f = (*parent_class)
.aggregate
.expect("Missing parent function `aggregate`");
@ -464,8 +454,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
fn parent_start(&self, aggregator: &Self::Type) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
(*parent_class)
.start
.map(|f| {
@ -489,8 +478,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
fn parent_stop(&self, aggregator: &Self::Type) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
(*parent_class)
.stop
.map(|f| {
@ -514,8 +502,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
fn parent_get_next_time(&self, aggregator: &Self::Type) -> gst::ClockTime {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
(*parent_class)
.get_next_time
.map(|f| {
@ -537,8 +524,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
) -> Option<AggregatorPad> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
let f = (*parent_class)
.create_new_pad
.expect("Missing parent function `create_new_pad`");
@ -558,8 +544,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
) -> Result<gst::Caps, gst::FlowError> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
let f = (*parent_class)
.update_src_caps
.expect("Missing parent function `update_src_caps`");
@ -577,8 +562,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
fn parent_fixate_src_caps(&self, aggregator: &Self::Type, caps: gst::Caps) -> gst::Caps {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
let f = (*parent_class)
.fixate_src_caps
@ -597,8 +581,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
) -> Result<(), gst::LoggableError> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
(*parent_class)
.negotiated_src_caps
.map(|f| {
@ -618,8 +601,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
fn parent_negotiate(&self, aggregator: &Self::Type) -> bool {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
(*parent_class)
.negotiate
.map(|f| {
@ -665,8 +647,8 @@ where
}
unsafe extern "C" fn aggregator_flush<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
) -> gst_sys::GstFlowReturn
ptr: *mut ffi::GstAggregator,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -681,10 +663,10 @@ where
}
unsafe extern "C" fn aggregator_clip<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
aggregator_pad: *mut gst_base_sys::GstAggregatorPad,
buffer: *mut gst_sys::GstBuffer,
) -> *mut gst_sys::GstBuffer
ptr: *mut ffi::GstAggregator,
aggregator_pad: *mut ffi::GstAggregatorPad,
buffer: *mut gst::ffi::GstBuffer,
) -> *mut gst::ffi::GstBuffer
where
T::Instance: PanicPoison,
{
@ -704,9 +686,9 @@ where
}
unsafe extern "C" fn aggregator_finish_buffer<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
buffer: *mut gst_sys::GstBuffer,
) -> gst_sys::GstFlowReturn
ptr: *mut ffi::GstAggregator,
buffer: *mut gst::ffi::GstBuffer,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -722,10 +704,10 @@ where
}
unsafe extern "C" fn aggregator_sink_event<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
aggregator_pad: *mut gst_base_sys::GstAggregatorPad,
event: *mut gst_sys::GstEvent,
) -> glib_sys::gboolean
ptr: *mut ffi::GstAggregator,
aggregator_pad: *mut ffi::GstAggregatorPad,
event: *mut gst::ffi::GstEvent,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -744,10 +726,10 @@ where
}
unsafe extern "C" fn aggregator_sink_event_pre_queue<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
aggregator_pad: *mut gst_base_sys::GstAggregatorPad,
event: *mut gst_sys::GstEvent,
) -> gst_sys::GstFlowReturn
ptr: *mut ffi::GstAggregator,
aggregator_pad: *mut ffi::GstAggregatorPad,
event: *mut gst::ffi::GstEvent,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -767,10 +749,10 @@ where
}
unsafe extern "C" fn aggregator_sink_query<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
aggregator_pad: *mut gst_base_sys::GstAggregatorPad,
query: *mut gst_sys::GstQuery,
) -> glib_sys::gboolean
ptr: *mut ffi::GstAggregator,
aggregator_pad: *mut ffi::GstAggregatorPad,
query: *mut gst::ffi::GstQuery,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -789,10 +771,10 @@ where
}
unsafe extern "C" fn aggregator_sink_query_pre_queue<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
aggregator_pad: *mut gst_base_sys::GstAggregatorPad,
query: *mut gst_sys::GstQuery,
) -> glib_sys::gboolean
ptr: *mut ffi::GstAggregator,
aggregator_pad: *mut ffi::GstAggregatorPad,
query: *mut gst::ffi::GstQuery,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -811,9 +793,9 @@ where
}
unsafe extern "C" fn aggregator_src_event<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
event: *mut gst_sys::GstEvent,
) -> glib_sys::gboolean
ptr: *mut ffi::GstAggregator,
event: *mut gst::ffi::GstEvent,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -828,9 +810,9 @@ where
}
unsafe extern "C" fn aggregator_src_query<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
query: *mut gst_sys::GstQuery,
) -> glib_sys::gboolean
ptr: *mut ffi::GstAggregator,
query: *mut gst::ffi::GstQuery,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -845,10 +827,10 @@ where
}
unsafe extern "C" fn aggregator_src_activate<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
mode: gst_sys::GstPadMode,
active: glib_sys::gboolean,
) -> glib_sys::gboolean
ptr: *mut ffi::GstAggregator,
mode: gst::ffi::GstPadMode,
active: glib::ffi::gboolean,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -869,9 +851,9 @@ where
}
unsafe extern "C" fn aggregator_aggregate<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
timeout: glib_sys::gboolean,
) -> gst_sys::GstFlowReturn
ptr: *mut ffi::GstAggregator,
timeout: glib::ffi::gboolean,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -887,8 +869,8 @@ where
}
unsafe extern "C" fn aggregator_start<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
) -> glib_sys::gboolean
ptr: *mut ffi::GstAggregator,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -909,8 +891,8 @@ where
}
unsafe extern "C" fn aggregator_stop<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
) -> glib_sys::gboolean
ptr: *mut ffi::GstAggregator,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -931,8 +913,8 @@ where
}
unsafe extern "C" fn aggregator_get_next_time<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
) -> gst_sys::GstClockTime
ptr: *mut ffi::GstAggregator,
) -> gst::ffi::GstClockTime
where
T::Instance: PanicPoison,
{
@ -947,11 +929,11 @@ where
}
unsafe extern "C" fn aggregator_create_new_pad<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
templ: *mut gst_sys::GstPadTemplate,
ptr: *mut ffi::GstAggregator,
templ: *mut gst::ffi::GstPadTemplate,
req_name: *const libc::c_char,
caps: *const gst_sys::GstCaps,
) -> *mut gst_base_sys::GstAggregatorPad
caps: *const gst::ffi::GstCaps,
) -> *mut ffi::GstAggregatorPad
where
T::Instance: PanicPoison,
{
@ -975,10 +957,10 @@ where
}
unsafe extern "C" fn aggregator_update_src_caps<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
caps: *mut gst_sys::GstCaps,
res: *mut *mut gst_sys::GstCaps,
) -> gst_sys::GstFlowReturn
ptr: *mut ffi::GstAggregator,
caps: *mut gst::ffi::GstCaps,
res: *mut *mut gst::ffi::GstCaps,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -1001,9 +983,9 @@ where
}
unsafe extern "C" fn aggregator_fixate_src_caps<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
caps: *mut gst_sys::GstCaps,
) -> *mut gst_sys::GstCaps
ptr: *mut ffi::GstAggregator,
caps: *mut gst::ffi::GstCaps,
) -> *mut gst::ffi::GstCaps
where
T::Instance: PanicPoison,
{
@ -1018,9 +1000,9 @@ where
}
unsafe extern "C" fn aggregator_negotiated_src_caps<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
caps: *mut gst_sys::GstCaps,
) -> glib_sys::gboolean
ptr: *mut ffi::GstAggregator,
caps: *mut gst::ffi::GstCaps,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -1041,8 +1023,8 @@ where
}
unsafe extern "C" fn aggregator_negotiate<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
) -> glib_sys::gboolean
ptr: *mut ffi::GstAggregator,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{

View file

@ -6,7 +6,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use super::super::gst_base_sys;
use super::super::ffi;
use glib::prelude::*;
use glib::subclass::prelude::*;
@ -59,8 +59,7 @@ impl<T: AggregatorPadImpl> AggregatorPadImplExt for T {
) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorPadClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorPadClass;
(*parent_class)
.flush
.map(|f| {
@ -85,8 +84,7 @@ impl<T: AggregatorPadImpl> AggregatorPadImplExt for T {
) -> bool {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstAggregatorPadClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorPadClass;
(*parent_class)
.skip_buffer
.map(|f| {
@ -113,9 +111,9 @@ unsafe impl<T: AggregatorPadImpl> IsSubclassable<T> for AggregatorPad {
}
unsafe extern "C" fn aggregator_pad_flush<T: AggregatorPadImpl>(
ptr: *mut gst_base_sys::GstAggregatorPad,
aggregator: *mut gst_base_sys::GstAggregator,
) -> gst_sys::GstFlowReturn {
ptr: *mut ffi::GstAggregatorPad,
aggregator: *mut ffi::GstAggregator,
) -> gst::ffi::GstFlowReturn {
let instance = &*(ptr as *mut T::Instance);
let imp = instance.get_impl();
let wrap: Borrowed<AggregatorPad> = from_glib_borrow(ptr);
@ -127,10 +125,10 @@ unsafe extern "C" fn aggregator_pad_flush<T: AggregatorPadImpl>(
}
unsafe extern "C" fn aggregator_pad_skip_buffer<T: AggregatorPadImpl>(
ptr: *mut gst_base_sys::GstAggregatorPad,
aggregator: *mut gst_base_sys::GstAggregator,
buffer: *mut gst_sys::GstBuffer,
) -> glib_sys::gboolean {
ptr: *mut ffi::GstAggregatorPad,
aggregator: *mut ffi::GstAggregator,
buffer: *mut gst::ffi::GstBuffer,
) -> glib::ffi::gboolean {
let instance = &*(ptr as *mut T::Instance);
let imp = instance.get_impl();
let wrap: Borrowed<AggregatorPad> = from_glib_borrow(ptr);

View file

@ -9,13 +9,13 @@
use glib::translate::mut_override;
#[must_use = "if unused the Mutex will immediately unlock"]
pub struct MutexGuard<'a>(&'a glib_sys::GMutex);
pub struct MutexGuard<'a>(&'a glib::ffi::GMutex);
impl<'a> MutexGuard<'a> {
#[allow(clippy::trivially_copy_pass_by_ref)]
pub fn lock(mutex: &'a glib_sys::GMutex) -> Self {
pub fn lock(mutex: &'a glib::ffi::GMutex) -> Self {
unsafe {
glib_sys::g_mutex_lock(mut_override(mutex));
glib::ffi::g_mutex_lock(mut_override(mutex));
}
MutexGuard(mutex)
}
@ -24,7 +24,7 @@ impl<'a> MutexGuard<'a> {
impl<'a> Drop for MutexGuard<'a> {
fn drop(&mut self) {
unsafe {
glib_sys::g_mutex_unlock(mut_override(self.0));
glib::ffi::g_mutex_unlock(mut_override(self.0));
}
}
}

View file

@ -20,6 +20,7 @@ use glib::subclass;
use glib::subclass::prelude::*;
use gst::prelude::*;
use gst::subclass::prelude::*;
use gst::{gst_debug, gst_element_error, gst_error, gst_error_msg};
use std::{mem, sync::Mutex};
@ -69,7 +70,7 @@ impl ObjectSubclass for CustomSource {
type Instance = gst::subclass::ElementInstanceStruct<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib_object_subclass!();
glib::glib_object_subclass!();
fn new() -> Self {
Self {

View file

@ -19,7 +19,7 @@ use glib::prelude::*;
mod imp;
glib_wrapper! {
glib::glib_wrapper! {
pub struct CustomSource(ObjectSubclass<imp::CustomSource>) @extends gst::Bin, gst::Element, gst::Object;
}

View file

@ -20,6 +20,10 @@ use glib::subclass;
use glib::subclass::prelude::*;
use gst::prelude::*;
use gst::subclass::prelude::*;
use gst::{
gst_debug, gst_element_error, gst_element_warning, gst_error, gst_error_msg, gst_info,
gst_warning,
};
use std::mem;
use std::sync::Mutex;
@ -309,7 +313,7 @@ impl ObjectSubclass for FallbackSrc {
type Instance = gst::subclass::ElementInstanceStruct<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib_object_subclass!();
glib::glib_object_subclass!();
fn new() -> Self {
Self {

View file

@ -20,7 +20,7 @@ use glib::prelude::*;
mod custom_source;
mod imp;
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, GEnum)]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::GEnum)]
#[repr(u32)]
#[genum(type_name = "GstFallbackSourceRetryReason")]
enum RetryReason {
@ -31,7 +31,7 @@ enum RetryReason {
Timeout,
}
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, GEnum)]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy, glib::GEnum)]
#[repr(u32)]
#[genum(type_name = "GstFallbackSourceStatus")]
enum Status {
@ -41,7 +41,7 @@ enum Status {
Running,
}
glib_wrapper! {
glib::glib_wrapper! {
pub struct FallbackSrc(ObjectSubclass<imp::FallbackSrc>) @extends gst::Bin, gst::Element, gst::Object;
}

View file

@ -30,6 +30,7 @@ use gst_base::subclass::prelude::*;
use glib::subclass;
use glib::subclass::prelude::*;
use gst::subclass::prelude::*;
use gst::{gst_debug, gst_error, gst_info, gst_log};
use once_cell::sync::Lazy;
@ -412,7 +413,7 @@ impl ObjectSubclass for FallbackSwitch {
type Instance = gst::subclass::ElementInstanceStruct<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib_object_subclass!();
glib::glib_object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -22,7 +22,7 @@ use crate::gst_base_compat as gst_base;
mod imp;
glib_wrapper! {
glib::glib_wrapper! {
pub struct FallbackSwitch(ObjectSubclass<imp::FallbackSwitch>) @extends gst_base::Aggregator, gst::Element, gst::Object;
}

View file

@ -15,11 +15,6 @@
// Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
// Boston, MA 02110-1335, USA.
#[macro_use]
extern crate glib;
#[macro_use]
extern crate gst;
#[cfg(not(feature = "v1_18"))]
#[path = "base/mod.rs"]
pub mod gst_base_compat;
@ -33,7 +28,7 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
Ok(())
}
gst_plugin_define!(
gst::gst_plugin_define!(
fallbackswitch,
env!("CARGO_PKG_DESCRIPTION"),
plugin_init,

View file

@ -16,9 +16,7 @@
// Boston, MA 02110-1335, USA.
use glib::prelude::*;
#[macro_use]
extern crate gst;
use gst::gst_debug;
use gst::prelude::*;
use once_cell::sync::Lazy;

View file

@ -9,14 +9,14 @@ edition = "2018"
[dependencies]
glib = { git = "https://github.com/gtk-rs/gtk-rs" }
gstreamer = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
gstreamer-audio = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
gstreamer-video = { git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
gst = { package = "gstreamer", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
gst-audio = { package = "gstreamer-audio", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
gst-video = { package = "gstreamer-video", git = "https://gitlab.freedesktop.org/gstreamer/gstreamer-rs" }
gtk = { git = "https://github.com/gtk-rs/gtk-rs", optional = true }
gio = { git = "https://github.com/gtk-rs/gtk-rs", optional = true }
parking_lot = "0.11"
more-asserts = "0.2"
lazy_static = "1.0"
once_cell = "1.0"
[dev-dependencies]
either = "1.0"

View file

@ -15,17 +15,9 @@
// Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
// Boston, MA 02110-1335, USA.
extern crate glib;
use glib::prelude::*;
extern crate gio;
use gio::prelude::*;
extern crate gstreamer as gst;
use gst::prelude::*;
extern crate gsttogglerecord;
extern crate gtk;
use gio::prelude::*;
use gtk::prelude::*;
use std::cell::RefCell;
use std::env;

View file

@ -15,28 +15,13 @@
// Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
// Boston, MA 02110-1335, USA.
#[macro_use]
extern crate glib;
#[macro_use]
extern crate gstreamer as gst;
extern crate gstreamer_audio as gst_audio;
extern crate gstreamer_video as gst_video;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate more_asserts;
extern crate parking_lot;
mod togglerecord;
fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
togglerecord::register(plugin)
}
gst_plugin_define!(
gst::gst_plugin_define!(
togglerecord,
env!("CARGO_PKG_DESCRIPTION"),
plugin_init,

View file

@ -20,7 +20,11 @@ use glib::subclass;
use glib::subclass::prelude::*;
use gst::prelude::*;
use gst::subclass::prelude::*;
use gst::{gst_debug, gst_element_error, gst_log, gst_trace, gst_warning};
use more_asserts::{assert_ge, assert_le, assert_lt};
use once_cell::sync::Lazy;
use parking_lot::{Condvar, Mutex};
use std::cmp;
use std::collections::HashMap;
@ -356,13 +360,13 @@ pub struct ToggleRecord {
pads: Mutex<HashMap<gst::Pad, Stream>>,
}
lazy_static! {
static ref CAT: gst::DebugCategory = gst::DebugCategory::new(
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
gst::DebugCategory::new(
"togglerecord",
gst::DebugColorFlags::empty(),
Some("Toggle Record Element"),
);
}
)
});
impl ToggleRecord {
fn handle_main_stream<T: HandleData>(
@ -1555,7 +1559,7 @@ impl ObjectSubclass for ToggleRecord {
type Instance = gst::subclass::ElementInstanceStruct<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib_object_subclass!();
glib::glib_object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -19,7 +19,7 @@ use glib::prelude::*;
mod imp;
glib_wrapper! {
glib::glib_wrapper! {
pub struct ToggleRecord(ObjectSubclass<imp::ToggleRecord>) @extends gst::Element, gst::Object;
}

View file

@ -15,20 +15,15 @@
// Free Software Foundation, Inc., 51 Franklin Street, Suite 500,
// Boston, MA 02110-1335, USA.
extern crate glib;
use glib::prelude::*;
extern crate gstreamer as gst;
use gst::prelude::*;
extern crate either;
use either::*;
use std::sync::{mpsc, Mutex};
use std::thread;
extern crate gsttogglerecord;
fn init() {
use std::sync::Once;
static INIT: Once = Once::new();