diff --git a/examples/src/bin/appsink.rs b/examples/src/bin/appsink.rs index d0cbbc8d7..3b3d1ba25 100644 --- a/examples/src/bin/appsink.rs +++ b/examples/src/bin/appsink.rs @@ -46,7 +46,7 @@ fn create_pipeline() -> Result { ) .build(); - pipeline.add_many(&[&src, appsink.upcast_ref()])?; + pipeline.add_many([&src, appsink.upcast_ref()])?; src.link(&appsink)?; // Getting data out of the appsink is done by setting callbacks on it. diff --git a/examples/src/bin/appsrc.rs b/examples/src/bin/appsrc.rs index 413a05902..7ef012f27 100644 --- a/examples/src/bin/appsrc.rs +++ b/examples/src/bin/appsrc.rs @@ -49,7 +49,7 @@ fn create_pipeline() -> Result { let videoconvert = gst::ElementFactory::make("videoconvert").build()?; let sink = gst::ElementFactory::make("autovideosink").build()?; - pipeline.add_many(&[appsrc.upcast_ref(), &videoconvert, &sink])?; + pipeline.add_many([appsrc.upcast_ref(), &videoconvert, &sink])?; gst::Element::link_many(&[appsrc.upcast_ref(), &videoconvert, &sink])?; // Our frame counter, that is stored in the mutable environment diff --git a/examples/src/bin/cairo_compositor.rs b/examples/src/bin/cairo_compositor.rs index d17a919ab..35f76db10 100644 --- a/examples/src/bin/cairo_compositor.rs +++ b/examples/src/bin/cairo_compositor.rs @@ -576,7 +576,7 @@ fn create_pipeline() -> Result { comp.set_property("background-color", 0xff_33_33_33u32); - pipeline.add_many(&[&src1, &src2, comp.upcast_ref(), &conv, &sink])?; + pipeline.add_many([&src1, &src2, comp.upcast_ref(), &conv, &sink])?; // Link everything together. src1.link_filtered( diff --git a/examples/src/bin/decodebin.rs b/examples/src/bin/decodebin.rs index 6cb091719..3ffb3091e 100644 --- a/examples/src/bin/decodebin.rs +++ b/examples/src/bin/decodebin.rs @@ -70,7 +70,7 @@ fn example_main() -> Result<(), Error> { .build()?; let decodebin = gst::ElementFactory::make("decodebin").build()?; - pipeline.add_many(&[&src, &decodebin])?; + pipeline.add_many([&src, &decodebin])?; gst::Element::link_many(&[&src, &decodebin])?; // Need to move a new reference into the closure. diff --git a/examples/src/bin/encodebin.rs b/examples/src/bin/encodebin.rs index f5cd7fb54..e7003b9fd 100644 --- a/examples/src/bin/encodebin.rs +++ b/examples/src/bin/encodebin.rs @@ -97,7 +97,7 @@ fn example_main() -> Result<(), Error> { configure_encodebin(&encodebin); pipeline - .add_many(&[&src, &encodebin, &sink]) + .add_many([&src, &encodebin, &sink]) .expect("failed to add elements to pipeline"); // It is clear from the start, that encodebin has only one src pad, so we can // directly link it to our filesink without problems. diff --git a/examples/src/bin/fd_allocator.rs b/examples/src/bin/fd_allocator.rs index df10b6cde..803ca20c3 100644 --- a/examples/src/bin/fd_allocator.rs +++ b/examples/src/bin/fd_allocator.rs @@ -45,7 +45,7 @@ fn create_receiver_pipeline( let queue = gst::ElementFactory::make("queue").build()?; let sink = gst::ElementFactory::make("autovideosink").build()?; - pipeline.add_many(&[src.upcast_ref(), &filter, &convert, &queue, &sink])?; + pipeline.add_many([src.upcast_ref(), &filter, &convert, &queue, &sink])?; gst::Element::link_many(&[src.upcast_ref(), &filter, &convert, &queue, &sink])?; let fd_allocator = gst_allocators::FdAllocator::new(); @@ -115,7 +115,7 @@ fn create_sender_pipeline( .ok_or_else(|| anyhow::anyhow!("is not a appsink"))? .set_caps(Some(&caps)); - pipeline.add_many(&[&src, &sink])?; + pipeline.add_many([&src, &sink])?; gst::Element::link_many(&[&src, &sink])?; let appsink = sink diff --git a/examples/src/bin/gtksink.rs b/examples/src/bin/gtksink.rs index d14e87a64..457135cd4 100644 --- a/examples/src/bin/gtksink.rs +++ b/examples/src/bin/gtksink.rs @@ -49,7 +49,7 @@ fn create_ui(app: >k::Application) { (sink, widget) }; - pipeline.add_many(&[&src, &sink]).unwrap(); + pipeline.add_many([&src, &sink]).unwrap(); src.link(&sink).unwrap(); // Create a simple gtk gui window to place our widget into. diff --git a/examples/src/bin/gtkvideooverlay.rs b/examples/src/bin/gtkvideooverlay.rs index 2846bb703..e5119deae 100644 --- a/examples/src/bin/gtkvideooverlay.rs +++ b/examples/src/bin/gtkvideooverlay.rs @@ -103,7 +103,7 @@ fn create_ui(app: >k::Application) { // specific. This example supports Linux and Mac (using X11 and Quartz). let sink = create_video_sink(); - pipeline.add_many(&[&src, &sink]).unwrap(); + pipeline.add_many([&src, &sink]).unwrap(); src.link(&sink).unwrap(); // First, we create our gtk window - which will contain a region where diff --git a/examples/src/bin/overlay-composition.rs b/examples/src/bin/overlay-composition.rs index 156a387a2..4a83cac63 100644 --- a/examples/src/bin/overlay-composition.rs +++ b/examples/src/bin/overlay-composition.rs @@ -77,7 +77,7 @@ fn create_pipeline() -> Result { let videoconvert = gst::ElementFactory::make("videoconvert").build()?; let sink = gst::ElementFactory::make("autovideosink").build()?; - pipeline.add_many(&[&src, &overlay, &capsfilter, &videoconvert, &sink])?; + pipeline.add_many([&src, &overlay, &capsfilter, &videoconvert, &sink])?; gst::Element::link_many(&[&src, &overlay, &capsfilter, &videoconvert, &sink])?; // The PangoFontMap represents the set of fonts available for a particular rendering system. diff --git a/examples/src/bin/pango-cairo.rs b/examples/src/bin/pango-cairo.rs index 968dca947..05c63bfca 100644 --- a/examples/src/bin/pango-cairo.rs +++ b/examples/src/bin/pango-cairo.rs @@ -76,7 +76,7 @@ fn create_pipeline() -> Result { let videoconvert = gst::ElementFactory::make("videoconvert").build()?; let sink = gst::ElementFactory::make("autovideosink").build()?; - pipeline.add_many(&[&src, &overlay, &capsfilter, &videoconvert, &sink])?; + pipeline.add_many([&src, &overlay, &capsfilter, &videoconvert, &sink])?; gst::Element::link_many(&[&src, &overlay, &capsfilter, &videoconvert, &sink])?; // The PangoFontMap represents the set of fonts available for a particular rendering system. diff --git a/examples/src/bin/rtpfecclient.rs b/examples/src/bin/rtpfecclient.rs index 4f6a29b59..b7848e7c0 100644 --- a/examples/src/bin/rtpfecclient.rs +++ b/examples/src/bin/rtpfecclient.rs @@ -114,7 +114,7 @@ fn example_main() -> Result<(), Error> { .property("caps", &video_caps) .build()?; - pipeline.add_many(&[&src, &netsim, &rtpbin, &depay, &dec, &conv, &scale, &filter])?; + pipeline.add_many([&src, &netsim, &rtpbin, &depay, &dec, &conv, &scale, &filter])?; gst::Element::link_many(&[&depay, &dec, &conv, &scale, &filter])?; match args[1].as_str() { @@ -132,7 +132,7 @@ fn example_main() -> Result<(), Error> { .property("location", "out.mkv") .build()?; - pipeline.add_many(&[&enc, &mux, &sink])?; + pipeline.add_many([&enc, &mux, &sink])?; gst::Element::link_many(&[&filter, &enc, &mux, &sink])?; eprintln!("Recording to out.mkv"); } diff --git a/examples/src/bin/rtpfecserver.rs b/examples/src/bin/rtpfecserver.rs index ee511df27..70144b571 100644 --- a/examples/src/bin/rtpfecserver.rs +++ b/examples/src/bin/rtpfecserver.rs @@ -99,7 +99,7 @@ fn example_main() -> Result<(), Error> { .property("sync", true) .build()?; - pipeline.add_many(&[&src, &conv, &q1, &enc, &q2, &pay, &rtpbin, &sink])?; + pipeline.add_many([&src, &conv, &q1, &enc, &q2, &pay, &rtpbin, &sink])?; conv.link(&q1)?; q1.link(&enc)?; diff --git a/examples/src/bin/rtsp-server-subclass.rs b/examples/src/bin/rtsp-server-subclass.rs index 9accaedf0..2b22c3d5a 100644 --- a/examples/src/bin/rtsp-server-subclass.rs +++ b/examples/src/bin/rtsp-server-subclass.rs @@ -137,7 +137,7 @@ mod media_factory { .build() .unwrap(); - bin.add_many(&[&src, &enc, &pay]).unwrap(); + bin.add_many([&src, &enc, &pay]).unwrap(); gst::Element::link_many(&[&src, &enc, &pay]).unwrap(); Some(bin.upcast()) diff --git a/examples/src/bin/subclass.rs b/examples/src/bin/subclass.rs index 77bfd925d..b90c87b84 100644 --- a/examples/src/bin/subclass.rs +++ b/examples/src/bin/subclass.rs @@ -248,7 +248,7 @@ fn create_pipeline() -> Result { let conv = gst::ElementFactory::make("audioconvert").build()?; let sink = gst::ElementFactory::make("autoaudiosink").build()?; - pipeline.add_many(&[&src, filter.upcast_ref(), &conv, &sink])?; + pipeline.add_many([&src, filter.upcast_ref(), &conv, &sink])?; src.link(&filter)?; filter.link(&conv)?; conv.link(&sink)?; diff --git a/examples/src/bin/toc.rs b/examples/src/bin/toc.rs index ef81f38c8..4503d1eb4 100644 --- a/examples/src/bin/toc.rs +++ b/examples/src/bin/toc.rs @@ -34,7 +34,7 @@ fn example_main() { .unwrap(); let decodebin = gst::ElementFactory::make("decodebin").build().unwrap(); - pipeline.add_many(&[&src, &decodebin]).unwrap(); + pipeline.add_many([&src, &decodebin]).unwrap(); gst::Element::link_many(&[&src, &decodebin]).unwrap(); // Need to move a new reference into the closure. diff --git a/examples/src/bin/transmux.rs b/examples/src/bin/transmux.rs index a8248099b..878bef73d 100644 --- a/examples/src/bin/transmux.rs +++ b/examples/src/bin/transmux.rs @@ -66,7 +66,7 @@ fn example_main() -> Result<(), Error> { // Increase the queue capacity to 100MB to avoid a stalling pipeline pipeline - .add_many(&[&src, &typefinder, &queue, &muxer, &sink]) + .add_many([&src, &typefinder, &queue, &muxer, &sink]) .expect("failed to add elements to pipeline"); src.link(&typefinder)?; diff --git a/examples/src/glupload.rs b/examples/src/glupload.rs index fde98e778..b6bec548f 100644 --- a/examples/src/glupload.rs +++ b/examples/src/glupload.rs @@ -555,7 +555,7 @@ impl App { if let Some(gl_element) = gl_element { let glupload = gst::ElementFactory::make("glupload").build()?; - pipeline.add_many(&[&src, &glupload])?; + pipeline.add_many([&src, &glupload])?; pipeline.add(gl_element)?; pipeline.add(&appsink)?; @@ -569,7 +569,7 @@ impl App { .property("sink", &appsink) .build()?; - pipeline.add_many(&[&src, &sink])?; + pipeline.add_many([&src, &sink])?; src.link(&sink)?; Ok((pipeline, appsink)) diff --git a/gstreamer/src/bin.rs b/gstreamer/src/bin.rs index 8e27d025e..809369524 100644 --- a/gstreamer/src/bin.rs +++ b/gstreamer/src/bin.rs @@ -23,9 +23,16 @@ impl Bin { pub trait GstBinExtManual: 'static { #[doc(alias = "gst_bin_add_many")] - fn add_many>(&self, elements: &[&E]) -> Result<(), glib::BoolError>; + fn add_many( + &self, + elements: impl IntoIterator>, + ) -> Result<(), glib::BoolError>; + #[doc(alias = "gst_bin_remove_many")] - fn remove_many>(&self, elements: &[&E]) -> Result<(), glib::BoolError>; + fn remove_many( + &self, + elements: impl IntoIterator>, + ) -> Result<(), glib::BoolError>; #[doc(alias = "do-latency")] fn connect_do_latency Result<(), LoggableError> + Send + Sync + 'static>( @@ -78,7 +85,10 @@ pub trait GstBinExtManual: 'static { } impl> GstBinExtManual for O { - fn add_many>(&self, elements: &[&E]) -> Result<(), glib::BoolError> { + fn add_many( + &self, + elements: impl IntoIterator>, + ) -> Result<(), glib::BoolError> { for e in elements { unsafe { glib::result_from_gboolean!( @@ -91,7 +101,10 @@ impl> GstBinExtManual for O { Ok(()) } - fn remove_many>(&self, elements: &[&E]) -> Result<(), glib::BoolError> { + fn remove_many( + &self, + elements: impl IntoIterator>, + ) -> Result<(), glib::BoolError> { for e in elements { unsafe { glib::result_from_gboolean!( diff --git a/gstreamer/src/subclass/element.rs b/gstreamer/src/subclass/element.rs index 6c027e4a5..315a334cb 100644 --- a/gstreamer/src/subclass/element.rs +++ b/gstreamer/src/subclass/element.rs @@ -733,7 +733,7 @@ mod tests { let sink = ElementFactory::make("fakesink").build().unwrap(); pipeline - .add_many(&[&src, element.upcast_ref(), &sink]) + .add_many([&src, element.upcast_ref(), &sink]) .unwrap(); Element::link_many(&[&src, element.upcast_ref(), &sink]).unwrap(); diff --git a/tutorials/src/bin/basic-tutorial-2.rs b/tutorials/src/bin/basic-tutorial-2.rs index febb83473..70e269234 100644 --- a/tutorials/src/bin/basic-tutorial-2.rs +++ b/tutorials/src/bin/basic-tutorial-2.rs @@ -22,7 +22,7 @@ fn tutorial_main() { let pipeline = gst::Pipeline::builder().name("test-pipeline").build(); // Build the pipeline - pipeline.add_many(&[&source, &sink]).unwrap(); + pipeline.add_many([&source, &sink]).unwrap(); source.link(&sink).expect("Elements could not be linked."); // Start playing diff --git a/tutorials/src/bin/basic-tutorial-3.rs b/tutorials/src/bin/basic-tutorial-3.rs index 4ead17752..a91f9da88 100644 --- a/tutorials/src/bin/basic-tutorial-3.rs +++ b/tutorials/src/bin/basic-tutorial-3.rs @@ -7,8 +7,7 @@ fn tutorial_main() { // Initialize GStreamer gst::init().unwrap(); - let uri = - "https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm"; + let uri = "http://desmottes.be/~cassidy/files/brol/test.mkv"; // Create the elements let source = gst::ElementFactory::make("uridecodebin") @@ -36,7 +35,7 @@ fn tutorial_main() { // Build the pipeline Note that we are NOT linking the source at this // point. We will do it later. pipeline - .add_many(&[&source, &convert, &resample, &sink]) + .add_many([&source, &convert, &resample, &sink]) .unwrap(); gst::Element::link_many(&[&convert, &resample, &sink]).expect("Elements could not be linked."); @@ -44,6 +43,10 @@ fn tutorial_main() { source.connect_pad_added(move |src, src_pad| { println!("Received new pad {} from {}", src_pad.name(), src.name()); + src.downcast_ref::() + .unwrap() + .debug_to_dot_file_with_ts(gst::DebugGraphDetails::all(), "pad-added"); + let sink_pad = convert .static_pad("sink") .expect("Failed to get static sink pad from convert"); diff --git a/tutorials/src/bin/basic-tutorial-6.rs b/tutorials/src/bin/basic-tutorial-6.rs index 600b3b46c..8069335fb 100644 --- a/tutorials/src/bin/basic-tutorial-6.rs +++ b/tutorials/src/bin/basic-tutorial-6.rs @@ -103,7 +103,7 @@ fn tutorial_main() { // Create the empty pipeline let pipeline = gst::Pipeline::builder().name("test-pipeline").build(); - pipeline.add_many(&[&source, &sink]).unwrap(); + pipeline.add_many([&source, &sink]).unwrap(); source.link(&sink).expect("Elements could not be linked."); // Print initial negotiated caps (in NULL state) diff --git a/tutorials/src/bin/basic-tutorial-7.rs b/tutorials/src/bin/basic-tutorial-7.rs index 55ce94482..1f64a9085 100644 --- a/tutorials/src/bin/basic-tutorial-7.rs +++ b/tutorials/src/bin/basic-tutorial-7.rs @@ -57,7 +57,7 @@ fn tutorial_main() { let pipeline = gst::Pipeline::builder().name("test-pipeline").build(); pipeline - .add_many(&[ + .add_many([ &audio_source, &tee, &audio_queue, diff --git a/tutorials/src/bin/basic-tutorial-8.rs b/tutorials/src/bin/basic-tutorial-8.rs index 082e23591..436609fa1 100644 --- a/tutorials/src/bin/basic-tutorial-8.rs +++ b/tutorials/src/bin/basic-tutorial-8.rs @@ -110,7 +110,7 @@ fn main() { let pipeline = gst::Pipeline::builder().name("test-pipeline").build(); pipeline - .add_many(&[ + .add_many([ appsrc.upcast_ref(), &tee, &audio_queue, diff --git a/tutorials/src/bin/playback-tutorial-7.rs b/tutorials/src/bin/playback-tutorial-7.rs index 8ed4c3cdc..deba437c3 100644 --- a/tutorials/src/bin/playback-tutorial-7.rs +++ b/tutorials/src/bin/playback-tutorial-7.rs @@ -28,7 +28,7 @@ fn tutorial_main() -> Result<(), Error> { // Create the sink bin, add the elements and link them let bin = gst::Bin::builder().name("audio_sink_bin").build(); - bin.add_many(&[&equalizer, &convert, &sink]).unwrap(); + bin.add_many([&equalizer, &convert, &sink]).unwrap(); gst::Element::link_many(&[&equalizer, &convert, &sink]).expect("Failed to link elements."); let pad = equalizer