forked from mirrors/gstreamer-rs
pbutils: implement debug() method on DiscovererInfo related structs
The default Debug implementation is not very useful but unfortunately cannot be overridden. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1290>
This commit is contained in:
parent
3c921f9320
commit
5b0f29003f
7 changed files with 220 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
|
||||
use std::{boxed::Box as Box_, mem::transmute};
|
||||
use std::{boxed::Box as Box_, fmt, mem::transmute};
|
||||
|
||||
use glib::{
|
||||
prelude::*,
|
||||
|
@ -8,7 +8,7 @@ use glib::{
|
|||
translate::*,
|
||||
};
|
||||
|
||||
use crate::auto::Discoverer;
|
||||
use crate::{auto::Discoverer, DiscovererInfo};
|
||||
|
||||
impl Discoverer {
|
||||
pub fn set_timeout(&self, timeout: gst::ClockTime) {
|
||||
|
@ -48,3 +48,75 @@ unsafe extern "C" fn notify_timeout_trampoline<P, F: Fn(&P) + Send + Sync + 'sta
|
|||
let f: &F = &*(f as *const F);
|
||||
f(Discoverer::from_glib_borrow(this).unsafe_cast_ref())
|
||||
}
|
||||
|
||||
pub struct DebugInfo<'a>(&'a DiscovererInfo);
|
||||
|
||||
impl<'a> fmt::Debug for DebugInfo<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let stream_info = self.0.stream_info();
|
||||
let stream_list = self.0.stream_list();
|
||||
let container_streams = self.0.container_streams();
|
||||
let audio_streams = self.0.audio_streams();
|
||||
let video_streams = self.0.video_streams();
|
||||
let subtitle_streams = self.0.subtitle_streams();
|
||||
|
||||
f.debug_struct("DiscovererInfo")
|
||||
.field("uri", &self.0.uri())
|
||||
.field("result", &self.0.result())
|
||||
.field("duration", &self.0.duration())
|
||||
.field("is-live", &self.0.is_live())
|
||||
.field("is-seekable", &self.0.is_seekable())
|
||||
.field(
|
||||
"stream-info",
|
||||
&stream_info.as_ref().map(|info| info.debug()),
|
||||
)
|
||||
.field(
|
||||
"stream-list",
|
||||
&stream_list
|
||||
.iter()
|
||||
.map(|info| info.debug())
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.field(
|
||||
"container-streams",
|
||||
&container_streams
|
||||
.iter()
|
||||
.map(|info| info.debug())
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.field(
|
||||
"audio-streams",
|
||||
&audio_streams
|
||||
.iter()
|
||||
.map(|info| info.debug())
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.field(
|
||||
"video-streams",
|
||||
&video_streams
|
||||
.iter()
|
||||
.map(|info| info.debug())
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.field(
|
||||
"subtitle-streams",
|
||||
&subtitle_streams
|
||||
.iter()
|
||||
.map(|info| info.debug())
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.field("toc", &self.0.toc())
|
||||
.field("misc", &self.0.misc())
|
||||
.field(
|
||||
"missing-elements-installer-details",
|
||||
&self.0.missing_elements_installer_details(),
|
||||
)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl DiscovererInfo {
|
||||
pub fn debug(&self) -> DebugInfo {
|
||||
DebugInfo(self)
|
||||
}
|
||||
}
|
||||
|
|
32
gstreamer-pbutils/src/discoverer_audio_info.rs
Normal file
32
gstreamer-pbutils/src/discoverer_audio_info.rs
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use glib::Cast;
|
||||
|
||||
use crate::{DiscovererAudioInfo, DiscovererStreamInfo};
|
||||
|
||||
pub struct Debug<'a>(&'a DiscovererAudioInfo);
|
||||
|
||||
impl<'a> fmt::Debug for Debug<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let info = self.0.upcast_ref::<DiscovererStreamInfo>();
|
||||
|
||||
f.debug_struct("DiscovererAudioInfo")
|
||||
.field("channels", &self.0.channels())
|
||||
.field("sample-rate", &self.0.sample_rate())
|
||||
.field("depth", &self.0.depth())
|
||||
.field("bitrate", &self.0.bitrate())
|
||||
.field("max-bitrate", &self.0.max_bitrate())
|
||||
.field("channel-mask", &self.0.channel_mask())
|
||||
.field("language", &self.0.language())
|
||||
.field("stream", &info.debug())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl DiscovererAudioInfo {
|
||||
pub fn debug(&self) -> Debug {
|
||||
Debug(self)
|
||||
}
|
||||
}
|
32
gstreamer-pbutils/src/discoverer_container_info.rs
Normal file
32
gstreamer-pbutils/src/discoverer_container_info.rs
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
use std::fmt;
|
||||
|
||||
use crate::{prelude::*, DiscovererContainerInfo};
|
||||
|
||||
pub struct Debug<'a>(&'a DiscovererContainerInfo);
|
||||
|
||||
impl<'a> fmt::Debug for Debug<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let streams = self.0.streams();
|
||||
|
||||
let mut d = f.debug_struct("DiscovererContainerInfo");
|
||||
|
||||
d.field("tags", &self.0.tags()).field(
|
||||
"streams",
|
||||
&streams.iter().map(|info| info.debug()).collect::<Vec<_>>(),
|
||||
);
|
||||
|
||||
#[cfg(feature = "v1_20")]
|
||||
d.field("stream-number", &self.0.stream_number());
|
||||
#[cfg(feature = "v1_20")]
|
||||
d.field("tags", &self.0.tags());
|
||||
|
||||
d.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl DiscovererContainerInfo {
|
||||
pub fn debug(&self) -> Debug {
|
||||
Debug(self)
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
use std::fmt;
|
||||
|
||||
use glib::translate::*;
|
||||
|
||||
|
@ -67,3 +68,28 @@ impl<O: IsA<DiscovererStreamInfo>> DiscovererStreamInfoExtManual for O {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Debug<'a>(&'a DiscovererStreamInfo);
|
||||
|
||||
impl<'a> fmt::Debug for Debug<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let mut d = f.debug_struct("DiscovererStreamInfo");
|
||||
d.field("caps", &self.0.caps())
|
||||
.field("stream-id", &self.0.stream_id())
|
||||
.field("misc", &self.0.misc())
|
||||
.field("stream-type-nick", &self.0.stream_type_nick())
|
||||
.field("tags", &self.0.tags())
|
||||
.field("toc", &self.0.toc());
|
||||
|
||||
#[cfg(feature = "v1_20")]
|
||||
d.field("stream-number", &self.0.stream_number());
|
||||
|
||||
d.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl DiscovererStreamInfo {
|
||||
pub fn debug(&self) -> Debug {
|
||||
Debug(self)
|
||||
}
|
||||
}
|
||||
|
|
26
gstreamer-pbutils/src/discoverer_subtitle_info.rs
Normal file
26
gstreamer-pbutils/src/discoverer_subtitle_info.rs
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
|
||||
use std::fmt;
|
||||
|
||||
use glib::Cast;
|
||||
|
||||
use crate::{DiscovererStreamInfo, DiscovererSubtitleInfo};
|
||||
|
||||
pub struct Debug<'a>(&'a DiscovererSubtitleInfo);
|
||||
|
||||
impl<'a> fmt::Debug for Debug<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let info = self.0.upcast_ref::<DiscovererStreamInfo>();
|
||||
|
||||
f.debug_struct("DiscovererSubtitleInfo")
|
||||
.field("language", &self.0.language())
|
||||
.field("stream", &info.debug())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl DiscovererSubtitleInfo {
|
||||
pub fn debug(&self) -> Debug {
|
||||
Debug(self)
|
||||
}
|
||||
}
|
|
@ -1,8 +1,10 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
|
||||
use glib::translate::*;
|
||||
use std::fmt;
|
||||
|
||||
use crate::DiscovererVideoInfo;
|
||||
use glib::{translate::*, Cast};
|
||||
|
||||
use crate::{DiscovererStreamInfo, DiscovererVideoInfo};
|
||||
|
||||
impl DiscovererVideoInfo {
|
||||
#[doc(alias = "get_framerate")]
|
||||
|
@ -28,4 +30,27 @@ impl DiscovererVideoInfo {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn debug(&self) -> Debug {
|
||||
Debug(self)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Debug<'a>(&'a DiscovererVideoInfo);
|
||||
|
||||
impl<'a> fmt::Debug for Debug<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let info = self.0.upcast_ref::<DiscovererStreamInfo>();
|
||||
|
||||
f.debug_struct("DiscovererVideoInfo")
|
||||
.field("width", &self.0.width())
|
||||
.field("height", &self.0.height())
|
||||
.field("depth", &self.0.depth())
|
||||
.field("bitrate", &self.0.bitrate())
|
||||
.field("max-bitrate", &self.0.max_bitrate())
|
||||
.field("is-image", &self.0.is_image())
|
||||
.field("is-interlaced", &self.0.is_interlaced())
|
||||
.field("stream", &info.debug())
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,10 @@ mod flag_serde;
|
|||
mod discoverer;
|
||||
pub use crate::discoverer::*;
|
||||
|
||||
mod discoverer_audio_info;
|
||||
mod discoverer_container_info;
|
||||
pub mod discoverer_stream_info;
|
||||
mod discoverer_subtitle_info;
|
||||
mod discoverer_video_info;
|
||||
|
||||
pub mod encoding_profile;
|
||||
|
|
Loading…
Reference in a new issue