mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-02-13 17:45:24 +00:00
video: Add VideoInfo::is_valid() and guard against finfo being NULL when retrieving the video format
This commit is contained in:
parent
51024345f8
commit
de0f228075
1 changed files with 8 additions and 0 deletions
|
@ -557,6 +557,10 @@ impl VideoInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_valid(&self) -> bool {
|
||||||
|
!self.0.finfo.is_null() && self.0.width > 0 && self.0.height > 0 && self.0.size > 0
|
||||||
|
}
|
||||||
|
|
||||||
pub fn from_caps(caps: &gst::CapsRef) -> Result<Self, glib::error::BoolError> {
|
pub fn from_caps(caps: &gst::CapsRef) -> Result<Self, glib::error::BoolError> {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
|
|
||||||
|
@ -586,6 +590,10 @@ impl VideoInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn format(&self) -> ::VideoFormat {
|
pub fn format(&self) -> ::VideoFormat {
|
||||||
|
if self.0.finfo.is_null() {
|
||||||
|
return ::VideoFormat::Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
unsafe { from_glib((*self.0.finfo).format) }
|
unsafe { from_glib((*self.0.finfo).format) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue