PadInfo: add caps_compatible

Returns true if 2 caps described by a string can
intersect.
This commit is contained in:
Stéphane Cerveau 2024-11-26 10:51:14 +01:00
parent 3028bef267
commit f545e1886a

View file

@ -12,6 +12,7 @@ use crate::gps::ElementInfo;
use crate::graphmanager::{PortDirection, PortPresence}; use crate::graphmanager::{PortDirection, PortPresence};
use gst::prelude::*; use gst::prelude::*;
use std::str::FromStr;
#[derive(Debug, PartialOrd, PartialEq, Eq)] #[derive(Debug, PartialOrd, PartialEq, Eq)]
pub struct PadInfo { pub struct PadInfo {
@ -50,6 +51,12 @@ impl PadInfo {
self.caps.as_ref().unwrap() self.caps.as_ref().unwrap()
} }
pub fn caps_compatible(caps1: &str, caps2: &str) -> bool {
let caps1 = gst::Caps::from_str(caps1).unwrap();
let caps2 = gst::Caps::from_str(caps2).unwrap();
caps1.can_intersect(&caps2)
}
pub fn pads(element_name: &str, include_on_request: bool) -> (Vec<PadInfo>, Vec<PadInfo>) { pub fn pads(element_name: &str, include_on_request: bool) -> (Vec<PadInfo>, Vec<PadInfo>) {
let mut input = vec![]; let mut input = vec![];
let mut output = vec![]; let mut output = vec![];