From 48fb744274e95bc6ff516bc61aaa3af26790bd79 Mon Sep 17 00:00:00 2001 From: Dave Patrick Caberto Date: Tue, 13 Feb 2024 19:06:52 +0800 Subject: [PATCH] misc: add debug asserts for checking if bin has the needed elements --- src/profile.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/profile.rs b/src/profile.rs index 9fb7d990..65193d71 100644 --- a/src/profile.rs +++ b/src/profile.rs @@ -153,6 +153,10 @@ impl Profile { sink: &gst::Element, ) -> Result<()> { let videoenc_bin = parse_bin("kooha-videoenc-bin", &self.data().videoenc_bin_str)?; + debug_assert!(videoenc_bin.iterate_elements().into_iter().any(|element| { + let factory = element.unwrap().factory().unwrap(); + factory.has_type(gst::ElementFactoryType::VIDEO_ENCODER) + })); pipeline.add(&videoenc_bin)?; video_src.link(&videoenc_bin)?; @@ -169,7 +173,6 @@ impl Profile { } (audioenc_str, Some(muxer_bin_str)) => { let muxer_bin = parse_bin("kooha-muxer-bin", muxer_bin_str)?; - let muxer = muxer_bin .iterate_elements() .find(|element| { @@ -187,8 +190,11 @@ impl Profile { let audioenc_str = audioenc_str .as_ref() .context("Failed to handle audio srcs: Profile has no audio encoder")?; - let audioenc_bin = parse_bin("kooha-audioenc-bin", audioenc_str)?; + debug_assert!(audioenc_bin.iterate_elements().into_iter().any(|element| { + let factory = element.unwrap().factory().unwrap(); + factory.has_type(gst::ElementFactoryType::AUDIO_ENCODER) + })); pipeline.add(&audioenc_bin)?; audio_srcs.link(&audioenc_bin)?;