From f545e1886a02c96890cb1f7a7b02c4b28dc5a5d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Cerveau?= Date: Tue, 26 Nov 2024 10:51:14 +0100 Subject: [PATCH] PadInfo: add caps_compatible Returns true if 2 caps described by a string can intersect. --- src/gps/pad.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gps/pad.rs b/src/gps/pad.rs index d9fc1d1..5338fe0 100644 --- a/src/gps/pad.rs +++ b/src/gps/pad.rs @@ -12,6 +12,7 @@ use crate::gps::ElementInfo; use crate::graphmanager::{PortDirection, PortPresence}; use gst::prelude::*; +use std::str::FromStr; #[derive(Debug, PartialOrd, PartialEq, Eq)] pub struct PadInfo { @@ -50,6 +51,12 @@ impl PadInfo { 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, Vec) { let mut input = vec![]; let mut output = vec![];