mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-26 11:31:06 +00:00
Description of debug categories is optional
Also add a getter for the description of a debug category
This commit is contained in:
parent
f7c971874d
commit
c2f075ed8d
1 changed files with 19 additions and 1 deletions
|
@ -22,7 +22,11 @@ use glib::translate::{from_glib, ToGlib, ToGlibPtr};
|
|||
pub struct DebugCategory(*mut ffi::GstDebugCategory);
|
||||
|
||||
impl DebugCategory {
|
||||
pub fn new(name: &str, color: ::DebugColorFlags, description: &str) -> DebugCategory {
|
||||
pub fn new<'a, P: Into<Option<&'a str>>>(
|
||||
name: &str,
|
||||
color: ::DebugColorFlags,
|
||||
description: P,
|
||||
) -> DebugCategory {
|
||||
extern "C" {
|
||||
fn _gst_debug_category_new(
|
||||
name: *const c_char,
|
||||
|
@ -30,6 +34,8 @@ impl DebugCategory {
|
|||
description: *const c_char,
|
||||
) -> *mut ffi::GstDebugCategory;
|
||||
}
|
||||
let description = description.into();
|
||||
|
||||
// Gets the category if it exists already
|
||||
unsafe {
|
||||
DebugCategory(_gst_debug_category_new(
|
||||
|
@ -84,6 +90,18 @@ impl DebugCategory {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_description(&self) -> Option<&str> {
|
||||
unsafe {
|
||||
let ptr = ffi::gst_debug_category_get_name(self.0);
|
||||
|
||||
if ptr.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(CStr::from_ptr(ptr).to_str().unwrap())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn log<O: IsA<::Object>>(
|
||||
&self,
|
||||
obj: Option<&O>,
|
||||
|
|
Loading…
Reference in a new issue