mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-29 04:51:09 +00:00
video: Add VideoInfo::is_valid() and guard against finfo being NULL when retrieving the video format
This commit is contained in:
parent
4a2cb80c06
commit
6ed505401f
1 changed files with 8 additions and 0 deletions
|
@ -558,6 +558,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> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
|
@ -587,6 +591,10 @@ impl VideoInfo {
|
|||
}
|
||||
|
||||
pub fn format(&self) -> ::VideoFormat {
|
||||
if self.0.finfo.is_null() {
|
||||
return ::VideoFormat::Unknown;
|
||||
}
|
||||
|
||||
unsafe { from_glib((*self.0.finfo).format) }
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue