From 01cc9e23d818afc51b2d85985254ab1649ee5bfd Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Tue, 28 Sep 2021 01:50:49 +0200 Subject: [PATCH] transcriberbin: switch to passthrough on transcriber error Part-of: --- video/closedcaption/src/transcriberbin/imp.rs | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/video/closedcaption/src/transcriberbin/imp.rs b/video/closedcaption/src/transcriberbin/imp.rs index 1361f1fc1..3c8a1ced5 100644 --- a/video/closedcaption/src/transcriberbin/imp.rs +++ b/video/closedcaption/src/transcriberbin/imp.rs @@ -854,4 +854,42 @@ impl ElementImpl for TranscriberBin { } } -impl BinImpl for TranscriberBin {} +impl BinImpl for TranscriberBin { + fn handle_message(&self, bin: &Self::Type, msg: gst::Message) { + use gst::MessageView; + + match msg.view() { + MessageView::Error(ref m) => { + /* We must have a state here */ + let s = self.state.lock().unwrap(); + + if let Some(state) = s.as_ref() { + if msg.src().as_ref() == Some(state.transcriber.upcast_ref()) { + gst_error!( + CAT, + obj: bin, + "Transcriber has posted an error ({:?}), going back to passthrough", + m + ); + drop(s); + let mut settings = self.settings.lock().unwrap(); + settings.passthrough = true; + bin.notify("passthrough"); + drop(settings); + bin.call_async(move |bin| { + let thiz = TranscriberBin::from_instance(bin); + thiz.block_and_update(bin, true); + }); + } else { + drop(s); + self.parent_handle_message(bin, msg); + } + } else { + drop(s); + self.parent_handle_message(bin, msg); + } + } + _ => self.parent_handle_message(bin, msg), + } + } +}