Skip to content

Commit

Permalink
misc: add debug asserts for checking if bin has the needed elements
Browse files Browse the repository at this point in the history
  • Loading branch information
SeaDve committed Feb 13, 2024
1 parent 81ef0f1 commit 48fb744
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand All @@ -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| {
Expand All @@ -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)?;
Expand Down

0 comments on commit 48fb744

Please sign in to comment.