From 24a00b9929b2a11ee90cc373d894fe8b9673fcaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 6 Jun 2023 14:06:41 +0300 Subject: [PATCH] pbutils: Manually implement `DiscovererStreamInfo::stream_id()` It can return `NULL` in some cases. The next release will use an `Option` but to keep backwards compatibility here, `NULL` is mapped to the empty string for now. Part-of: --- gstreamer-pbutils/Gir.toml | 4 ++++ .../src/auto/discoverer_stream_info.rs | 12 ------------ gstreamer-pbutils/src/discoverer_stream_info.rs | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/gstreamer-pbutils/Gir.toml b/gstreamer-pbutils/Gir.toml index bd5383d77..dd510f957 100644 --- a/gstreamer-pbutils/Gir.toml +++ b/gstreamer-pbutils/Gir.toml @@ -279,6 +279,10 @@ final_type = false name = "list_free" ignore = true + [[object.function]] + name = "get_stream_id" + manual = true + [[object]] name = "GstPbutils.DiscovererSubtitleInfo" status = "generate" diff --git a/gstreamer-pbutils/src/auto/discoverer_stream_info.rs b/gstreamer-pbutils/src/auto/discoverer_stream_info.rs index 2c26aa57c..f234c8929 100644 --- a/gstreamer-pbutils/src/auto/discoverer_stream_info.rs +++ b/gstreamer-pbutils/src/auto/discoverer_stream_info.rs @@ -40,10 +40,6 @@ pub trait DiscovererStreamInfoExt: 'static { #[must_use] fn previous(&self) -> Option; - #[doc(alias = "gst_discoverer_stream_info_get_stream_id")] - #[doc(alias = "get_stream_id")] - fn stream_id(&self) -> glib::GString; - #[cfg(any(feature = "v1_20", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] #[doc(alias = "gst_discoverer_stream_info_get_stream_number")] @@ -96,14 +92,6 @@ impl> DiscovererStreamInfoExt for O { } } - fn stream_id(&self) -> glib::GString { - unsafe { - from_glib_none(ffi::gst_discoverer_stream_info_get_stream_id( - self.as_ref().to_glib_none().0, - )) - } - } - #[cfg(any(feature = "v1_20", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))] fn stream_number(&self) -> i32 { diff --git a/gstreamer-pbutils/src/discoverer_stream_info.rs b/gstreamer-pbutils/src/discoverer_stream_info.rs index 8f83fa3ba..756e35725 100644 --- a/gstreamer-pbutils/src/discoverer_stream_info.rs +++ b/gstreamer-pbutils/src/discoverer_stream_info.rs @@ -1,5 +1,7 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use glib::translate::*; + use crate::{prelude::*, DiscovererStreamInfo}; #[derive(Debug)] @@ -42,6 +44,18 @@ impl DiscovererStreamInfo { direction_forward: false, } } + + fn stream_id(&self) -> glib::GString { + unsafe { + let ptr = ffi::gst_discoverer_stream_info_get_stream_id(self.as_ref().to_glib_none().0); + + if ptr.is_null() { + glib::GString::new() + } else { + from_glib_none(ptr) + } + } + } } impl std::iter::FusedIterator for Iter {}