From 7ba0073052c81c8f2f1ebe500048ed6d974e81d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Laignel?= Date: Wed, 10 May 2023 17:02:08 +0200 Subject: [PATCH] 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: --- audio/audiofx/src/audioloudnorm/imp.rs | 4 +- generic/sodium/src/decrypter/imp.rs | 4 +- generic/sodium/src/encrypter/imp.rs | 4 +- .../standalone/sink/async_mutex/imp.rs | 2 +- .../standalone/sink/sync_mutex/imp.rs | 2 +- .../examples/standalone/sink/task/imp.rs | 2 +- .../examples/standalone/src/imp.rs | 2 +- generic/threadshare/src/appsrc/imp.rs | 2 +- generic/threadshare/src/audiotestsrc/imp.rs | 2 +- generic/threadshare/src/inputselector/imp.rs | 7 +- generic/threadshare/src/jitterbuffer/imp.rs | 4 +- generic/threadshare/src/proxy/imp.rs | 4 +- generic/threadshare/src/queue/imp.rs | 4 +- generic/threadshare/src/tcpclientsrc/imp.rs | 2 +- generic/threadshare/src/udpsink/imp.rs | 2 +- generic/threadshare/src/udpsrc/imp.rs | 2 +- generic/threadshare/tests/pad.rs | 4 +- mux/flavors/src/flvdemux/imp.rs | 4 +- mux/fmp4/src/fmp4mux/imp.rs | 7 +- net/aws/src/s3hlssink/imp.rs | 8 +- net/aws/src/transcribe_parse/imp.rs | 4 +- net/aws/src/transcriber/imp.rs | 95 +++++++------- net/hlssink3/src/imp.rs | 8 +- net/ndi/src/ndisinkcombiner/imp.rs | 7 +- net/ndi/src/ndisrcdemux/imp.rs | 6 +- net/onvif/src/onvifmetadatacombiner/imp.rs | 5 +- net/onvif/src/onvifmetadataoverlay/imp.rs | 4 +- net/onvif/src/onvifmetadataparse/imp.rs | 4 +- net/raptorq/src/raptorqdec/imp.rs | 7 +- net/raptorq/src/raptorqenc/imp.rs | 6 +- net/reqwest/tests/reqwesthttpsrc.rs | 3 +- net/rtp/src/gcc/imp.rs | 4 +- net/webrtc/src/webrtcsink/imp.rs | 15 +-- net/webrtc/src/webrtcsrc/imp.rs | 12 +- net/webrtchttp/src/whepsrc/imp.rs | 4 +- net/webrtchttp/src/whipsink/imp.rs | 4 +- text/ahead/src/textahead/imp.rs | 4 +- text/json/src/jsongstenc/imp.rs | 4 +- text/json/src/jsongstparse/imp.rs | 4 +- text/regex/src/gstregex/imp.rs | 4 +- text/wrap/src/gsttextwrap/imp.rs | 4 +- tutorial/src/identity/imp.rs | 4 +- tutorial/src/progressbin/imp.rs | 4 +- .../src/fallbacksrc/custom_source/imp.rs | 7 +- utils/fallbackswitch/src/fallbacksrc/imp.rs | 40 +++--- .../fallbackswitch/src/fallbackswitch/imp.rs | 72 +++++----- utils/livesync/src/livesync/imp.rs | 124 +++++++++--------- utils/togglerecord/src/togglerecord/imp.rs | 10 +- .../uriplaylistbin/src/uriplaylistbin/imp.rs | 5 +- video/closedcaption/src/cea608overlay/imp.rs | 4 +- video/closedcaption/src/cea608tocea708/imp.rs | 4 +- video/closedcaption/src/cea608tojson/imp.rs | 4 +- video/closedcaption/src/cea608tott/imp.rs | 4 +- video/closedcaption/src/jsontovtt/imp.rs | 4 +- video/closedcaption/src/mcc_enc/imp.rs | 4 +- video/closedcaption/src/mcc_parse/imp.rs | 4 +- video/closedcaption/src/scc_enc/imp.rs | 4 +- video/closedcaption/src/scc_parse/imp.rs | 4 +- video/closedcaption/src/transcriberbin/imp.rs | 61 ++++----- video/closedcaption/src/tttocea608/imp.rs | 4 +- video/closedcaption/src/tttojson/imp.rs | 4 +- video/ffv1/tests/ffv1dec.rs | 2 +- video/gtk4/examples/gtksink.rs | 7 +- video/videofx/src/videocompare/mod.rs | 8 +- video/webp/src/dec/imp.rs | 4 +- 65 files changed, 327 insertions(+), 345 deletions(-) diff --git a/audio/audiofx/src/audioloudnorm/imp.rs b/audio/audiofx/src/audioloudnorm/imp.rs index 183b7c1c..cc7c03c1 100644 --- a/audio/audiofx/src/audioloudnorm/imp.rs +++ b/audio/audiofx/src/audioloudnorm/imp.rs @@ -1690,7 +1690,7 @@ impl ObjectSubclass for AudioLoudNorm { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { Self::catch_panic_pad_function( parent, @@ -1705,7 +1705,7 @@ impl ObjectSubclass for AudioLoudNorm { .build(); 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| { Self::catch_panic_pad_function(parent, || false, |this| this.src_query(pad, query)) }) diff --git a/generic/sodium/src/decrypter/imp.rs b/generic/sodium/src/decrypter/imp.rs index f722314e..794e0d5a 100644 --- a/generic/sodium/src/decrypter/imp.rs +++ b/generic/sodium/src/decrypter/imp.rs @@ -526,10 +526,10 @@ impl ObjectSubclass for Decrypter { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::from_template(&templ, Some("sink")); + let sinkpad = gst::Pad::from_template(&templ); 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) .getrange_function(|pad, parent, offset, buffer, size| { Decrypter::catch_panic_pad_function( parent, diff --git a/generic/sodium/src/encrypter/imp.rs b/generic/sodium/src/encrypter/imp.rs index af99edde..b6560e0f 100644 --- a/generic/sodium/src/encrypter/imp.rs +++ b/generic/sodium/src/encrypter/imp.rs @@ -329,7 +329,7 @@ impl ObjectSubclass for Encrypter { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { Encrypter::catch_panic_pad_function( parent, @@ -347,7 +347,7 @@ impl ObjectSubclass for Encrypter { .build(); 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| { Encrypter::catch_panic_pad_function( parent, diff --git a/generic/threadshare/examples/standalone/sink/async_mutex/imp.rs b/generic/threadshare/examples/standalone/sink/async_mutex/imp.rs index b909ab48..75613181 100644 --- a/generic/threadshare/examples/standalone/sink/async_mutex/imp.rs +++ b/generic/threadshare/examples/standalone/sink/async_mutex/imp.rs @@ -241,7 +241,7 @@ impl ObjectSubclass for AsyncMutexSink { let sink_pad_handler = AsyncPadSinkHandler::default(); Self { sink_pad: PadSink::new( - gst::Pad::from_template(&klass.pad_template("sink").unwrap(), Some("sink")), + gst::Pad::from_template(&klass.pad_template("sink").unwrap()), sink_pad_handler.clone(), ), sink_pad_handler, diff --git a/generic/threadshare/examples/standalone/sink/sync_mutex/imp.rs b/generic/threadshare/examples/standalone/sink/sync_mutex/imp.rs index bef18db1..18957e40 100644 --- a/generic/threadshare/examples/standalone/sink/sync_mutex/imp.rs +++ b/generic/threadshare/examples/standalone/sink/sync_mutex/imp.rs @@ -234,7 +234,7 @@ impl ObjectSubclass for DirectSink { let sink_pad_handler = SyncPadSinkHandler::default(); Self { sink_pad: PadSink::new( - gst::Pad::from_template(&klass.pad_template("sink").unwrap(), Some("sink")), + gst::Pad::from_template(&klass.pad_template("sink").unwrap()), sink_pad_handler.clone(), ), sink_pad_handler, diff --git a/generic/threadshare/examples/standalone/sink/task/imp.rs b/generic/threadshare/examples/standalone/sink/task/imp.rs index 3979a0e3..1ac86965 100644 --- a/generic/threadshare/examples/standalone/sink/task/imp.rs +++ b/generic/threadshare/examples/standalone/sink/task/imp.rs @@ -305,7 +305,7 @@ impl ObjectSubclass for TaskSink { fn with_class(klass: &Self::Class) -> Self { Self { sink_pad: PadSink::new( - gst::Pad::from_template(&klass.pad_template("sink").unwrap(), Some("sink")), + gst::Pad::from_template(&klass.pad_template("sink").unwrap()), TaskPadSinkHandler, ), task: Task::default(), diff --git a/generic/threadshare/examples/standalone/src/imp.rs b/generic/threadshare/examples/standalone/src/imp.rs index ba397d2f..821025f9 100644 --- a/generic/threadshare/examples/standalone/src/imp.rs +++ b/generic/threadshare/examples/standalone/src/imp.rs @@ -318,7 +318,7 @@ impl ObjectSubclass for TestSrc { fn with_class(klass: &Self::Class) -> Self { Self { src_pad: PadSrc::new( - gst::Pad::from_template(&klass.pad_template("src").unwrap(), Some("src")), + gst::Pad::from_template(&klass.pad_template("src").unwrap()), TestSrcPadHandler, ), task: Task::default(), diff --git a/generic/threadshare/src/appsrc/imp.rs b/generic/threadshare/src/appsrc/imp.rs index ceb79201..10e5c963 100644 --- a/generic/threadshare/src/appsrc/imp.rs +++ b/generic/threadshare/src/appsrc/imp.rs @@ -432,7 +432,7 @@ impl ObjectSubclass for AppSrc { fn with_class(klass: &Self::Class) -> Self { Self { src_pad: PadSrc::new( - gst::Pad::from_template(&klass.pad_template("src").unwrap(), Some("src")), + gst::Pad::from_template(&klass.pad_template("src").unwrap()), AppSrcPadHandler, ), task: Task::default(), diff --git a/generic/threadshare/src/audiotestsrc/imp.rs b/generic/threadshare/src/audiotestsrc/imp.rs index c48f56fa..a628c193 100644 --- a/generic/threadshare/src/audiotestsrc/imp.rs +++ b/generic/threadshare/src/audiotestsrc/imp.rs @@ -543,7 +543,7 @@ impl ObjectSubclass for AudioTestSrc { fn with_class(klass: &Self::Class) -> Self { Self { src_pad: PadSrc::new( - gst::Pad::from_template(&klass.pad_template("src").unwrap(), Some("src")), + gst::Pad::from_template(&klass.pad_template("src").unwrap()), AudioTestSrcPadHandler, ), task: Task::default(), diff --git a/generic/threadshare/src/inputselector/imp.rs b/generic/threadshare/src/inputselector/imp.rs index 0455f227..81cf5cd3 100644 --- a/generic/threadshare/src/inputselector/imp.rs +++ b/generic/threadshare/src/inputselector/imp.rs @@ -355,7 +355,7 @@ impl ObjectSubclass for InputSelector { fn with_class(klass: &Self::Class) -> Self { Self { src_pad: PadSrc::new( - gst::Pad::from_template(&klass.pad_template("src").unwrap(), Some("src")), + gst::Pad::from_template(&klass.pad_template("src").unwrap()), InputSelectorPadSrcHandler, ), state: Mutex::new(State::default()), @@ -545,8 +545,9 @@ impl ElementImpl for InputSelector { ) -> Option { let mut state = self.state.lock().unwrap(); let mut pads = self.pads.lock().unwrap(); - let sink_pad = - gst::Pad::from_template(templ, Some(format!("sink_{}", pads.pad_serial).as_str())); + let sink_pad = gst::Pad::builder_from_template(templ) + .name(format!("sink_{}", pads.pad_serial).as_str()) + .build(); pads.pad_serial += 1; sink_pad.set_active(true).unwrap(); self.obj().add_pad(&sink_pad).unwrap(); diff --git a/generic/threadshare/src/jitterbuffer/imp.rs b/generic/threadshare/src/jitterbuffer/imp.rs index 881d6844..b5b51513 100644 --- a/generic/threadshare/src/jitterbuffer/imp.rs +++ b/generic/threadshare/src/jitterbuffer/imp.rs @@ -1302,11 +1302,11 @@ impl ObjectSubclass for JitterBuffer { Self { sink_pad: PadSink::new( - gst::Pad::from_template(&klass.pad_template("sink").unwrap(), Some("sink")), + gst::Pad::from_template(&klass.pad_template("sink").unwrap()), sink_pad_handler.clone(), ), src_pad: PadSrc::new( - gst::Pad::from_template(&klass.pad_template("src").unwrap(), Some("src")), + gst::Pad::from_template(&klass.pad_template("src").unwrap()), src_pad_handler.clone(), ), sink_pad_handler, diff --git a/generic/threadshare/src/proxy/imp.rs b/generic/threadshare/src/proxy/imp.rs index 04acca05..50537414 100644 --- a/generic/threadshare/src/proxy/imp.rs +++ b/generic/threadshare/src/proxy/imp.rs @@ -542,7 +542,7 @@ impl ObjectSubclass for ProxySink { fn with_class(klass: &Self::Class) -> Self { Self { sink_pad: PadSink::new( - gst::Pad::from_template(&klass.pad_template("sink").unwrap(), Some("sink")), + gst::Pad::from_template(&klass.pad_template("sink").unwrap()), ProxySinkPadHandler, ), proxy_ctx: Mutex::new(None), @@ -1045,7 +1045,7 @@ impl ObjectSubclass for ProxySrc { fn with_class(klass: &Self::Class) -> Self { Self { src_pad: PadSrc::new( - gst::Pad::from_template(&klass.pad_template("src").unwrap(), Some("src")), + gst::Pad::from_template(&klass.pad_template("src").unwrap()), ProxySrcPadHandler, ), task: Task::default(), diff --git a/generic/threadshare/src/queue/imp.rs b/generic/threadshare/src/queue/imp.rs index 71cc631d..cc528763 100644 --- a/generic/threadshare/src/queue/imp.rs +++ b/generic/threadshare/src/queue/imp.rs @@ -631,11 +631,11 @@ impl ObjectSubclass for Queue { fn with_class(klass: &Self::Class) -> Self { Self { sink_pad: PadSink::new( - gst::Pad::from_template(&klass.pad_template("sink").unwrap(), Some("sink")), + gst::Pad::from_template(&klass.pad_template("sink").unwrap()), QueuePadSinkHandler, ), src_pad: PadSrc::new( - gst::Pad::from_template(&klass.pad_template("src").unwrap(), Some("src")), + gst::Pad::from_template(&klass.pad_template("src").unwrap()), QueuePadSrcHandler, ), task: Task::default(), diff --git a/generic/threadshare/src/tcpclientsrc/imp.rs b/generic/threadshare/src/tcpclientsrc/imp.rs index cbbf2505..ee6c18d6 100644 --- a/generic/threadshare/src/tcpclientsrc/imp.rs +++ b/generic/threadshare/src/tcpclientsrc/imp.rs @@ -485,7 +485,7 @@ impl ObjectSubclass for TcpClientSrc { fn with_class(klass: &Self::Class) -> Self { Self { src_pad: PadSrc::new( - gst::Pad::from_template(&klass.pad_template("src").unwrap(), Some("src")), + gst::Pad::from_template(&klass.pad_template("src").unwrap()), TcpClientSrcPadHandler, ), task: Task::default(), diff --git a/generic/threadshare/src/udpsink/imp.rs b/generic/threadshare/src/udpsink/imp.rs index 77053235..138d15e9 100644 --- a/generic/threadshare/src/udpsink/imp.rs +++ b/generic/threadshare/src/udpsink/imp.rs @@ -848,7 +848,7 @@ impl ObjectSubclass for UdpSink { let sink_pad_handler = UdpSinkPadHandler::default(); Self { sink_pad: PadSink::new( - gst::Pad::from_template(&klass.pad_template("sink").unwrap(), Some("sink")), + gst::Pad::from_template(&klass.pad_template("sink").unwrap()), sink_pad_handler.clone(), ), sink_pad_handler, diff --git a/generic/threadshare/src/udpsrc/imp.rs b/generic/threadshare/src/udpsrc/imp.rs index cfd95de8..18f9d0a8 100644 --- a/generic/threadshare/src/udpsrc/imp.rs +++ b/generic/threadshare/src/udpsrc/imp.rs @@ -620,7 +620,7 @@ impl ObjectSubclass for UdpSrc { fn with_class(klass: &Self::Class) -> Self { Self { src_pad: PadSrc::new( - gst::Pad::from_template(&klass.pad_template("src").unwrap(), Some("src")), + gst::Pad::from_template(&klass.pad_template("src").unwrap()), UdpSrcPadHandler, ), task: Task::default(), diff --git a/generic/threadshare/tests/pad.rs b/generic/threadshare/tests/pad.rs index c99f6a3b..406b1503 100644 --- a/generic/threadshare/tests/pad.rs +++ b/generic/threadshare/tests/pad.rs @@ -282,7 +282,7 @@ mod imp_src { fn with_class(klass: &Self::Class) -> Self { ElementSrcTest { src_pad: PadSrc::new( - gst::Pad::from_template(&klass.pad_template("src").unwrap(), Some("src")), + gst::Pad::from_template(&klass.pad_template("src").unwrap()), PadSrcTestHandler, ), task: Task::default(), @@ -575,7 +575,7 @@ mod imp_sink { fn with_class(klass: &Self::Class) -> Self { ElementSinkTest { sink_pad: PadSink::new( - gst::Pad::from_template(&klass.pad_template("sink").unwrap(), Some("sink")), + gst::Pad::from_template(&klass.pad_template("sink").unwrap()), PadSinkTestHandler, ), flushing: AtomicBool::new(true), diff --git a/mux/flavors/src/flvdemux/imp.rs b/mux/flavors/src/flvdemux/imp.rs index d92f2376..528d3dae 100644 --- a/mux/flavors/src/flvdemux/imp.rs +++ b/mux/flavors/src/flvdemux/imp.rs @@ -129,7 +129,7 @@ impl ObjectSubclass for FlvDemux { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .activate_function(|pad, parent| { FlvDemux::catch_panic_pad_function( parent, @@ -620,7 +620,7 @@ impl FlvDemux { fn create_srcpad(&self, name: &str, caps: &gst::Caps) -> gst::Pad { let templ = self.obj().element_class().pad_template(name).unwrap(); - let srcpad = gst::Pad::builder_with_template(&templ, Some(name)) + let srcpad = gst::Pad::builder_from_template(&templ) .event_function(|pad, parent, event| { FlvDemux::catch_panic_pad_function( parent, diff --git a/mux/fmp4/src/fmp4mux/imp.rs b/mux/fmp4/src/fmp4mux/imp.rs index d96f0199..ae913571 100644 --- a/mux/fmp4/src/fmp4mux/imp.rs +++ b/mux/fmp4/src/fmp4mux/imp.rs @@ -2890,10 +2890,9 @@ impl ObjectImpl for FMP4Mux { templ.presence() == gst::PadPresence::Always && templ.direction() == gst::PadDirection::Sink }) { - let sinkpad = - gst::PadBuilder::::from_template(&templ, Some("sink")) - .flags(gst::PadFlags::ACCEPT_INTERSECT) - .build(); + let sinkpad = gst::PadBuilder::::from_template(&templ) + .flags(gst::PadFlags::ACCEPT_INTERSECT) + .build(); obj.add_pad(&sinkpad).unwrap(); } diff --git a/net/aws/src/s3hlssink/imp.rs b/net/aws/src/s3hlssink/imp.rs index e4255d8f..1c53189a 100644 --- a/net/aws/src/s3hlssink/imp.rs +++ b/net/aws/src/s3hlssink/imp.rs @@ -884,9 +884,7 @@ impl ElementImpl for S3HlsSink { } let audio_pad = self.hlssink.request_pad_simple("audio").unwrap(); - let sink_pad = - gst::GhostPad::from_template_with_target(templ, Some("audio"), &audio_pad) - .unwrap(); + let sink_pad = gst::GhostPad::from_template_with_target(templ, &audio_pad).unwrap(); self.obj().add_pad(&sink_pad).unwrap(); sink_pad.set_active(true).unwrap(); settings.audio_sink = true; @@ -904,9 +902,7 @@ impl ElementImpl for S3HlsSink { } let video_pad = self.hlssink.request_pad_simple("video").unwrap(); - let sink_pad = - gst::GhostPad::from_template_with_target(templ, Some("video"), &video_pad) - .unwrap(); + let sink_pad = gst::GhostPad::from_template_with_target(templ, &video_pad).unwrap(); self.obj().add_pad(&sink_pad).unwrap(); sink_pad.set_active(true).unwrap(); settings.video_sink = true; diff --git a/net/aws/src/transcribe_parse/imp.rs b/net/aws/src/transcribe_parse/imp.rs index b8ba0fd5..4a3a4865 100644 --- a/net/aws/src/transcribe_parse/imp.rs +++ b/net/aws/src/transcribe_parse/imp.rs @@ -252,7 +252,7 @@ impl ObjectSubclass for TranscribeParse { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { TranscribeParse::catch_panic_pad_function( parent, @@ -270,7 +270,7 @@ impl ObjectSubclass for TranscribeParse { .build(); let templ = klass.pad_template("src").unwrap(); - let srcpad = gst::Pad::builder_with_template(&templ, Some("src")).build(); + let srcpad = gst::Pad::from_template(&templ); Self { srcpad, diff --git a/net/aws/src/transcriber/imp.rs b/net/aws/src/transcriber/imp.rs index 9658b814..bc160b63 100644 --- a/net/aws/src/transcriber/imp.rs +++ b/net/aws/src/transcriber/imp.rs @@ -589,7 +589,7 @@ impl ObjectSubclass for Transcriber { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { Transcriber::catch_panic_pad_function( parent, @@ -607,29 +607,28 @@ impl ObjectSubclass for Transcriber { .build(); let templ = klass.pad_template("src").unwrap(); - let static_srcpad = - gst::PadBuilder::::from_template(&templ, Some("src")) - .activatemode_function(|pad, parent, mode, active| { - Transcriber::catch_panic_pad_function( - parent, - || { - Err(gst::loggable_error!( - CAT, - "Panic activating TranslateSrcPad" - )) - }, - |elem| TranslateSrcPad::activatemode(elem, pad, mode, active), - ) - }) - .query_function(|pad, parent, query| { - Transcriber::catch_panic_pad_function( - parent, - || false, - |elem| TranslateSrcPad::src_query(elem, pad, query), - ) - }) - .flags(gst::PadFlags::FIXED_CAPS) - .build(); + let static_srcpad = gst::PadBuilder::::from_template(&templ) + .activatemode_function(|pad, parent, mode, active| { + Transcriber::catch_panic_pad_function( + parent, + || { + Err(gst::loggable_error!( + CAT, + "Panic activating TranslateSrcPad" + )) + }, + |elem| TranslateSrcPad::activatemode(elem, pad, mode, active), + ) + }) + .query_function(|pad, parent, query| { + Transcriber::catch_panic_pad_function( + parent, + || false, + |elem| TranslateSrcPad::src_query(elem, pad, query), + ) + }) + .flags(gst::PadFlags::FIXED_CAPS) + .build(); // Setting the channel capacity so that a TranslateSrcPad that would lag // behind for some reasons get a chance to catch-up without loosing items. @@ -986,31 +985,29 @@ impl ElementImpl for Transcriber { ) -> Option { let mut state = self.state.lock().unwrap(); - let pad = gst::PadBuilder::::from_template( - templ, - Some(format!("translate_src_{}", state.pad_serial).as_str()), - ) - .activatemode_function(|pad, parent, mode, active| { - Transcriber::catch_panic_pad_function( - parent, - || { - Err(gst::loggable_error!( - CAT, - "Panic activating TranslateSrcPad" - )) - }, - |elem| TranslateSrcPad::activatemode(elem, pad, mode, active), - ) - }) - .query_function(|pad, parent, query| { - Transcriber::catch_panic_pad_function( - parent, - || false, - |elem| TranslateSrcPad::src_query(elem, pad, query), - ) - }) - .flags(gst::PadFlags::FIXED_CAPS) - .build(); + let pad = gst::PadBuilder::::from_template(templ) + .name(format!("translate_src_{}", state.pad_serial).as_str()) + .activatemode_function(|pad, parent, mode, active| { + Transcriber::catch_panic_pad_function( + parent, + || { + Err(gst::loggable_error!( + CAT, + "Panic activating TranslateSrcPad" + )) + }, + |elem| TranslateSrcPad::activatemode(elem, pad, mode, active), + ) + }) + .query_function(|pad, parent, query| { + Transcriber::catch_panic_pad_function( + parent, + || false, + |elem| TranslateSrcPad::src_query(elem, pad, query), + ) + }) + .flags(gst::PadFlags::FIXED_CAPS) + .build(); state.srcpads.insert(pad.clone()); diff --git a/net/hlssink3/src/imp.rs b/net/hlssink3/src/imp.rs index 324634b1..c629ce40 100644 --- a/net/hlssink3/src/imp.rs +++ b/net/hlssink3/src/imp.rs @@ -797,9 +797,7 @@ impl ElementImpl for HlsSink3 { } let peer_pad = settings.splitmuxsink.request_pad_simple("audio_0").unwrap(); - let sink_pad = - gst::GhostPad::from_template_with_target(templ, Some("audio"), &peer_pad) - .unwrap(); + let sink_pad = gst::GhostPad::from_template_with_target(templ, &peer_pad).unwrap(); self.obj().add_pad(&sink_pad).unwrap(); sink_pad.set_active(true).unwrap(); settings.audio_sink = true; @@ -817,9 +815,7 @@ impl ElementImpl for HlsSink3 { } let peer_pad = settings.splitmuxsink.request_pad_simple("video").unwrap(); - let sink_pad = - gst::GhostPad::from_template_with_target(templ, Some("video"), &peer_pad) - .unwrap(); + let sink_pad = gst::GhostPad::from_template_with_target(templ, &peer_pad).unwrap(); self.obj().add_pad(&sink_pad).unwrap(); sink_pad.set_active(true).unwrap(); settings.video_sink = true; diff --git a/net/ndi/src/ndisinkcombiner/imp.rs b/net/ndi/src/ndisinkcombiner/imp.rs index c2921091..eb83af97 100644 --- a/net/ndi/src/ndisinkcombiner/imp.rs +++ b/net/ndi/src/ndisinkcombiner/imp.rs @@ -52,9 +52,7 @@ impl ObjectSubclass for NdiSinkCombiner { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("video").unwrap(); - let video_pad = - gst::PadBuilder::::from_template(&templ, Some("video")) - .build(); + let video_pad = gst::PadBuilder::::from_template(&templ).build(); Self { video_pad, @@ -176,8 +174,7 @@ impl AggregatorImpl for NdiSinkCombiner { return None; } - let pad = - gst::PadBuilder::::from_template(templ, Some("audio")).build(); + let pad = gst::PadBuilder::::from_template(templ).build(); *audio_pad_storage = Some(pad.clone()); gst::debug!(CAT, imp: self, "Requested audio pad"); diff --git a/net/ndi/src/ndisrcdemux/imp.rs b/net/ndi/src/ndisrcdemux/imp.rs index a64c280f..75901664 100644 --- a/net/ndi/src/ndisrcdemux/imp.rs +++ b/net/ndi/src/ndisrcdemux/imp.rs @@ -40,7 +40,7 @@ impl ObjectSubclass for NdiSrcDemux { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .flags(gst::PadFlags::FIXED_CAPS) .chain_function(|pad, parent, buffer| { NdiSrcDemux::catch_panic_pad_function( @@ -180,7 +180,7 @@ impl NdiSrcDemux { gst::debug!(CAT, imp: self, "Adding audio pad with caps {}", caps); let templ = self.obj().element_class().pad_template("audio").unwrap(); - let pad = gst::Pad::builder_with_template(&templ, Some("audio")) + let pad = gst::Pad::builder_from_template(&templ) .flags(gst::PadFlags::FIXED_CAPS) .build(); @@ -229,7 +229,7 @@ impl NdiSrcDemux { gst::debug!(CAT, imp: self, "Adding video pad with caps {}", caps); let templ = self.obj().element_class().pad_template("video").unwrap(); - let pad = gst::Pad::builder_with_template(&templ, Some("video")) + let pad = gst::Pad::builder_from_template(&templ) .flags(gst::PadFlags::FIXED_CAPS) .build(); diff --git a/net/onvif/src/onvifmetadatacombiner/imp.rs b/net/onvif/src/onvifmetadatacombiner/imp.rs index 2a5e8737..9cd56f53 100644 --- a/net/onvif/src/onvifmetadatacombiner/imp.rs +++ b/net/onvif/src/onvifmetadatacombiner/imp.rs @@ -42,12 +42,11 @@ impl ObjectSubclass for OnvifMetadataCombiner { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("media").unwrap(); let media_sink_pad = - gst::PadBuilder::::from_template(&templ, Some("media")) - .build(); + gst::PadBuilder::::from_template(&templ).build(); let templ = klass.pad_template("meta").unwrap(); let meta_sink_pad = - gst::PadBuilder::::from_template(&templ, Some("meta")).build(); + gst::PadBuilder::::from_template(&templ).build(); Self { media_sink_pad, diff --git a/net/onvif/src/onvifmetadataoverlay/imp.rs b/net/onvif/src/onvifmetadataoverlay/imp.rs index f1acaedd..6003ff3a 100644 --- a/net/onvif/src/onvifmetadataoverlay/imp.rs +++ b/net/onvif/src/onvifmetadataoverlay/imp.rs @@ -715,7 +715,7 @@ impl ObjectSubclass for OnvifMetadataOverlay { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { OnvifMetadataOverlay::catch_panic_pad_function( parent, @@ -735,7 +735,7 @@ impl ObjectSubclass for OnvifMetadataOverlay { .build(); 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) .flags(gst::PadFlags::PROXY_CAPS) .flags(gst::PadFlags::PROXY_ALLOCATION) .build(); diff --git a/net/onvif/src/onvifmetadataparse/imp.rs b/net/onvif/src/onvifmetadataparse/imp.rs index 2e138d54..f1464e41 100644 --- a/net/onvif/src/onvifmetadataparse/imp.rs +++ b/net/onvif/src/onvifmetadataparse/imp.rs @@ -1407,7 +1407,7 @@ impl ObjectSubclass for OnvifMetadataParse { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { OnvifMetadataParse::catch_panic_pad_function( parent, @@ -1433,7 +1433,7 @@ impl ObjectSubclass for OnvifMetadataParse { .build(); 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) .event_function(|pad, parent, event| { OnvifMetadataParse::catch_panic_pad_function( parent, diff --git a/net/raptorq/src/raptorqdec/imp.rs b/net/raptorq/src/raptorqdec/imp.rs index aba109eb..6c305b95 100644 --- a/net/raptorq/src/raptorqdec/imp.rs +++ b/net/raptorq/src/raptorqdec/imp.rs @@ -590,7 +590,7 @@ impl ObjectSubclass for RaptorqDec { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { Self::catch_panic_pad_function( parent, @@ -612,7 +612,7 @@ impl ObjectSubclass for RaptorqDec { .build(); 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) .iterate_internal_links_function(|pad, parent| { Self::catch_panic_pad_function( parent, @@ -821,7 +821,8 @@ impl ElementImpl for RaptorqDec { return None; } - let sinkpad_fec = gst::Pad::builder_with_template(templ, name) + let sinkpad_fec = gst::Pad::builder_from_template(templ) + .maybe_name(name) .chain_function(|pad, parent, buffer| { Self::catch_panic_pad_function( parent, diff --git a/net/raptorq/src/raptorqenc/imp.rs b/net/raptorq/src/raptorqenc/imp.rs index 07264d7f..cb37a0a2 100644 --- a/net/raptorq/src/raptorqenc/imp.rs +++ b/net/raptorq/src/raptorqenc/imp.rs @@ -659,7 +659,7 @@ impl ObjectSubclass for RaptorqEnc { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { Self::catch_panic_pad_function( parent, @@ -681,7 +681,7 @@ impl ObjectSubclass for RaptorqEnc { .build(); 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) .iterate_internal_links_function(|pad, parent| { Self::catch_panic_pad_function( parent, @@ -693,7 +693,7 @@ impl ObjectSubclass for RaptorqEnc { .build(); let templ = klass.pad_template("fec_0").unwrap(); - let srcpad_fec = gst::Pad::builder_with_template(&templ, Some("fec_0")) + let srcpad_fec = gst::Pad::builder_from_template(&templ) .activatemode_function(move |pad, parent, mode, active| { Self::catch_panic_pad_function( parent, diff --git a/net/reqwest/tests/reqwesthttpsrc.rs b/net/reqwest/tests/reqwesthttpsrc.rs index da5a9c85..9287822a 100644 --- a/net/reqwest/tests/reqwesthttpsrc.rs +++ b/net/reqwest/tests/reqwesthttpsrc.rs @@ -72,7 +72,8 @@ impl Harness { let (sender, receiver) = mpsc::sync_channel(0); // Sink pad that receives everything the source is generating - let pad = gst::Pad::builder(Some("sink"), gst::PadDirection::Sink) + let pad = gst::Pad::builder(gst::PadDirection::Sink) + .name("sink") .chain_function({ let sender_clone = sender.clone(); move |_pad, _parent, buffer| { diff --git a/net/rtp/src/gcc/imp.rs b/net/rtp/src/gcc/imp.rs index f56d0a78..1955ecf1 100644 --- a/net/rtp/src/gcc/imp.rs +++ b/net/rtp/src/gcc/imp.rs @@ -1146,7 +1146,7 @@ impl ObjectSubclass for BandwidthEstimator { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|_pad, parent, mut buffer| { BandwidthEstimator::catch_panic_pad_function( parent, @@ -1166,7 +1166,7 @@ impl ObjectSubclass for BandwidthEstimator { .build(); 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) .event_function(|pad, parent, event| { BandwidthEstimator::catch_panic_pad_function( parent, diff --git a/net/webrtc/src/webrtcsink/imp.rs b/net/webrtc/src/webrtcsink/imp.rs index c3fbda7c..5e5a8c89 100644 --- a/net/webrtc/src/webrtcsink/imp.rs +++ b/net/webrtc/src/webrtcsink/imp.rs @@ -399,10 +399,8 @@ fn make_converter_for_video_caps(caps: &gst::Caps) -> Result Result @default-panic, move |pad, parent, buffer| { let padret = gst::ProxyPad::chain_default(pad, parent, buffer); @@ -443,8 +445,7 @@ impl WebRTCSrc { gst::Pad::event_default(pad, parent, event) })) - .build_with_target(pad) - .unwrap(); + .build(); bin.add_pad(&ghostpad) .expect("Adding ghostpad to the bin should always work"); @@ -550,7 +551,7 @@ impl WebRTCSrc { webrtcbin.set_property("stun-server", stun_server); } - let bin = gst::Bin::new(None); + let bin = gst::Bin::new(); bin.connect_pad_removed(glib::clone!(@weak self as this => move |_, pad| this.state.lock().unwrap().flow_combiner.remove_pad(pad); )); @@ -751,7 +752,8 @@ impl WebRTCSrc { let caps_with_raw = [caps.clone(), raw_caps.clone()] .into_iter() .collect::(); - let ghost = gst::GhostPad::builder_with_template(&template, Some(&name)) + let ghost = gst::GhostPad::builder_from_template(&template) + .name(name) .build() .downcast::() .unwrap(); diff --git a/net/webrtchttp/src/whepsrc/imp.rs b/net/webrtchttp/src/whepsrc/imp.rs index e0752ac8..d8be2284 100644 --- a/net/webrtchttp/src/whepsrc/imp.rs +++ b/net/webrtchttp/src/whepsrc/imp.rs @@ -534,9 +534,7 @@ impl WhepSrc { ); let templ = self_.obj().pad_template("src_%u").unwrap(); - let src_pad = gst::GhostPad::builder_with_template(&templ, Some(&pad.name())) - .build_with_target(pad) - .unwrap(); + let src_pad = gst::GhostPad::from_template_with_target(&templ, pad).unwrap(); src_pad.set_target(Some(pad)).unwrap(); src_pad diff --git a/net/webrtchttp/src/whipsink/imp.rs b/net/webrtchttp/src/whipsink/imp.rs index c1ac7c28..1b3f5b65 100644 --- a/net/webrtchttp/src/whipsink/imp.rs +++ b/net/webrtchttp/src/whipsink/imp.rs @@ -135,7 +135,9 @@ impl ElementImpl for WhipSink { caps: Option<&gst::Caps>, ) -> Option { let wb_sink_pad = self.webrtcbin.request_pad(templ, name, caps)?; - let sink_pad = gst::GhostPad::new(Some(&wb_sink_pad.name()), gst::PadDirection::Sink); + let sink_pad = gst::GhostPad::builder(gst::PadDirection::Sink) + .name(wb_sink_pad.name()) + .build(); sink_pad.set_target(Some(&wb_sink_pad)).unwrap(); self.obj().add_pad(&sink_pad).unwrap(); diff --git a/text/ahead/src/textahead/imp.rs b/text/ahead/src/textahead/imp.rs index 6af01de9..90c937ea 100644 --- a/text/ahead/src/textahead/imp.rs +++ b/text/ahead/src/textahead/imp.rs @@ -78,7 +78,7 @@ impl ObjectSubclass for TextAhead { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sink_pad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sink_pad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { TextAhead::catch_panic_pad_function( parent, @@ -96,7 +96,7 @@ impl ObjectSubclass for TextAhead { .build(); let templ = klass.pad_template("src").unwrap(); - let src_pad = gst::Pad::builder_with_template(&templ, Some("src")).build(); + let src_pad = gst::Pad::from_template(&templ); Self { sink_pad, diff --git a/text/json/src/jsongstenc/imp.rs b/text/json/src/jsongstenc/imp.rs index 84b81e6c..42e87021 100644 --- a/text/json/src/jsongstenc/imp.rs +++ b/text/json/src/jsongstenc/imp.rs @@ -183,7 +183,7 @@ impl ObjectSubclass for JsonGstEnc { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { JsonGstEnc::catch_panic_pad_function( parent, @@ -201,7 +201,7 @@ impl ObjectSubclass for JsonGstEnc { .build(); let templ = klass.pad_template("src").unwrap(); - let srcpad = gst::Pad::builder_with_template(&templ, Some("src")).build(); + let srcpad = gst::Pad::from_template(&templ); Self { srcpad, diff --git a/text/json/src/jsongstparse/imp.rs b/text/json/src/jsongstparse/imp.rs index 3550daf6..b15bb739 100644 --- a/text/json/src/jsongstparse/imp.rs +++ b/text/json/src/jsongstparse/imp.rs @@ -822,7 +822,7 @@ impl ObjectSubclass for JsonGstParse { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .activate_function(|pad, parent| { JsonGstParse::catch_panic_pad_function( parent, @@ -859,7 +859,7 @@ impl ObjectSubclass for JsonGstParse { .build(); 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) .event_function(|pad, parent, event| { JsonGstParse::catch_panic_pad_function( parent, diff --git a/text/regex/src/gstregex/imp.rs b/text/regex/src/gstregex/imp.rs index c09f251e..bfe7987d 100644 --- a/text/regex/src/gstregex/imp.rs +++ b/text/regex/src/gstregex/imp.rs @@ -111,7 +111,7 @@ impl ObjectSubclass for RegEx { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { RegEx::catch_panic_pad_function( parent, @@ -123,7 +123,7 @@ impl ObjectSubclass for RegEx { .build(); 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) .flags(gst::PadFlags::PROXY_CAPS | gst::PadFlags::FIXED_CAPS) .build(); diff --git a/text/wrap/src/gsttextwrap/imp.rs b/text/wrap/src/gsttextwrap/imp.rs index 91847650..de98e2b8 100644 --- a/text/wrap/src/gsttextwrap/imp.rs +++ b/text/wrap/src/gsttextwrap/imp.rs @@ -405,7 +405,7 @@ impl ObjectSubclass for TextWrap { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { TextWrap::catch_panic_pad_function( parent, @@ -424,7 +424,7 @@ impl ObjectSubclass for TextWrap { .build(); 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| { TextWrap::catch_panic_pad_function( parent, diff --git a/tutorial/src/identity/imp.rs b/tutorial/src/identity/imp.rs index 92d56629..7b26806c 100644 --- a/tutorial/src/identity/imp.rs +++ b/tutorial/src/identity/imp.rs @@ -123,7 +123,7 @@ impl ObjectSubclass for Identity { // // Details about what each function is good for is next to each function definition let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { Identity::catch_panic_pad_function( parent, @@ -148,7 +148,7 @@ impl ObjectSubclass for Identity { .build(); 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) .event_function(|pad, parent, event| { Identity::catch_panic_pad_function( parent, diff --git a/tutorial/src/progressbin/imp.rs b/tutorial/src/progressbin/imp.rs index f0bdafff..eee52691 100644 --- a/tutorial/src/progressbin/imp.rs +++ b/tutorial/src/progressbin/imp.rs @@ -58,9 +58,9 @@ impl ObjectSubclass for ProgressBin { // // We do that and adding the pads inside glib::Object::constructed() later. let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::GhostPad::from_template(&templ, Some("sink")); + let sinkpad = gst::GhostPad::from_template(&templ); let templ = klass.pad_template("src").unwrap(); - let srcpad = gst::GhostPad::from_template(&templ, Some("src")); + let srcpad = gst::GhostPad::from_template(&templ); // Create the progressreport element. let progress = gst::ElementFactory::make("progressreport") diff --git a/utils/fallbackswitch/src/fallbacksrc/custom_source/imp.rs b/utils/fallbackswitch/src/fallbacksrc/custom_source/imp.rs index 2159f27a..b158fa1b 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 8ba75c5a..4be3ed44 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 5db9ba0e..bea69f1a 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::::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::::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(); diff --git a/utils/livesync/src/livesync/imp.rs b/utils/livesync/src/livesync/imp.rs index 99eac29f..93c73132 100644 --- a/utils/livesync/src/livesync/imp.rs +++ b/utils/livesync/src/livesync/imp.rs @@ -199,72 +199,70 @@ impl ObjectSubclass for LiveSync { type ParentType = gst::Element; fn with_class(class: &Self::Class) -> Self { - let sinkpad = - gst::Pad::builder_with_template(&class.pad_template("sink").unwrap(), Some("sink")) - .activatemode_function(|pad, parent, mode, active| { - Self::catch_panic_pad_function( - parent, - || Err(gst::loggable_error!(CAT, "sink_activate_mode panicked")), - |livesync| livesync.sink_activate_mode(pad, mode, active), - ) - }) - .event_function(|pad, parent, event| { - Self::catch_panic_pad_function( - parent, - || false, - |livesync| livesync.sink_event(pad, event), - ) - }) - .query_function(|pad, parent, query| { - Self::catch_panic_pad_function( - parent, - || false, - |livesync| livesync.sink_query(pad, query), - ) - }) - .chain_function(|pad, parent, buffer| { - Self::catch_panic_pad_function( - parent, - || Err(gst::FlowError::Error), - |livesync| livesync.sink_chain(pad, buffer), - ) - }) - .flags( - gst::PadFlags::PROXY_CAPS - | gst::PadFlags::PROXY_ALLOCATION - | gst::PadFlags::PROXY_SCHEDULING, + let sinkpad = gst::Pad::builder_from_template(&class.pad_template("sink").unwrap()) + .activatemode_function(|pad, parent, mode, active| { + Self::catch_panic_pad_function( + parent, + || Err(gst::loggable_error!(CAT, "sink_activate_mode panicked")), + |livesync| livesync.sink_activate_mode(pad, mode, active), ) - .build(); + }) + .event_function(|pad, parent, event| { + Self::catch_panic_pad_function( + parent, + || false, + |livesync| livesync.sink_event(pad, event), + ) + }) + .query_function(|pad, parent, query| { + Self::catch_panic_pad_function( + parent, + || false, + |livesync| livesync.sink_query(pad, query), + ) + }) + .chain_function(|pad, parent, buffer| { + Self::catch_panic_pad_function( + parent, + || Err(gst::FlowError::Error), + |livesync| livesync.sink_chain(pad, buffer), + ) + }) + .flags( + gst::PadFlags::PROXY_CAPS + | gst::PadFlags::PROXY_ALLOCATION + | gst::PadFlags::PROXY_SCHEDULING, + ) + .build(); - let srcpad = - gst::Pad::builder_with_template(&class.pad_template("src").unwrap(), Some("src")) - .activatemode_function(|pad, parent, mode, active| { - Self::catch_panic_pad_function( - parent, - || Err(gst::loggable_error!(CAT, "src_activate_mode panicked")), - |livesync| livesync.src_activate_mode(pad, mode, active), - ) - }) - .event_function(|pad, parent, event| { - Self::catch_panic_pad_function( - parent, - || false, - |livesync| livesync.src_event(pad, event), - ) - }) - .query_function(|pad, parent, query| { - Self::catch_panic_pad_function( - parent, - || false, - |livesync| livesync.src_query(pad, query), - ) - }) - .flags( - gst::PadFlags::PROXY_CAPS - | gst::PadFlags::PROXY_ALLOCATION - | gst::PadFlags::PROXY_SCHEDULING, + let srcpad = gst::Pad::builder_from_template(&class.pad_template("src").unwrap()) + .activatemode_function(|pad, parent, mode, active| { + Self::catch_panic_pad_function( + parent, + || Err(gst::loggable_error!(CAT, "src_activate_mode panicked")), + |livesync| livesync.src_activate_mode(pad, mode, active), ) - .build(); + }) + .event_function(|pad, parent, event| { + Self::catch_panic_pad_function( + parent, + || false, + |livesync| livesync.src_event(pad, event), + ) + }) + .query_function(|pad, parent, query| { + Self::catch_panic_pad_function( + parent, + || false, + |livesync| livesync.src_query(pad, query), + ) + }) + .flags( + gst::PadFlags::PROXY_CAPS + | gst::PadFlags::PROXY_ALLOCATION + | gst::PadFlags::PROXY_SCHEDULING, + ) + .build(); Self { state: Default::default(), diff --git a/utils/togglerecord/src/togglerecord/imp.rs b/utils/togglerecord/src/togglerecord/imp.rs index beffa206..d32ba350 100644 --- a/utils/togglerecord/src/togglerecord/imp.rs +++ b/utils/togglerecord/src/togglerecord/imp.rs @@ -1705,7 +1705,7 @@ impl ObjectSubclass for ToggleRecord { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { ToggleRecord::catch_panic_pad_function( parent, @@ -1737,7 +1737,7 @@ impl ObjectSubclass for ToggleRecord { .build(); 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) .event_function(|pad, parent, event| { ToggleRecord::catch_panic_pad_function( parent, @@ -2002,7 +2002,8 @@ impl ElementImpl for ToggleRecord { *pad_count += 1; let templ = self.obj().pad_template("sink_%u").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some(format!("sink_{id}").as_str())) + let sinkpad = gst::Pad::builder_from_template(&templ) + .name(format!("sink_{id}").as_str()) .chain_function(|pad, parent, buffer| { ToggleRecord::catch_panic_pad_function( parent, @@ -2034,7 +2035,8 @@ impl ElementImpl for ToggleRecord { .build(); let templ = self.obj().pad_template("src_%u").unwrap(); - let srcpad = gst::Pad::builder_with_template(&templ, Some(format!("src_{id}").as_str())) + let srcpad = gst::Pad::builder_from_template(&templ) + .name(format!("src_{id}").as_str()) .event_function(|pad, parent, event| { ToggleRecord::catch_panic_pad_function( parent, diff --git a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs index 50f2493b..c98c2542 100644 --- a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs +++ b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs @@ -1342,7 +1342,10 @@ impl UriPlaylistBin { // ghost streamsynchronizer src pad let sync_src_name = sync_sink.name().as_str().replace("sink", "src"); let src = state.streamsynchronizer.static_pad(&sync_src_name).unwrap(); - let ghost = gst::GhostPad::with_target(Some(pad_name.as_str()), &src).unwrap(); + let ghost = gst::GhostPad::builder_with_target(&src) + .unwrap() + .name(pad_name.as_str()) + .build(); ghost.set_active(true).unwrap(); // proxy sticky events diff --git a/video/closedcaption/src/cea608overlay/imp.rs b/video/closedcaption/src/cea608overlay/imp.rs index ce7988d3..c3cba027 100644 --- a/video/closedcaption/src/cea608overlay/imp.rs +++ b/video/closedcaption/src/cea608overlay/imp.rs @@ -522,7 +522,7 @@ impl ObjectSubclass for Cea608Overlay { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { Cea608Overlay::catch_panic_pad_function( parent, @@ -542,7 +542,7 @@ impl ObjectSubclass for Cea608Overlay { .build(); 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) .flags(gst::PadFlags::PROXY_CAPS) .flags(gst::PadFlags::PROXY_ALLOCATION) .build(); diff --git a/video/closedcaption/src/cea608tocea708/imp.rs b/video/closedcaption/src/cea608tocea708/imp.rs index 2a53c7cb..bed38463 100644 --- a/video/closedcaption/src/cea608tocea708/imp.rs +++ b/video/closedcaption/src/cea608tocea708/imp.rs @@ -721,7 +721,7 @@ impl ObjectSubclass for Cea608ToCea708 { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { Cea608ToCea708::catch_panic_pad_function( parent, @@ -740,7 +740,7 @@ impl ObjectSubclass for Cea608ToCea708 { .build(); 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) .flags(gst::PadFlags::FIXED_CAPS) .build(); diff --git a/video/closedcaption/src/cea608tojson/imp.rs b/video/closedcaption/src/cea608tojson/imp.rs index c513dff3..4eda8472 100644 --- a/video/closedcaption/src/cea608tojson/imp.rs +++ b/video/closedcaption/src/cea608tojson/imp.rs @@ -780,7 +780,7 @@ impl ObjectSubclass for Cea608ToJson { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { Cea608ToJson::catch_panic_pad_function( parent, @@ -799,7 +799,7 @@ impl ObjectSubclass for Cea608ToJson { .build(); 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) .flags(gst::PadFlags::FIXED_CAPS) .build(); diff --git a/video/closedcaption/src/cea608tott/imp.rs b/video/closedcaption/src/cea608tott/imp.rs index c265dc7a..c781585b 100644 --- a/video/closedcaption/src/cea608tott/imp.rs +++ b/video/closedcaption/src/cea608tott/imp.rs @@ -377,7 +377,7 @@ impl ObjectSubclass for Cea608ToTt { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { Cea608ToTt::catch_panic_pad_function( parent, @@ -396,7 +396,7 @@ impl ObjectSubclass for Cea608ToTt { .build(); 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) .flags(gst::PadFlags::FIXED_CAPS) .build(); diff --git a/video/closedcaption/src/jsontovtt/imp.rs b/video/closedcaption/src/jsontovtt/imp.rs index 42e02940..d2c1549e 100644 --- a/video/closedcaption/src/jsontovtt/imp.rs +++ b/video/closedcaption/src/jsontovtt/imp.rs @@ -536,7 +536,7 @@ impl ObjectSubclass for JsonToVtt { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { JsonToVtt::catch_panic_pad_function( parent, @@ -555,7 +555,7 @@ impl ObjectSubclass for JsonToVtt { .build(); 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) .flags(gst::PadFlags::FIXED_CAPS) .event_function(|pad, parent, event| { JsonToVtt::catch_panic_pad_function( diff --git a/video/closedcaption/src/mcc_enc/imp.rs b/video/closedcaption/src/mcc_enc/imp.rs index 32656e88..bec2b999 100644 --- a/video/closedcaption/src/mcc_enc/imp.rs +++ b/video/closedcaption/src/mcc_enc/imp.rs @@ -424,7 +424,7 @@ impl ObjectSubclass for MccEnc { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { MccEnc::catch_panic_pad_function( parent, @@ -438,7 +438,7 @@ impl ObjectSubclass for MccEnc { .build(); 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) .event_function(|pad, parent, event| { MccEnc::catch_panic_pad_function(parent, || false, |enc| enc.src_event(pad, event)) }) diff --git a/video/closedcaption/src/mcc_parse/imp.rs b/video/closedcaption/src/mcc_parse/imp.rs index f994cc45..6bbbf0d9 100644 --- a/video/closedcaption/src/mcc_parse/imp.rs +++ b/video/closedcaption/src/mcc_parse/imp.rs @@ -1072,7 +1072,7 @@ impl ObjectSubclass for MccParse { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .activate_function(|pad, parent| { MccParse::catch_panic_pad_function( parent, @@ -1109,7 +1109,7 @@ impl ObjectSubclass for MccParse { .build(); 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) .event_function(|pad, parent, event| { MccParse::catch_panic_pad_function( parent, diff --git a/video/closedcaption/src/scc_enc/imp.rs b/video/closedcaption/src/scc_enc/imp.rs index 75107049..60dab946 100644 --- a/video/closedcaption/src/scc_enc/imp.rs +++ b/video/closedcaption/src/scc_enc/imp.rs @@ -355,7 +355,7 @@ impl ObjectSubclass for SccEnc { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { SccEnc::catch_panic_pad_function( parent, @@ -369,7 +369,7 @@ impl ObjectSubclass for SccEnc { .build(); 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) .event_function(|pad, parent, event| { SccEnc::catch_panic_pad_function(parent, || false, |enc| enc.src_event(pad, event)) }) diff --git a/video/closedcaption/src/scc_parse/imp.rs b/video/closedcaption/src/scc_parse/imp.rs index 78fc6cf6..4cdc96d0 100644 --- a/video/closedcaption/src/scc_parse/imp.rs +++ b/video/closedcaption/src/scc_parse/imp.rs @@ -951,7 +951,7 @@ impl ObjectSubclass for SccParse { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .activate_function(|pad, parent| { SccParse::catch_panic_pad_function( parent, @@ -988,7 +988,7 @@ impl ObjectSubclass for SccParse { .build(); 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) .event_function(|pad, parent, event| { SccParse::catch_panic_pad_function( parent, diff --git a/video/closedcaption/src/transcriberbin/imp.rs b/video/closedcaption/src/transcriberbin/imp.rs index f974ae8f..5673e512 100644 --- a/video/closedcaption/src/transcriberbin/imp.rs +++ b/video/closedcaption/src/transcriberbin/imp.rs @@ -149,9 +149,8 @@ impl TranscriberBin { .build(), ); - let sinkpad = gst::GhostPad::with_target(Some("sink"), &queue.static_pad("sink").unwrap())?; - let srcpad = - gst::GhostPad::with_target(Some("src"), &converter.static_pad("src").unwrap())?; + let sinkpad = gst::GhostPad::with_target(&queue.static_pad("sink").unwrap()).unwrap(); + let srcpad = gst::GhostPad::with_target(&converter.static_pad("src").unwrap()).unwrap(); bin.add_pad(&sinkpad)?; bin.add_pad(&srcpad)?; @@ -214,14 +213,11 @@ impl TranscriberBin { state.ccmux.set_property("latency", CEA608MUX_LATENCY); - let transcription_audio_sinkpad = gst::GhostPad::with_target( - Some("sink"), - &aqueue_transcription.static_pad("sink").unwrap(), - )?; - let transcription_audio_srcpad = gst::GhostPad::with_target( - Some("src"), - &state.transcription_valve.static_pad("src").unwrap(), - )?; + let transcription_audio_sinkpad = + gst::GhostPad::with_target(&aqueue_transcription.static_pad("sink").unwrap()).unwrap(); + let transcription_audio_srcpad = + gst::GhostPad::with_target(&state.transcription_valve.static_pad("src").unwrap()) + .unwrap(); state .transcription_bin @@ -260,22 +256,27 @@ impl TranscriberBin { .video_queue .link_pads(Some("src"), &state.cccombiner, Some("sink"))?; - let internal_audio_sinkpad = gst::GhostPad::with_target( - Some("audio_sink"), - &aclocksync.static_pad("sink").unwrap(), - )?; - let internal_audio_srcpad = gst::GhostPad::with_target( - Some("audio_src"), + let internal_audio_sinkpad = + gst::GhostPad::builder_with_target(&aclocksync.static_pad("sink").unwrap()) + .unwrap() + .name("audio_sink") + .build(); + let internal_audio_srcpad = gst::GhostPad::builder_with_target( &state.audio_queue_passthrough.static_pad("src").unwrap(), - )?; - let internal_video_sinkpad = gst::GhostPad::with_target( - Some("video_sink"), - &vclocksync.static_pad("sink").unwrap(), - )?; - let internal_video_srcpad = gst::GhostPad::with_target( - Some("video_src"), - &state.cccombiner.static_pad("src").unwrap(), - )?; + ) + .unwrap() + .name("audio_src") + .build(); + let internal_video_sinkpad = + gst::GhostPad::builder_with_target(&vclocksync.static_pad("sink").unwrap()) + .unwrap() + .name("video_sink") + .build(); + let internal_video_srcpad = + gst::GhostPad::builder_with_target(&state.cccombiner.static_pad("src").unwrap()) + .unwrap() + .name("video_src") + .build(); state.internal_bin.add_pad(&internal_audio_sinkpad)?; state.internal_bin.add_pad(&internal_audio_srcpad)?; @@ -835,9 +836,9 @@ impl ObjectSubclass for TranscriberBin { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink_audio").unwrap(); - let audio_sinkpad = gst::GhostPad::from_template(&templ, Some("sink_audio")); + let audio_sinkpad = gst::GhostPad::from_template(&templ); let templ = klass.pad_template("src_audio").unwrap(); - let audio_srcpad = gst::GhostPad::builder_with_template(&templ, Some("src_audio")) + let audio_srcpad = gst::GhostPad::builder_from_template(&templ) .query_function(|pad, parent, query| { TranscriberBin::catch_panic_pad_function( parent, @@ -848,7 +849,7 @@ impl ObjectSubclass for TranscriberBin { .build(); let templ = klass.pad_template("sink_video").unwrap(); - let video_sinkpad = gst::GhostPad::builder_with_template(&templ, Some("sink_video")) + let video_sinkpad = gst::GhostPad::builder_from_template(&templ) .event_function(|pad, parent, event| { TranscriberBin::catch_panic_pad_function( parent, @@ -858,7 +859,7 @@ impl ObjectSubclass for TranscriberBin { }) .build(); let templ = klass.pad_template("src_video").unwrap(); - let video_srcpad = gst::GhostPad::builder_with_template(&templ, Some("src_video")) + let video_srcpad = gst::GhostPad::builder_from_template(&templ) .query_function(|pad, parent, query| { TranscriberBin::catch_panic_pad_function( parent, diff --git a/video/closedcaption/src/tttocea608/imp.rs b/video/closedcaption/src/tttocea608/imp.rs index 9e85ca5e..f4f916c1 100644 --- a/video/closedcaption/src/tttocea608/imp.rs +++ b/video/closedcaption/src/tttocea608/imp.rs @@ -977,7 +977,7 @@ impl ObjectSubclass for TtToCea608 { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { TtToCea608::catch_panic_pad_function( parent, @@ -996,7 +996,7 @@ impl ObjectSubclass for TtToCea608 { .build(); 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) .flags(gst::PadFlags::FIXED_CAPS) .build(); diff --git a/video/closedcaption/src/tttojson/imp.rs b/video/closedcaption/src/tttojson/imp.rs index b8d4228e..e4f98fe3 100644 --- a/video/closedcaption/src/tttojson/imp.rs +++ b/video/closedcaption/src/tttojson/imp.rs @@ -192,7 +192,7 @@ impl ObjectSubclass for TtToJson { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { TtToJson::catch_panic_pad_function( parent, @@ -210,7 +210,7 @@ impl ObjectSubclass for TtToJson { .build(); let templ = klass.pad_template("src").unwrap(); - let srcpad = gst::Pad::builder_with_template(&templ, Some("src")).build(); + let srcpad = gst::Pad::from_template(&templ); Self { srcpad, diff --git a/video/ffv1/tests/ffv1dec.rs b/video/ffv1/tests/ffv1dec.rs index d1ae38ad..47410eb9 100644 --- a/video/ffv1/tests/ffv1dec.rs +++ b/video/ffv1/tests/ffv1dec.rs @@ -44,7 +44,7 @@ fn test_decode(name: &str) { .unwrap(); let srcpad = bin.by_name("ffv1dec").unwrap().static_pad("src").unwrap(); - let _ = bin.add_pad(&gst::GhostPad::with_target(Some("src"), &srcpad).unwrap()); + let _ = bin.add_pad(&gst::GhostPad::with_target(&srcpad).unwrap()); let mut h = gst_check::Harness::with_element(&bin, None, Some("src")); diff --git a/video/gtk4/examples/gtksink.rs b/video/gtk4/examples/gtksink.rs index 77855af7..2346a8cd 100644 --- a/video/gtk4/examples/gtksink.rs +++ b/video/gtk4/examples/gtksink.rs @@ -48,11 +48,8 @@ fn create_ui(app: >k::Application) { sink.add(>ksink).unwrap(); convert.link(>ksink).unwrap(); - sink.add_pad( - &gst::GhostPad::with_target(Some("sink"), &convert.static_pad("sink").unwrap()) - .unwrap(), - ) - .unwrap(); + sink.add_pad(&gst::GhostPad::with_target(&convert.static_pad("sink").unwrap()).unwrap()) + .unwrap(); (src, sink.upcast()) }; diff --git a/video/videofx/src/videocompare/mod.rs b/video/videofx/src/videocompare/mod.rs index 67bccd4f..a31493ac 100644 --- a/video/videofx/src/videocompare/mod.rs +++ b/video/videofx/src/videocompare/mod.rs @@ -200,7 +200,9 @@ mod test { let mut message = VideoCompareMessage::default(); message.pad_distances.push(PadDistance { - pad: gst::Pad::new(Some("sink_0"), gst::PadDirection::Sink), + pad: gst::Pad::builder(gst::PadDirection::Sink) + .name("sink_0") + .build(), distance: 42_f64, }); message.running_time = Some(running_time); @@ -236,7 +238,9 @@ mod test { gst::Array::from_iter([gst::Structure::builder("pad-distance") .field( "pad", - gst::Pad::new(Some("sink_0"), gst::PadDirection::Sink), + gst::Pad::builder(gst::PadDirection::Sink) + .name("sink_0") + .build(), ) .field("distance", 42f64) .build() diff --git a/video/webp/src/dec/imp.rs b/video/webp/src/dec/imp.rs index b5f97e56..8e70c950 100644 --- a/video/webp/src/dec/imp.rs +++ b/video/webp/src/dec/imp.rs @@ -273,7 +273,7 @@ impl ObjectSubclass for WebPDec { fn with_class(klass: &Self::Class) -> Self { let templ = klass.pad_template("sink").unwrap(); - let sinkpad = gst::Pad::builder_with_template(&templ, Some("sink")) + let sinkpad = gst::Pad::builder_from_template(&templ) .chain_function(|pad, parent, buffer| { WebPDec::catch_panic_pad_function( parent, @@ -291,7 +291,7 @@ impl ObjectSubclass for WebPDec { .build(); 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) .event_function(|pad, parent, event| { WebPDec::catch_panic_pad_function(parent, || false, |dec| dec.src_event(pad, event)) })