gstreamer-base: Update manual code to 2018 edition

This commit is contained in:
Sebastian Dröge 2020-11-21 19:59:22 +02:00
parent 80b4cb590e
commit 88a7c18746
20 changed files with 602 additions and 773 deletions

View file

@ -11,31 +11,29 @@ homepage = "https://gstreamer.freedesktop.org"
documentation = "https://gstreamer.pages.freedesktop.org/gstreamer-rs/gstreamer_base/"
keywords = ["gstreamer", "multimedia", "audio", "video", "gnome"]
build = "build.rs"
edition = "2018"
[dependencies]
libc = "0.2"
bitflags = "1.0"
glib-sys = { git = "https://github.com/gtk-rs/gtk-rs" }
gobject-sys = { git = "https://github.com/gtk-rs/gtk-rs" }
gstreamer-sys = { path = "../gstreamer/sys", features = ["v1_8"] }
gstreamer-base-sys = { path = "../gstreamer-base/sys", features = ["v1_8"] }
ffi = { package = "gstreamer-base-sys", path = "../gstreamer-base/sys", features = ["v1_8"] }
glib = { git = "https://github.com/gtk-rs/gtk-rs" }
gstreamer = { path = "../gstreamer" }
gst = { package = "gstreamer", path = "../gstreamer" }
[build-dependencies]
gstreamer-rs-lgpl-docs = { path = "../docs", optional = true }
[features]
default = []
v1_10 = ["gstreamer/v1_10", "gstreamer-base-sys/v1_10"]
v1_12 = ["gstreamer/v1_12", "gstreamer-base-sys/v1_12", "v1_10"]
v1_14 = ["gstreamer/v1_14", "gstreamer-base-sys/v1_14", "v1_12"]
v1_14_1 = ["gstreamer/v1_14", "gstreamer-base-sys/v1_14_1", "v1_14"]
v1_16 = ["gstreamer/v1_16", "gstreamer-base-sys/v1_16", "v1_14_1"]
v1_18 = ["gstreamer/v1_18", "gstreamer-base-sys/v1_18", "v1_16"]
v1_10 = ["gst/v1_10", "ffi/v1_10"]
v1_12 = ["gst/v1_12", "ffi/v1_12", "v1_10"]
v1_14 = ["gst/v1_14", "ffi/v1_14", "v1_12"]
v1_14_1 = ["gst/v1_14", "ffi/v1_14_1", "v1_14"]
v1_16 = ["gst/v1_16", "ffi/v1_16", "v1_14_1"]
v1_18 = ["gst/v1_18", "ffi/v1_18", "v1_16"]
embed-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
purge-lgpl-docs = ["gstreamer-rs-lgpl-docs"]
dox = ["v1_18", "gstreamer-base-sys/dox", "glib/dox", "gstreamer/dox"]
dox = ["v1_18", "ffi/dox", "glib/dox", "gst/dox"]
[package.metadata.docs.rs]
features = ["dox", "embed-lgpl-docs"]

View file

