diff --git a/examples/src/bin/debug_ringbuffer.rs b/examples/src/bin/debug_ringbuffer.rs index 29522fb8c..fc59ef3d9 100644 --- a/examples/src/bin/debug_ringbuffer.rs +++ b/examples/src/bin/debug_ringbuffer.rs @@ -19,11 +19,11 @@ fn example_main() { /* Disable stdout debug, then configure the debug ringbuffer and enable * all debug */ - gst::debug_remove_default_log_function(); + gst::log::remove_default_log_function(); /* Keep 1KB of logs per thread, removing old threads after 10 seconds */ - gst::debug_add_ring_buffer_logger(1024, 10); + gst::log::add_ring_buffer_logger(1024, 10); /* Enable all debug categories */ - gst::debug_set_default_threshold(gst::DebugLevel::Log); + gst::log::set_default_threshold(gst::DebugLevel::Log); let mut context = gst::ParseContext::new(); let pipeline = @@ -73,7 +73,7 @@ fn example_main() { gst::error!(gst::CAT_DEFAULT, "Hi from the debug log ringbuffer example"); println!("Dumping debug logs\n"); - for s in gst::debug_ring_buffer_logger_get_logs().iter() { + for s in gst::log::ring_buffer_logger_get_logs().iter() { println!("{s}\n------------------"); } } diff --git a/examples/src/bin/rtpfecclient.rs b/examples/src/bin/rtpfecclient.rs index 36986c8bb..a3b4c7a5a 100644 --- a/examples/src/bin/rtpfecclient.rs +++ b/examples/src/bin/rtpfecclient.rs @@ -252,11 +252,7 @@ fn example_main() -> Result<(), Error> { if let Some(element) = msg.src() { if element == &pipeline && s.current() == gst::State::Playing { eprintln!("PLAYING"); - gst::debug_bin_to_dot_file( - &pipeline, - gst::DebugGraphDetails::all(), - "client-playing", - ); + pipeline.debug_to_dot_file(gst::DebugGraphDetails::all(), "client-playing"); } } } diff --git a/examples/src/bin/rtpfecserver.rs b/examples/src/bin/rtpfecserver.rs index 70144b571..32e610436 100644 --- a/examples/src/bin/rtpfecserver.rs +++ b/examples/src/bin/rtpfecserver.rs @@ -179,11 +179,7 @@ fn example_main() -> Result<(), Error> { if let Some(element) = msg.src() { if element == &pipeline && s.current() == gst::State::Playing { eprintln!("PLAYING"); - gst::debug_bin_to_dot_file( - &pipeline, - gst::DebugGraphDetails::all(), - "server-playing", - ); + pipeline.debug_to_dot_file(gst::DebugGraphDetails::all(), "server-playing"); } } } diff --git a/gstreamer/src/bin.rs b/gstreamer/src/bin.rs index ac22484bd..885e4ecb3 100644 --- a/gstreamer/src/bin.rs +++ b/gstreamer/src/bin.rs @@ -164,7 +164,7 @@ pub trait GstBinExtManual: sealed::Sealed + IsA + 'static { #[doc(alias = "gst_debug_bin_to_dot_data")] fn debug_to_dot_data(&self, details: crate::DebugGraphDetails) -> GString { - crate::debug_bin_to_dot_data(self, details) + crate::auto::functions::debug_bin_to_dot_data(self, details) } #[doc(alias = "GST_DEBUG_BIN_TO_DOT_FILE")] @@ -174,7 +174,7 @@ pub trait GstBinExtManual: sealed::Sealed + IsA + 'static { details: crate::DebugGraphDetails, file_name: impl AsRef, ) { - crate::debug_bin_to_dot_file(self, details, file_name) + crate::auto::functions::debug_bin_to_dot_file(self, details, file_name) } #[doc(alias = "GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS")] @@ -184,7 +184,7 @@ pub trait GstBinExtManual: sealed::Sealed + IsA + 'static { details: crate::DebugGraphDetails, file_name: impl AsRef, ) { - crate::debug_bin_to_dot_file_with_ts(self, details, file_name) + crate::auto::functions::debug_bin_to_dot_file_with_ts(self, details, file_name) } fn set_bin_flags(&self, flags: BinFlags) { diff --git a/gstreamer/src/functions.rs b/gstreamer/src/functions.rs index 08274f318..0afbcccd0 100644 --- a/gstreamer/src/functions.rs +++ b/gstreamer/src/functions.rs @@ -9,7 +9,11 @@ use glib::{prelude::*, translate::*}; use crate::Tracer; use crate::{Bin, Element, Object, ParseContext, ParseFlags}; -pub use crate::auto::functions::*; +// import only functions which do not have their own module as namespace +pub use crate::auto::functions::{ + main_executable_path, parse_bin_from_description, parse_launch, parse_launchv, update_registry, + util_get_timestamp, version, version_string, +}; pub fn parse_bin_from_description_with_name( bin_description: &str, diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index 4166c2c5a..62c9117cc 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -50,8 +50,15 @@ mod serde_macros; pub use crate::serde_macros::*; #[macro_use] -mod log; -pub use crate::log::*; +pub mod log; +pub use crate::log::{ + DebugCategory, DebugLogFunction, DebugMessage, LoggedObject, CAT_BUFFER, CAT_BUFFER_LIST, + CAT_BUS, CAT_CALL_TRACE, CAT_CAPS, CAT_CLOCK, CAT_CONTEXT, CAT_DEFAULT, CAT_ELEMENT_PADS, + CAT_ERROR_SYSTEM, CAT_EVENT, CAT_GST_INIT, CAT_LOCKING, CAT_MEMORY, CAT_MESSAGE, CAT_META, + CAT_NEGOTIATION, CAT_PADS, CAT_PARAMS, CAT_PARENTAGE, CAT_PERFORMANCE, CAT_PIPELINE, + CAT_PLUGIN_INFO, CAT_PLUGIN_LOADING, CAT_PROBE, CAT_PROPERTIES, CAT_QOS, CAT_REFCOUNTING, + CAT_REGISTRY, CAT_RUST, CAT_SCHEDULING, CAT_SIGNAL, CAT_STATES, +}; #[macro_use] mod error; diff --git a/gstreamer/src/log.rs b/gstreamer/src/log.rs index 6f25d2b01..ac11c0115 100644 --- a/gstreamer/src/log.rs +++ b/gstreamer/src/log.rs @@ -8,6 +8,22 @@ use libc::c_char; use crate::DebugLevel; +// import and rename those so they are namespaced as log::* +pub use crate::auto::functions::debug_add_ring_buffer_logger as add_ring_buffer_logger; +pub use crate::auto::functions::debug_get_default_threshold as get_default_threshold; +pub use crate::auto::functions::debug_get_stack_trace as get_stack_trace; +pub use crate::auto::functions::debug_is_active as is_active; +pub use crate::auto::functions::debug_is_colored as is_colored; +pub use crate::auto::functions::debug_print_stack_trace as print_stack_trace; +pub use crate::auto::functions::debug_remove_ring_buffer_logger as remove_ring_buffer_logger; +pub use crate::auto::functions::debug_ring_buffer_logger_get_logs as ring_buffer_logger_get_logs; +pub use crate::auto::functions::debug_set_active as set_active; +pub use crate::auto::functions::debug_set_colored as set_colored; +pub use crate::auto::functions::debug_set_default_threshold as set_default_threshold; +pub use crate::auto::functions::debug_set_threshold_for_name as set_threshold_for_name; +pub use crate::auto::functions::debug_set_threshold_from_string as set_threshold_from_string; +pub use crate::auto::functions::debug_unset_threshold_for_name as unset_threshold_for_name; + #[derive(PartialEq, Eq)] #[doc(alias = "GstDebugMessage")] pub struct DebugMessage(ptr::NonNull); @@ -1185,7 +1201,7 @@ impl fmt::Display for LoggedObject { } #[doc(alias = "gst_debug_add_log_function")] -pub fn debug_add_log_function(function: T) -> DebugLogFunction +pub fn add_log_function(function: T) -> DebugLogFunction where T: Fn( DebugCategory, @@ -1212,7 +1228,7 @@ where } } -pub fn debug_remove_default_log_function() { +pub fn remove_default_log_function() { skip_assert_initialized!(); unsafe { ffi::gst_debug_remove_log_function(None); @@ -1220,7 +1236,7 @@ pub fn debug_remove_default_log_function() { } #[doc(alias = "gst_debug_remove_log_function_by_data")] -pub fn debug_remove_log_function(log_fn: DebugLogFunction) { +pub fn remove_log_function(log_fn: DebugLogFunction) { skip_assert_initialized!(); unsafe { ffi::gst_debug_remove_log_function_by_data(log_fn.0.as_ptr()); @@ -1328,13 +1344,13 @@ mod tests { let _ = sender.lock().unwrap().send(()); }; - debug_remove_default_log_function(); - let log_fn = debug_add_log_function(handler); + remove_default_log_function(); + let log_fn = add_log_function(handler); info!(cat, obj: &obj, "meh"); receiver.recv().unwrap(); - debug_remove_log_function(log_fn); + remove_log_function(log_fn); info!(cat, obj: &obj, "meh2"); assert!(receiver.recv().is_err());