mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 17:41:05 +00:00
gstreamer-base: update signatures to Result<(), ErrorMessage>
See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/175
This commit is contained in:
parent
5d1a839558
commit
c65214b207
4 changed files with 166 additions and 44 deletions
|
@ -88,11 +88,11 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
||||||
timeout: bool,
|
timeout: bool,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||||
|
|
||||||
fn start(&self, aggregator: &Aggregator) -> bool {
|
fn start(&self, aggregator: &Aggregator) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_start(aggregator)
|
self.parent_start(aggregator)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stop(&self, aggregator: &Aggregator) -> bool {
|
fn stop(&self, aggregator: &Aggregator) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_stop(aggregator)
|
self.parent_stop(aggregator)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,25 +287,45 @@ pub trait AggregatorImpl: ElementImpl + Send + Sync + 'static {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_start(&self, aggregator: &Aggregator) -> bool {
|
fn parent_start(&self, aggregator: &Aggregator) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = self.get_type_data();
|
let data = self.get_type_data();
|
||||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||||
(*parent_class)
|
let f = (*parent_class).start.ok_or_else(|| {
|
||||||
.start
|
gst_error_msg!(
|
||||||
.map(|f| from_glib(f(aggregator.to_glib_none().0)))
|
gst::CoreError::Failed,
|
||||||
.unwrap_or(false)
|
["Parent function `start` is not defined"]
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
if from_glib(f(aggregator.to_glib_none().0)) {
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(gst_error_msg!(
|
||||||
|
gst::CoreError::Failed,
|
||||||
|
["Parent function `start` failed"]
|
||||||
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_stop(&self, aggregator: &Aggregator) -> bool {
|
fn parent_stop(&self, aggregator: &Aggregator) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = self.get_type_data();
|
let data = self.get_type_data();
|
||||||
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
let parent_class = data.as_ref().get_parent_class() as *mut ffi::GstAggregatorClass;
|
||||||
(*parent_class)
|
let f = (*parent_class).stop.ok_or_else(|| {
|
||||||
.stop
|
gst_error_msg!(
|
||||||
.map(|f| from_glib(f(aggregator.to_glib_none().0)))
|
gst::CoreError::Failed,
|
||||||
.unwrap_or(false)
|
["Parent function `stop` is not defined"]
|
||||||
|
)
|
||||||
|
})?;
|
||||||
|
if from_glib(f(aggregator.to_glib_none().0)) {
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(gst_error_msg!(
|
||||||
|
gst::CoreError::Failed,
|
||||||
|
["Parent function `stop` failed"]
|
||||||
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -635,7 +655,16 @@ where
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: Aggregator = from_glib_borrow(ptr);
|
let wrap: Aggregator = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.start(&wrap) }).to_glib()
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
|
match imp.start(&wrap) {
|
||||||
|
Ok(()) => true,
|
||||||
|
Err(err) => {
|
||||||
|
wrap.post_error_message(&err);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn aggregator_stop<T: ObjectSubclass>(
|
unsafe extern "C" fn aggregator_stop<T: ObjectSubclass>(
|
||||||
|
@ -650,7 +679,16 @@ where
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: Aggregator = from_glib_borrow(ptr);
|
let wrap: Aggregator = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.stop(&wrap) }).to_glib()
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
|
match imp.stop(&wrap) {
|
||||||
|
Ok(()) => true,
|
||||||
|
Err(err) => {
|
||||||
|
wrap.post_error_message(&err);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn aggregator_get_next_time<T: ObjectSubclass>(
|
unsafe extern "C" fn aggregator_get_next_time<T: ObjectSubclass>(
|
||||||
|
|
|
@ -23,12 +23,12 @@ use BaseSink;
|
||||||
use BaseSinkClass;
|
use BaseSinkClass;
|
||||||
|
|
||||||
pub trait BaseSinkImpl: ElementImpl + Send + Sync + 'static {
|
pub trait BaseSinkImpl: ElementImpl + Send + Sync + 'static {
|
||||||
fn start(&self, _element: &BaseSink) -> bool {
|
fn start(&self, _element: &BaseSink) -> Result<(), gst::ErrorMessage> {
|
||||||
true
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stop(&self, _element: &BaseSink) -> bool {
|
fn stop(&self, _element: &BaseSink) -> Result<(), gst::ErrorMessage> {
|
||||||
true
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render(
|
fn render(
|
||||||
|
@ -87,12 +87,12 @@ pub trait BaseSinkImpl: ElementImpl + Send + Sync + 'static {
|
||||||
self.parent_fixate(element, caps)
|
self.parent_fixate(element, caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unlock(&self, _element: &BaseSink) -> bool {
|
fn unlock(&self, _element: &BaseSink) -> Result<(), gst::ErrorMessage> {
|
||||||
true
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unlock_stop(&self, _element: &BaseSink) -> bool {
|
fn unlock_stop(&self, _element: &BaseSink) -> Result<(), gst::ErrorMessage> {
|
||||||
true
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_query(&self, element: &BaseSink, query: &mut gst::QueryRef) -> bool {
|
fn parent_query(&self, element: &BaseSink, query: &mut gst::QueryRef) -> bool {
|
||||||
|
@ -207,7 +207,16 @@ where
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: BaseSink = from_glib_borrow(ptr);
|
let wrap: BaseSink = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.start(&wrap) }).to_glib()
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
|
match imp.start(&wrap) {
|
||||||
|
Ok(()) => true,
|
||||||
|
Err(err) => {
|
||||||
|
wrap.post_error_message(&err);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn base_sink_stop<T: ObjectSubclass>(
|
unsafe extern "C" fn base_sink_stop<T: ObjectSubclass>(
|
||||||
|
@ -222,7 +231,16 @@ where
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: BaseSink = from_glib_borrow(ptr);
|
let wrap: BaseSink = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.stop(&wrap) }).to_glib()
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
|
match imp.stop(&wrap) {
|
||||||
|
Ok(()) => true,
|
||||||
|
Err(err) => {
|
||||||
|
wrap.post_error_message(&err);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn base_sink_render<T: ObjectSubclass>(
|
unsafe extern "C" fn base_sink_render<T: ObjectSubclass>(
|
||||||
|
@ -427,7 +445,16 @@ where
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: BaseSink = from_glib_borrow(ptr);
|
let wrap: BaseSink = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.unlock(&wrap) }).to_glib()
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
|
match imp.unlock(&wrap) {
|
||||||
|
Ok(()) => true,
|
||||||
|
Err(err) => {
|
||||||
|
wrap.post_error_message(&err);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn base_sink_unlock_stop<T: ObjectSubclass>(
|
unsafe extern "C" fn base_sink_unlock_stop<T: ObjectSubclass>(
|
||||||
|
@ -443,7 +470,13 @@ where
|
||||||
let wrap: BaseSink = from_glib_borrow(ptr);
|
let wrap: BaseSink = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
imp.unlock_stop(&wrap)
|
match imp.unlock_stop(&wrap) {
|
||||||
|
Ok(()) => true,
|
||||||
|
Err(err) => {
|
||||||
|
wrap.post_error_message(&err);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,12 +23,12 @@ use BaseSrc;
|
||||||
use BaseSrcClass;
|
use BaseSrcClass;
|
||||||
|
|
||||||
pub trait BaseSrcImpl: ElementImpl + Send + Sync + 'static {
|
pub trait BaseSrcImpl: ElementImpl + Send + Sync + 'static {
|
||||||
fn start(&self, _element: &BaseSrc) -> bool {
|
fn start(&self, _element: &BaseSrc) -> Result<(), gst::ErrorMessage> {
|
||||||
true
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stop(&self, _element: &BaseSrc) -> bool {
|
fn stop(&self, _element: &BaseSrc) -> Result<(), gst::ErrorMessage> {
|
||||||
true
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_seekable(&self, _element: &BaseSrc) -> bool {
|
fn is_seekable(&self, _element: &BaseSrc) -> bool {
|
||||||
|
@ -86,12 +86,12 @@ pub trait BaseSrcImpl: ElementImpl + Send + Sync + 'static {
|
||||||
self.parent_fixate(element, caps)
|
self.parent_fixate(element, caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unlock(&self, _element: &BaseSrc) -> bool {
|
fn unlock(&self, _element: &BaseSrc) -> Result<(), gst::ErrorMessage> {
|
||||||
true
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unlock_stop(&self, _element: &BaseSrc) -> bool {
|
fn unlock_stop(&self, _element: &BaseSrc) -> Result<(), gst::ErrorMessage> {
|
||||||
true
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_create(
|
fn parent_create(
|
||||||
|
@ -259,7 +259,16 @@ where
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: BaseSrc = from_glib_borrow(ptr);
|
let wrap: BaseSrc = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.start(&wrap) }).to_glib()
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
|
match imp.start(&wrap) {
|
||||||
|
Ok(()) => true,
|
||||||
|
Err(err) => {
|
||||||
|
wrap.post_error_message(&err);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn base_src_stop<T: ObjectSubclass>(
|
unsafe extern "C" fn base_src_stop<T: ObjectSubclass>(
|
||||||
|
@ -274,7 +283,16 @@ where
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: BaseSrc = from_glib_borrow(ptr);
|
let wrap: BaseSrc = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.stop(&wrap) }).to_glib()
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
|
match imp.stop(&wrap) {
|
||||||
|
Ok(()) => true,
|
||||||
|
Err(err) => {
|
||||||
|
wrap.post_error_message(&err);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn base_src_is_seekable<T: ObjectSubclass>(
|
unsafe extern "C" fn base_src_is_seekable<T: ObjectSubclass>(
|
||||||
|
@ -537,7 +555,16 @@ where
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: BaseSrc = from_glib_borrow(ptr);
|
let wrap: BaseSrc = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.unlock(&wrap) }).to_glib()
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
|
match imp.unlock(&wrap) {
|
||||||
|
Ok(()) => true,
|
||||||
|
Err(err) => {
|
||||||
|
wrap.post_error_message(&err);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn base_src_unlock_stop<T: ObjectSubclass>(
|
unsafe extern "C" fn base_src_unlock_stop<T: ObjectSubclass>(
|
||||||
|
@ -553,7 +580,13 @@ where
|
||||||
let wrap: BaseSrc = from_glib_borrow(ptr);
|
let wrap: BaseSrc = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
imp.unlock_stop(&wrap)
|
match imp.unlock_stop(&wrap) {
|
||||||
|
Ok(()) => true,
|
||||||
|
Err(err) => {
|
||||||
|
wrap.post_error_message(&err);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,12 +21,12 @@ use BaseTransform;
|
||||||
use BaseTransformClass;
|
use BaseTransformClass;
|
||||||
|
|
||||||
pub trait BaseTransformImpl: ElementImpl + Send + Sync + 'static {
|
pub trait BaseTransformImpl: ElementImpl + Send + Sync + 'static {
|
||||||
fn start(&self, _element: &BaseTransform) -> bool {
|
fn start(&self, _element: &BaseTransform) -> Result<(), gst::ErrorMessage> {
|
||||||
true
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stop(&self, _element: &BaseTransform) -> bool {
|
fn stop(&self, _element: &BaseTransform) -> Result<(), gst::ErrorMessage> {
|
||||||
true
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn transform_caps(
|
fn transform_caps(
|
||||||
|
@ -349,7 +349,16 @@ where
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: BaseTransform = from_glib_borrow(ptr);
|
let wrap: BaseTransform = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.start(&wrap) }).to_glib()
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
|
match imp.start(&wrap) {
|
||||||
|
Ok(()) => true,
|
||||||
|
Err(err) => {
|
||||||
|
wrap.post_error_message(&err);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn base_transform_stop<T: ObjectSubclass>(
|
unsafe extern "C" fn base_transform_stop<T: ObjectSubclass>(
|
||||||
|
@ -364,7 +373,16 @@ where
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: BaseTransform = from_glib_borrow(ptr);
|
let wrap: BaseTransform = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, { imp.stop(&wrap) }).to_glib()
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
|
match imp.stop(&wrap) {
|
||||||
|
Ok(()) => true,
|
||||||
|
Err(err) => {
|
||||||
|
wrap.post_error_message(&err);
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn base_transform_transform_caps<T: ObjectSubclass>(
|
unsafe extern "C" fn base_transform_transform_caps<T: ObjectSubclass>(
|
||||||
|
|
Loading…
Reference in a new issue