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: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1274>
This commit is contained in:
Sebastian Dröge 2023-06-06 14:06:41 +03:00
parent 545781d241
commit 24a00b9929
3 changed files with 18 additions and 12 deletions

View file

@ -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"

View file

@ -40,10 +40,6 @@ pub trait DiscovererStreamInfoExt: 'static {
#[must_use]
fn previous(&self) -> Option<DiscovererStreamInfo>;
#[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<O: IsA<DiscovererStreamInfo>> 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 {

View file

@ -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 {}