diff options
author | Shaun Ren <sren@codeweavers.com> | 2022-10-11 23:42:28 +0300 |
---|---|---|
committer | Arkadiusz Hiler <ahiler@codeweavers.com> | 2022-10-26 21:29:10 +0300 |
commit | 1b73b5e0c2ad13e1ed1df44ca13610a77453087f (patch) | |
tree | 0a638d54c3f33040ee8a15beca1b93a172fc7bb0 | |
parent | da319012f286162a50bd43022d2d419f42ec1b7c (diff) |
media-converter: Set stream ID as the video hash.
If a stream ID is not set, gstreamer will generate random stream IDs for
the streams in downstream elements. This can cause decodebin to generate
its source pads in a non-deterministic order, as decodebin takes into
account the stream IDs when sorting the source pads.
This patch includes some changes from Arek Hiler.
CW-Bug-Id: #21192
-rw-r--r-- | media-converter/src/videoconv/imp.rs | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/media-converter/src/videoconv/imp.rs b/media-converter/src/videoconv/imp.rs index 95556d2a..7680bab0 100644 --- a/media-converter/src/videoconv/imp.rs +++ b/media-converter/src/videoconv/imp.rs @@ -297,6 +297,8 @@ struct VideoConvState { our_duration: Option<u64>, transcoded_tag: u32, + + need_stream_start: bool, } impl VideoConvState { @@ -320,6 +322,8 @@ impl VideoConvState { our_duration: None, transcoded_tag: VIDEOCONV_FOZ_TAG_MKVDATA, + + need_stream_start: true, }) } @@ -794,15 +798,29 @@ impl VideoConv { .activate_mode(mode, active)?; if mode == gst::PadMode::Pull { - let mut state = self.state.lock().unwrap(); - - let mut state = match &mut *state { - Some(s) => s, + let need_stream_start; + let hash; + + /* push_event, below, can also grab state and cause a deadlock, so make sure it's + * released before calling */ + match &mut *self.state.lock().unwrap() { + Some(state) => { + self.init_transcode(state)?; + need_stream_start = state.need_stream_start; + hash = state.transcode_hash; + }, None => { return Err(loggable_error!(CAT, "VideoConv not yet in READY state?")); } }; - /* once we're initted in pull mode, we can start transcoding */ - self.init_transcode(&mut state)?; + if need_stream_start && active && hash.is_some() { + let stream_id = format!("{:032x}", hash.unwrap()); + self.srcpad.push_event(gst::event::StreamStart::new(&stream_id)); + + match &mut *self.state.lock().unwrap() { + Some(state) => { state.need_stream_start = false }, + None => { return Err(loggable_error!(CAT, "VideoConv not yet in READY state?")); } + }; + } } Ok(()) |