Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2020-06-23 10:01:27 +0300
committerSebastian Dröge <sebastian@centricular.com>2020-06-23 10:01:27 +0300
commitfe274ac6e7d8a812766631b563b7ee95fc7453e9 (patch)
tree2f18587558fe190d72d75f2ea4e8a845c696f9f5
parentfc20df294e375f3c0f96d502a9fbb2bc9c7a9a6a (diff)
fallbacksrc: Use new proxy_pad_chain_function() support when building pads
Less unsafe code.
-rw-r--r--utils/fallbackswitch/src/fallbacksrc.rs28
1 files changed, 12 insertions, 16 deletions
diff --git a/utils/fallbackswitch/src/fallbacksrc.rs b/utils/fallbackswitch/src/fallbacksrc.rs
index 1a9325c44..f78d9048d 100644
--- a/utils/fallbackswitch/src/fallbacksrc.rs
+++ b/utils/fallbackswitch/src/fallbacksrc.rs
@@ -781,25 +781,21 @@ impl FallbackSrc {
.get_pad_template(if is_audio { "audio" } else { "video" })
.unwrap();
let ghostpad = gst::GhostPad::builder_with_template(&templ, Some(&templ.get_name()))
+ .proxy_pad_chain_function({
+ let element_weak = element.downgrade();
+ move |pad, _parent, buffer| {
+ let element = match element_weak.upgrade() {
+ None => return Err(gst::FlowError::Flushing),
+ Some(element) => element,
+ };
+
+ let src = FallbackSrc::from_instance(&element);
+ src.proxy_pad_chain(&element, pad, buffer)
+ }
+ })
.build_with_target(&srcpad)
.unwrap();
- let proxypad = ghostpad.get_internal().expect("no internal pad");
- let element_weak = element.downgrade();
- // Safety: Nothing else can have a reference to the proxy pad yet apart from the ghost pad
- // itself, so changing the chain function is still safe.
- unsafe {
- proxypad.set_chain_function(move |pad, _parent, buffer| {
- let element = match element_weak.upgrade() {
- None => return Err(gst::FlowError::Flushing),
- Some(element) => element,
- };
-
- let src = FallbackSrc::from_instance(&element);
- src.proxy_pad_chain(&element, pad, buffer)
- });
- }
-
element.add_pad(&ghostpad).unwrap();
Ok(Stream {