analyticscombiner: Use NULL caps instead of EMPTY caps in the array for streams with no caps

EMPTY/ANY caps are not considered fixed caps.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2444>
This commit is contained in:
Sebastian Dröge 2025-08-09 17:12:26 +03:00 committed by GStreamer Marge Bot
parent fe23979a9a
commit 817d923459
3 changed files with 24 additions and 24 deletions

View file

@ -440,7 +440,7 @@ impl AggregatorImpl for AnalyticsCombiner {
let Some(stream_caps) = streams
.get(pad_index)
.map(|v| v.get::<gst::Caps>().unwrap())
.and_then(|v| v.get::<Option<gst::Caps>>().unwrap())
else {
continue;
};
@ -532,11 +532,11 @@ impl AggregatorImpl for AnalyticsCombiner {
return None;
};
let caps = caps.caps_owned();
Some(caps)
Some(Some(caps))
})
.unwrap_or_else(|| {
gst::warning!(CAT, obj = pad, "No caps for pad, using empty caps for now");
gst::Caps::new_empty()
gst::warning!(CAT, obj = pad, "No caps for pad, using NULL caps for now");
None::<gst::Caps>
});
streams.append(caps);

View file

@ -16,7 +16,7 @@ static CAT: LazyLock<gst::DebugCategory> = LazyLock::new(|| {
struct Stream {
pad: gst::Pad,
caps: gst::Caps,
caps: Option<gst::Caps>,
}
struct State {
@ -240,7 +240,7 @@ impl AnalyticsSplitter {
};
let streams = streams
.iter()
.map(|v| v.get::<gst::Caps>().unwrap())
.map(|v| v.get::<Option<gst::Caps>>().unwrap())
.collect::<Vec<_>>();
let mut state_guard = self.state.lock().unwrap();
@ -410,7 +410,7 @@ impl AnalyticsSplitter {
let Some(stream_caps) = streams
.get(pad_index)
.map(|v| v.get::<gst::Caps>().unwrap())
.and_then(|v| v.get::<Option<gst::Caps>>().unwrap())
else {
continue;
};

View file

@ -185,11 +185,11 @@ fn test_combine_multi() {
.get::<gst::ArrayRef>("streams")
.unwrap()
.iter()
.map(|v| v.get::<gst::Caps>().unwrap())
.map(|v| v.get::<Option<gst::Caps>>().unwrap())
.collect::<Vec<_>>();
assert_eq!(streams.len(), 2);
assert_eq!(&streams[0], &h0_caps);
assert_eq!(&streams[1], &h1_caps);
assert_eq!(streams[0].as_ref(), Some(&h0_caps));
assert_eq!(streams[1].as_ref(), Some(&h1_caps));
let ev = h0.pull_event().unwrap();
assert_eq!(ev.type_(), gst::EventType::Segment);
@ -374,10 +374,10 @@ fn test_strategy_all() {
.get::<gst::ArrayRef>("streams")
.unwrap()
.iter()
.map(|v| v.get::<gst::Caps>().unwrap())
.map(|v| v.get::<Option<gst::Caps>>().unwrap())
.collect::<Vec<_>>();
assert_eq!(streams.len(), 1);
assert_eq!(&streams[0], &h_caps);
assert_eq!(streams[0].as_ref(), Some(&h_caps));
let ev = h.pull_event().unwrap();
assert_eq!(ev.type_(), gst::EventType::Segment);
@ -557,10 +557,10 @@ fn test_strategy_first() {
.get::<gst::ArrayRef>("streams")
.unwrap()
.iter()
.map(|v| v.get::<gst::Caps>().unwrap())
.map(|v| v.get::<Option<gst::Caps>>().unwrap())
.collect::<Vec<_>>();
assert_eq!(streams.len(), 1);
assert_eq!(&streams[0], &h_caps);
assert_eq!(streams[0].as_ref(), Some(&h_caps));
let ev = h.pull_event().unwrap();
assert_eq!(ev.type_(), gst::EventType::Segment);
@ -740,10 +740,10 @@ fn test_strategy_first_with_overlap() {
.get::<gst::ArrayRef>("streams")
.unwrap()
.iter()
.map(|v| v.get::<gst::Caps>().unwrap())
.map(|v| v.get::<Option<gst::Caps>>().unwrap())
.collect::<Vec<_>>();
assert_eq!(streams.len(), 1);
assert_eq!(&streams[0], &h_caps);
assert_eq!(streams[0].as_ref(), Some(&h_caps));
let ev = h.pull_event().unwrap();
assert_eq!(ev.type_(), gst::EventType::Segment);
@ -923,10 +923,10 @@ fn test_strategy_last() {
.get::<gst::ArrayRef>("streams")
.unwrap()
.iter()
.map(|v| v.get::<gst::Caps>().unwrap())
.map(|v| v.get::<Option<gst::Caps>>().unwrap())
.collect::<Vec<_>>();
assert_eq!(streams.len(), 1);
assert_eq!(&streams[0], &h_caps);
assert_eq!(streams[0].as_ref(), Some(&h_caps));
let ev = h.pull_event().unwrap();
assert_eq!(ev.type_(), gst::EventType::Segment);
@ -1156,11 +1156,11 @@ fn test_combine_multi_initial_gap() {
.get::<gst::ArrayRef>("streams")
.unwrap()
.iter()
.map(|v| v.get::<gst::Caps>().unwrap())
.map(|v| v.get::<Option<gst::Caps>>().unwrap())
.collect::<Vec<_>>();
assert_eq!(streams.len(), 2);
assert_eq!(&streams[0], &h0_caps);
assert_eq!(&streams[1], &gst::Caps::new_empty());
assert_eq!(streams[0].as_ref(), Some(&h0_caps));
assert_eq!(streams[1].as_ref(), None);
let ev = h0.pull_event().unwrap();
assert_eq!(ev.type_(), gst::EventType::Segment);
@ -1177,11 +1177,11 @@ fn test_combine_multi_initial_gap() {
.get::<gst::ArrayRef>("streams")
.unwrap()
.iter()
.map(|v| v.get::<gst::Caps>().unwrap())
.map(|v| v.get::<Option<gst::Caps>>().unwrap())
.collect::<Vec<_>>();
assert_eq!(streams.len(), 2);
assert_eq!(&streams[0], &h0_caps);
assert_eq!(&streams[1], &h1_caps);
assert_eq!(streams[0].as_ref(), Some(&h0_caps));
assert_eq!(streams[1].as_ref(), Some(&h1_caps));
let ev = h0.pull_event().unwrap();
assert_eq!(ev.type_(), gst::EventType::Eos);