Merge branch 'minitypename' into 'main'

gst: Add getting for mini object type names

See merge request gstreamer/gstreamer-rs!1289
This commit is contained in:
Thibault Saunier 2025-04-13 09:43:56 +00:00
commit fa19164f59
3 changed files with 29 additions and 0 deletions

View file

@ -245,6 +245,15 @@ impl EventRef {
self.structure().is_some_and(|s| s.has_name(name))
}
#[doc(alias = "gst_event_type_get_name")]
#[inline]
pub fn type_name(&self) -> &'static str {
unsafe {
let type_ = ffi::gst_event_type_get_name((*self.as_ptr()).type_);
CStr::from_ptr(type_).to_str().unwrap()
}
}
pub fn view(&self) -> EventView {
unsafe {
let type_ = (*self.as_ptr()).type_;
@ -3253,6 +3262,7 @@ mod tests {
let flush_start_evt = FlushStart::builder()
.other_field("extra-field", true)
.build();
assert_eq!(flush_start_evt.type_name(), "flush-start");
match flush_start_evt.view() {
EventView::FlushStart(flush_start_evt) => {
assert!(flush_start_evt.structure().is_some());

View file

@ -130,6 +130,15 @@ impl MessageRef {
self.structure().is_some_and(|s| s.has_name(name))
}
#[doc(alias = "gst_message_type_get_name")]
#[inline]
pub fn type_name(&self) -> &'static str {
unsafe {
let type_ = ffi::gst_message_type_get_name((*self.as_ptr()).type_);
CStr::from_ptr(type_).to_str().unwrap()
}
}
pub fn view(&self) -> MessageView {
unsafe {
let type_ = (*self.as_ptr()).type_;
@ -4430,6 +4439,7 @@ mod tests {
// Message without arguments
let seqnum = Seqnum::next();
let eos_msg = Eos::builder().seqnum(seqnum).build();
assert_eq!(eos_msg.type_name(), "eos");
match eos_msg.view() {
MessageView::Eos(eos_msg) => {
assert_eq!(eos_msg.seqnum(), seqnum);

View file

@ -36,6 +36,15 @@ impl QueryRef {
}
}
#[doc(alias = "gst_query_type_get_name")]
#[inline]
pub fn type_name(&self) -> &'static str {
unsafe {
let type_ = ffi::gst_query_type_get_name((*self.as_ptr()).type_);
CStr::from_ptr(type_).to_str().unwrap()
}
}
#[doc(alias = "get_mut_structure")]
#[doc(alias = "gst_query_writable_structure")]
#[inline]