gstreamer-rs/gstreamer-tag/src/tags.rs
Bilal Elmoussaoui 4ebec84f5e Adapt to no longer renamed ffi crates
Allows us to set all the crates in the main workspace file, so changing
their versions or branch is much simpler and reduce the amount of noise
in the diff

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1450>
2024-06-02 11:20:55 +02:00

38 lines
1.1 KiB
Rust

use gst::glib::translate::*;
use std::ptr;
pub struct ExtendedComment {
pub key: Option<glib::GString>,
pub lang: Option<glib::GString>,
pub value: glib::GString,
}
#[doc(alias = "gst_tag_parse_extended_comment")]
pub fn tag_parse_extended_comment(
ext_comment: &str,
fail_if_no_key: bool,
) -> Result<ExtendedComment, gst::glib::BoolError> {
skip_assert_initialized!();
unsafe {
let mut c_key = ptr::null_mut();
let mut c_lang = ptr::null_mut();
let mut c_value = ptr::null_mut();
let res: bool = from_glib(crate::ffi::gst_tag_parse_extended_comment(
ext_comment.to_glib_none().0,
&mut c_key,
&mut c_lang,
&mut c_value,
fail_if_no_key.into_glib(),
));
if !res {
Err(glib::bool_error!("Failed to parse extended comment"))
} else {
let key = from_glib_full(c_key);
let lang = from_glib_full(c_lang);
let value = from_glib_full(c_value);
Ok(ExtendedComment { key, lang, value })
}
}
}