utils/fallbacksrc: Add update-uri signal

This allows to update the URI just before configuring it on
uridecodebin3. It might be necessary to update the original URI because
it expired in the meantime, for example.
This commit is contained in:
Sebastian Dröge 2020-09-22 15:06:07 +03:00 committed by Sebastian Dröge
parent 331374fabe
commit 4561b0bc3c

View file

@ -313,6 +313,21 @@ impl ObjectSubclass for FallbackSrc {
klass.add_pad_template(src_pad_template);
klass.install_properties(&PROPERTIES);
klass.add_signal_with_class_handler_and_accumulator(
"update-uri",
glib::SignalFlags::RUN_LAST | glib::SignalFlags::ACTION,
&[String::static_type()],
String::static_type(),
|_token, args| {
// Simplify return the input by default
Some(args[1].clone())
},
|_hint, ret, value| {
*ret = value.clone();
false
},
);
}
}
@ -648,6 +663,14 @@ impl FallbackSrc {
let source = gst::ElementFactory::make("uridecodebin3", Some("uridecodebin"))
.expect("No uridecodebin3 found");
let uri = element
.emit("update-uri", &[uri])
.expect("Failed to emit update-uri signal")
.expect("No value returned");
let uri = uri
.get::<&str>()
.expect("Wrong type returned from update-uri signal");
source.set_property("uri", &uri).unwrap();
source.set_property("use-buffering", &true).unwrap();
source