forked from mirrors/gstreamer-rs
gstreamer: Add Stream::debug() and StreamCollection::debug()
These provide more helpful debug output than just the pointer when printing.
This commit is contained in:
parent
43e7f9f589
commit
d623bcdce5
3 changed files with 51 additions and 2 deletions
|
@ -244,7 +244,7 @@ pub use tag_setter::TagSetterExtManual;
|
||||||
mod plugin;
|
mod plugin;
|
||||||
pub use plugin::GstPluginExtManual;
|
pub use plugin::GstPluginExtManual;
|
||||||
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
||||||
mod stream;
|
pub mod stream;
|
||||||
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
||||||
pub mod stream_collection;
|
pub mod stream_collection;
|
||||||
|
|
||||||
|
|
|
@ -8,13 +8,13 @@
|
||||||
|
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
use gst_sys;
|
use gst_sys;
|
||||||
|
use std::fmt;
|
||||||
use Caps;
|
use Caps;
|
||||||
use Stream;
|
use Stream;
|
||||||
use StreamFlags;
|
use StreamFlags;
|
||||||
use StreamType;
|
use StreamType;
|
||||||
|
|
||||||
impl Stream {
|
impl Stream {
|
||||||
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
stream_id: Option<&str>,
|
stream_id: Option<&str>,
|
||||||
caps: Option<&Caps>,
|
caps: Option<&Caps>,
|
||||||
|
@ -47,4 +47,22 @@ impl Stream {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn debug(&self) -> Debug {
|
||||||
|
Debug(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Debug<'a>(&'a Stream);
|
||||||
|
|
||||||
|
impl<'a> fmt::Debug for Debug<'a> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
f.debug_struct("Stream")
|
||||||
|
.field("stream_id", &self.0.get_stream_id())
|
||||||
|
.field("stream_type", &self.0.get_stream_type())
|
||||||
|
.field("stream_flags", &self.0.get_stream_flags())
|
||||||
|
.field("caps", &self.0.get_caps())
|
||||||
|
.field("tags", &self.0.get_tags())
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
use glib::object::IsA;
|
use glib::object::IsA;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
use gst_sys;
|
use gst_sys;
|
||||||
|
use std::fmt;
|
||||||
use Stream;
|
use Stream;
|
||||||
use StreamCollection;
|
use StreamCollection;
|
||||||
|
|
||||||
|
@ -102,4 +103,34 @@ impl StreamCollection {
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
self.len() == 0
|
self.len() == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn debug(&self) -> Debug {
|
||||||
|
Debug(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct Debug<'a>(&'a StreamCollection);
|
||||||
|
|
||||||
|
impl<'a> fmt::Debug for Debug<'a> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
struct Streams<'a>(&'a StreamCollection);
|
||||||
|
|
||||||
|
impl<'a> fmt::Debug for Streams<'a> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
let mut f = f.debug_list();
|
||||||
|
|
||||||
|
for stream in self.0.iter() {
|
||||||
|
f.entry(&stream.debug());
|
||||||
|
}
|
||||||
|
|
||||||
|
f.finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let streams = Streams(self.0);
|
||||||
|
|
||||||
|
f.debug_struct("StreamCollection")
|
||||||
|
.field("streams", &streams)
|
||||||
|
.finish()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue