(
pipeline: gst::Pipeline,
on_message: impl Fn(&gst::Message) -> bool,
)
| 37 | } |
| 38 | |
| 39 | pub fn gstreamer_loop( |
| 40 | pipeline: gst::Pipeline, |
| 41 | on_message: impl Fn(&gst::Message) -> bool, |
| 42 | ) -> anyhow::Result<()> { |
| 43 | use gst::prelude::*; |
| 44 | |
| 45 | pipeline.set_state(gst::State::Playing)?; |
| 46 | |
| 47 | let bus = pipeline.bus().unwrap(); |
| 48 | |
| 49 | for message in bus.iter_timed(gst::ClockTime::NONE) { |
| 50 | match message.view() { |
| 51 | gst::MessageView::Eos(_) => break, |
| 52 | gst::MessageView::Error(err) => anyhow::bail!(format!("{:?}", err)), |
| 53 | _ => {} |
| 54 | } |
| 55 | |
| 56 | let should_break = on_message(&message); |
| 57 | if should_break { |
| 58 | break; |
| 59 | }; |
| 60 | } |
| 61 | |
| 62 | pipeline.set_state(gst::State::Null)?; |
| 63 | |
| 64 | Ok(()) |
| 65 | } |
| 66 | |
| 67 | pub fn replace_multiple_whitespace(input: &str) -> String { |
| 68 | let mut result = String::new(); |
no outgoing calls
no test coverage detected