mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-09-29 15:22:08 +00:00
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:
commit
afd8a20a8e
3 changed files with 29 additions and 0 deletions
|
@ -238,6 +238,15 @@ impl EventRef {
|
||||||
self.structure().map_or(false, |s| s.has_name(name))
|
self.structure().map_or(false, |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 {
|
pub fn view(&self) -> EventView {
|
||||||
unsafe {
|
unsafe {
|
||||||
let type_ = (*self.as_ptr()).type_;
|
let type_ = (*self.as_ptr()).type_;
|
||||||
|
@ -3068,6 +3077,7 @@ mod tests {
|
||||||
let flush_start_evt = FlushStart::builder()
|
let flush_start_evt = FlushStart::builder()
|
||||||
.other_fields(&[("extra-field", &true)])
|
.other_fields(&[("extra-field", &true)])
|
||||||
.build();
|
.build();
|
||||||
|
assert_eq!(flush_start_evt.type_name(), "flush-start");
|
||||||
match flush_start_evt.view() {
|
match flush_start_evt.view() {
|
||||||
EventView::FlushStart(flush_start_evt) => {
|
EventView::FlushStart(flush_start_evt) => {
|
||||||
assert!(flush_start_evt.structure().is_some());
|
assert!(flush_start_evt.structure().is_some());
|
||||||
|
|
|
@ -83,6 +83,15 @@ impl MessageRef {
|
||||||
self.structure().map_or(false, |s| s.has_name(name))
|
self.structure().map_or(false, |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 {
|
pub fn view(&self) -> MessageView {
|
||||||
unsafe {
|
unsafe {
|
||||||
let type_ = (*self.as_ptr()).type_;
|
let type_ = (*self.as_ptr()).type_;
|
||||||
|
@ -3956,6 +3965,7 @@ mod tests {
|
||||||
// Message without arguments
|
// Message without arguments
|
||||||
let seqnum = Seqnum::next();
|
let seqnum = Seqnum::next();
|
||||||
let eos_msg = Eos::builder().seqnum(seqnum).build();
|
let eos_msg = Eos::builder().seqnum(seqnum).build();
|
||||||
|
assert_eq!(eos_msg.type_name(), "eos");
|
||||||
match eos_msg.view() {
|
match eos_msg.view() {
|
||||||
MessageView::Eos(eos_msg) => {
|
MessageView::Eos(eos_msg) => {
|
||||||
assert_eq!(eos_msg.seqnum(), seqnum);
|
assert_eq!(eos_msg.seqnum(), seqnum);
|
||||||
|
|
|
@ -34,6 +34,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 = "get_mut_structure")]
|
||||||
#[doc(alias = "gst_query_writable_structure")]
|
#[doc(alias = "gst_query_writable_structure")]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Reference in a new issue