mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-26 18:10:35 +00:00
utils: streamproducer: add API to retrieve last sample from producer
This may be used for example to easily generate thumbnails from video producers.
This commit is contained in:
parent
0e17878bed
commit
fbceaab941
1 changed files with 9 additions and 0 deletions
|
@ -210,6 +210,11 @@ impl StreamProducer {
|
|||
let _ = consumer.post_message(msg_builder.build());
|
||||
}
|
||||
}
|
||||
|
||||
/// The last sample produced by this producer.
|
||||
pub fn last_sample(&self) -> Option<gst::Sample> {
|
||||
self.appsink.property("last-sample")
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a gst_app::AppSink> for StreamProducer {
|
||||
|
@ -611,6 +616,8 @@ mod tests {
|
|||
.expect("Couldn't set producer pipeline state");
|
||||
consumers.push(consumer);
|
||||
|
||||
assert!(producer.last_sample().is_none());
|
||||
|
||||
for i in 0..10 {
|
||||
let caps = gst::Caps::from_str(&format!("test,n={}", i)).unwrap();
|
||||
producer_src.set_caps(Some(&caps));
|
||||
|
@ -639,6 +646,8 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
assert!(producer.last_sample().is_some());
|
||||
|
||||
assert_eq!(link1.pushed(), 6);
|
||||
assert_eq!(link1.dropped(), 0);
|
||||
assert_eq!(link2.pushed(), 10);
|
||||
|
|
Loading…
Reference in a new issue