diff options
author | François Laignel <francois@centricular.com> | 2023-05-10 18:02:08 +0300 |
---|---|---|
committer | François Laignel <francois@centricular.com> | 2023-05-12 13:55:31 +0300 |
commit | 7ba0073052c81c8f2f1ebe500048ed6d974e81d8 (patch) | |
tree | 26a4f2b74ac8a7129b6ecc95e8affcb302aa1bc2 /video | |
parent | 8e93d294e5a61a94f14e812bef59cd0e529494e1 (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 'video')
-rw-r--r-- | video/closedcaption/src/cea608overlay/imp.rs | 4 | ||||
-rw-r--r-- | video/closedcaption/src/cea608tocea708/imp.rs | 4 | ||||
-rw-r--r-- | video/closedcaption/src/cea608tojson/imp.rs | 4 | ||||
-rw-r--r-- | video/closedcaption/src/cea608tott/imp.rs | 4 | ||||
-rw-r--r-- | video/closedcaption/src/jsontovtt/imp.rs | 4 | ||||
-rw-r--r-- | video/closedcaption/src/mcc_enc/imp.rs | 4 | ||||
-rw-r--r-- | video/closedcaption/src/mcc_parse/imp.rs | 4 | ||||
-rw-r--r-- | video/closedcaption/src/scc_enc/imp.rs | 4 | ||||
-rw-r--r-- | video/closedcaption/src/scc_parse/imp.rs | 4 | ||||
-rw-r--r-- | video/closedcaption/src/transcriberbin/imp.rs | 61 | ||||
-rw-r--r-- | video/closedcaption/src/tttocea608/imp.rs | 4 | ||||
-rw-r--r-- | video/closedcaption/src/tttojson/imp.rs | 4 | ||||
-rw-r--r-- | video/ffv1/tests/ffv1dec.rs | 2 | ||||
-rw-r--r-- | video/gtk4/examples/gtksink.rs | 7 | ||||
-rw-r--r-- | video/videofx/src/videocompare/mod.rs | 8 | ||||
-rw-r--r-- | video/webp/src/dec/imp.rs | 4 |
16 files changed, 64 insertions, 62 deletions
diff --git a/video/closedcaption/src/cea608overlay/imp.rs b/video/closedcaption/src/cea608overlay/imp.rs index ce7988d33..c3cba0275 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 2a53c7cbb..bed384630 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 c513dff3a..4eda84720 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 c265dc7a3..c781585b0 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 42e029409..d2c1549e2 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 32656e888..bec2b9999 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 f994cc45e..6bbbf0d99 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 75107049e..60dab9460 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 78fc6cf63..4cdc96d0a 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 f974ae8f6..5673e5120 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 9e85ca5eb..f4f916c14 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 b8d4228e2..e4f98fe39 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 d1ae38ad7..47410eb90 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 77855af75..2346a8cd3 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 67bccd4f1..a31493ace 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 b5f97e56e..8e70c950b 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)) }) |