diff options
author | Seungha Yang <seungha@centricular.com> | 2023-03-31 17:07:26 +0300 |
---|---|---|
committer | GStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2023-04-03 16:05:15 +0300 |
commit | 4000d60305f65dcd7f0e0ef26660ad51272399b6 (patch) | |
tree | 57135868176452e9294a181cd519102662c396ac | |
parent | c6e1efa0feba12f79a12289e13fb5a390c47019a (diff) |
awstranscriber: Avoid too large initial GAP event
Initialized GstSegment.position is always zero
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1154>
-rw-r--r-- | net/aws/src/transcriber/imp.rs | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/net/aws/src/transcriber/imp.rs b/net/aws/src/transcriber/imp.rs index 0703c969..a177f6c7 100644 --- a/net/aws/src/transcriber/imp.rs +++ b/net/aws/src/transcriber/imp.rs @@ -280,6 +280,16 @@ impl Transcriber { ) -> Result<gst::FlowSuccess, gst::FlowError> { gst::log!(CAT, obj: pad, "Handling {buffer:?}"); + if buffer.pts().is_none() { + gst::element_imp_error!( + self, + gst::StreamError::Format, + ["Stream with timestamped buffers required"] + ); + + return Err(gst::FlowError::Error); + } + self.ensure_connection().map_err(|err| { gst::element_imp_error!(self, gst::StreamError::Failed, ["Streaming failed: {err}"]); gst::FlowError::Error @@ -1311,12 +1321,12 @@ impl TranslationPadTask { let (mut last_position, mut discont_pending) = { let mut state = self.pad.state.lock().unwrap(); - let last_position = if let Some(pos) = state.out_segment.position() { - pos - } else { + if state.start_time.is_none() { + state.start_time = Some(start_time); state.out_segment.set_position(start_time); - start_time - }; + } + + let last_position = state.out_segment.position().unwrap(); (last_position, state.discont_pending) }; @@ -1517,6 +1527,7 @@ struct TranslationPadState { discont_pending: bool, out_segment: gst::FormattedSegment<gst::ClockTime>, task_abort_handle: Option<AbortHandle>, + start_time: Option<gst::ClockTime>, } impl Default for TranslationPadState { @@ -1525,6 +1536,7 @@ impl Default for TranslationPadState { discont_pending: true, out_segment: Default::default(), task_abort_handle: None, + start_time: None, } } } |