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
This commit is contained in:
Shaun Ren 2022-10-11 16:42:28 -04:00 committed by Arkadiusz Hiler
parent 6d138f5e96
commit e2493e2dfd

View file

@ -298,6 +298,8 @@ struct VideoConvState {
our_duration: Option<u64>, our_duration: Option<u64>,
transcoded_tag: u32, transcoded_tag: u32,
need_stream_start: bool,
} }
impl VideoConvState { impl VideoConvState {
@ -321,6 +323,8 @@ impl VideoConvState {
our_duration: None, our_duration: None,
transcoded_tag: VIDEOCONV_FOZ_TAG_MKVDATA, transcoded_tag: VIDEOCONV_FOZ_TAG_MKVDATA,
need_stream_start: true,
}) })
} }
@ -802,15 +806,29 @@ impl VideoConv {
.activate_mode(mode, active)?; .activate_mode(mode, active)?;
if mode == gst::PadMode::Pull { if mode == gst::PadMode::Pull {
let mut state = self.state.lock().unwrap(); let need_stream_start;
let hash;
let mut state = match &mut *state { /* push_event, below, can also grab state and cause a deadlock, so make sure it's
Some(s) => 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?")); } None => { return Err(loggable_error!(CAT, "VideoConv not yet in READY state?")); }
}; };
/* once we're initted in pull mode, we can start transcoding */ if need_stream_start && active && hash.is_some() {
self.init_transcode(&mut state)?; 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(()) Ok(())