diff --git a/Gir_Gst.toml b/Gir_Gst.toml index fd886b769..5d8c16ca2 100644 --- a/Gir_Gst.toml +++ b/Gir_Gst.toml @@ -512,6 +512,11 @@ manual_traits = ["ElementExtManual"] # manual implementation also works for earlier versions ignore = true + [[object.function]] + name = "post_message" + # takes ownership of message + ignore = true + [[object.function]] name = "add_pad" [object.function.return] diff --git a/gstreamer-audio/src/subclass/audio_decoder.rs b/gstreamer-audio/src/subclass/audio_decoder.rs index e30ab1b0a..5e6be2c95 100644 --- a/gstreamer-audio/src/subclass/audio_decoder.rs +++ b/gstreamer-audio/src/subclass/audio_decoder.rs @@ -554,7 +554,7 @@ where match imp.open(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -577,7 +577,7 @@ where match imp.close(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -600,7 +600,7 @@ where match imp.start(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -623,7 +623,7 @@ where match imp.stop(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -890,7 +890,7 @@ where match imp.propose_allocation(&wrap, query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -915,7 +915,7 @@ where match imp.decide_allocation(&wrap, query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } diff --git a/gstreamer-audio/src/subclass/audio_encoder.rs b/gstreamer-audio/src/subclass/audio_encoder.rs index 5e8a28ac4..5ed7dc0b1 100644 --- a/gstreamer-audio/src/subclass/audio_encoder.rs +++ b/gstreamer-audio/src/subclass/audio_encoder.rs @@ -502,7 +502,7 @@ where match imp.open(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -525,7 +525,7 @@ where match imp.close(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -548,7 +548,7 @@ where match imp.start(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -571,7 +571,7 @@ where match imp.stop(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -807,7 +807,7 @@ where match imp.propose_allocation(&wrap, query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -832,7 +832,7 @@ where match imp.decide_allocation(&wrap, query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } diff --git a/gstreamer-base/src/subclass/aggregator.rs b/gstreamer-base/src/subclass/aggregator.rs index 9a7b185cf..e779aad7f 100644 --- a/gstreamer-base/src/subclass/aggregator.rs +++ b/gstreamer-base/src/subclass/aggregator.rs @@ -888,7 +888,7 @@ where match imp.start(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -911,7 +911,7 @@ where match imp.stop(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } diff --git a/gstreamer-base/src/subclass/base_parse.rs b/gstreamer-base/src/subclass/base_parse.rs index d932cffd0..abc6c16a5 100644 --- a/gstreamer-base/src/subclass/base_parse.rs +++ b/gstreamer-base/src/subclass/base_parse.rs @@ -247,7 +247,7 @@ where match imp.start(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -270,7 +270,7 @@ where match imp.stop(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -295,7 +295,7 @@ where match imp.set_sink_caps(&wrap, &caps) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } diff --git a/gstreamer-base/src/subclass/base_sink.rs b/gstreamer-base/src/subclass/base_sink.rs index 7dc2ea4c0..134830458 100644 --- a/gstreamer-base/src/subclass/base_sink.rs +++ b/gstreamer-base/src/subclass/base_sink.rs @@ -421,7 +421,7 @@ where match imp.start(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -444,7 +444,7 @@ where match imp.stop(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -644,7 +644,7 @@ where match imp.unlock(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -667,7 +667,7 @@ where match imp.unlock_stop(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } diff --git a/gstreamer-base/src/subclass/base_src.rs b/gstreamer-base/src/subclass/base_src.rs index 5f212f6d0..195acc98e 100644 --- a/gstreamer-base/src/subclass/base_src.rs +++ b/gstreamer-base/src/subclass/base_src.rs @@ -614,7 +614,7 @@ where match imp.start(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -637,7 +637,7 @@ where match imp.stop(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -1006,7 +1006,7 @@ where match imp.unlock(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -1029,7 +1029,7 @@ where match imp.unlock_stop(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } diff --git a/gstreamer-base/src/subclass/base_transform.rs b/gstreamer-base/src/subclass/base_transform.rs index f9f068ad9..1de1b2a3d 100644 --- a/gstreamer-base/src/subclass/base_transform.rs +++ b/gstreamer-base/src/subclass/base_transform.rs @@ -923,7 +923,7 @@ where match imp.start(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -946,7 +946,7 @@ where match imp.stop(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } diff --git a/gstreamer-video/src/subclass/video_decoder.rs b/gstreamer-video/src/subclass/video_decoder.rs index 5d8d436c0..76cb77354 100644 --- a/gstreamer-video/src/subclass/video_decoder.rs +++ b/gstreamer-video/src/subclass/video_decoder.rs @@ -544,7 +544,7 @@ where match imp.open(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -567,7 +567,7 @@ where match imp.close(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -590,7 +590,7 @@ where match imp.start(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -613,7 +613,7 @@ where match imp.stop(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -877,7 +877,7 @@ where match imp.propose_allocation(&wrap, query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -902,7 +902,7 @@ where match imp.decide_allocation(&wrap, query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } diff --git a/gstreamer-video/src/subclass/video_encoder.rs b/gstreamer-video/src/subclass/video_encoder.rs index 849633657..0d8a0c85a 100644 --- a/gstreamer-video/src/subclass/video_encoder.rs +++ b/gstreamer-video/src/subclass/video_encoder.rs @@ -478,7 +478,7 @@ where match imp.open(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -501,7 +501,7 @@ where match imp.close(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -524,7 +524,7 @@ where match imp.start(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -547,7 +547,7 @@ where match imp.stop(&wrap) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -770,7 +770,7 @@ where match imp.propose_allocation(&wrap, query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } @@ -795,7 +795,7 @@ where match imp.decide_allocation(&wrap, query) { Ok(()) => true, Err(err) => { - wrap.post_error_message(&err); + wrap.post_error_message(err); false } } diff --git a/gstreamer/src/auto/element.rs b/gstreamer/src/auto/element.rs index 884d28adc..374f3f7ad 100644 --- a/gstreamer/src/auto/element.rs +++ b/gstreamer/src/auto/element.rs @@ -19,7 +19,6 @@ use Clock; use ClockTime; use Context; use ElementFactory; -use Message; use Object; use Pad; use PadLinkCheck; @@ -151,8 +150,6 @@ pub trait ElementExt: 'static { fn no_more_pads(&self); - fn post_message(&self, message: &Message) -> Result<(), glib::error::BoolError>; - fn provide_clock(&self) -> Option; fn release_request_pad>(&self, pad: &P); @@ -524,18 +521,6 @@ impl> ElementExt for O { } } - fn post_message(&self, message: &Message) -> Result<(), glib::error::BoolError> { - unsafe { - glib_result_from_gboolean!( - gst_sys::gst_element_post_message( - self.as_ref().to_glib_none().0, - message.to_glib_full() - ), - "Failed to post message" - ) - } - } - fn provide_clock(&self) -> Option { unsafe { from_glib_full(gst_sys::gst_element_provide_clock( diff --git a/gstreamer/src/element.rs b/gstreamer/src/element.rs index 7f2e6d20c..bc9d9ded4 100644 --- a/gstreamer/src/element.rs +++ b/gstreamer/src/element.rs @@ -189,7 +189,8 @@ pub trait ElementExtManual: 'static { structure: ::Structure, ); - fn post_error_message(&self, msg: &::ErrorMessage); + fn post_message(&self, message: ::Message) -> Result<(), glib::error::BoolError>; + fn post_error_message(&self, msg: ::ErrorMessage); fn iterate_pads(&self) -> ::Iterator; fn iterate_sink_pads(&self) -> ::Iterator; @@ -454,7 +455,19 @@ impl> ElementExtManual for O { } } - fn post_error_message(&self, msg: &::ErrorMessage) { + fn post_message(&self, message: ::Message) -> Result<(), glib::error::BoolError> { + unsafe { + glib_result_from_gboolean!( + gst_sys::gst_element_post_message( + self.as_ref().to_glib_none().0, + message.into_ptr() + ), + "Failed to post message" + ) + } + } + + fn post_error_message(&self, msg: ::ErrorMessage) { let ::ErrorMessage { error_domain, error_code, @@ -463,7 +476,7 @@ impl> ElementExtManual for O { filename, function, line, - } = *msg; + } = msg; unsafe { gst_sys::gst_element_message_full( diff --git a/gstreamer/src/subclass/error.rs b/gstreamer/src/subclass/error.rs index 1653b8be8..b660b3605 100644 --- a/gstreamer/src/subclass/error.rs +++ b/gstreamer/src/subclass/error.rs @@ -21,7 +21,7 @@ macro_rules! gst_panic_to_error( #[allow(clippy::unused_unit)] { if $panicked.load(Ordering::Relaxed) { - $element.post_error_message(&gst_error_msg!($crate::LibraryError::Failed, ["Panicked"])); + $element.post_error_message(gst_error_msg!($crate::LibraryError::Failed, ["Panicked"])); $ret } else { let result = panic::catch_unwind(AssertUnwindSafe(|| $code)); @@ -31,11 +31,11 @@ macro_rules! gst_panic_to_error( Err(err) => { $panicked.store(true, Ordering::Relaxed); if let Some(cause) = err.downcast_ref::<&str>() { - $element.post_error_message(&gst_error_msg!($crate::LibraryError::Failed, ["Panicked: {}", cause])); + $element.post_error_message(gst_error_msg!($crate::LibraryError::Failed, ["Panicked: {}", cause])); } else if let Some(cause) = err.downcast_ref::() { - $element.post_error_message(&gst_error_msg!($crate::LibraryError::Failed, ["Panicked: {}", cause])); + $element.post_error_message(gst_error_msg!($crate::LibraryError::Failed, ["Panicked: {}", cause])); } else { - $element.post_error_message(&gst_error_msg!($crate::LibraryError::Failed, ["Panicked"])); + $element.post_error_message(gst_error_msg!($crate::LibraryError::Failed, ["Panicked"])); } $ret } diff --git a/tutorials/src/bin/basic-tutorial-5.rs b/tutorials/src/bin/basic-tutorial-5.rs index fe2053c76..5595b883b 100644 --- a/tutorials/src/bin/basic-tutorial-5.rs +++ b/tutorials/src/bin/basic-tutorial-5.rs @@ -303,7 +303,7 @@ mod tutorial5 { // We are possibly in a GStreamer working thread, so we notify the main // thread of this event through a message in the bus fn post_app_message(playbin: &gst::Element) { - let _ = playbin.post_message(&gst::message::Application::new(gst::Structure::new_empty( + let _ = playbin.post_message(gst::message::Application::new(gst::Structure::new_empty( "tags-changed", ))); }