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:
authorFrançois Laignel <francois@centricular.com>2023-05-10 18:02:08 +0300
committerFrançois Laignel <francois@centricular.com>2023-05-12 13:55:31 +0300
commit7ba0073052c81c8f2f1ebe500048ed6d974e81d8 (patch)
tree26a4f2b74ac8a7129b6ecc95e8affcb302aa1bc2 /utils/fallbackswitch
parent8e93d294e5a61a94f14e812bef59cd0e529494e1 (diff)
use Pad builders for optional name definition
Also, apply auto-naming in the following cases * When building from a non wildcard-named template, the name of the template is automatically assigned to the Pad. User can override with a specific name by calling `name()` on the `PadBuilder`. * When building with a target and no name was provided via the above, the GhostPad is named after the target. See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/448 Auto-naming discussion: https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1255#note_1891181 Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1197>
Diffstat (limited to 'utils/fallbackswitch')
-rw-r--r--utils/fallbackswitch/src/fallbacksrc/custom_source/imp.rs7
-rw-r--r--utils/fallbackswitch/src/fallbacksrc/imp.rs40
-rw-r--r--utils/fallbackswitch/src/fallbackswitch/imp.rs72
3 files changed, 55 insertions, 64 deletions
diff --git a/utils/fallbackswitch/src/fallbacksrc/custom_source/imp.rs b/utils/fallbackswitch/src/fallbacksrc/custom_source/imp.rs
index 2159f27a3..b158fa1ba 100644
--- a/utils/fallbackswitch/src/fallbacksrc/custom_source/imp.rs
+++ b/utils/fallbackswitch/src/fallbacksrc/custom_source/imp.rs
@@ -292,9 +292,10 @@ impl CustomSource {
(self.obj().pad_template("video_%u").unwrap(), name)
};
- let ghost_pad = gst::GhostPad::builder_with_template(&templ, Some(&name))
- .build_with_target(pad)
- .unwrap();
+ let ghost_pad = gst::GhostPad::builder_from_template_with_target(&templ, pad)
+ .unwrap()
+ .name(name)
+ .build();
let stream = Stream {
source_pad: pad.clone(),
diff --git a/utils/fallbackswitch/src/fallbacksrc/imp.rs b/utils/fallbackswitch/src/fallbacksrc/imp.rs
index 8ba75c5ae..4be3ed44c 100644
--- a/utils/fallbackswitch/src/fallbacksrc/imp.rs
+++ b/utils/fallbackswitch/src/fallbacksrc/imp.rs
@@ -943,8 +943,7 @@ impl FallbackSrc {
])
.unwrap();
- let ghostpad =
- gst::GhostPad::with_target(Some("src"), &queue.static_pad("src").unwrap()).unwrap();
+ let ghostpad = gst::GhostPad::with_target(&queue.static_pad("src").unwrap()).unwrap();
ghostpad.set_active(true).unwrap();
bin.add_pad(&ghostpad).unwrap();
@@ -1002,8 +1001,7 @@ impl FallbackSrc {
])
.unwrap();
- let ghostpad =
- gst::GhostPad::with_target(Some("src"), &queue.static_pad("src").unwrap()).unwrap();
+ let ghostpad = gst::GhostPad::with_target(&queue.static_pad("src").unwrap()).unwrap();
ghostpad.set_active(true).unwrap();
bin.add_pad(&ghostpad).unwrap();
@@ -1204,7 +1202,9 @@ impl FallbackSrc {
.obj()
.pad_template(if is_audio { "audio" } else { "video" })
.unwrap();
- let ghostpad = gst::GhostPad::builder_with_template(&templ, Some(&templ.name()))
+ let ghostpad = gst::GhostPad::builder_from_template_with_target(&templ, &srcpad)
+ .unwrap()
+ .name(templ.name())
.proxy_pad_chain_function({
move |pad, parent, buffer| {
let parent = parent.and_then(|p| p.parent());
@@ -1215,8 +1215,7 @@ impl FallbackSrc {
)
}
})
- .build_with_target(&srcpad)
- .unwrap();
+ .build();
let _ = ghostpad.set_active(true);
@@ -1612,14 +1611,11 @@ impl FallbackSrc {
gst::Element::link_many([&videoconvert, &videoscale, &imagefreeze, &capsfilter]).unwrap();
let ghostpad =
- gst::GhostPad::with_target(Some("sink"), &videoconvert.static_pad("sink").unwrap())
- .unwrap();
+ gst::GhostPad::with_target(&videoconvert.static_pad("sink").unwrap()).unwrap();
ghostpad.set_active(true).unwrap();
bin.add_pad(&ghostpad).unwrap();
- let ghostpad =
- gst::GhostPad::with_target(Some("src"), &capsfilter.static_pad("src").unwrap())
- .unwrap();
+ let ghostpad = gst::GhostPad::with_target(&capsfilter.static_pad("src").unwrap()).unwrap();
ghostpad.set_active(true).unwrap();
bin.add_pad(&ghostpad).unwrap();
@@ -1660,14 +1656,11 @@ impl FallbackSrc {
gst::Element::link_many([&videoconvert, &videoscale, &capsfilter]).unwrap();
let ghostpad =
- gst::GhostPad::with_target(Some("sink"), &videoconvert.static_pad("sink").unwrap())
- .unwrap();
+ gst::GhostPad::with_target(&videoconvert.static_pad("sink").unwrap()).unwrap();
ghostpad.set_active(true).unwrap();
bin.add_pad(&ghostpad).unwrap();
- let ghostpad =
- gst::GhostPad::with_target(Some("src"), &capsfilter.static_pad("src").unwrap())
- .unwrap();
+ let ghostpad = gst::GhostPad::with_target(&capsfilter.static_pad("src").unwrap()).unwrap();
ghostpad.set_active(true).unwrap();
bin.add_pad(&ghostpad).unwrap();
@@ -1708,14 +1701,11 @@ impl FallbackSrc {
gst::Element::link_many([&audioconvert, &audioresample, &capsfilter]).unwrap();
let ghostpad =
- gst::GhostPad::with_target(Some("sink"), &audioconvert.static_pad("sink").unwrap())
- .unwrap();
+ gst::GhostPad::with_target(&audioconvert.static_pad("sink").unwrap()).unwrap();
ghostpad.set_active(true).unwrap();
bin.add_pad(&ghostpad).unwrap();
- let ghostpad =
- gst::GhostPad::with_target(Some("src"), &capsfilter.static_pad("src").unwrap())
- .unwrap();
+ let ghostpad = gst::GhostPad::with_target(&capsfilter.static_pad("src").unwrap()).unwrap();
ghostpad.set_active(true).unwrap();
bin.add_pad(&ghostpad).unwrap();
@@ -1891,8 +1881,10 @@ impl FallbackSrc {
gst::Element::link_many([&converters, &queue, &clocksync]).unwrap();
- let ghostpad =
- gst::GhostPad::with_target(Some(type_), &clocksync.static_pad("src").unwrap()).unwrap();
+ let ghostpad = gst::GhostPad::builder_with_target(&clocksync.static_pad("src").unwrap())
+ .unwrap()
+ .name(type_)
+ .build();
let _ = ghostpad.set_active(true);
source.source.add_pad(&ghostpad).unwrap();
diff --git a/utils/fallbackswitch/src/fallbackswitch/imp.rs b/utils/fallbackswitch/src/fallbackswitch/imp.rs
index 5db9ba0e5..bea69f1a3 100644
--- a/utils/fallbackswitch/src/fallbackswitch/imp.rs
+++ b/utils/fallbackswitch/src/fallbackswitch/imp.rs
@@ -1043,7 +1043,7 @@ impl ObjectSubclass for FallbackSwitch {
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.pad_template("src").unwrap();
- let srcpad = gst::Pad::builder_with_template(&templ, Some("src"))
+ let srcpad = gst::Pad::builder_from_template(&templ)
.query_function(|pad, parent, query| {
FallbackSwitch::catch_panic_pad_function(
parent,
@@ -1334,42 +1334,40 @@ impl ElementImpl for FallbackSwitch {
let pad_serial = self.sink_pad_serial.fetch_add(1, Ordering::SeqCst);
- let pad = gst::PadBuilder::<super::FallbackSwitchSinkPad>::from_template(
- templ,
- Some(format!("sink_{pad_serial}").as_str()),
- )
- .chain_function(|pad, parent, buffer| {
- FallbackSwitch::catch_panic_pad_function(
- parent,
- || Err(gst::FlowError::Error),
- |fallbackswitch| fallbackswitch.sink_chain(pad, buffer),
- )
- })
- .chain_list_function(|pad, parent, bufferlist| {
- FallbackSwitch::catch_panic_pad_function(
- parent,
- || Err(gst::FlowError::Error),
- |fallbackswitch| fallbackswitch.sink_chain_list(pad, bufferlist),
- )
- })
- .event_function(|pad, parent, event| {
- FallbackSwitch::catch_panic_pad_function(
- parent,
- || false,
- |fallbackswitch| fallbackswitch.sink_event(pad, event),
- )
- })
- .query_function(|pad, parent, query| {
- FallbackSwitch::catch_panic_pad_function(
- parent,
- || false,
- |fallbackswitch| fallbackswitch.sink_query(pad, query),
- )
- })
- .activatemode_function(|pad, _parent, mode, activate| {
- Self::sink_activatemode(pad, mode, activate)
- })
- .build();
+ let pad = gst::PadBuilder::<super::FallbackSwitchSinkPad>::from_template(templ)
+ .name(format!("sink_{pad_serial}").as_str())
+ .chain_function(|pad, parent, buffer| {
+ FallbackSwitch::catch_panic_pad_function(
+ parent,
+ || Err(gst::FlowError::Error),
+ |fallbackswitch| fallbackswitch.sink_chain(pad, buffer),
+ )
+ })
+ .chain_list_function(|pad, parent, bufferlist| {
+ FallbackSwitch::catch_panic_pad_function(
+ parent,
+ || Err(gst::FlowError::Error),
+ |fallbackswitch| fallbackswitch.sink_chain_list(pad, bufferlist),
+ )
+ })
+ .event_function(|pad, parent, event| {
+ FallbackSwitch::catch_panic_pad_function(
+ parent,
+ || false,
+ |fallbackswitch| fallbackswitch.sink_event(pad, event),
+ )
+ })
+ .query_function(|pad, parent, query| {
+ FallbackSwitch::catch_panic_pad_function(
+ parent,
+ || false,
+ |fallbackswitch| fallbackswitch.sink_query(pad, query),
+ )
+ })
+ .activatemode_function(|pad, _parent, mode, activate| {
+ Self::sink_activatemode(pad, mode, activate)
+ })
+ .build();
pad.set_active(true).unwrap();
self.obj().add_pad(&pad).unwrap();