forked from mirrors/gstreamer-rs
parent
56c00d9250
commit
ac00608b7e
4 changed files with 148 additions and 152 deletions
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2017,2018 Sebastian Dröge <sebastian@centricular.com>
|
||||
// Copyright (C) 2017-2019 Sebastian Dröge <sebastian@centricular.com>
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
|
@ -170,10 +170,10 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||
(*parent_class)
|
||||
let f = (*parent_class)
|
||||
.finish_buffer
|
||||
.map(|f| from_glib(f(aggregator.to_glib_none().0, buffer.into_ptr())))
|
||||
.unwrap_or(gst::FlowReturn::Ok)
|
||||
.expect("Missing parent function `finish_buffer`");
|
||||
gst::FlowReturn::from_glib(f(aggregator.to_glib_none().0, buffer.into_ptr()))
|
||||
.into_result()
|
||||
}
|
||||
}
|
||||
|
@ -187,16 +187,14 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||
(*parent_class)
|
||||
let f = (*parent_class)
|
||||
.sink_event
|
||||
.map(|f| {
|
||||
.expect("Missing parent function `sink_event`");
|
||||
from_glib(f(
|
||||
aggregator.to_glib_none().0,
|
||||
aggregator_pad.to_glib_none().0,
|
||||
event.into_ptr(),
|
||||
))
|
||||
})
|
||||
.unwrap_or(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,16 +207,14 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||
(*parent_class)
|
||||
let f = (*parent_class)
|
||||
.sink_query
|
||||
.map(|f| {
|
||||
.expect("Missing parent function `sink_query`");
|
||||
from_glib(f(
|
||||
aggregator.to_glib_none().0,
|
||||
aggregator_pad.to_glib_none().0,
|
||||
query.as_mut_ptr(),
|
||||
))
|
||||
})
|
||||
.unwrap_or(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -226,10 +222,10 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||
(*parent_class)
|
||||
let f = (*parent_class)
|
||||
.src_event
|
||||
.map(|f| from_glib(f(aggregator.to_glib_none().0, event.into_ptr())))
|
||||
.unwrap_or(false)
|
||||
.expect("Missing parent function `src_event`");
|
||||
from_glib(f(aggregator.to_glib_none().0, event.into_ptr()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,10 +233,10 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||
(*parent_class)
|
||||
let f = (*parent_class)
|
||||
.src_query
|
||||
.map(|f| from_glib(f(aggregator.to_glib_none().0, query.as_mut_ptr())))
|
||||
.unwrap_or(false)
|
||||
.expect("Missing parent function `src_query`");
|
||||
from_glib(f(aggregator.to_glib_none().0, query.as_mut_ptr()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,13 +249,9 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||
let f = (*parent_class).src_activate.ok_or_else(|| {
|
||||
gst_loggable_error!(
|
||||
gst::CAT_RUST,
|
||||
"Parent function `src_activate` is not defined"
|
||||
)
|
||||
})?;
|
||||
gst_result_from_gboolean!(
|
||||
match (*parent_class).src_activate {
|
||||
None => Ok(()),
|
||||
Some(f) => gst_result_from_gboolean!(
|
||||
f(
|
||||
aggregator.to_glib_none().0,
|
||||
mode.to_glib(),
|
||||
|
@ -267,7 +259,8 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `src_activate` failed"
|
||||
)
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,10 +272,10 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||
(*parent_class)
|
||||
let f = (*parent_class)
|
||||
.aggregate
|
||||
.map(|f| from_glib(f(aggregator.to_glib_none().0, timeout.to_glib())))
|
||||
.unwrap_or(gst::FlowReturn::Error)
|
||||
.expect("Missing parent function `aggregate`");
|
||||
gst::FlowReturn::from_glib(f(aggregator.to_glib_none().0, timeout.to_glib()))
|
||||
.into_result()
|
||||
}
|
||||
}
|
||||
|
@ -291,12 +284,9 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||
let f = (*parent_class).start.ok_or_else(|| {
|
||||
gst_error_msg!(
|
||||
gst::CoreError::Failed,
|
||||
["Parent function `start` is not defined"]
|
||||
)
|
||||
})?;
|
||||
(*parent_class)
|
||||
.start
|
||||
.map(|f| {
|
||||
if from_glib(f(aggregator.to_glib_none().0)) {
|
||||
Ok(())
|
||||
} else {
|
||||
|
@ -305,6 +295,8 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
["Parent function `start` failed"]
|
||||
))
|
||||
}
|
||||
})
|
||||
.unwrap_or(Ok(()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,12 +304,9 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||
let f = (*parent_class).stop.ok_or_else(|| {
|
||||
gst_error_msg!(
|
||||
gst::CoreError::Failed,
|
||||
["Parent function `stop` is not defined"]
|
||||
)
|
||||
})?;
|
||||
(*parent_class)
|
||||
.stop
|
||||
.map(|f| {
|
||||
if from_glib(f(aggregator.to_glib_none().0)) {
|
||||
Ok(())
|
||||
} else {
|
||||
|
@ -326,6 +315,8 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
["Parent function `stop` failed"]
|
||||
))
|
||||
}
|
||||
})
|
||||
.unwrap_or(Ok(()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,17 +341,15 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||
(*parent_class)
|
||||
let f = (*parent_class)
|
||||
.create_new_pad
|
||||
.map(|f| {
|
||||
.expect("Missing parent function `create_new_pad`");
|
||||
from_glib_full(f(
|
||||
aggregator.to_glib_none().0,
|
||||
templ.to_glib_none().0,
|
||||
req_name.to_glib_none().0,
|
||||
caps.map(|c| c.as_ptr()).unwrap_or(ptr::null()),
|
||||
))
|
||||
})
|
||||
.unwrap_or(None)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -372,18 +361,17 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||
(*parent_class)
|
||||
let f = (*parent_class)
|
||||
.update_src_caps
|
||||
.map(|f| {
|
||||
.expect("Missing parent function `update_src_caps`");
|
||||
|
||||
let mut out_caps = ptr::null_mut();
|
||||
let flow_ret: gst::FlowReturn = from_glib(f(
|
||||
gst::FlowReturn::from_glib(f(
|
||||
aggregator.to_glib_none().0,
|
||||
caps.as_mut_ptr(),
|
||||
&mut out_caps,
|
||||
));
|
||||
flow_ret.into_result_value(|| from_glib_full(out_caps))
|
||||
})
|
||||
.unwrap_or(Err(gst::FlowError::Error))
|
||||
))
|
||||
.into_result_value(|| from_glib_full(out_caps))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -392,10 +380,10 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||
|
||||
match (*parent_class).fixate_src_caps {
|
||||
Some(ref f) => from_glib_full(f(aggregator.to_glib_none().0, caps.into_ptr())),
|
||||
None => caps,
|
||||
}
|
||||
let f = (*parent_class)
|
||||
.fixate_src_caps
|
||||
.expect("Missing parent function `fixate_src_caps`");
|
||||
from_glib_full(f(aggregator.to_glib_none().0, caps.into_ptr()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -407,17 +395,16 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||
let f = (*parent_class).negotiated_src_caps.ok_or_else(|| {
|
||||
gst_loggable_error!(
|
||||
gst::CAT_RUST,
|
||||
"Parent function `negotiated_src_caps` is not defined"
|
||||
)
|
||||
})?;
|
||||
(*parent_class)
|
||||
.negotiated_src_caps
|
||||
.map(|f| {
|
||||
gst_result_from_gboolean!(
|
||||
f(aggregator.to_glib_none().0, caps.as_mut_ptr()),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `negotiated_src_caps` failed"
|
||||
)
|
||||
})
|
||||
.unwrap_or(Ok(()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2017,2018 Sebastian Dröge <sebastian@centricular.com>
|
||||
// Copyright (C) 2017-2019 Sebastian Dröge <sebastian@centricular.com>
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
|
@ -113,7 +113,7 @@ pub trait BaseSinkImpl: ElementImpl + Send + Sync + 'static {
|
|||
(*parent_class)
|
||||
.event
|
||||
.map(|f| from_glib(f(element.to_glib_none().0, event.into_ptr())))
|
||||
.unwrap_or(false)
|
||||
.unwrap_or(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,14 +146,16 @@ pub trait BaseSinkImpl: ElementImpl + Send + Sync + 'static {
|
|||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSinkClass;
|
||||
let f = (*parent_class).set_caps.ok_or_else(|| {
|
||||
gst_loggable_error!(gst::CAT_RUST, "Parent function `set_caps` is not defined")
|
||||
})?;
|
||||
(*parent_class)
|
||||
.set_caps
|
||||
.map(|f| {
|
||||
gst_result_from_gboolean!(
|
||||
f(element.to_glib_none().0, caps.as_mut_ptr()),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `set_caps` failed"
|
||||
)
|
||||
})
|
||||
.unwrap_or(Ok(()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2017,2018 Sebastian Dröge <sebastian@centricular.com>
|
||||
// Copyright (C) 2017-2019 Sebastian Dröge <sebastian@centricular.com>
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
|
@ -115,7 +115,7 @@ pub trait BaseSrcImpl: ElementImpl + Send + Sync + 'static {
|
|||
|
||||
ret.into_result_value(|| from_glib_full(buffer))
|
||||
})
|
||||
.unwrap_or(Err(gst::FlowError::Error))
|
||||
.unwrap_or(Err(gst::FlowError::NotSupported))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,14 +177,16 @@ pub trait BaseSrcImpl: ElementImpl + Send + Sync + 'static {
|
|||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
|
||||
let f = (*parent_class).negotiate.ok_or_else(|| {
|
||||
gst_loggable_error!(gst::CAT_RUST, "Parent function `negotiate` is not defined")
|
||||
})?;
|
||||
(*parent_class)
|
||||
.negotiate
|
||||
.map(|f| {
|
||||
gst_result_from_gboolean!(
|
||||
f(element.to_glib_none().0),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `negotiate` failed"
|
||||
)
|
||||
})
|
||||
.unwrap_or(Ok(()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,14 +198,16 @@ pub trait BaseSrcImpl: ElementImpl + Send + Sync + 'static {
|
|||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
|
||||
let f = (*parent_class).set_caps.ok_or_else(|| {
|
||||
gst_loggable_error!(gst::CAT_RUST, "Parent function `set_caps` is not defined")
|
||||
})?;
|
||||
(*parent_class)
|
||||
.set_caps
|
||||
.map(|f| {
|
||||
gst_result_from_gboolean!(
|
||||
f(element.to_glib_none().0, caps.as_mut_ptr()),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `set_caps` failed"
|
||||
)
|
||||
})
|
||||
.unwrap_or(Ok(()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (C) 2017,2018 Sebastian Dröge <sebastian@centricular.com>
|
||||
// Copyright (C) 2017-2019 Sebastian Dröge <sebastian@centricular.com>
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
|
@ -35,7 +35,7 @@ pub trait BaseTransformImpl: ElementImpl + Send + Sync + 'static {
|
|||
direction: gst::PadDirection,
|
||||
caps: &gst::Caps,
|
||||
filter: Option<&gst::Caps>,
|
||||
) -> gst::Caps {
|
||||
) -> Option<gst::Caps> {
|
||||
self.parent_transform_caps(element, direction, caps, filter)
|
||||
}
|
||||
|
||||
|
@ -130,19 +130,21 @@ pub trait BaseTransformImpl: ElementImpl + Send + Sync + 'static {
|
|||
direction: gst::PadDirection,
|
||||
caps: &gst::Caps,
|
||||
filter: Option<&gst::Caps>,
|
||||
) -> gst::Caps {
|
||||
) -> Option<gst::Caps> {
|
||||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseTransformClass;
|
||||
match (*parent_class).transform_caps {
|
||||
Some(f) => from_glib_full(f(
|
||||
(*parent_class)
|
||||
.transform_caps
|
||||
.map(|f| {
|
||||
from_glib_full(f(
|
||||
element.to_glib_none().0,
|
||||
direction.to_glib(),
|
||||
caps.to_glib_none().0,
|
||||
filter.to_glib_none().0,
|
||||
)),
|
||||
None => caps.clone(),
|
||||
}
|
||||
))
|
||||
})
|
||||
.unwrap_or(None)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -252,7 +254,7 @@ pub trait BaseTransformImpl: ElementImpl + Send + Sync + 'static {
|
|||
(*parent_class)
|
||||
.sink_event
|
||||
.map(|f| from_glib(f(element.to_glib_none().0, event.into_ptr())))
|
||||
.unwrap_or(false)
|
||||
.unwrap_or(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,7 +265,7 @@ pub trait BaseTransformImpl: ElementImpl + Send + Sync + 'static {
|
|||
(*parent_class)
|
||||
.src_event
|
||||
.map(|f| from_glib(f(element.to_glib_none().0, event.into_ptr())))
|
||||
.unwrap_or(false)
|
||||
.unwrap_or(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -400,7 +402,7 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: BaseTransform = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), None, {
|
||||
let filter = if filter.is_null() {
|
||||
None
|
||||
} else {
|
||||
|
@ -414,7 +416,8 @@ where
|
|||
filter.as_ref(),
|
||||
)
|
||||
})
|
||||
.into_ptr()
|
||||
.map(|caps| caps.into_ptr())
|
||||
.unwrap_or(std::ptr::null_mut())
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_transform_fixate_caps<T: ObjectSubclass>(
|
||||
|
|
Loading…
Reference in a new issue