mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 19:11:06 +00:00
gstreamer-base: update signatures to Result<(), LoggableError>
See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/175
This commit is contained in:
parent
2b2c3bbade
commit
5d1a839558
3 changed files with 119 additions and 41 deletions
|
@ -73,7 +73,12 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
self.parent_src_query(aggregator, query)
|
||||
}
|
||||
|
||||
fn src_activate(&self, aggregator: &Aggregator, mode: gst::PadMode, active: bool) -> bool {
|
||||
fn src_activate(
|
||||
&self,
|
||||
aggregator: &Aggregator,
|
||||
mode: gst::PadMode,
|
||||
active: bool,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_src_activate(aggregator, mode, active)
|
||||
}
|
||||
|
||||
|
@ -117,7 +122,11 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
self.parent_fixate_src_caps(aggregator, caps)
|
||||
}
|
||||
|
||||
fn negotiated_src_caps(&self, aggregator: &Aggregator, caps: &gst::CapsRef) -> bool {
|
||||
fn negotiated_src_caps(
|
||||
&self,
|
||||
aggregator: &Aggregator,
|
||||
caps: &gst::CapsRef,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_negotiated_src_caps(aggregator, caps)
|
||||
}
|
||||
|
||||
|
@ -240,20 +249,25 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
aggregator: &Aggregator,
|
||||
mode: gst::PadMode,
|
||||
active: bool,
|
||||
) -> bool {
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||
(*parent_class)
|
||||
.src_activate
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
aggregator.to_glib_none().0,
|
||||
mode.to_glib(),
|
||||
active.to_glib(),
|
||||
))
|
||||
})
|
||||
.unwrap_or(false)
|
||||
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!(
|
||||
f(
|
||||
aggregator.to_glib_none().0,
|
||||
mode.to_glib(),
|
||||
active.to_glib()
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `src_activate` failed"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,14 +379,25 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_negotiated_src_caps(&self, aggregator: &Aggregator, caps: &gst::CapsRef) -> bool {
|
||||
fn parent_negotiated_src_caps(
|
||||
&self,
|
||||
aggregator: &Aggregator,
|
||||
caps: &gst::CapsRef,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||
(*parent_class)
|
||||
.negotiated_src_caps
|
||||
.map(|f| from_glib(f(aggregator.to_glib_none().0, caps.as_mut_ptr())))
|
||||
.unwrap_or(false)
|
||||
let f = (*parent_class).negotiated_src_caps.ok_or_else(|| {
|
||||
gst_loggable_error!(
|
||||
gst::CAT_RUST,
|
||||
"Parent function `negotiated_src_caps` is not defined"
|
||||
)
|
||||
})?;
|
||||
gst_result_from_gboolean!(
|
||||
f(aggregator.to_glib_none().0, caps.as_mut_ptr()),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `negotiated_src_caps` failed"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -568,7 +593,13 @@ where
|
|||
let wrap: Aggregator = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
imp.src_activate(&wrap, from_glib(mode), from_glib(active))
|
||||
match imp.src_activate(&wrap, from_glib(mode), from_glib(active)) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&wrap);
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
@ -743,7 +774,13 @@ where
|
|||
let wrap: Aggregator = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
imp.negotiated_src_caps(&wrap, gst::CapsRef::from_ptr(caps))
|
||||
match imp.negotiated_src_caps(&wrap, gst::CapsRef::from_ptr(caps)) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&wrap);
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ pub trait BaseSinkImpl: ElementImpl + Send + Sync + 'static {
|
|||
self.parent_get_caps(element, filter)
|
||||
}
|
||||
|
||||
fn set_caps(&self, element: &BaseSink, caps: &gst::CapsRef) -> bool {
|
||||
fn set_caps(&self, element: &BaseSink, caps: &gst::CapsRef) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_caps(element, caps)
|
||||
}
|
||||
|
||||
|
@ -138,14 +138,22 @@ pub trait BaseSinkImpl: ElementImpl + Send + Sync + 'static {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_set_caps(&self, element: &BaseSink, caps: &gst::CapsRef) -> bool {
|
||||
fn parent_set_caps(
|
||||
&self,
|
||||
element: &BaseSink,
|
||||
caps: &gst::CapsRef,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSinkClass;
|
||||
(*parent_class)
|
||||
.set_caps
|
||||
.map(|f| from_glib(f(element.to_glib_none().0, caps.as_mut_ptr())))
|
||||
.unwrap_or(true)
|
||||
let f = (*parent_class).set_caps.ok_or_else(|| {
|
||||
gst_loggable_error!(gst::CAT_RUST, "Parent function `set_caps` is not defined")
|
||||
})?;
|
||||
gst_result_from_gboolean!(
|
||||
f(element.to_glib_none().0, caps.as_mut_ptr()),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `set_caps` failed"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -376,7 +384,13 @@ where
|
|||
let caps = gst::CapsRef::from_ptr(caps);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
imp.set_caps(&wrap, caps)
|
||||
match imp.set_caps(&wrap, caps) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&wrap);
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
|
|
@ -74,11 +74,11 @@ pub trait BaseSrcImpl: ElementImpl + Send + Sync + 'static {
|
|||
self.parent_get_caps(element, filter)
|
||||
}
|
||||
|
||||
fn negotiate(&self, element: &BaseSrc) -> bool {
|
||||
fn negotiate(&self, element: &BaseSrc) -> Result<(), gst::LoggableError> {
|
||||
self.parent_negotiate(element)
|
||||
}
|
||||
|
||||
fn set_caps(&self, element: &BaseSrc, caps: &gst::CapsRef) -> bool {
|
||||
fn set_caps(&self, element: &BaseSrc, caps: &gst::CapsRef) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_caps(element, caps)
|
||||
}
|
||||
|
||||
|
@ -173,25 +173,37 @@ pub trait BaseSrcImpl: ElementImpl + Send + Sync + 'static {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_negotiate(&self, element: &BaseSrc) -> bool {
|
||||
fn parent_negotiate(&self, element: &BaseSrc) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
|
||||
(*parent_class)
|
||||
.negotiate
|
||||
.map(|f| from_glib(f(element.to_glib_none().0)))
|
||||
.unwrap_or(false)
|
||||
let f = (*parent_class).negotiate.ok_or_else(|| {
|
||||
gst_loggable_error!(gst::CAT_RUST, "Parent function `negotiate` is not defined")
|
||||
})?;
|
||||
gst_result_from_gboolean!(
|
||||
f(element.to_glib_none().0),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `negotiate` failed"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_set_caps(&self, element: &BaseSrc, caps: &gst::CapsRef) -> bool {
|
||||
fn parent_set_caps(
|
||||
&self,
|
||||
element: &BaseSrc,
|
||||
caps: &gst::CapsRef,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = self.get_type_data();
|
||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstBaseSrcClass;
|
||||
(*parent_class)
|
||||
.set_caps
|
||||
.map(|f| from_glib(f(element.to_glib_none().0, caps.as_mut_ptr())))
|
||||
.unwrap_or(true)
|
||||
let f = (*parent_class).set_caps.ok_or_else(|| {
|
||||
gst_loggable_error!(gst::CAT_RUST, "Parent function `set_caps` is not defined")
|
||||
})?;
|
||||
gst_result_from_gboolean!(
|
||||
f(element.to_glib_none().0, caps.as_mut_ptr()),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `set_caps` failed"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -455,7 +467,16 @@ where
|
|||
let imp = instance.get_impl();
|
||||
let wrap: BaseSrc = from_glib_borrow(ptr);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.negotiate(&wrap) }).to_glib()
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
match imp.negotiate(&wrap) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&wrap);
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_src_set_caps<T: ObjectSubclass>(
|
||||
|
@ -473,7 +494,13 @@ where
|
|||
let caps = gst::CapsRef::from_ptr(caps);
|
||||
|
||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||
imp.set_caps(&wrap, caps)
|
||||
match imp.set_caps(&wrap, caps) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&wrap);
|
||||
false
|
||||
}
|
||||
}
|
||||
})
|
||||
.to_glib()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue