diff --git a/gstreamer-app/src/app_sink.rs b/gstreamer-app/src/app_sink.rs index 35b20ba5e..7784b9e3f 100644 --- a/gstreamer-app/src/app_sink.rs +++ b/gstreamer-app/src/app_sink.rs @@ -1273,7 +1273,7 @@ mod tests { .unwrap(); let appsink = gst::ElementFactory::make("appsink").build().unwrap(); - let pipeline = gst::Pipeline::new(None); + let pipeline = gst::Pipeline::new(); pipeline.add(&videotestsrc).unwrap(); pipeline.add(&appsink).unwrap(); diff --git a/gstreamer-app/src/app_src.rs b/gstreamer-app/src/app_src.rs index ec7987903..4b8c6b58a 100644 --- a/gstreamer-app/src/app_src.rs +++ b/gstreamer-app/src/app_src.rs @@ -651,7 +651,7 @@ mod tests { .build() .unwrap(); - let pipeline = gst::Pipeline::new(None); + let pipeline = gst::Pipeline::new(); pipeline.add(&appsrc).unwrap(); pipeline.add(&fakesink).unwrap(); diff --git a/gstreamer-validate/src/action_type.rs b/gstreamer-validate/src/action_type.rs index 55effae62..6fd4c890f 100644 --- a/gstreamer-validate/src/action_type.rs +++ b/gstreamer-validate/src/action_type.rs @@ -283,7 +283,7 @@ mod tests { file.write_all(b"succeeds").unwrap(); let runner = crate::Runner::new(); - let pipeline = gst::Pipeline::new(None); + let pipeline = gst::Pipeline::new(); let scenario = crate::Scenario::factory_create(&runner, &pipeline, file.path().to_str().unwrap()) .unwrap(); diff --git a/gstreamer/Gir.toml b/gstreamer/Gir.toml index e004a39f1..d8ee6582b 100644 --- a/gstreamer/Gir.toml +++ b/gstreamer/Gir.toml @@ -406,6 +406,11 @@ status = "generate" name = "Gst.Bin" status = "generate" trait_name = "GstBinExt" + [[object.function]] + name = "new" + # Remove the optional `name` argument in favor of using the builder + manual = true + [[object.signal]] name = "do-latency" # Use Result<(), glib::BoolError> @@ -1674,13 +1679,13 @@ manual_traits = ["PadExtManual"] [[object.function]] name = "new_from_template" - # Also has builder_with_template() + # Also has builder_from_template() rename = "from_template" manual = true [[object.function]] name = "new_from_static_template" - # Also has builder_with_static_template() + # Also has builder_from_static_template() rename = "from_static_template" manual = true @@ -1880,6 +1885,11 @@ status = "generate" [[object]] name = "Gst.Pipeline" status = "generate" + [[object.function]] + name = "new" + # Remove the optional `name` argument in favor of using the builder + manual = true + [[object.function]] name = "get_delay" [object.function.return] diff --git a/gstreamer/src/auto/bin.rs b/gstreamer/src/auto/bin.rs index acb59e5b7..f0e346ef1 100644 --- a/gstreamer/src/auto/bin.rs +++ b/gstreamer/src/auto/bin.rs @@ -22,12 +22,6 @@ glib::wrapper! { impl Bin { pub const NONE: Option<&'static Bin> = None; - - #[doc(alias = "gst_bin_new")] - pub fn new(name: Option<&str>) -> Bin { - assert_initialized_main_thread!(); - unsafe { Element::from_glib_none(ffi::gst_bin_new(name.to_glib_none().0)).unsafe_cast() } - } } unsafe impl Send for Bin {} diff --git a/gstreamer/src/auto/pipeline.rs b/gstreamer/src/auto/pipeline.rs index 273fd3cab..32b6e5ec0 100644 --- a/gstreamer/src/auto/pipeline.rs +++ b/gstreamer/src/auto/pipeline.rs @@ -22,14 +22,6 @@ glib::wrapper! { impl Pipeline { pub const NONE: Option<&'static Pipeline> = None; - - #[doc(alias = "gst_pipeline_new")] - pub fn new(name: Option<&str>) -> Pipeline { - assert_initialized_main_thread!(); - unsafe { - Element::from_glib_none(ffi::gst_pipeline_new(name.to_glib_none().0)).unsafe_cast() - } - } } unsafe impl Send for Pipeline {} diff --git a/gstreamer/src/bin.rs b/gstreamer/src/bin.rs index c4d122b96..f520eaf39 100644 --- a/gstreamer/src/bin.rs +++ b/gstreamer/src/bin.rs @@ -12,10 +12,31 @@ use glib::{ use crate::{prelude::*, Bin, BinFlags, Element, LoggableError}; impl Bin { + // rustdoc-stripper-ignore-next + /// Creates a new [`Bin`] object with a default name. + /// + /// Use [`Bin::with_name()`] to create a [`Bin`] with a specific name. + /// Use [`Bin::builder()`] for additional configuration. + #[doc(alias = "gst_bin_new")] + pub fn new() -> Bin { + assert_initialized_main_thread!(); + unsafe { Element::from_glib_none(ffi::gst_bin_new(std::ptr::null())).unsafe_cast() } + } + + // rustdoc-stripper-ignore-next + /// Creates a new [`Bin`] object with the specified name. + /// + /// Use [`Bin::builder()`] for additional configuration. + #[doc(alias = "gst_bin_new")] + pub fn with_name(name: &str) -> Bin { + assert_initialized_main_thread!(); + unsafe { Element::from_glib_none(ffi::gst_bin_new(name.to_glib_none().0)).unsafe_cast() } + } + // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`Bin`] objects. /// - /// This method returns an instance of [`BinBuilder`](crate::builders::BinBuilder) which can be used to create [`Bin`] objects. + /// This method returns an instance of [`BinBuilder`] which can be used to create [`Bin`] objects. pub fn builder() -> BinBuilder { BinBuilder::new() } @@ -311,7 +332,7 @@ mod tests { fn test_get_children() { crate::init().unwrap(); - let bin = crate::Bin::new(None); + let bin = crate::Bin::new(); bin.add( &crate::ElementFactory::make("identity") .name("identity0") diff --git a/gstreamer/src/format/mod.rs b/gstreamer/src/format/mod.rs index 013f68fa6..d555c8793 100644 --- a/gstreamer/src/format/mod.rs +++ b/gstreamer/src/format/mod.rs @@ -30,7 +30,7 @@ //! # use gstreamer as gst; //! # use gst::prelude::ElementExtManual; //! # gst::init(); -//! # let pipeline = gst::Pipeline::new(None); +//! # let pipeline = gst::Pipeline::new(); //! let res = pipeline.query_position::(); //! ``` //! @@ -40,7 +40,7 @@ //! # use gstreamer as gst; //! # use gst::{format::prelude::*, prelude::ElementExtManual}; //! # gst::init(); -//! # let pipeline = gst::Pipeline::new(None); +//! # let pipeline = gst::Pipeline::new(); //! # let seek_flags = gst::SeekFlags::FLUSH | gst::SeekFlags::KEY_UNIT; //! let seek_pos = gst::ClockTime::from_seconds(10); //! let res = pipeline.seek_simple(seek_flags, seek_pos); diff --git a/gstreamer/src/iterator.rs b/gstreamer/src/iterator.rs index 156453b67..3942efd65 100644 --- a/gstreamer/src/iterator.rs +++ b/gstreamer/src/iterator.rs @@ -803,7 +803,7 @@ mod tests { crate::init().unwrap(); - let bin = crate::Bin::new(None); + let bin = crate::Bin::new(); let id1 = crate::ElementFactory::make("identity").build().unwrap(); let id2 = crate::ElementFactory::make("identity").build().unwrap(); @@ -834,7 +834,7 @@ mod tests { crate::init().unwrap(); - let bin = crate::Bin::new(None); + let bin = crate::Bin::new(); let id1 = crate::ElementFactory::make("identity").build().unwrap(); let id2 = crate::ElementFactory::make("identity").build().unwrap(); diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index 94cb459b1..842d19f68 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -146,8 +146,10 @@ mod element; pub mod element_factory; mod bin; +pub use bin::BinBuilder; mod pipeline; +pub use pipeline::PipelineBuilder; mod allocation_params; pub use self::allocation_params::AllocationParams; diff --git a/gstreamer/src/log.rs b/gstreamer/src/log.rs index 58f9cac87..807f34ed4 100644 --- a/gstreamer/src/log.rs +++ b/gstreamer/src/log.rs @@ -1245,7 +1245,7 @@ mod tests { trace!(cat, "meh"); memdump!(cat, "meh"); - let obj = crate::Bin::new(Some("meh")); + let obj = crate::Bin::with_name("meh"); error!(cat, obj: &obj, "meh"); warning!(cat, obj: &obj, "meh"); @@ -1276,7 +1276,7 @@ mod tests { Some("some debug category"), ); cat.set_threshold(DebugLevel::Info); - let obj = crate::Bin::new(Some("meh")); + let obj = crate::Bin::with_name("meh"); let (sender, receiver) = mpsc::channel(); diff --git a/gstreamer/src/object.rs b/gstreamer/src/object.rs index 3b7ec8ddf..1a4c80a38 100644 --- a/gstreamer/src/object.rs +++ b/gstreamer/src/object.rs @@ -138,7 +138,7 @@ mod tests { fn test_deep_notify() { crate::init().unwrap(); - let bin = crate::Bin::new(None); + let bin = crate::Bin::new(); let identity = crate::ElementFactory::make("identity") .name("id") .build() diff --git a/gstreamer/src/pipeline.rs b/gstreamer/src/pipeline.rs index 4af854d89..097740a04 100644 --- a/gstreamer/src/pipeline.rs +++ b/gstreamer/src/pipeline.rs @@ -5,10 +5,36 @@ use glib::{prelude::*, translate::*}; use crate::{prelude::*, Pipeline, PipelineFlags}; impl Pipeline { + // rustdoc-stripper-ignore-next + /// Creates a new [`Pipeline`] object with a default name. + /// + /// Use [`Pipeline::with_name()`] to create a [`Pipeline`] with a specific name. + /// Use [`Pipeline::builder()`] to get a [`PipelineBuilder`] and then define a specific name. + #[doc(alias = "gst_pipeline_new")] + pub fn new() -> Pipeline { + assert_initialized_main_thread!(); + unsafe { + crate::Element::from_glib_none(ffi::gst_pipeline_new(std::ptr::null())).unsafe_cast() + } + } + + // rustdoc-stripper-ignore-next + /// Creates a new [`Pipeline`] object with the specified name. + /// + /// Use [`Pipeline::builder()`] for additional configuration. + #[doc(alias = "gst_pipeline_new")] + pub fn with_name(name: &str) -> Pipeline { + assert_initialized_main_thread!(); + unsafe { + crate::Element::from_glib_none(ffi::gst_pipeline_new(name.to_glib_none().0)) + .unsafe_cast() + } + } + // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`Pipeline`] objects. /// - /// This method returns an instance of [`PipelineBuilder`](crate::builders::PipelineBuilder) which can be used to create [`Pipeline`] objects. + /// This method returns an instance of [`PipelineBuilder`] which can be used to create [`Pipeline`] objects. pub fn builder() -> PipelineBuilder { PipelineBuilder::new() } diff --git a/gstreamer/src/subclass/element.rs b/gstreamer/src/subclass/element.rs index e906f8dab..c3b7aa96e 100644 --- a/gstreamer/src/subclass/element.rs +++ b/gstreamer/src/subclass/element.rs @@ -725,7 +725,7 @@ mod tests { Some("Test Element") ); - let pipeline = crate::Pipeline::new(None); + let pipeline = crate::Pipeline::new(); let src = ElementFactory::make("fakesrc") .property("num-buffers", 100i32) .build() diff --git a/tutorials/src/bin/basic-tutorial-2.rs b/tutorials/src/bin/basic-tutorial-2.rs index 70e269234..ff6e0755c 100644 --- a/tutorials/src/bin/basic-tutorial-2.rs +++ b/tutorials/src/bin/basic-tutorial-2.rs @@ -19,7 +19,7 @@ fn tutorial_main() { .expect("Could not create sink element"); // Create the empty pipeline - let pipeline = gst::Pipeline::builder().name("test-pipeline").build(); + let pipeline = gst::Pipeline::with_name("test-pipeline"); // Build the pipeline pipeline.add_many([&source, &sink]).unwrap(); diff --git a/tutorials/src/bin/basic-tutorial-3.rs b/tutorials/src/bin/basic-tutorial-3.rs index b2d8259e4..1717847c9 100644 --- a/tutorials/src/bin/basic-tutorial-3.rs +++ b/tutorials/src/bin/basic-tutorial-3.rs @@ -30,7 +30,7 @@ fn tutorial_main() { .expect("Could not create resample element."); // Create the empty pipeline - let pipeline = gst::Pipeline::builder().name("test-pipeline").build(); + let pipeline = gst::Pipeline::with_name("test-pipeline"); // Build the pipeline Note that we are NOT linking the source at this // point. We will do it later. diff --git a/tutorials/src/bin/basic-tutorial-6.rs b/tutorials/src/bin/basic-tutorial-6.rs index 8069335fb..7924475ca 100644 --- a/tutorials/src/bin/basic-tutorial-6.rs +++ b/tutorials/src/bin/basic-tutorial-6.rs @@ -101,7 +101,7 @@ fn tutorial_main() { .expect("Failed to create sink element"); // Create the empty pipeline - let pipeline = gst::Pipeline::builder().name("test-pipeline").build(); + let pipeline = gst::Pipeline::with_name("test-pipeline"); pipeline.add_many([&source, &sink]).unwrap(); source.link(&sink).expect("Elements could not be linked."); diff --git a/tutorials/src/bin/basic-tutorial-7.rs b/tutorials/src/bin/basic-tutorial-7.rs index 1c819078f..5304e1625 100644 --- a/tutorials/src/bin/basic-tutorial-7.rs +++ b/tutorials/src/bin/basic-tutorial-7.rs @@ -54,7 +54,7 @@ fn tutorial_main() { .build() .unwrap(); - let pipeline = gst::Pipeline::builder().name("test-pipeline").build(); + let pipeline = gst::Pipeline::with_name("test-pipeline"); pipeline .add_many([ diff --git a/tutorials/src/bin/basic-tutorial-8.rs b/tutorials/src/bin/basic-tutorial-8.rs index a91487f66..8ce126af3 100644 --- a/tutorials/src/bin/basic-tutorial-8.rs +++ b/tutorials/src/bin/basic-tutorial-8.rs @@ -107,7 +107,7 @@ fn main() { .name("app_sink") .build(); - let pipeline = gst::Pipeline::builder().name("test-pipeline").build(); + let pipeline = gst::Pipeline::with_name("test-pipeline"); pipeline .add_many([ diff --git a/tutorials/src/bin/playback-tutorial-7.rs b/tutorials/src/bin/playback-tutorial-7.rs index 4c23beed1..86dd0c40f 100644 --- a/tutorials/src/bin/playback-tutorial-7.rs +++ b/tutorials/src/bin/playback-tutorial-7.rs @@ -27,7 +27,7 @@ fn tutorial_main() -> Result<(), Error> { .expect("Could not create autoaudiosink element."); // Create the sink bin, add the elements and link them - let bin = gst::Bin::builder().name("audio_sink_bin").build(); + let bin = gst::Bin::with_name("audio_sink_bin"); bin.add_many([&equalizer, &convert, &sink]).unwrap(); gst::Element::link_many([&equalizer, &convert, &sink]).expect("Failed to link elements.");