StreamProducer does not forward tag events to consumers
Seems like most events are actually not forwarded from the StreamProducer
. One of the important ones to forward is tags. We have this patch locally to support this, but it does not seem like the cleanest solution:
@@ -147,11 +147,25 @@ impl<'a> From<&'a gst_app::AppSink> for StreamProducer {
.new_sample(move |appsink| {
let mut consumers = consumers_clone.lock().unwrap();
- let sample = match appsink.pull_sample() {
- Ok(sample) => sample,
- Err(_err) => {
- return Err(gst::FlowError::Flushing);
+ let mut sample = None;
+ let mut events = vec![];
+ while let Ok(obj) = appsink.pull_object() {
+ let obj = match obj.downcast::<gst::Event>() {
+ Ok(event) => {
+ events.push(event);
+ continue;
+ }
+ Err(obj) => obj,
+ };
+ if let Ok(sam) = obj.downcast::<gst::Sample>() {
+ sample = Some(sam);
+ break;
}
+ }
+
+ let sample = match sample {
+ Some(sample) => sample,
+ None => return Err(gst::FlowError::Flushing),
};
if consumers.discard {
@@ -205,6 +219,11 @@ impl<'a> From<&'a gst_app::AppSink> for StreamProducer {
drop(consumers);
for consumer in current_consumers {
+ for event in &events {
+ let src_pad = consumer.static_pad("src").unwrap();
+ src_pad.push_event(event.clone());
+ }
+
let _ = consumer.push_sample(&sample);
}