From 9a8ca0cadd820ba2b2ef2db7438b4b1eeb186838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 6 Apr 2022 09:51:37 +0300 Subject: [PATCH] gstreamer: Add bindings for the new 1.22 selectable query --- gstreamer/src/query.rs | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/gstreamer/src/query.rs b/gstreamer/src/query.rs index faed360f3..6ad150949 100644 --- a/gstreamer/src/query.rs +++ b/gstreamer/src/query.rs @@ -78,6 +78,8 @@ impl QueryRef { ffi::GST_QUERY_CONTEXT => Context::view(self), #[cfg(any(feature = "v1_16", feature = "dox"))] ffi::GST_QUERY_BITRATE => Bitrate::view(self), + #[cfg(any(feature = "v1_22", feature = "dox"))] + ffi::GST_QUERY_SELECTABLE => Selectable::view(self), _ => Other::view(self), } } @@ -106,6 +108,8 @@ impl QueryRef { ffi::GST_QUERY_CONTEXT => Context::view_mut(self), #[cfg(any(feature = "v1_16", feature = "dox"))] ffi::GST_QUERY_BITRATE => Bitrate::view_mut(self), + #[cfg(any(feature = "v1_22", feature = "dox"))] + ffi::GST_QUERY_SELECTABLE => Selectable::view_mut(self), _ => Other::view_mut(self), } } @@ -153,6 +157,9 @@ pub enum QueryView<'a> { #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] Bitrate(&'a Bitrate), + #[cfg(any(feature = "v1_22", feature = "dox"))] + #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))] + Selectable(&'a Selectable), Other(&'a Other), } @@ -178,6 +185,9 @@ pub enum QueryViewMut<'a> { #[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_16")))] Bitrate(&'a mut Bitrate), + #[cfg(any(feature = "v1_22", feature = "dox"))] + #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))] + Selectable(&'a mut Selectable), Other(&'a mut Other), } @@ -1558,6 +1568,49 @@ impl Bitrate { } } +#[cfg(any(feature = "v1_22", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))] +declare_concrete_query!(Selectable, T); + +#[cfg(any(feature = "v1_22", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))] +impl Selectable { + #[doc(alias = "gst_query_new_selectable")] + pub fn new() -> Self { + assert_initialized_main_thread!(); + unsafe { Self(from_glib_full(ffi::gst_query_new_selectable())) } + } +} + +#[cfg(any(feature = "v1_22", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))] +impl Default for Selectable { + fn default() -> Self { + Self::new() + } +} + +#[cfg(any(feature = "v1_22", feature = "dox"))] +#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))] +impl Selectable { + #[doc(alias = "get_selectable")] + #[doc(alias = "gst_query_parse_selectable")] + pub fn selectable(&self) -> bool { + unsafe { + let mut selectable = mem::MaybeUninit::uninit(); + ffi::gst_query_parse_selectable(self.as_mut_ptr(), selectable.as_mut_ptr()); + from_glib(selectable.assume_init()) + } + } + + #[doc(alias = "gst_query_set_selectable")] + pub fn set_selectable(&mut self, selectable: bool) { + unsafe { + ffi::gst_query_set_selectable(self.as_mut_ptr(), selectable.into_glib()); + } + } +} + declare_concrete_query!(Other, T); #[cfg(test)]