@ -6,18 +6,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crate::Adapter;
use glib::translate::*;
use gst;
use gst_base_sys;
use std::io;
use std::ops;
use Adapter;
impl Adapter {
pub fn copy(&self, offset: usize, dest: &mut [u8]) {
unsafe {
let size = dest.len();
gst_base_sys::gst_adapter_copy(
ffi::gst_adapter_copy(
self.to_glib_none().0,
dest.as_mut_ptr() as *mut _,
offset,
@ -28,7 +26,7 @@ impl Adapter {
pub fn push(&self, buf: gst::Buffer) {
unsafe {
gst_base_sys::gst_adapter_push(self.to_glib_none().0, buf.into_ptr());
ffi::gst_adapter_push(self.to_glib_none().0, buf.into_ptr());
}
}
}
@ -193,9 +191,9 @@ impl UniqueAdapter {
use std::slice;
unsafe {
let ptr = gst_base_sys::gst_adapter_map(self.0.to_glib_none().0, nbytes);
let ptr = ffi::gst_adapter_map(self.0.to_glib_none().0, nbytes);
if ptr.is_null() {
Err(glib_bool_error!("size bytes are not available"))
Err(glib::glib_bool_error!("size bytes are not available"))
} else {
Ok(UniqueAdapterMap(
self,
@ -212,7 +210,7 @@ pub struct UniqueAdapterMap<'a>(&'a UniqueAdapter, &'a [u8]);
impl<'a> Drop for UniqueAdapterMap<'a> {
fn drop(&mut self) {
unsafe {
gst_base_sys::gst_adapter_unmap((self.0).0.to_glib_none().0);
ffi::gst_adapter_unmap((self.0).0.to_glib_none().0);
}
}
}

View file

@ -6,6 +6,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crate::Aggregator;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
use glib::prelude::*;
@ -17,8 +18,6 @@ use glib::IsA;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
use glib::Value;
use gst;
use gst_base_sys;
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
use std::boxed::Box as Box_;
@ -27,7 +26,6 @@ use std::mem;
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
use std::mem::transmute;
use std::ptr;
use Aggregator;
pub trait AggregatorExtManual: 'static {
fn get_allocator(&self) -> (Option<gst::Allocator>, gst::AllocationParams);
@ -96,7 +94,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,
@ -107,7 +105,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(),
))
@ -122,7 +120,7 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
bufferlist: gst::BufferList,
) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn = unsafe {
from_glib(gst_base_sys::gst_aggregator_finish_buffer_list(
from_glib(ffi::gst_aggregator_finish_buffer_list(
self.as_ref().to_glib_none().0,
bufferlist.into_ptr(),
))
@ -135,8 +133,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,
);
@ -151,8 +149,8 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
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,
);
@ -181,7 +179,7 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
fn update_segment<F: gst::FormattedValue>(&self, segment: &gst::FormattedSegment<F>) {
unsafe {
gst_base_sys::gst_aggregator_update_segment(
ffi::gst_aggregator_update_segment(
self.as_ref().to_glib_none().0,
mut_override(segment.to_glib_none().0),
)
@ -198,7 +196,7 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
info: Option<&gst::StructureRef>,
) {
unsafe {
gst_base_sys::gst_aggregator_selected_samples(
ffi::gst_aggregator_selected_samples(
self.as_ref().to_glib_none().0,
pts.to_glib(),
dts.to_glib(),
@ -242,13 +240,13 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
) + Send
+ 'static,
>(
this: *mut gst_base_sys::GstAggregator,
segment: *mut gst_sys::GstSegment,
pts: gst_sys::GstClockTime,
dts: gst_sys::GstClockTime,
duration: gst_sys::GstClockTime,
info: *mut gst_sys::GstStructure,
f: glib_sys::gpointer,
this: *mut ffi::GstAggregator,
segment: *mut gst::ffi::GstSegment,
pts: gst::ffi::GstClockTime,
dts: gst::ffi::GstClockTime,
duration: gst::ffi::GstClockTime,
info: *mut gst::ffi::GstStructure,
f: glib::ffi::gpointer,
) where
P: IsA<Aggregator>,
{
@ -284,9 +282,9 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
#[cfg(any(feature = "v1_16", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))]
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,12 +6,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crate::AggregatorPad;
use glib::object::IsA;
use glib::translate::*;
use gst;
use gst_base_sys;
use gst_sys;
use AggregatorPad;
pub trait AggregatorPadExtManual: 'static {
fn get_segment(&self) -> gst::Segment;
@ -20,9 +17,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 _guard = ::utils::MutexGuard::lock(&ptr.parent.object.lock);
from_glib_none(&ptr.segment as *const gst_sys::GstSegment)
let ptr: &ffi::GstAggregatorPad = &*(self.as_ptr() as *const _);
let _guard = crate::utils::MutexGuard::lock(&ptr.parent.object.lock);
from_glib_none(&ptr.segment as *const gst::ffi::GstSegment)
}
}
}

View file

@ -6,15 +6,13 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crate::BaseParse;
use crate::BaseParseFrame;
use glib::object::IsA;
use glib::translate::*;
use gst;
use gst::FormattedValue;
use gst_base_sys;
use std::convert::TryFrom;
use std::mem;
use BaseParse;
use BaseParseFrame;
pub trait BaseParseExtManual: 'static {
fn get_sink_pad(&self) -> gst::Pad;
@ -43,14 +41,14 @@ pub trait BaseParseExtManual: 'static {
impl<O: IsA<BaseParse>> BaseParseExtManual for O {
fn get_sink_pad(&self) -> gst::Pad {
unsafe {
let elt: &gst_base_sys::GstBaseParse = &*(self.as_ptr() as *const _);
let elt: &ffi::GstBaseParse = &*(self.as_ptr() as *const _);
from_glib_none(elt.sinkpad)
}
}
fn get_src_pad(&self) -> gst::Pad {
unsafe {
let elt: &gst_base_sys::GstBaseParse = &*(self.as_ptr() as *const _);
let elt: &ffi::GstBaseParse = &*(self.as_ptr() as *const _);
from_glib_none(elt.srcpad)
}
}
@ -58,7 +56,7 @@ impl<O: IsA<BaseParse>> BaseParseExtManual for O {
fn set_duration<V: Into<gst::GenericFormattedValue>>(&self, duration: V, interval: u32) {
let duration = duration.into();
unsafe {
gst_base_sys::gst_base_parse_set_duration(
ffi::gst_base_parse_set_duration(
self.as_ref().to_glib_none().0,
duration.get_format().to_glib(),
duration.get_value(),
@ -70,7 +68,7 @@ impl<O: IsA<BaseParse>> BaseParseExtManual for O {
fn set_frame_rate(&self, fps: gst::Fraction, lead_in: u32, lead_out: u32) {
let (fps_num, fps_den) = fps.into();
unsafe {
gst_base_sys::gst_base_parse_set_frame_rate(
ffi::gst_base_parse_set_frame_rate(
self.as_ref().to_glib_none().0,
fps_num as u32,
fps_den as u32,
@ -87,7 +85,7 @@ impl<O: IsA<BaseParse>> BaseParseExtManual for O {
let src_val = src_val.into();
unsafe {
let mut dest_val = mem::MaybeUninit::uninit();
let ret = from_glib(gst_base_sys::gst_base_parse_convert_default(
let ret = from_glib(ffi::gst_base_parse_convert_default(
self.as_ref().to_glib_none().0,
src_val.get_format().to_glib(),
src_val.to_raw_value(),
@ -110,7 +108,7 @@ impl<O: IsA<BaseParse>> BaseParseExtManual for O {
let src_val = src_val.into();
unsafe {
let mut dest_val = mem::MaybeUninit::uninit();
let ret = from_glib(gst_base_sys::gst_base_parse_convert_default(
let ret = from_glib(ffi::gst_base_parse_convert_default(
self.as_ref().to_glib_none().0,
src_val.get_format().to_glib(),
src_val.to_raw_value(),
@ -134,7 +132,7 @@ impl<O: IsA<BaseParse>> BaseParseExtManual for O {
size: u32,
) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe {
gst::FlowReturn::from_glib(gst_base_sys::gst_base_parse_finish_frame(
gst::FlowReturn::from_glib(ffi::gst_base_parse_finish_frame(
self.as_ref().to_glib_none().0,
frame.to_glib_none().0,
i32::try_from(size).expect("size higher than i32::MAX"),

View file

@ -7,18 +7,16 @@
// except according to those terms.
use glib::translate::*;
use gst;
use gst_base_sys;
use std::convert::TryFrom;
use std::fmt;
use std::marker::PhantomData;
use std::ptr;
use BaseParse;
use BaseParseFrameFlags;
use crate::BaseParse;
use crate::BaseParseFrameFlags;
pub struct BaseParseFrame<'a>(
ptr::NonNull<gst_base_sys::GstBaseParseFrame>,
ptr::NonNull<ffi::GstBaseParseFrame>,
PhantomData<&'a BaseParse>,
);
@ -59,18 +57,14 @@ impl FromGlib<i32> for Overhead {
}
#[doc(hidden)]
impl<'a> ::glib::translate::ToGlibPtr<'a, *mut gst_base_sys::GstBaseParseFrame>
for BaseParseFrame<'a>
{
impl<'a> ::glib::translate::ToGlibPtr<'a, *mut ffi::GstBaseParseFrame> for BaseParseFrame<'a> {
type Storage = &'a Self;
fn to_glib_none(
&'a self,
) -> ::glib::translate::Stash<*mut gst_base_sys::GstBaseParseFrame, Self> {
fn to_glib_none(&'a self) -> ::glib::translate::Stash<*mut ffi::GstBaseParseFrame, Self> {
Stash(self.0.as_ptr(), self)
}
fn to_glib_full(&self) -> *mut gst_base_sys::GstBaseParseFrame {
fn to_glib_full(&self) -> *mut ffi::GstBaseParseFrame {
unimplemented!()
}
}
@ -91,7 +85,7 @@ impl<'a> fmt::Debug for BaseParseFrame<'a> {
impl<'a> BaseParseFrame<'a> {
pub(crate) unsafe fn new(
frame: *mut gst_base_sys::GstBaseParseFrame,
frame: *mut ffi::GstBaseParseFrame,
_parse: &'a BaseParse,
) -> BaseParseFrame<'a> {
skip_assert_initialized!();
@ -116,8 +110,8 @@ impl<'a> BaseParseFrame<'a> {
if ptr.is_null() {
None
} else {
let writable: bool = from_glib(gst_sys::gst_mini_object_is_writable(
ptr as *const gst_sys::GstMiniObject,
let writable: bool = from_glib(gst::ffi::gst_mini_object_is_writable(
ptr as *const gst::ffi::GstMiniObject,
));
assert!(writable);
@ -143,8 +137,8 @@ impl<'a> BaseParseFrame<'a> {
if ptr.is_null() {
None
} else {
let writable: bool = from_glib(gst_sys::gst_mini_object_is_writable(
ptr as *const gst_sys::GstMiniObject,
let writable: bool = from_glib(gst::ffi::gst_mini_object_is_writable(
ptr as *const gst::ffi::GstMiniObject,
));
assert!(writable);
@ -158,12 +152,12 @@ impl<'a> BaseParseFrame<'a> {
let prev = (*self.to_glib_none().0).out_buffer;
if !prev.is_null() {
gst_sys::gst_mini_object_unref(prev as *mut gst_sys::GstMiniObject);
gst::ffi::gst_mini_object_unref(prev as *mut gst::ffi::GstMiniObject);
}
let ptr = output_buffer.into_ptr();
let writable: bool = from_glib(gst_sys::gst_mini_object_is_writable(
ptr as *const gst_sys::GstMiniObject,
let writable: bool = from_glib(gst::ffi::gst_mini_object_is_writable(
ptr as *const gst::ffi::GstMiniObject,
));
assert!(writable);

View file

@ -6,12 +6,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crate::BaseSink;
use glib::object::IsA;
use glib::translate::*;
use gst;
use gst_base_sys;
use std::mem;
use BaseSink;
pub trait BaseSinkExtManual: 'static {
fn get_segment(&self) -> gst::Segment;
@ -38,8 +36,8 @@ pub trait BaseSinkExtManual: 'static {
impl<O: IsA<BaseSink>> BaseSinkExtManual for O {
fn get_segment(&self) -> gst::Segment {
unsafe {
let sink: &gst_base_sys::GstBaseSink = &*(self.as_ptr() as *const _);
let _guard = ::utils::MutexGuard::lock(&sink.element.object.lock);
let sink: &ffi::GstBaseSink = &*(self.as_ptr() as *const _);
let _guard = crate::utils::MutexGuard::lock(&sink.element.object.lock);
from_glib_none(&sink.segment as *const _)
}
}
@ -50,7 +48,7 @@ impl<O: IsA<BaseSink>> BaseSinkExtManual for O {
) -> (Result<gst::FlowSuccess, gst::FlowError>, gst::ClockTimeDiff) {
unsafe {
let mut jitter = 0;
let ret: gst::FlowReturn = from_glib(gst_base_sys::gst_base_sink_wait(
let ret: gst::FlowReturn = from_glib(ffi::gst_base_sink_wait(
self.as_ref().to_glib_none().0,
time.to_glib(),
&mut jitter,
@ -61,7 +59,7 @@ impl<O: IsA<BaseSink>> BaseSinkExtManual for O {
fn wait_preroll(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn = unsafe {
from_glib(gst_base_sys::gst_base_sink_wait_preroll(
from_glib(ffi::gst_base_sink_wait_preroll(
self.as_ref().to_glib_none().0,
))
};
@ -77,7 +75,7 @@ impl<O: IsA<BaseSink>> BaseSinkExtManual for O {
) {
unsafe {
let mut jitter = 0;
let ret: gst::ClockReturn = from_glib(gst_base_sys::gst_base_sink_wait_clock(
let ret: gst::ClockReturn = from_glib(ffi::gst_base_sink_wait_clock(
self.as_ref().to_glib_none().0,
time.to_glib(),
&mut jitter,
@ -94,7 +92,7 @@ impl<O: IsA<BaseSink>> BaseSinkExtManual for O {
let mut upstream_live = mem::MaybeUninit::uninit();
let mut min_latency = mem::MaybeUninit::uninit();
let mut max_latency = mem::MaybeUninit::uninit();
let ret = from_glib(gst_base_sys::gst_base_sink_query_latency(
let ret = from_glib(ffi::gst_base_sink_query_latency(
self.as_ref().to_glib_none().0,
live.as_mut_ptr(),
upstream_live.as_mut_ptr(),
@ -113,7 +111,7 @@ impl<O: IsA<BaseSink>> BaseSinkExtManual for O {
from_glib(max_latency),
))
} else {
Err(glib_bool_error!("Failed to query latency"))
Err(glib::glib_bool_error!("Failed to query latency"))
}
}
}

View file

@ -8,12 +8,10 @@
use glib::object::IsA;
use glib::translate::*;
use gst;
use gst_base_sys;
use std::mem;
use std::ptr;
use BaseSrc;
use crate::BaseSrc;
pub trait BaseSrcExtManual: 'static {
fn get_allocator(&self) -> (Option<gst::Allocator>, gst::AllocationParams);
@ -38,7 +36,7 @@ impl<O: IsA<BaseSrc>> BaseSrcExtManual for O {
unsafe {
let mut allocator = ptr::null_mut();
let mut params = mem::zeroed();
gst_base_sys::gst_base_src_get_allocator(
ffi::gst_base_src_get_allocator(
self.as_ref().to_glib_none().0,
&mut allocator,
&mut params,
@ -49,8 +47,8 @@ impl<O: IsA<BaseSrc>> BaseSrcExtManual for O {
fn get_segment(&self) -> gst::Segment {
unsafe {
let src: &gst_base_sys::GstBaseSrc = &*(self.as_ptr() as *const _);
let _guard = ::utils::MutexGuard::lock(&src.element.object.lock);
let src: &ffi::GstBaseSrc = &*(self.as_ptr() as *const _);
let _guard = crate::utils::MutexGuard::lock(&src.element.object.lock);
from_glib_none(&src.segment as *const _)
}
}
@ -58,25 +56,19 @@ impl<O: IsA<BaseSrc>> BaseSrcExtManual for O {
fn start_complete(&self, ret: Result<gst::FlowSuccess, gst::FlowError>) {
let ret: gst::FlowReturn = ret.into();
unsafe {
gst_base_sys::gst_base_src_start_complete(
self.as_ref().to_glib_none().0,
ret.to_glib(),
);
ffi::gst_base_src_start_complete(self.as_ref().to_glib_none().0, ret.to_glib());
}
}
fn start_wait(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn = unsafe {
from_glib(gst_base_sys::gst_base_src_start_wait(
self.as_ref().to_glib_none().0,
))
};
let ret: gst::FlowReturn =
unsafe { from_glib(ffi::gst_base_src_start_wait(self.as_ref().to_glib_none().0)) };
ret.into_result()
}
fn wait_playing(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
let ret: gst::FlowReturn = unsafe {
from_glib(gst_base_sys::gst_base_src_wait_playing(
from_glib(ffi::gst_base_src_wait_playing(
self.as_ref().to_glib_none().0,
))
};
@ -88,7 +80,7 @@ impl<O: IsA<BaseSrc>> BaseSrcExtManual for O {
let mut live = mem::MaybeUninit::uninit();
let mut min_latency = mem::MaybeUninit::uninit();
let mut max_latency = mem::MaybeUninit::uninit();
let ret = from_glib(gst_base_sys::gst_base_src_query_latency(
let ret = from_glib(ffi::gst_base_src_query_latency(
self.as_ref().to_glib_none().0,
live.as_mut_ptr(),
min_latency.as_mut_ptr(),
@ -104,7 +96,7 @@ impl<O: IsA<BaseSrc>> BaseSrcExtManual for O {
from_glib(max_latency),
))
} else {
Err(glib_bool_error!("Failed to query latency"))
Err(glib::glib_bool_error!("Failed to query latency"))
}
}
}
@ -113,7 +105,7 @@ impl<O: IsA<BaseSrc>> BaseSrcExtManual for O {
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
fn new_segment(&self, segment: &gst::Segment) -> Result<(), glib::BoolError> {
unsafe {
let ret = from_glib(gst_base_sys::gst_base_src_new_segment(
let ret = from_glib(ffi::gst_base_src_new_segment(
self.as_ref().to_glib_none().0,
segment.to_glib_none().0,
));
@ -121,7 +113,7 @@ impl<O: IsA<BaseSrc>> BaseSrcExtManual for O {
if ret {
Ok(())
} else {
Err(glib_bool_error!("Failed to configure new segment"))
Err(glib::glib_bool_error!("Failed to configure new segment"))
}
}
}

View file

@ -6,13 +6,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use crate::BaseTransform;
use glib::object::IsA;
use glib::translate::*;
use gst;
use gst_base_sys;
use std::mem;
use std::ptr;
use BaseTransform;
pub trait BaseTransformExtManual: 'static {
fn get_allocator(&self) -> (Option<gst::Allocator>, gst::AllocationParams);
@ -25,7 +23,7 @@ impl<O: IsA<BaseTransform>> BaseTransformExtManual for O {
unsafe {
let mut allocator = ptr::null_mut();
let mut params = mem::zeroed();
gst_base_sys::gst_base_transform_get_allocator(
ffi::gst_base_transform_get_allocator(
self.as_ref().to_glib_none().0,
&mut allocator,
&mut params,
@ -36,8 +34,8 @@ impl<O: IsA<BaseTransform>> BaseTransformExtManual for O {
fn get_segment(&self) -> gst::Segment {
unsafe {
let trans: &gst_base_sys::GstBaseTransform = &*(self.as_ptr() as *const _);
let _guard = ::utils::MutexGuard::lock(&trans.element.object.lock);
let trans: &ffi::GstBaseTransform = &*(self.as_ptr() as *const _);
let _guard = crate::utils::MutexGuard::lock(&trans.element.object.lock);
from_glib_none(&trans.segment as *const _)
}
}

View file

@ -8,54 +8,45 @@
use glib::object::IsA;
use glib::translate::*;
use gobject_sys;
use gst;
use gst_base_sys;
glib_wrapper! {
glib::glib_wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct FlowCombiner(Shared<gst_base_sys::GstFlowCombiner>);
pub struct FlowCombiner(Shared<ffi::GstFlowCombiner>);
match fn {
ref => |ptr| gobject_sys::g_boxed_copy(gst_base_sys::gst_flow_combiner_get_type(), ptr as *mut _),
unref => |ptr| gobject_sys::g_boxed_free(gst_base_sys::gst_flow_combiner_get_type(), ptr as *mut _),
get_type => || gst_base_sys::gst_flow_combiner_get_type(),
ref => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::gst_flow_combiner_get_type(), ptr as *mut _),
unref => |ptr| glib::gobject_ffi::g_boxed_free(ffi::gst_flow_combiner_get_type(), ptr as *mut _),
get_type => || ffi::gst_flow_combiner_get_type(),
}
}
impl FlowCombiner {
pub fn new() -> FlowCombiner {
assert_initialized_main_thread!();
unsafe { from_glib_full(gst_base_sys::gst_flow_combiner_new()) }
unsafe { from_glib_full(ffi::gst_flow_combiner_new()) }
}
pub fn add_pad<P: IsA<gst::Pad>>(&self, pad: &P) {
unsafe {
gst_base_sys::gst_flow_combiner_add_pad(
self.to_glib_none().0,
pad.as_ref().to_glib_none().0,
);
ffi::gst_flow_combiner_add_pad(self.to_glib_none().0, pad.as_ref().to_glib_none().0);
}
}
pub fn clear(&self) {
unsafe {
gst_base_sys::gst_flow_combiner_clear(self.to_glib_none().0);
ffi::gst_flow_combiner_clear(self.to_glib_none().0);
}
}
pub fn remove_pad<P: IsA<gst::Pad>>(&self, pad: &P) {
unsafe {
gst_base_sys::gst_flow_combiner_remove_pad(
self.to_glib_none().0,
pad.as_ref().to_glib_none().0,
);
ffi::gst_flow_combiner_remove_pad(self.to_glib_none().0, pad.as_ref().to_glib_none().0);
}
}
pub fn reset(&self) {
unsafe {
gst_base_sys::gst_flow_combiner_reset(self.to_glib_none().0);
ffi::gst_flow_combiner_reset(self.to_glib_none().0);
}
}
@ -65,7 +56,7 @@ impl FlowCombiner {
) -> Result<gst::FlowSuccess, gst::FlowError> {
let fret: gst::FlowReturn = fret.into();
let ret: gst::FlowReturn = unsafe {
from_glib(gst_base_sys::gst_flow_combiner_update_flow(
from_glib(ffi::gst_flow_combiner_update_flow(
self.to_glib_none().0,
fret.to_glib(),
))
@ -80,7 +71,7 @@ impl FlowCombiner {
) -> Result<gst::FlowSuccess, gst::FlowError> {
let fret: gst::FlowReturn = fret.into();
let ret: gst::FlowReturn = unsafe {
from_glib(gst_base_sys::gst_flow_combiner_update_pad_flow(
from_glib(ffi::gst_flow_combiner_update_pad_flow(
self.to_glib_none().0,
pad.as_ref().to_glib_none().0,
fret.to_glib(),

View file

@ -8,8 +8,6 @@
use glib::object::IsA;
use glib::translate::*;
use gst;
use gst_base_sys;
use std::mem;
pub fn type_find_helper_for_data<P: IsA<gst::Object>, R: AsRef<[u8]>>(
@ -21,14 +19,14 @@ pub fn type_find_helper_for_data<P: IsA<gst::Object>, R: AsRef<[u8]>>(
let mut prob = mem::MaybeUninit::uninit();
let data = data.as_ref();
let (ptr, len) = (data.as_ptr(), data.len());
let ret = gst_base_sys::gst_type_find_helper_for_data(
let ret = ffi::gst_type_find_helper_for_data(
obj.map(|p| p.as_ref()).to_glib_none().0,
mut_override(ptr),
len,
prob.as_mut_ptr(),
);
if ret.is_null() {
Err(glib_bool_error!("No type could be found"))
Err(glib::glib_bool_error!("No type could be found"))
} else {
Ok((from_glib_full(ret), from_glib(prob.assume_init())))
}
@ -47,7 +45,7 @@ pub fn type_find_helper_for_data_with_extension<P: IsA<gst::Object>, R: AsRef<[u
let mut prob = mem::MaybeUninit::uninit();
let data = data.as_ref();
let (ptr, len) = (data.as_ptr(), data.len());
let ret = gst_base_sys::gst_type_find_helper_for_data_with_extension(
let ret = ffi::gst_type_find_helper_for_data_with_extension(
obj.map(|p| p.as_ref()).to_glib_none().0,
mut_override(ptr),
len,
@ -55,7 +53,7 @@ pub fn type_find_helper_for_data_with_extension<P: IsA<gst::Object>, R: AsRef<[u
prob.as_mut_ptr(),
);
if ret.is_null() {
Err(glib_bool_error!("No type could be found"))
Err(glib::glib_bool_error!("No type could be found"))
} else {
Ok((from_glib_full(ret), from_glib(prob.assume_init())))
}
@ -69,13 +67,13 @@ pub fn type_find_helper_for_buffer<P: IsA<gst::Object>>(
assert_initialized_main_thread!();
unsafe {
let mut prob = mem::MaybeUninit::uninit();
let ret = gst_base_sys::gst_type_find_helper_for_buffer(
let ret = ffi::gst_type_find_helper_for_buffer(
obj.map(|p| p.as_ref()).to_glib_none().0,
buf.to_glib_none().0,
prob.as_mut_ptr(),
);
if ret.is_null() {
Err(glib_bool_error!("No type could be found"))
Err(glib::glib_bool_error!("No type could be found"))
} else {
Ok((from_glib_full(ret), from_glib(prob.assume_init())))
}
@ -92,14 +90,14 @@ pub fn type_find_helper_for_buffer_with_extension<P: IsA<gst::Object>>(
assert_initialized_main_thread!();
unsafe {
let mut prob = mem::MaybeUninit::uninit();
let ret = gst_base_sys::gst_type_find_helper_for_buffer_with_extension(
let ret = ffi::gst_type_find_helper_for_buffer_with_extension(
obj.map(|p| p.as_ref()).to_glib_none().0,
buf.to_glib_none().0,
extension.to_glib_none().0,
prob.as_mut_ptr(),
);
if ret.is_null() {
Err(glib_bool_error!("No type could be found"))
Err(glib::glib_bool_error!("No type could be found"))
} else {
Ok((from_glib_full(ret), from_glib(prob.assume_init())))
}

View file

@ -8,23 +8,11 @@
#![cfg_attr(feature = "dox", feature(doc_cfg))]
extern crate glib_sys;
extern crate gobject_sys;
#[macro_use]
extern crate gstreamer as gst;
extern crate gstreamer_base_sys as gst_base_sys;
extern crate gstreamer_sys as gst_sys;
extern crate libc;
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate glib;
pub use ffi;
macro_rules! assert_initialized_main_thread {
() => {
if unsafe { ::gst_sys::gst_is_initialized() } != ::glib_sys::GTRUE {
if unsafe { gst::ffi::gst_is_initialized() } != glib::ffi::GTRUE {
panic!("GStreamer has not been initialized. Call `gst::init` first.");
}
};
@ -40,16 +28,16 @@ macro_rules! skip_assert_initialized {
#[allow(clippy::type_complexity)]
#[allow(unused_imports)]
mod auto;
pub use auto::functions::*;
pub use auto::*;
pub use crate::auto::functions::*;
pub use crate::auto::*;
pub mod functions;
pub use functions::*;
pub use crate::functions::*;
mod adapter;
pub use adapter::*;
pub use crate::adapter::*;
mod flow_combiner;
pub use flow_combiner::*;
pub use crate::flow_combiner::*;
#[cfg(any(feature = "v1_14", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
mod aggregator;
@ -63,16 +51,16 @@ mod aggregator_pad;
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
pub use aggregator_pad::AggregatorPadExtManual;
mod base_parse;
pub use base_parse::BaseParseExtManual;
pub use crate::base_parse::BaseParseExtManual;
mod base_sink;
pub use base_sink::BaseSinkExtManual;
pub use crate::base_sink::BaseSinkExtManual;
mod base_src;
pub use base_src::BaseSrcExtManual;
pub use crate::base_src::BaseSrcExtManual;
mod base_transform;
pub use base_transform::BaseTransformExtManual;
pub use crate::base_transform::BaseTransformExtManual;
pub mod base_parse_frame;
pub use base_parse_frame::BaseParseFrame;
pub use crate::base_parse_frame::BaseParseFrame;
pub const BASE_TRANSFORM_FLOW_DROPPED: gst::FlowSuccess = gst::FlowSuccess::CustomSuccess;
pub const BASE_PARSE_FLOW_DROPPED: gst::FlowSuccess = gst::FlowSuccess::CustomSuccess;
@ -86,15 +74,15 @@ pub mod prelude {
#[cfg(any(feature = "v1_14", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
pub use aggregator::AggregatorExtManual;
pub use crate::aggregator::AggregatorExtManual;
#[cfg(any(feature = "v1_14", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
pub use aggregator_pad::AggregatorPadExtManual;
pub use auto::traits::*;
pub use base_parse::BaseParseExtManual;
pub use base_sink::BaseSinkExtManual;
pub use base_src::BaseSrcExtManual;
pub use base_transform::BaseTransformExtManual;
pub use crate::aggregator_pad::AggregatorPadExtManual;
pub use crate::auto::traits::*;
pub use crate::base_parse::BaseParseExtManual;
pub use crate::base_sink::BaseSinkExtManual;
pub use crate::base_src::BaseSrcExtManual;
pub use crate::base_transform::BaseTransformExtManual;
}
mod utils;

View file

@ -6,23 +6,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use libc;
use glib_sys;
use gst_base_sys;
use gst_sys;
use glib::prelude::*;
use glib::subclass::prelude::*;
use glib::translate::*;
use gst;
use gst::subclass::prelude::*;
use std::ptr;
use Aggregator;
use AggregatorPad;
use crate::Aggregator;
use crate::AggregatorPad;
pub trait AggregatorImpl: AggregatorImplExt + ElementImpl {
fn flush(&self, aggregator: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError> {
@ -298,8 +291,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| {
@ -321,8 +313,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(
@ -341,8 +332,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`");
@ -363,8 +353,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_list
.expect("Missing parent function `finish_buffer_list`");
@ -384,8 +373,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`");
@ -407,8 +395,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`");
@ -429,8 +416,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`");
@ -452,8 +438,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`");
@ -468,8 +453,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`");
@ -483,8 +467,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`");
@ -503,11 +486,10 @@ 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!(
Some(f) => gst::gst_result_from_gboolean!(
f(
aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
mode.to_glib(),
@ -527,8 +509,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`");
@ -543,8 +524,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| {
@ -555,7 +535,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
{
Ok(())
} else {
Err(gst_error_msg!(
Err(gst::gst_error_msg!(
gst::CoreError::Failed,
["Parent function `start` failed"]
))
@ -568,8 +548,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| {
@ -580,7 +559,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
{
Ok(())
} else {
Err(gst_error_msg!(
Err(gst::gst_error_msg!(
gst::CoreError::Failed,
["Parent function `stop` failed"]
))
@ -593,8 +572,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| {
@ -616,8 +594,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`");
@ -637,8 +614,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`");
@ -656,8 +632,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
@ -676,12 +651,11 @@ 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| {
gst_result_from_gboolean!(
gst::gst_result_from_gboolean!(
f(
aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
caps.to_glib_none().0
@ -699,8 +673,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| {
@ -722,8 +695,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
) -> Option<gst::Sample> {
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)
.peek_next_sample
.map(|f| {
@ -772,8 +744,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,
{
@ -781,17 +753,17 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
imp.flush(wrap.unsafe_cast_ref()).into()
})
.to_glib()
}
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,
{
@ -799,7 +771,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
let ret = gst_panic_to_error!(&wrap, &instance.panicked(), None, {
let ret = gst::gst_panic_to_error!(&wrap, &instance.panicked(), None, {
imp.clip(
wrap.unsafe_cast_ref(),
&from_glib_borrow(aggregator_pad),
@ -811,9 +783,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,
{
@ -821,7 +793,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
imp.finish_buffer(wrap.unsafe_cast_ref(), from_glib_full(buffer))
.into()
})
@ -831,9 +803,9 @@ where
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
unsafe extern "C" fn aggregator_finish_buffer_list<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
buffer_list: *mut gst_sys::GstBufferList,
) -> gst_sys::GstFlowReturn
ptr: *mut ffi::GstAggregator,
buffer_list: *mut gst::ffi::GstBufferList,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -841,7 +813,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
imp.finish_buffer_list(wrap.unsafe_cast_ref(), from_glib_full(buffer_list))
.into()
})
@ -849,10 +821,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,
{
@ -860,7 +832,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(wrap, &instance.panicked(), false, {
imp.sink_event(
wrap.unsafe_cast_ref(),
&from_glib_borrow(aggregator_pad),
@ -873,10 +845,10 @@ where
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
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,
{
@ -884,7 +856,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
imp.sink_event_pre_queue(
wrap.unsafe_cast_ref(),
&from_glib_borrow(aggregator_pad),
@ -896,10 +868,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,
{
@ -907,7 +879,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
imp.sink_query(
wrap.unsafe_cast_ref(),
&from_glib_borrow(aggregator_pad),
@ -920,10 +892,10 @@ where
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
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,
{
@ -931,7 +903,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
imp.sink_query_pre_queue(
wrap.unsafe_cast_ref(),
&from_glib_borrow(aggregator_pad),
@ -942,9 +914,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,
{
@ -952,16 +924,16 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event))
})
.to_glib()
}
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,
{
@ -969,17 +941,17 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
imp.src_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
})
.to_glib()
}
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,
{
@ -987,7 +959,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.src_activate(wrap.unsafe_cast_ref(), from_glib(mode), from_glib(active)) {
Ok(()) => true,
Err(err) => {
@ -1000,9 +972,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,
{
@ -1010,7 +982,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
imp.aggregate(wrap.unsafe_cast_ref(), from_glib(timeout))
.into()
})
@ -1018,8 +990,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,
{
@ -1027,7 +999,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.start(wrap.unsafe_cast_ref()) {
Ok(()) => true,
Err(err) => {
@ -1040,8 +1012,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,
{
@ -1049,7 +1021,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.stop(wrap.unsafe_cast_ref()) {
Ok(()) => true,
Err(err) => {
@ -1062,8 +1034,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,
{
@ -1071,18 +1043,18 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), gst::CLOCK_TIME_NONE, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::CLOCK_TIME_NONE, {
imp.get_next_time(wrap.unsafe_cast_ref())
})
.to_glib()
}
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,
{
@ -1090,7 +1062,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), None, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), None, {
let req_name: Borrowed<Option<glib::GString>> = from_glib_borrow(req_name);
imp.create_new_pad(
@ -1106,10 +1078,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,
{
@ -1119,7 +1091,7 @@ where
*res = ptr::null_mut();
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
match imp.update_src_caps(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) {
Ok(res_caps) => {
*res = res_caps.into_ptr();
@ -1132,9 +1104,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,
{
@ -1142,16 +1114,16 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
imp.fixate_src_caps(wrap.unsafe_cast_ref(), from_glib_full(caps))
})
.into_ptr()
}
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,
{
@ -1159,7 +1131,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.negotiated_src_caps(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) {
Ok(()) => true,
Err(err) => {
@ -1174,8 +1146,8 @@ where
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
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,
{
@ -1183,7 +1155,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
imp.negotiate(wrap.unsafe_cast_ref())
})
.to_glib()
@ -1192,9 +1164,9 @@ where
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
unsafe extern "C" fn aggregator_peek_next_sample<T: AggregatorImpl>(
ptr: *mut gst_base_sys::GstAggregator,
pad: *mut gst_base_sys::GstAggregatorPad,
) -> *mut gst_sys::GstSample
ptr: *mut ffi::GstAggregator,
pad: *mut ffi::GstAggregatorPad,
) -> *mut gst::ffi::GstSample
where
T::Instance: PanicPoison,
{
@ -1202,7 +1174,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<Aggregator> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), None, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), None, {
imp.peek_next_sample(wrap.unsafe_cast_ref(), &from_glib_borrow(pad))
})
.to_glib_full()

View file

@ -6,19 +6,14 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use glib_sys;
use gst_base_sys;
use gst_sys;
use glib::prelude::*;
use glib::subclass::prelude::*;
use glib::translate::*;
use gst;
use gst::subclass::prelude::*;
use Aggregator;
use AggregatorPad;
use crate::Aggregator;
use crate::AggregatorPad;
pub trait AggregatorPadImpl: AggregatorPadImplExt + PadImpl {
fn flush(
@ -62,8 +57,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| {
@ -88,8 +82,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| {
@ -116,9 +109,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);
@ -130,10 +123,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

@ -6,22 +6,18 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use glib_sys;
use gst_base_sys;
use gst_sys;
use std::convert::TryFrom;
use std::mem;
use prelude::*;
use crate::prelude::*;
use glib::subclass::prelude::*;
use glib::translate::*;
use gst;
use gst::subclass::prelude::*;
use BaseParse;
use BaseParseFrame;
use crate::BaseParse;
use crate::BaseParseFrame;
pub trait BaseParseImpl: BaseParseImplExt + ElementImpl {
fn start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
@ -87,15 +83,14 @@ impl<T: BaseParseImpl> BaseParseImplExt for T {
fn parent_start(&self, element: &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::GstBaseParseClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseParseClass;
(*parent_class)
.start
.map(|f| {
if from_glib(f(element.unsafe_cast_ref::<BaseParse>().to_glib_none().0)) {
Ok(())
} else {
Err(gst_error_msg!(
Err(gst::gst_error_msg!(
gst::CoreError::StateChange,
["Parent function `start` failed"]
))
@ -108,15 +103,14 @@ impl<T: BaseParseImpl> BaseParseImplExt for T {
fn parent_stop(&self, element: &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::GstBaseParseClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseParseClass;
(*parent_class)
.stop
.map(|f| {
if from_glib(f(element.unsafe_cast_ref::<BaseParse>().to_glib_none().0)) {
Ok(())
} else {
Err(gst_error_msg!(
Err(gst::gst_error_msg!(
gst::CoreError::StateChange,
["Parent function `stop` failed"]
))
@ -133,8 +127,7 @@ impl<T: BaseParseImpl> BaseParseImplExt for T {
) -> Result<(), gst::ErrorMessage> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseParseClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseParseClass;
(*parent_class)
.set_sink_caps
.map(|f| {
@ -144,7 +137,7 @@ impl<T: BaseParseImpl> BaseParseImplExt for T {
)) {
Ok(())
} else {
Err(gst_error_msg!(
Err(gst::gst_error_msg!(
gst::CoreError::StateChange,
["Parent function `set_sink_caps` failed"]
))
@ -161,8 +154,7 @@ impl<T: BaseParseImpl> BaseParseImplExt for T {
) -> Result<(gst::FlowSuccess, u32), gst::FlowError> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseParseClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseParseClass;
let mut skipsize = 0;
let res = (*parent_class).handle_frame.map(|f| {
let res = gst::FlowReturn::from_glib(f(
@ -191,8 +183,7 @@ impl<T: BaseParseImpl> BaseParseImplExt for T {
) -> Option<gst::GenericFormattedValue> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseParseClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseParseClass;
let src_val = src_val.into();
let res = (*parent_class).convert.map(|f| {
let mut dest_val = mem::MaybeUninit::uninit();
@ -234,8 +225,8 @@ where
}
unsafe extern "C" fn base_parse_start<T: BaseParseImpl>(
ptr: *mut gst_base_sys::GstBaseParse,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseParse,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -243,7 +234,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseParse> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.start(wrap.unsafe_cast_ref()) {
Ok(()) => true,
Err(err) => {
@ -256,8 +247,8 @@ where
}
unsafe extern "C" fn base_parse_stop<T: BaseParseImpl>(
ptr: *mut gst_base_sys::GstBaseParse,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseParse,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -265,7 +256,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseParse> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.stop(wrap.unsafe_cast_ref()) {
Ok(()) => true,
Err(err) => {
@ -278,9 +269,9 @@ where
}
unsafe extern "C" fn base_parse_set_sink_caps<T: BaseParseImpl>(
ptr: *mut gst_base_sys::GstBaseParse,
caps: *mut gst_sys::GstCaps,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseParse,
caps: *mut gst::ffi::GstCaps,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -289,7 +280,7 @@ where
let wrap: Borrowed<BaseParse> = from_glib_borrow(ptr);
let caps: Borrowed<gst::Caps> = from_glib_borrow(caps);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.set_sink_caps(wrap.unsafe_cast_ref(), &caps) {
Ok(()) => true,
Err(err) => {
@ -302,10 +293,10 @@ where
}
unsafe extern "C" fn base_parse_handle_frame<T: BaseParseImpl>(
ptr: *mut gst_base_sys::GstBaseParse,
frame: *mut gst_base_sys::GstBaseParseFrame,
ptr: *mut ffi::GstBaseParse,
frame: *mut ffi::GstBaseParseFrame,
skipsize: *mut i32,
) -> gst_sys::GstFlowReturn
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -314,7 +305,7 @@ where
let wrap: Borrowed<BaseParse> = from_glib_borrow(ptr);
let wrap_frame = BaseParseFrame::new(frame, &wrap);
let res = gst_panic_to_error!(&wrap, &instance.panicked(), Err(gst::FlowError::Error), {
let res = gst::gst_panic_to_error!(&wrap, &instance.panicked(), Err(gst::FlowError::Error), {
imp.handle_frame(&wrap.unsafe_cast_ref(), wrap_frame)
});
@ -329,12 +320,12 @@ where
}
unsafe extern "C" fn base_parse_convert<T: BaseParseImpl>(
ptr: *mut gst_base_sys::GstBaseParse,
source_format: gst_sys::GstFormat,
ptr: *mut ffi::GstBaseParse,
source_format: gst::ffi::GstFormat,
source_value: i64,
dest_format: gst_sys::GstFormat,
dest_format: gst::ffi::GstFormat,
dest_value: *mut i64,
) -> glib_sys::gboolean
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -343,7 +334,7 @@ where
let wrap: Borrowed<BaseParse> = from_glib_borrow(ptr);
let source = gst::GenericFormattedValue::new(from_glib(source_format), source_value);
let res = gst_panic_to_error!(&wrap, &instance.panicked(), None, {
let res = gst::gst_panic_to_error!(&wrap, &instance.panicked(), None, {
imp.convert(wrap.unsafe_cast_ref(), source, from_glib(dest_format))
});

View file

@ -6,20 +6,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use glib_sys;
use gst_base_sys;
use gst_sys;
use glib::prelude::*;
use glib::subclass::prelude::*;
use glib::translate::*;
use gst;
use gst::subclass::prelude::*;
use std::ptr;
use BaseSink;
use crate::BaseSink;
pub trait BaseSinkImpl: BaseSinkImplExt + ElementImpl {
fn start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
@ -147,15 +142,14 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
fn parent_start(&self, element: &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::GstBaseSinkClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSinkClass;
(*parent_class)
.start
.map(|f| {
if from_glib(f(element.unsafe_cast_ref::<BaseSink>().to_glib_none().0)) {
Ok(())
} else {
Err(gst_error_msg!(
Err(gst::gst_error_msg!(
gst::CoreError::StateChange,
["Parent function `start` failed"]
))
@ -168,15 +162,14 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
fn parent_stop(&self, element: &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::GstBaseSinkClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSinkClass;
(*parent_class)
.stop
.map(|f| {
if from_glib(f(element.unsafe_cast_ref::<BaseSink>().to_glib_none().0)) {
Ok(())
} else {
Err(gst_error_msg!(
Err(gst::gst_error_msg!(
gst::CoreError::StateChange,
["Parent function `stop` failed"]
))
@ -193,8 +186,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt 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::GstBaseSinkClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSinkClass;
(*parent_class)
.render
.map(|f| {
@ -215,8 +207,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt 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::GstBaseSinkClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSinkClass;
(*parent_class)
.prepare
.map(|f| {
@ -237,8 +228,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt 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::GstBaseSinkClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSinkClass;
(*parent_class)
.render_list
.map(|f| {
@ -264,8 +254,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt 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::GstBaseSinkClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSinkClass;
(*parent_class)
.prepare_list
.map(|f| {
@ -287,8 +276,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
fn parent_query(&self, element: &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::GstBaseSinkClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSinkClass;
(*parent_class)
.query
.map(|f| {
@ -304,8 +292,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
fn parent_event(&self, element: &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::GstBaseSinkClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSinkClass;
(*parent_class)
.event
.map(|f| {
@ -325,8 +312,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
) -> Option<gst::Caps> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseSinkClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSinkClass;
(*parent_class)
.get_caps
@ -347,12 +333,11 @@ impl<T: BaseSinkImpl> BaseSinkImplExt 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::GstBaseSinkClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSinkClass;
(*parent_class)
.set_caps
.map(|f| {
gst_result_from_gboolean!(
gst::gst_result_from_gboolean!(
f(
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
caps.to_glib_none().0
@ -368,8 +353,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
fn parent_fixate(&self, element: &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::GstBaseSinkClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSinkClass;
match (*parent_class).fixate {
Some(fixate) => from_glib_full(fixate(
@ -384,15 +368,14 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
fn parent_unlock(&self, element: &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::GstBaseSinkClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSinkClass;
(*parent_class)
.unlock
.map(|f| {
if from_glib(f(element.unsafe_cast_ref::<BaseSink>().to_glib_none().0)) {
Ok(())
} else {
Err(gst_error_msg!(
Err(gst::gst_error_msg!(
gst::CoreError::Failed,
["Parent function `unlock` failed"]
))
@ -405,15 +388,14 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
fn parent_unlock_stop(&self, element: &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::GstBaseSinkClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSinkClass;
(*parent_class)
.unlock_stop
.map(|f| {
if from_glib(f(element.unsafe_cast_ref::<BaseSink>().to_glib_none().0)) {
Ok(())
} else {
Err(gst_error_msg!(
Err(gst::gst_error_msg!(
gst::CoreError::Failed,
["Parent function `unlock_stop` failed"]
))
@ -448,8 +430,8 @@ where
}
unsafe extern "C" fn base_sink_start<T: BaseSinkImpl>(
ptr: *mut gst_base_sys::GstBaseSink,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseSink,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -457,7 +439,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.start(wrap.unsafe_cast_ref()) {
Ok(()) => true,
Err(err) => {
@ -470,8 +452,8 @@ where
}
unsafe extern "C" fn base_sink_stop<T: BaseSinkImpl>(
ptr: *mut gst_base_sys::GstBaseSink,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseSink,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -479,7 +461,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.stop(wrap.unsafe_cast_ref()) {
Ok(()) => true,
Err(err) => {
@ -492,9 +474,9 @@ where
}
unsafe extern "C" fn base_sink_render<T: BaseSinkImpl>(
ptr: *mut gst_base_sys::GstBaseSink,
buffer: *mut gst_sys::GstBuffer,
) -> gst_sys::GstFlowReturn
ptr: *mut ffi::GstBaseSink,
buffer: *mut gst::ffi::GstBuffer,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -503,16 +485,16 @@ where
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
let buffer = from_glib_borrow(buffer);
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
imp.render(wrap.unsafe_cast_ref(), &buffer).into()
})
.to_glib()
}
unsafe extern "C" fn base_sink_prepare<T: BaseSinkImpl>(
ptr: *mut gst_base_sys::GstBaseSink,
buffer: *mut gst_sys::GstBuffer,
) -> gst_sys::GstFlowReturn
ptr: *mut ffi::GstBaseSink,
buffer: *mut gst::ffi::GstBuffer,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -521,16 +503,16 @@ where
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
let buffer = from_glib_borrow(buffer);
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
imp.prepare(wrap.unsafe_cast_ref(), &buffer).into()
})
.to_glib()
}
unsafe extern "C" fn base_sink_render_list<T: BaseSinkImpl>(
ptr: *mut gst_base_sys::GstBaseSink,
list: *mut gst_sys::GstBufferList,
) -> gst_sys::GstFlowReturn
ptr: *mut ffi::GstBaseSink,
list: *mut gst::ffi::GstBufferList,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -539,16 +521,16 @@ where
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
let list = from_glib_borrow(list);
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
imp.render_list(wrap.unsafe_cast_ref(), &list).into()
})
.to_glib()
}
unsafe extern "C" fn base_sink_prepare_list<T: BaseSinkImpl>(
ptr: *mut gst_base_sys::GstBaseSink,
list: *mut gst_sys::GstBufferList,
) -> gst_sys::GstFlowReturn
ptr: *mut ffi::GstBaseSink,
list: *mut gst::ffi::GstBufferList,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -557,16 +539,16 @@ where
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
let list = from_glib_borrow(list);
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
imp.prepare_list(wrap.unsafe_cast_ref(), &list).into()
})
.to_glib()
}
unsafe extern "C" fn base_sink_query<T: BaseSinkImpl>(
ptr: *mut gst_base_sys::GstBaseSink,
query_ptr: *mut gst_sys::GstQuery,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseSink,
query_ptr: *mut gst::ffi::GstQuery,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -575,16 +557,16 @@ where
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
let query = gst::QueryRef::from_mut_ptr(query_ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
BaseSinkImpl::query(imp, wrap.unsafe_cast_ref(), query)
})
.to_glib()
}
unsafe extern "C" fn base_sink_event<T: BaseSinkImpl>(
ptr: *mut gst_base_sys::GstBaseSink,
event_ptr: *mut gst_sys::GstEvent,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseSink,
event_ptr: *mut gst::ffi::GstEvent,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -592,16 +574,16 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
imp.event(wrap.unsafe_cast_ref(), from_glib_full(event_ptr))
})
.to_glib()
}
unsafe extern "C" fn base_sink_get_caps<T: BaseSinkImpl>(
ptr: *mut gst_base_sys::GstBaseSink,
filter: *mut gst_sys::GstCaps,
) -> *mut gst_sys::GstCaps
ptr: *mut ffi::GstBaseSink,
filter: *mut gst::ffi::GstCaps,
) -> *mut gst::ffi::GstCaps
where
T::Instance: PanicPoison,
{
@ -610,7 +592,7 @@ where
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
let filter = Option::<gst::Caps>::from_glib_borrow(filter);
gst_panic_to_error!(&wrap, &instance.panicked(), None, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), None, {
imp.get_caps(wrap.unsafe_cast_ref(), filter.as_ref().as_ref())
})
.map(|caps| caps.into_ptr())
@ -618,9 +600,9 @@ where
}
unsafe extern "C" fn base_sink_set_caps<T: BaseSinkImpl>(
ptr: *mut gst_base_sys::GstBaseSink,
caps: *mut gst_sys::GstCaps,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseSink,
caps: *mut gst::ffi::GstCaps,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -629,7 +611,7 @@ where
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
let caps = from_glib_borrow(caps);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.set_caps(wrap.unsafe_cast_ref(), &caps) {
Ok(()) => true,
Err(err) => {
@ -642,9 +624,9 @@ where
}
unsafe extern "C" fn base_sink_fixate<T: BaseSinkImpl>(
ptr: *mut gst_base_sys::GstBaseSink,
caps: *mut gst_sys::GstCaps,
) -> *mut gst_sys::GstCaps
ptr: *mut ffi::GstBaseSink,
caps: *mut gst::ffi::GstCaps,
) -> *mut gst::ffi::GstCaps
where
T::Instance: PanicPoison,
{
@ -653,15 +635,15 @@ where
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
let caps = from_glib_full(caps);
gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
imp.fixate(wrap.unsafe_cast_ref(), caps)
})
.into_ptr()
}
unsafe extern "C" fn base_sink_unlock<T: BaseSinkImpl>(
ptr: *mut gst_base_sys::GstBaseSink,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseSink,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -669,7 +651,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.unlock(wrap.unsafe_cast_ref()) {
Ok(()) => true,
Err(err) => {
@ -682,8 +664,8 @@ where
}
unsafe extern "C" fn base_sink_unlock_stop<T: BaseSinkImpl>(
ptr: *mut gst_base_sys::GstBaseSink,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseSink,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -691,7 +673,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.unlock_stop(wrap.unsafe_cast_ref()) {
Ok(()) => true,
Err(err) => {

View file

@ -6,21 +6,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use glib_sys;
use gst_base_sys;
use gst_sys;
use glib::prelude::*;
use glib::subclass::prelude::*;
use glib::translate::*;
use gst;
use gst::subclass::prelude::*;
use std::mem;
use std::ptr;
use BaseSrc;
use crate::BaseSrc;
#[derive(Debug)]
pub enum CreateSuccess {
@ -188,15 +183,14 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
fn parent_start(&self, element: &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::GstBaseSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
(*parent_class)
.start
.map(|f| {
if from_glib(f(element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0)) {
Ok(())
} else {
Err(gst_error_msg!(
Err(gst::gst_error_msg!(
gst::CoreError::StateChange,
["Parent function `start` failed"]
))
@ -209,15 +203,14 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
fn parent_stop(&self, element: &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::GstBaseSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
(*parent_class)
.stop
.map(|f| {
if from_glib(f(element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0)) {
Ok(())
} else {
Err(gst_error_msg!(
Err(gst::gst_error_msg!(
gst::CoreError::StateChange,
["Parent function `stop` failed"]
))
@ -230,8 +223,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
fn parent_is_seekable(&self, element: &Self::Type) -> bool {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
(*parent_class)
.is_seekable
.map(|f| from_glib(f(element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0)))
@ -242,8 +234,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
fn parent_get_size(&self, element: &Self::Type) -> Option<u64> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
(*parent_class)
.get_size
.map(|f| {
@ -268,8 +259,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
) -> (gst::ClockTime, gst::ClockTime) {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
(*parent_class)
.get_times
.map(|f| {
@ -299,8 +289,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt 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::GstBaseSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
(*parent_class)
.fill
.map(|f| {
@ -324,16 +313,15 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
) -> Result<gst::Buffer, gst::FlowError> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
(*parent_class)
.alloc
.map(|f| {
let mut buffer_ptr: *mut gst_sys::GstBuffer = ptr::null_mut();
let mut buffer_ptr: *mut gst::ffi::GstBuffer = ptr::null_mut();
// FIXME: Wrong signature in -sys bindings
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3
let buffer_ref = &mut buffer_ptr as *mut _ as *mut gst_sys::GstBuffer;
let buffer_ref = &mut buffer_ptr as *mut _ as *mut gst::ffi::GstBuffer;
let res = gst::FlowReturn::from_glib(f(
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
@ -356,8 +344,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
) -> Result<CreateSuccess, gst::FlowError> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
(*parent_class)
.create
.map(|f| {
@ -369,7 +356,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
// FIXME: Wrong signature in -sys bindings
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3
let buffer_ref = &mut buffer_ptr as *mut _ as *mut gst_sys::GstBuffer;
let buffer_ref = &mut buffer_ptr as *mut _ as *mut gst::ffi::GstBuffer;
gst::FlowReturn::from_glib(
f(
@ -384,7 +371,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
if buffer_ptr != orig_buffer_ptr {
let new_buffer = gst::BufferRef::from_ptr(buffer_ptr);
gst_debug!(
gst::gst_debug!(
gst::CAT_PERFORMANCE,
obj: element.unsafe_cast_ref::<BaseSrc>(),
"Returned new buffer from parent create function, copying into passed buffer"
@ -393,7 +380,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
let mut map = match passed_buffer.map_writable() {
Ok(map) => map,
Err(_) => {
gst_error!(
gst::gst_error!(
gst::CAT_RUST,
obj: element.unsafe_cast_ref::<BaseSrc>(),
"Failed to map passed buffer writable"
@ -412,7 +399,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
match new_buffer.copy_into(passed_buffer, gst::BUFFER_COPY_METADATA, 0, None) {
Ok(_) => Ok(CreateSuccess::FilledBuffer),
Err(_) => {
gst_error!(
gst::gst_error!(
gst::CAT_RUST,
obj: element.unsafe_cast_ref::<BaseSrc>(),
"Failed to copy buffer metadata"
@ -435,8 +422,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
fn parent_do_seek(&self, element: &Self::Type, segment: &mut gst::Segment) -> bool {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
(*parent_class)
.do_seek
.map(|f| {
@ -452,8 +438,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
fn parent_query(&self, element: &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::GstBaseSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
(*parent_class)
.query
.map(|f| {
@ -469,8 +454,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
fn parent_event(&self, element: &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::GstBaseSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
(*parent_class)
.event
.map(|f| {
@ -490,8 +474,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
) -> Option<gst::Caps> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
(*parent_class)
.get_caps
@ -508,12 +491,11 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
(*parent_class)
.negotiate
.map(|f| {
gst_result_from_gboolean!(
gst::gst_result_from_gboolean!(
f(element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0),
gst::CAT_RUST,
"Parent function `negotiate` failed"
@ -530,12 +512,11 @@ impl<T: BaseSrcImpl> BaseSrcImplExt 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::GstBaseSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
(*parent_class)
.set_caps
.map(|f| {
gst_result_from_gboolean!(
gst::gst_result_from_gboolean!(
f(
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
caps.to_glib_none().0
@ -551,8 +532,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
fn parent_fixate(&self, element: &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::GstBaseSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
match (*parent_class).fixate {
Some(fixate) => from_glib_full(fixate(
@ -567,15 +547,14 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
fn parent_unlock(&self, element: &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::GstBaseSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
(*parent_class)
.unlock
.map(|f| {
if from_glib(f(element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0)) {
Ok(())
} else {
Err(gst_error_msg!(
Err(gst::gst_error_msg!(
gst::CoreError::Failed,
["Parent function `unlock` failed"]
))
@ -588,15 +567,14 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
fn parent_unlock_stop(&self, element: &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::GstBaseSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
(*parent_class)
.unlock_stop
.map(|f| {
if from_glib(f(element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0)) {
Ok(())
} else {
Err(gst_error_msg!(
Err(gst::gst_error_msg!(
gst::CoreError::Failed,
["Parent function `unlock_stop` failed"]
))
@ -635,8 +613,8 @@ where
}
unsafe extern "C" fn base_src_start<T: BaseSrcImpl>(
ptr: *mut gst_base_sys::GstBaseSrc,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseSrc,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -644,7 +622,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.start(wrap.unsafe_cast_ref()) {
Ok(()) => true,
Err(err) => {
@ -656,9 +634,7 @@ where
.to_glib()
}
unsafe extern "C" fn base_src_stop<T: BaseSrcImpl>(
ptr: *mut gst_base_sys::GstBaseSrc,
) -> glib_sys::gboolean
unsafe extern "C" fn base_src_stop<T: BaseSrcImpl>(ptr: *mut ffi::GstBaseSrc) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -666,7 +642,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.stop(wrap.unsafe_cast_ref()) {
Ok(()) => true,
Err(err) => {
@ -679,8 +655,8 @@ where
}
unsafe extern "C" fn base_src_is_seekable<T: BaseSrcImpl>(
ptr: *mut gst_base_sys::GstBaseSrc,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseSrc,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -688,16 +664,16 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
imp.is_seekable(wrap.unsafe_cast_ref())
})
.to_glib()
}
unsafe extern "C" fn base_src_get_size<T: BaseSrcImpl>(
ptr: *mut gst_base_sys::GstBaseSrc,
ptr: *mut ffi::GstBaseSrc,
size: *mut u64,
) -> glib_sys::gboolean
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -705,7 +681,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.get_size(wrap.unsafe_cast_ref()) {
Some(s) => {
*size = s;
@ -718,10 +694,10 @@ where
}
unsafe extern "C" fn base_src_get_times<T: BaseSrcImpl>(
ptr: *mut gst_base_sys::GstBaseSrc,
buffer: *mut gst_sys::GstBuffer,
start: *mut gst_sys::GstClockTime,
stop: *mut gst_sys::GstClockTime,
ptr: *mut ffi::GstBaseSrc,
buffer: *mut gst::ffi::GstBuffer,
start: *mut gst::ffi::GstClockTime,
stop: *mut gst::ffi::GstClockTime,
) where
T::Instance: PanicPoison,
{
@ -730,10 +706,10 @@ unsafe extern "C" fn base_src_get_times<T: BaseSrcImpl>(
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
let buffer = gst::BufferRef::from_ptr(buffer);
*start = gst_sys::GST_CLOCK_TIME_NONE;
*stop = gst_sys::GST_CLOCK_TIME_NONE;
*start = gst::ffi::GST_CLOCK_TIME_NONE;
*stop = gst::ffi::GST_CLOCK_TIME_NONE;
gst_panic_to_error!(&wrap, &instance.panicked(), (), {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), (), {
let (start_, stop_) = imp.get_times(wrap.unsafe_cast_ref(), buffer);
*start = start_.to_glib();
*stop = stop_.to_glib();
@ -741,11 +717,11 @@ unsafe extern "C" fn base_src_get_times<T: BaseSrcImpl>(
}
unsafe extern "C" fn base_src_fill<T: BaseSrcImpl>(
ptr: *mut gst_base_sys::GstBaseSrc,
ptr: *mut ffi::GstBaseSrc,
offset: u64,
length: u32,
buffer: *mut gst_sys::GstBuffer,
) -> gst_sys::GstFlowReturn
buffer: *mut gst::ffi::GstBuffer,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -754,7 +730,7 @@ where
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
let buffer = gst::BufferRef::from_mut_ptr(buffer);
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
imp.fill(wrap.unsafe_cast_ref(), offset, length, buffer)
.into()
})
@ -762,11 +738,11 @@ where
}
unsafe extern "C" fn base_src_alloc<T: BaseSrcImpl>(
ptr: *mut gst_base_sys::GstBaseSrc,
ptr: *mut ffi::GstBaseSrc,
offset: u64,
length: u32,
buffer_ptr: *mut gst_sys::GstBuffer,
) -> gst_sys::GstFlowReturn
buffer_ptr: *mut gst::ffi::GstBuffer,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -775,9 +751,9 @@ where
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
// FIXME: Wrong signature in -sys bindings
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3
let buffer_ptr = buffer_ptr as *mut *mut gst_sys::GstBuffer;
let buffer_ptr = buffer_ptr as *mut *mut gst::ffi::GstBuffer;
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
match imp.alloc(wrap.unsafe_cast_ref(), offset, length) {
Ok(buffer) => {
*buffer_ptr = buffer.into_ptr();
@ -790,11 +766,11 @@ where
}
unsafe extern "C" fn base_src_create<T: BaseSrcImpl>(
ptr: *mut gst_base_sys::GstBaseSrc,
ptr: *mut ffi::GstBaseSrc,
offset: u64,
length: u32,
buffer_ptr: *mut gst_sys::GstBuffer,
) -> gst_sys::GstFlowReturn
buffer_ptr: *mut gst::ffi::GstBuffer,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -803,7 +779,7 @@ where
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
// FIXME: Wrong signature in -sys bindings
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3
let buffer_ptr = buffer_ptr as *mut *mut gst_sys::GstBuffer;
let buffer_ptr = buffer_ptr as *mut *mut gst::ffi::GstBuffer;
let mut buffer = if (*buffer_ptr).is_null() {
None
@ -811,7 +787,7 @@ where
Some(gst::BufferRef::from_mut_ptr(*buffer_ptr))
};
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
match imp.create(
wrap.unsafe_cast_ref(),
offset,
@ -821,7 +797,7 @@ where
Ok(CreateSuccess::NewBuffer(new_buffer)) => {
if let Some(passed_buffer) = buffer {
if passed_buffer.as_ptr() != new_buffer.as_ptr() {
gst_debug!(
gst::gst_debug!(
gst::CAT_PERFORMANCE,
obj: &*wrap,
"Returned new buffer from create function, copying into passed buffer"
@ -830,7 +806,7 @@ where
let mut map = match passed_buffer.map_writable() {
Ok(map) => map,
Err(_) => {
gst_error!(
gst::gst_error!(
gst::CAT_RUST,
obj: &*wrap,
"Failed to map passed buffer writable"
@ -854,7 +830,7 @@ where
) {
Ok(_) => gst::FlowReturn::Ok,
Err(_) => {
gst_error!(
gst::gst_error!(
gst::CAT_RUST,
obj: &*wrap,
"Failed to copy buffer metadata"
@ -879,9 +855,9 @@ where
}
unsafe extern "C" fn base_src_do_seek<T: BaseSrcImpl>(
ptr: *mut gst_base_sys::GstBaseSrc,
segment: *mut gst_sys::GstSegment,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseSrc,
segment: *mut gst::ffi::GstSegment,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -889,7 +865,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
let mut s = from_glib_none(segment);
let res = imp.do_seek(wrap.unsafe_cast_ref(), &mut s);
ptr::write(segment, *(s.to_glib_none().0));
@ -900,9 +876,9 @@ where
}
unsafe extern "C" fn base_src_query<T: BaseSrcImpl>(
ptr: *mut gst_base_sys::GstBaseSrc,
query_ptr: *mut gst_sys::GstQuery,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseSrc,
query_ptr: *mut gst::ffi::GstQuery,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -911,16 +887,16 @@ where
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
let query = gst::QueryRef::from_mut_ptr(query_ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
BaseSrcImpl::query(imp, wrap.unsafe_cast_ref(), query)
})
.to_glib()
}
unsafe extern "C" fn base_src_event<T: BaseSrcImpl>(
ptr: *mut gst_base_sys::GstBaseSrc,
event_ptr: *mut gst_sys::GstEvent,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseSrc,
event_ptr: *mut gst::ffi::GstEvent,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -928,16 +904,16 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
imp.event(wrap.unsafe_cast_ref(), &from_glib_borrow(event_ptr))
})
.to_glib()
}
unsafe extern "C" fn base_src_get_caps<T: BaseSrcImpl>(
ptr: *mut gst_base_sys::GstBaseSrc,
filter: *mut gst_sys::GstCaps,
) -> *mut gst_sys::GstCaps
ptr: *mut ffi::GstBaseSrc,
filter: *mut gst::ffi::GstCaps,
) -> *mut gst::ffi::GstCaps
where
T::Instance: PanicPoison,
{
@ -946,7 +922,7 @@ where
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
let filter = Option::<gst::Caps>::from_glib_borrow(filter);
gst_panic_to_error!(&wrap, &instance.panicked(), None, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), None, {
imp.get_caps(wrap.unsafe_cast_ref(), filter.as_ref().as_ref())
})
.map(|caps| caps.into_ptr())
@ -954,8 +930,8 @@ where
}
unsafe extern "C" fn base_src_negotiate<T: BaseSrcImpl>(
ptr: *mut gst_base_sys::GstBaseSrc,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseSrc,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -963,7 +939,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.negotiate(wrap.unsafe_cast_ref()) {
Ok(()) => true,
Err(err) => {
@ -976,9 +952,9 @@ where
}
unsafe extern "C" fn base_src_set_caps<T: BaseSrcImpl>(
ptr: *mut gst_base_sys::GstBaseSrc,
caps: *mut gst_sys::GstCaps,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseSrc,
caps: *mut gst::ffi::GstCaps,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -987,7 +963,7 @@ where
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
let caps = from_glib_borrow(caps);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.set_caps(wrap.unsafe_cast_ref(), &caps) {
Ok(()) => true,
Err(err) => {
@ -1000,9 +976,9 @@ where
}
unsafe extern "C" fn base_src_fixate<T: BaseSrcImpl>(
ptr: *mut gst_base_sys::GstBaseSrc,
caps: *mut gst_sys::GstCaps,
) -> *mut gst_sys::GstCaps
ptr: *mut ffi::GstBaseSrc,
caps: *mut gst::ffi::GstCaps,
) -> *mut gst::ffi::GstCaps
where
T::Instance: PanicPoison,
{
@ -1011,15 +987,15 @@ where
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
let caps = from_glib_full(caps);
gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
imp.fixate(wrap.unsafe_cast_ref(), caps)
})
.into_ptr()
}
unsafe extern "C" fn base_src_unlock<T: BaseSrcImpl>(
ptr: *mut gst_base_sys::GstBaseSrc,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseSrc,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -1027,7 +1003,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.unlock(wrap.unsafe_cast_ref()) {
Ok(()) => true,
Err(err) => {
@ -1040,8 +1016,8 @@ where
}
unsafe extern "C" fn base_src_unlock_stop<T: BaseSrcImpl>(
ptr: *mut gst_base_sys::GstBaseSrc,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseSrc,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -1049,7 +1025,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.unlock_stop(wrap.unsafe_cast_ref()) {
Ok(()) => true,
Err(err) => {

View file

@ -6,22 +6,17 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use glib_sys;
use gst_base_sys;
use gst_sys;
use prelude::*;
use crate::prelude::*;
use glib::subclass::prelude::*;
use glib::translate::*;
use gst;
use gst::subclass::prelude::*;
use std::mem;
use std::ptr;
use BaseTransform;
use crate::BaseTransform;
pub trait BaseTransformImpl: BaseTransformImplExt + ElementImpl {
fn start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
@ -301,8 +296,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
fn parent_start(&self, element: &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::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
(*parent_class)
.start
.map(|f| {
@ -313,7 +307,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
{
Ok(())
} else {
Err(gst_error_msg!(
Err(gst::gst_error_msg!(
gst::CoreError::StateChange,
["Parent function `start` failed"]
))
@ -326,8 +320,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
fn parent_stop(&self, element: &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::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
(*parent_class)
.stop
.map(|f| {
@ -338,7 +331,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
{
Ok(())
} else {
Err(gst_error_msg!(
Err(gst::gst_error_msg!(
gst::CoreError::StateChange,
["Parent function `stop` failed"]
))
@ -357,8 +350,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
) -> Option<gst::Caps> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
(*parent_class)
.transform_caps
.map(|f| {
@ -382,8 +374,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
) -> gst::Caps {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
match (*parent_class).fixate_caps {
Some(f) => from_glib_full(f(
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
@ -404,12 +395,11 @@ impl<T: BaseTransformImpl> BaseTransformImplExt 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::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
(*parent_class)
.set_caps
.map(|f| {
gst_result_from_gboolean!(
gst::gst_result_from_gboolean!(
f(
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
incaps.to_glib_none().0,
@ -431,8 +421,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
) -> bool {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
(*parent_class)
.accept_caps
.map(|f| {
@ -454,8 +443,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
) -> bool {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
(*parent_class)
.query
.map(|f| {
@ -479,8 +467,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
) -> Option<usize> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
(*parent_class)
.transform_size
.map(|f| {
@ -506,8 +493,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
fn parent_get_unit_size(&self, element: &Self::Type, caps: &gst::Caps) -> Option<usize> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
let f = (*parent_class).get_unit_size.unwrap_or_else(|| {
if !element.unsafe_cast_ref::<BaseTransform>().is_in_place() {
unimplemented!(concat!(
@ -538,8 +524,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
fn parent_sink_event(&self, element: &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::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
(*parent_class)
.sink_event
.map(|f| {
@ -555,8 +540,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
fn parent_src_event(&self, element: &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::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
(*parent_class)
.src_event
.map(|f| {
@ -576,17 +560,16 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
) -> Result<PrepareOutputBufferSuccess, gst::FlowError> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
(*parent_class)
.prepare_output_buffer
.map(|f| {
let mut outbuf: *mut gst_sys::GstBuffer = ptr::null_mut();
let mut outbuf: *mut gst::ffi::GstBuffer = ptr::null_mut();
// FIXME: Wrong signature in FFI
let res = from_glib(f(
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
inbuf.as_ptr() as *mut gst_sys::GstBuffer,
(&mut outbuf) as *mut *mut gst_sys::GstBuffer as *mut gst_sys::GstBuffer,
inbuf.as_ptr() as *mut gst::ffi::GstBuffer,
(&mut outbuf) as *mut *mut gst::ffi::GstBuffer as *mut gst::ffi::GstBuffer,
));
match gst::FlowReturn::into_result(res) {
@ -612,8 +595,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt 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::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
(*parent_class)
.transform
.map(|f| {
@ -644,8 +626,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt 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::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
let f = (*parent_class).transform_ip.unwrap_or_else(|| {
if element.unsafe_cast_ref::<BaseTransform>().is_in_place() {
panic!(concat!(
@ -675,8 +656,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt 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::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
let f = (*parent_class).transform_ip.unwrap_or_else(|| {
if element.unsafe_cast_ref::<BaseTransform>().is_in_place() {
panic!(concat!(
@ -692,7 +672,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
});
// FIXME: Wrong signature in FFI
let buf: *mut gst_sys::GstBuffer = buf.to_glib_none().0;
let buf: *mut gst::ffi::GstBuffer = buf.to_glib_none().0;
gst::FlowReturn::from_glib(f(
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
buf as *mut _,
@ -709,10 +689,9 @@ impl<T: BaseTransformImpl> BaseTransformImplExt 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::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
if let Some(ref f) = (*parent_class).copy_metadata {
gst_result_from_gboolean!(
gst::gst_result_from_gboolean!(
f(
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
inbuf.as_ptr() as *mut _,
@ -736,8 +715,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
) -> bool {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
(*parent_class)
.transform_meta
.map(|f| {
@ -755,8 +733,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
fn parent_before_transform(&self, element: &Self::Type, inbuf: &gst::BufferRef) {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
if let Some(ref f) = (*parent_class).before_transform {
f(
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
@ -774,8 +751,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt 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::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
let f = (*parent_class)
.submit_input_buffer
.expect("Missing parent function `submit_input_buffer`");
@ -795,8 +771,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
) -> Result<GenerateOutputSuccess, gst::FlowError> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseTransformClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
let f = (*parent_class)
.generate_output
.expect("Missing parent function `generate_output`");
@ -808,7 +783,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
))
.into_result()
.map(|res| {
if res == ::BASE_TRANSFORM_FLOW_DROPPED {
if res == crate::BASE_TRANSFORM_FLOW_DROPPED {
GenerateOutputSuccess::Dropped
} else if res != gst::FlowSuccess::Ok || outbuf.is_null() {
GenerateOutputSuccess::NoOutput
@ -826,7 +801,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
{
unsafe {
let element = self.get_instance();
let ptr: *mut gst_base_sys::GstBaseTransform =
let ptr: *mut ffi::GstBaseTransform =
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0;
let sinkpad: Borrowed<gst::Pad> = from_glib_borrow((*ptr).sinkpad);
let _stream_lock = sinkpad.stream_lock();
@ -843,7 +818,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
{
unsafe {
let element = self.get_instance();
let ptr: *mut gst_base_sys::GstBaseTransform =
let ptr: *mut ffi::GstBaseTransform =
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0;
let sinkpad: Borrowed<gst::Pad> = from_glib_borrow((*ptr).sinkpad);
let _stream_lock = sinkpad.stream_lock();
@ -898,7 +873,7 @@ pub unsafe trait BaseTransformClassSubclassExt: Sized + 'static {
<T as ObjectSubclass>::Instance: PanicPoison,
{
unsafe {
let klass = &mut *(self as *mut Self as *mut gst_base_sys::GstBaseTransformClass);
let klass = &mut *(self as *mut Self as *mut ffi::GstBaseTransformClass);
klass.passthrough_on_same_caps = passthrough_on_same_caps.to_glib();
klass.transform_ip_on_passthrough = transform_ip_on_passthrough.to_glib();
@ -942,8 +917,8 @@ pub enum PrepareOutputBufferSuccess {
}
unsafe extern "C" fn base_transform_start<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseTransform,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -951,7 +926,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.start(wrap.unsafe_cast_ref()) {
Ok(()) => true,
Err(err) => {
@ -964,8 +939,8 @@ where
}
unsafe extern "C" fn base_transform_stop<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseTransform,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -973,7 +948,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.stop(wrap.unsafe_cast_ref()) {
Ok(()) => true,
Err(err) => {
@ -986,11 +961,11 @@ where
}
unsafe extern "C" fn base_transform_transform_caps<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
direction: gst_sys::GstPadDirection,
caps: *mut gst_sys::GstCaps,
filter: *mut gst_sys::GstCaps,
) -> *mut gst_sys::GstCaps
ptr: *mut ffi::GstBaseTransform,
direction: gst::ffi::GstPadDirection,
caps: *mut gst::ffi::GstCaps,
filter: *mut gst::ffi::GstCaps,
) -> *mut gst::ffi::GstCaps
where
T::Instance: PanicPoison,
{
@ -998,7 +973,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), None, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), None, {
let filter: Borrowed<Option<gst::Caps>> = from_glib_borrow(filter);
imp.transform_caps(
@ -1013,11 +988,11 @@ where
}
unsafe extern "C" fn base_transform_fixate_caps<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
direction: gst_sys::GstPadDirection,
caps: *mut gst_sys::GstCaps,
othercaps: *mut gst_sys::GstCaps,
) -> *mut gst_sys::GstCaps
ptr: *mut ffi::GstBaseTransform,
direction: gst::ffi::GstPadDirection,
caps: *mut gst::ffi::GstCaps,
othercaps: *mut gst::ffi::GstCaps,
) -> *mut gst::ffi::GstCaps
where
T::Instance: PanicPoison,
{
@ -1025,7 +1000,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
imp.fixate_caps(
wrap.unsafe_cast_ref(),
from_glib(direction),
@ -1037,10 +1012,10 @@ where
}
unsafe extern "C" fn base_transform_set_caps<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
incaps: *mut gst_sys::GstCaps,
outcaps: *mut gst_sys::GstCaps,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseTransform,
incaps: *mut gst::ffi::GstCaps,
outcaps: *mut gst::ffi::GstCaps,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -1048,7 +1023,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.set_caps(
wrap.unsafe_cast_ref(),
&from_glib_borrow(incaps),
@ -1065,10 +1040,10 @@ where
}
unsafe extern "C" fn base_transform_accept_caps<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
direction: gst_sys::GstPadDirection,
caps: *mut gst_sys::GstCaps,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseTransform,
direction: gst::ffi::GstPadDirection,
caps: *mut gst::ffi::GstCaps,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -1076,7 +1051,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
imp.accept_caps(
wrap.unsafe_cast_ref(),
from_glib(direction),
@ -1087,10 +1062,10 @@ where
}
unsafe extern "C" fn base_transform_query<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
direction: gst_sys::GstPadDirection,
query: *mut gst_sys::GstQuery,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseTransform,
direction: gst::ffi::GstPadDirection,
query: *mut gst::ffi::GstQuery,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -1098,7 +1073,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
BaseTransformImpl::query(
imp,
wrap.unsafe_cast_ref(),
@ -1110,13 +1085,13 @@ where
}
unsafe extern "C" fn base_transform_transform_size<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
direction: gst_sys::GstPadDirection,
caps: *mut gst_sys::GstCaps,
ptr: *mut ffi::GstBaseTransform,
direction: gst::ffi::GstPadDirection,
caps: *mut gst::ffi::GstCaps,
size: usize,
othercaps: *mut gst_sys::GstCaps,
othercaps: *mut gst::ffi::GstCaps,
othersize: *mut usize,
) -> glib_sys::gboolean
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -1124,7 +1099,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.transform_size(
wrap.unsafe_cast_ref(),
from_glib(direction),
@ -1143,10 +1118,10 @@ where
}
unsafe extern "C" fn base_transform_get_unit_size<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
caps: *mut gst_sys::GstCaps,
ptr: *mut ffi::GstBaseTransform,
caps: *mut gst::ffi::GstCaps,
size: *mut usize,
) -> glib_sys::gboolean
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -1154,7 +1129,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
match imp.get_unit_size(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) {
Some(s) => {
*size = s;
@ -1167,10 +1142,10 @@ where
}
unsafe extern "C" fn base_transform_prepare_output_buffer<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
inbuf: *mut gst_sys::GstBuffer,
outbuf: *mut gst_sys::GstBuffer,
) -> gst_sys::GstFlowReturn
ptr: *mut ffi::GstBaseTransform,
inbuf: *mut gst::ffi::GstBuffer,
outbuf: *mut gst::ffi::GstBuffer,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -1179,9 +1154,9 @@ where
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
// FIXME: Wrong signature in FFI
let outbuf = outbuf as *mut *mut gst_sys::GstBuffer;
let outbuf = outbuf as *mut *mut gst::ffi::GstBuffer;
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
match imp.prepare_output_buffer(wrap.unsafe_cast_ref(), gst::BufferRef::from_ptr(inbuf)) {
Ok(PrepareOutputBufferSuccess::InputBuffer) => {
*outbuf = inbuf;
@ -1198,9 +1173,9 @@ where
}
unsafe extern "C" fn base_transform_sink_event<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
event: *mut gst_sys::GstEvent,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseTransform,
event: *mut gst::ffi::GstEvent,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -1208,16 +1183,16 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
imp.sink_event(wrap.unsafe_cast_ref(), from_glib_full(event))
})
.to_glib()
}
unsafe extern "C" fn base_transform_src_event<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
event: *mut gst_sys::GstEvent,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseTransform,
event: *mut gst::ffi::GstEvent,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -1225,17 +1200,17 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event))
})
.to_glib()
}
unsafe extern "C" fn base_transform_transform<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
inbuf: *mut gst_sys::GstBuffer,
outbuf: *mut gst_sys::GstBuffer,
) -> gst_sys::GstFlowReturn
ptr: *mut ffi::GstBaseTransform,
inbuf: *mut gst::ffi::GstBuffer,
outbuf: *mut gst::ffi::GstBuffer,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -1243,7 +1218,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
imp.transform(
wrap.unsafe_cast_ref(),
&from_glib_borrow(inbuf),
@ -1255,9 +1230,9 @@ where
}
unsafe extern "C" fn base_transform_transform_ip<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
buf: *mut *mut gst_sys::GstBuffer,
) -> gst_sys::GstFlowReturn
ptr: *mut ffi::GstBaseTransform,
buf: *mut *mut gst::ffi::GstBuffer,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -1266,10 +1241,10 @@ where
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
// FIXME: Wrong signature in FFI
let buf = buf as *mut gst_sys::GstBuffer;
let buf = buf as *mut gst::ffi::GstBuffer;
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
if from_glib(gst_base_sys::gst_base_transform_is_passthrough(ptr)) {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
if from_glib(ffi::gst_base_transform_is_passthrough(ptr)) {
imp.transform_ip_passthrough(wrap.unsafe_cast_ref(), &from_glib_borrow(buf))
.into()
} else {
@ -1281,11 +1256,11 @@ where
}
unsafe extern "C" fn base_transform_transform_meta<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
outbuf: *mut gst_sys::GstBuffer,
meta: *mut gst_sys::GstMeta,
inbuf: *mut gst_sys::GstBuffer,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseTransform,
outbuf: *mut gst::ffi::GstBuffer,
meta: *mut gst::ffi::GstMeta,
inbuf: *mut gst::ffi::GstBuffer,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -1295,7 +1270,7 @@ where
let inbuf = gst::BufferRef::from_ptr(inbuf);
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), false, {
imp.transform_meta(
wrap.unsafe_cast_ref(),
gst::BufferRef::from_mut_ptr(outbuf),
@ -1307,10 +1282,10 @@ where
}
unsafe extern "C" fn base_transform_copy_metadata<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
inbuf: *mut gst_sys::GstBuffer,
outbuf: *mut gst_sys::GstBuffer,
) -> glib_sys::gboolean
ptr: *mut ffi::GstBaseTransform,
inbuf: *mut gst::ffi::GstBuffer,
outbuf: *mut gst::ffi::GstBuffer,
) -> glib::ffi::gboolean
where
T::Instance: PanicPoison,
{
@ -1318,17 +1293,17 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
if gst_sys::gst_mini_object_is_writable(outbuf as *mut _) == glib_sys::GFALSE {
gst_warning!(
if gst::ffi::gst_mini_object_is_writable(outbuf as *mut _) == glib::ffi::GFALSE {
gst::gst_warning!(
gst::CAT_RUST,
obj: &*wrap,
"buffer {:?} not writable",
outbuf
);
return glib_sys::GFALSE;
return glib::ffi::GFALSE;
}
gst_panic_to_error!(&wrap, &instance.panicked(), true, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), true, {
match imp.copy_metadata(
wrap.unsafe_cast_ref(),
gst::BufferRef::from_ptr(inbuf),
@ -1345,8 +1320,8 @@ where
}
unsafe extern "C" fn base_transform_before_transform<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
inbuf: *mut gst_sys::GstBuffer,
ptr: *mut ffi::GstBaseTransform,
inbuf: *mut gst::ffi::GstBuffer,
) where
T::Instance: PanicPoison,
{
@ -1354,16 +1329,16 @@ unsafe extern "C" fn base_transform_before_transform<T: BaseTransformImpl>(
let imp = instance.get_impl();
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), (), {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), (), {
imp.before_transform(wrap.unsafe_cast_ref(), gst::BufferRef::from_ptr(inbuf));
})
}
unsafe extern "C" fn base_transform_submit_input_buffer<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
is_discont: glib_sys::gboolean,
buf: *mut gst_sys::GstBuffer,
) -> gst_sys::GstFlowReturn
ptr: *mut ffi::GstBaseTransform,
is_discont: glib::ffi::gboolean,
buf: *mut gst::ffi::GstBuffer,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -1371,7 +1346,7 @@ where
let imp = instance.get_impl();
let wrap: Borrowed<BaseTransform> = from_glib_borrow(ptr);
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
imp.submit_input_buffer(
wrap.unsafe_cast_ref(),
from_glib(is_discont),
@ -1383,9 +1358,9 @@ where
}
unsafe extern "C" fn base_transform_generate_output<T: BaseTransformImpl>(
ptr: *mut gst_base_sys::GstBaseTransform,
buf: *mut *mut gst_sys::GstBuffer,
) -> gst_sys::GstFlowReturn
ptr: *mut ffi::GstBaseTransform,
buf: *mut *mut gst::ffi::GstBuffer,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -1395,9 +1370,9 @@ where
*buf = ptr::null_mut();
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
match imp.generate_output(wrap.unsafe_cast_ref()) {
Ok(GenerateOutputSuccess::Dropped) => ::BASE_TRANSFORM_FLOW_DROPPED.into(),
Ok(GenerateOutputSuccess::Dropped) => crate::BASE_TRANSFORM_FLOW_DROPPED.into(),
Ok(GenerateOutputSuccess::NoOutput) => gst::FlowReturn::Ok,
Ok(GenerateOutputSuccess::Buffer(outbuf)) => {
*buf = outbuf.into_ptr();

View file

@ -6,20 +6,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use gst_base_sys;
use gst_sys;
use glib::prelude::*;
use glib::subclass::prelude::*;
use glib::translate::*;
use gst;
use gst::subclass::prelude::*;
use std::ptr;
use super::base_src::BaseSrcImpl;
use PushSrc;
use crate::PushSrc;
pub trait PushSrcImpl: PushSrcImplExt + BaseSrcImpl {
fn fill(
@ -59,8 +55,7 @@ impl<T: PushSrcImpl> PushSrcImplExt 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::GstPushSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstPushSrcClass;
(*parent_class)
.fill
.map(|f| {
@ -77,16 +72,15 @@ impl<T: PushSrcImpl> PushSrcImplExt for T {
fn parent_alloc(&self, element: &Self::Type) -> Result<gst::Buffer, gst::FlowError> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstPushSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstPushSrcClass;
(*parent_class)
.alloc
.map(|f| {
let mut buffer_ptr: *mut gst_sys::GstBuffer = ptr::null_mut();
let mut buffer_ptr: *mut gst::ffi::GstBuffer = ptr::null_mut();
// FIXME: Wrong signature in -sys bindings
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3
let buffer_ref = &mut buffer_ptr as *mut _ as *mut gst_sys::GstBuffer;
let buffer_ref = &mut buffer_ptr as *mut _ as *mut gst::ffi::GstBuffer;
let res = gst::FlowReturn::from_glib(f(
element.unsafe_cast_ref::<PushSrc>().to_glib_none().0,
@ -101,16 +95,15 @@ impl<T: PushSrcImpl> PushSrcImplExt for T {
fn parent_create(&self, element: &Self::Type) -> Result<gst::Buffer, gst::FlowError> {
unsafe {
let data = T::type_data();
let parent_class =
data.as_ref().get_parent_class() as *mut gst_base_sys::GstPushSrcClass;
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstPushSrcClass;
(*parent_class)
.create
.map(|f| {
let mut buffer_ptr: *mut gst_sys::GstBuffer = ptr::null_mut();
let mut buffer_ptr: *mut gst::ffi::GstBuffer = ptr::null_mut();
// FIXME: Wrong signature in -sys bindings
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3
let buffer_ref = &mut buffer_ptr as *mut _ as *mut gst_sys::GstBuffer;
let buffer_ref = &mut buffer_ptr as *mut _ as *mut gst::ffi::GstBuffer;
let res = gst::FlowReturn::from_glib(f(
element.unsafe_cast_ref::<PushSrc>().to_glib_none().0,
@ -128,7 +121,7 @@ where
<T as ObjectSubclass>::Instance: PanicPoison,
{
fn override_vfuncs(klass: &mut glib::Class<Self>) {
<::BaseSrc as IsSubclassable<T>>::override_vfuncs(klass);
<crate::BaseSrc as IsSubclassable<T>>::override_vfuncs(klass);
let klass = klass.as_mut();
klass.fill = Some(push_src_fill::<T>);
klass.alloc = Some(push_src_alloc::<T>);
@ -137,9 +130,9 @@ where
}
unsafe extern "C" fn push_src_fill<T: PushSrcImpl>(
ptr: *mut gst_base_sys::GstPushSrc,
buffer: *mut gst_sys::GstBuffer,
) -> gst_sys::GstFlowReturn
ptr: *mut ffi::GstPushSrc,
buffer: *mut gst::ffi::GstBuffer,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -148,16 +141,16 @@ where
let wrap: Borrowed<PushSrc> = from_glib_borrow(ptr);
let buffer = gst::BufferRef::from_mut_ptr(buffer);
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
PushSrcImpl::fill(imp, wrap.unsafe_cast_ref(), buffer).into()
})
.to_glib()
}
unsafe extern "C" fn push_src_alloc<T: PushSrcImpl>(
ptr: *mut gst_base_sys::GstPushSrc,
buffer_ptr: *mut gst_sys::GstBuffer,
) -> gst_sys::GstFlowReturn
ptr: *mut ffi::GstPushSrc,
buffer_ptr: *mut gst::ffi::GstBuffer,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -166,9 +159,9 @@ where
let wrap: Borrowed<PushSrc> = from_glib_borrow(ptr);
// FIXME: Wrong signature in -sys bindings
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3
let buffer_ptr = buffer_ptr as *mut *mut gst_sys::GstBuffer;
let buffer_ptr = buffer_ptr as *mut *mut gst::ffi::GstBuffer;
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
match PushSrcImpl::alloc(imp, wrap.unsafe_cast_ref()) {
Ok(buffer) => {
*buffer_ptr = buffer.into_ptr();
@ -181,9 +174,9 @@ where
}
unsafe extern "C" fn push_src_create<T: PushSrcImpl>(
ptr: *mut gst_base_sys::GstPushSrc,
buffer_ptr: *mut gst_sys::GstBuffer,
) -> gst_sys::GstFlowReturn
ptr: *mut ffi::GstPushSrc,
buffer_ptr: *mut gst::ffi::GstBuffer,
) -> gst::ffi::GstFlowReturn
where
T::Instance: PanicPoison,
{
@ -192,9 +185,9 @@ where
let wrap: Borrowed<PushSrc> = from_glib_borrow(ptr);
// FIXME: Wrong signature in -sys bindings
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3
let buffer_ptr = buffer_ptr as *mut *mut gst_sys::GstBuffer;
let buffer_ptr = buffer_ptr as *mut *mut gst::ffi::GstBuffer;
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
gst::gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
match PushSrcImpl::create(imp, wrap.unsafe_cast_ref()) {
Ok(buffer) => {
*buffer_ptr = buffer.into_ptr();

View file

@ -7,17 +7,16 @@
// except according to those terms.
use glib::translate::mut_override;
use glib_sys;
#[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 {
skip_assert_initialized!();
unsafe {
glib_sys::g_mutex_lock(mut_override(mutex));
glib::ffi::g_mutex_lock(mut_override(mutex));
}
MutexGuard(mutex)
}
@ -26,7 +25,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));
}
}
}