mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 09:31:06 +00:00
gst: Manually impl Bin & Pipeline constructors
Set `Bin` & `Pipeline` constructors to manual implementation to remove optional `name` argument (use builder to specify name). Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1255>
This commit is contained in:
parent
ccf3b57a8b
commit
13f0483a44
20 changed files with 81 additions and 36 deletions
|
@ -1273,7 +1273,7 @@ mod tests {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let appsink = gst::ElementFactory::make("appsink").build().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(&videotestsrc).unwrap();
|
||||||
pipeline.add(&appsink).unwrap();
|
pipeline.add(&appsink).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -651,7 +651,7 @@ mod tests {
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let pipeline = gst::Pipeline::new(None);
|
let pipeline = gst::Pipeline::new();
|
||||||
pipeline.add(&appsrc).unwrap();
|
pipeline.add(&appsrc).unwrap();
|
||||||
pipeline.add(&fakesink).unwrap();
|
pipeline.add(&fakesink).unwrap();
|
||||||
|
|
||||||
|
|
|
@ -283,7 +283,7 @@ mod tests {
|
||||||
file.write_all(b"succeeds").unwrap();
|
file.write_all(b"succeeds").unwrap();
|
||||||
|
|
||||||
let runner = crate::Runner::new();
|
let runner = crate::Runner::new();
|
||||||
let pipeline = gst::Pipeline::new(None);
|
let pipeline = gst::Pipeline::new();
|
||||||
let scenario =
|
let scenario =
|
||||||
crate::Scenario::factory_create(&runner, &pipeline, file.path().to_str().unwrap())
|
crate::Scenario::factory_create(&runner, &pipeline, file.path().to_str().unwrap())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
@ -406,6 +406,11 @@ status = "generate"
|
||||||
name = "Gst.Bin"
|
name = "Gst.Bin"
|
||||||
status = "generate"
|
status = "generate"
|
||||||
trait_name = "GstBinExt"
|
trait_name = "GstBinExt"
|
||||||
|
[[object.function]]
|
||||||
|
name = "new"
|
||||||
|
# Remove the optional `name` argument in favor of using the builder
|
||||||
|
manual = true
|
||||||
|
|
||||||
[[object.signal]]
|
[[object.signal]]
|
||||||
name = "do-latency"
|
name = "do-latency"
|
||||||
# Use Result<(), glib::BoolError>
|
# Use Result<(), glib::BoolError>
|
||||||
|
@ -1674,13 +1679,13 @@ manual_traits = ["PadExtManual"]
|
||||||
|
|
||||||
[[object.function]]
|
[[object.function]]
|
||||||
name = "new_from_template"
|
name = "new_from_template"
|
||||||
# Also has builder_with_template()
|
# Also has builder_from_template()
|
||||||
rename = "from_template"
|
rename = "from_template"
|
||||||
manual = true
|
manual = true
|
||||||
|
|
||||||
[[object.function]]
|
[[object.function]]
|
||||||
name = "new_from_static_template"
|
name = "new_from_static_template"
|
||||||
# Also has builder_with_static_template()
|
# Also has builder_from_static_template()
|
||||||
rename = "from_static_template"
|
rename = "from_static_template"
|
||||||
manual = true
|
manual = true
|
||||||
|
|
||||||
|
@ -1880,6 +1885,11 @@ status = "generate"
|
||||||
[[object]]
|
[[object]]
|
||||||
name = "Gst.Pipeline"
|
name = "Gst.Pipeline"
|
||||||
status = "generate"
|
status = "generate"
|
||||||
|
[[object.function]]
|
||||||
|
name = "new"
|
||||||
|
# Remove the optional `name` argument in favor of using the builder
|
||||||
|
manual = true
|
||||||
|
|
||||||
[[object.function]]
|
[[object.function]]
|
||||||
name = "get_delay"
|
name = "get_delay"
|
||||||
[object.function.return]
|
[object.function.return]
|
||||||
|
|
|
@ -22,12 +22,6 @@ glib::wrapper! {
|
||||||
|
|
||||||
impl Bin {
|
impl Bin {
|
||||||
pub const NONE: Option<&'static Bin> = None;
|
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 {}
|
unsafe impl Send for Bin {}
|
||||||
|
|
|
@ -22,14 +22,6 @@ glib::wrapper! {
|
||||||
|
|
||||||
impl Pipeline {
|
impl Pipeline {
|
||||||
pub const NONE: Option<&'static Pipeline> = None;
|
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 {}
|
unsafe impl Send for Pipeline {}
|
||||||
|
|
|
@ -12,10 +12,31 @@ use glib::{
|
||||||
use crate::{prelude::*, Bin, BinFlags, Element, LoggableError};
|
use crate::{prelude::*, Bin, BinFlags, Element, LoggableError};
|
||||||
|
|
||||||
impl Bin {
|
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
|
// rustdoc-stripper-ignore-next
|
||||||
/// Creates a new builder-pattern struct instance to construct [`Bin`] objects.
|
/// 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 {
|
pub fn builder() -> BinBuilder {
|
||||||
BinBuilder::new()
|
BinBuilder::new()
|
||||||
}
|
}
|
||||||
|
@ -311,7 +332,7 @@ mod tests {
|
||||||
fn test_get_children() {
|
fn test_get_children() {
|
||||||
crate::init().unwrap();
|
crate::init().unwrap();
|
||||||
|
|
||||||
let bin = crate::Bin::new(None);
|
let bin = crate::Bin::new();
|
||||||
bin.add(
|
bin.add(
|
||||||
&crate::ElementFactory::make("identity")
|
&crate::ElementFactory::make("identity")
|
||||||
.name("identity0")
|
.name("identity0")
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
//! # use gstreamer as gst;
|
//! # use gstreamer as gst;
|
||||||
//! # use gst::prelude::ElementExtManual;
|
//! # use gst::prelude::ElementExtManual;
|
||||||
//! # gst::init();
|
//! # gst::init();
|
||||||
//! # let pipeline = gst::Pipeline::new(None);
|
//! # let pipeline = gst::Pipeline::new();
|
||||||
//! let res = pipeline.query_position::<gst::ClockTime>();
|
//! let res = pipeline.query_position::<gst::ClockTime>();
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
//! # use gstreamer as gst;
|
//! # use gstreamer as gst;
|
||||||
//! # use gst::{format::prelude::*, prelude::ElementExtManual};
|
//! # use gst::{format::prelude::*, prelude::ElementExtManual};
|
||||||
//! # gst::init();
|
//! # 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_flags = gst::SeekFlags::FLUSH | gst::SeekFlags::KEY_UNIT;
|
||||||
//! let seek_pos = gst::ClockTime::from_seconds(10);
|
//! let seek_pos = gst::ClockTime::from_seconds(10);
|
||||||
//! let res = pipeline.seek_simple(seek_flags, seek_pos);
|
//! let res = pipeline.seek_simple(seek_flags, seek_pos);
|
||||||
|
|
|
@ -803,7 +803,7 @@ mod tests {
|
||||||
|
|
||||||
crate::init().unwrap();
|
crate::init().unwrap();
|
||||||
|
|
||||||
let bin = crate::Bin::new(None);
|
let bin = crate::Bin::new();
|
||||||
let id1 = crate::ElementFactory::make("identity").build().unwrap();
|
let id1 = crate::ElementFactory::make("identity").build().unwrap();
|
||||||
let id2 = crate::ElementFactory::make("identity").build().unwrap();
|
let id2 = crate::ElementFactory::make("identity").build().unwrap();
|
||||||
|
|
||||||
|
@ -834,7 +834,7 @@ mod tests {
|
||||||
|
|
||||||
crate::init().unwrap();
|
crate::init().unwrap();
|
||||||
|
|
||||||
let bin = crate::Bin::new(None);
|
let bin = crate::Bin::new();
|
||||||
let id1 = crate::ElementFactory::make("identity").build().unwrap();
|
let id1 = crate::ElementFactory::make("identity").build().unwrap();
|
||||||
let id2 = crate::ElementFactory::make("identity").build().unwrap();
|
let id2 = crate::ElementFactory::make("identity").build().unwrap();
|
||||||
|
|
||||||
|
|
|
@ -146,8 +146,10 @@ mod element;
|
||||||
pub mod element_factory;
|
pub mod element_factory;
|
||||||
|
|
||||||
mod bin;
|
mod bin;
|
||||||
|
pub use bin::BinBuilder;
|
||||||
|
|
||||||
mod pipeline;
|
mod pipeline;
|
||||||
|
pub use pipeline::PipelineBuilder;
|
||||||
|
|
||||||
mod allocation_params;
|
mod allocation_params;
|
||||||
pub use self::allocation_params::AllocationParams;
|
pub use self::allocation_params::AllocationParams;
|
||||||
|
|
|
@ -1245,7 +1245,7 @@ mod tests {
|
||||||
trace!(cat, "meh");
|
trace!(cat, "meh");
|
||||||
memdump!(cat, "meh");
|
memdump!(cat, "meh");
|
||||||
|
|
||||||
let obj = crate::Bin::new(Some("meh"));
|
let obj = crate::Bin::with_name("meh");
|
||||||
|
|
||||||
error!(cat, obj: &obj, "meh");
|
error!(cat, obj: &obj, "meh");
|
||||||
warning!(cat, obj: &obj, "meh");
|
warning!(cat, obj: &obj, "meh");
|
||||||
|
@ -1276,7 +1276,7 @@ mod tests {
|
||||||
Some("some debug category"),
|
Some("some debug category"),
|
||||||
);
|
);
|
||||||
cat.set_threshold(DebugLevel::Info);
|
cat.set_threshold(DebugLevel::Info);
|
||||||
let obj = crate::Bin::new(Some("meh"));
|
let obj = crate::Bin::with_name("meh");
|
||||||
|
|
||||||
let (sender, receiver) = mpsc::channel();
|
let (sender, receiver) = mpsc::channel();
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ mod tests {
|
||||||
fn test_deep_notify() {
|
fn test_deep_notify() {
|
||||||
crate::init().unwrap();
|
crate::init().unwrap();
|
||||||
|
|
||||||
let bin = crate::Bin::new(None);
|
let bin = crate::Bin::new();
|
||||||
let identity = crate::ElementFactory::make("identity")
|
let identity = crate::ElementFactory::make("identity")
|
||||||
.name("id")
|
.name("id")
|
||||||
.build()
|
.build()
|
||||||
|
|
|
@ -5,10 +5,36 @@ use glib::{prelude::*, translate::*};
|
||||||
use crate::{prelude::*, Pipeline, PipelineFlags};
|
use crate::{prelude::*, Pipeline, PipelineFlags};
|
||||||
|
|
||||||
impl Pipeline {
|
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
|
// rustdoc-stripper-ignore-next
|
||||||
/// Creates a new builder-pattern struct instance to construct [`Pipeline`] objects.
|
/// 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 {
|
pub fn builder() -> PipelineBuilder {
|
||||||
PipelineBuilder::new()
|
PipelineBuilder::new()
|
||||||
}
|
}
|
||||||
|
|
|
@ -725,7 +725,7 @@ mod tests {
|
||||||
Some("Test Element")
|
Some("Test Element")
|
||||||
);
|
);
|
||||||
|
|
||||||
let pipeline = crate::Pipeline::new(None);
|
let pipeline = crate::Pipeline::new();
|
||||||
let src = ElementFactory::make("fakesrc")
|
let src = ElementFactory::make("fakesrc")
|
||||||
.property("num-buffers", 100i32)
|
.property("num-buffers", 100i32)
|
||||||
.build()
|
.build()
|
||||||
|
|
|
@ -19,7 +19,7 @@ fn tutorial_main() {
|
||||||
.expect("Could not create sink element");
|
.expect("Could not create sink element");
|
||||||
|
|
||||||
// Create the empty pipeline
|
// Create the empty pipeline
|
||||||
let pipeline = gst::Pipeline::builder().name("test-pipeline").build();
|
let pipeline = gst::Pipeline::with_name("test-pipeline");
|
||||||
|
|
||||||
// Build the pipeline
|
// Build the pipeline
|
||||||
pipeline.add_many([&source, &sink]).unwrap();
|
pipeline.add_many([&source, &sink]).unwrap();
|
||||||
|
|
|
@ -30,7 +30,7 @@ fn tutorial_main() {
|
||||||
.expect("Could not create resample element.");
|
.expect("Could not create resample element.");
|
||||||
|
|
||||||
// Create the empty pipeline
|
// 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
|
// Build the pipeline Note that we are NOT linking the source at this
|
||||||
// point. We will do it later.
|
// point. We will do it later.
|
||||||
|
|
|
@ -101,7 +101,7 @@ fn tutorial_main() {
|
||||||
.expect("Failed to create sink element");
|
.expect("Failed to create sink element");
|
||||||
|
|
||||||
// Create the empty pipeline
|
// 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();
|
pipeline.add_many([&source, &sink]).unwrap();
|
||||||
source.link(&sink).expect("Elements could not be linked.");
|
source.link(&sink).expect("Elements could not be linked.");
|
||||||
|
|
|
@ -54,7 +54,7 @@ fn tutorial_main() {
|
||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let pipeline = gst::Pipeline::builder().name("test-pipeline").build();
|
let pipeline = gst::Pipeline::with_name("test-pipeline");
|
||||||
|
|
||||||
pipeline
|
pipeline
|
||||||
.add_many([
|
.add_many([
|
||||||
|
|
|
@ -107,7 +107,7 @@ fn main() {
|
||||||
.name("app_sink")
|
.name("app_sink")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
let pipeline = gst::Pipeline::builder().name("test-pipeline").build();
|
let pipeline = gst::Pipeline::with_name("test-pipeline");
|
||||||
|
|
||||||
pipeline
|
pipeline
|
||||||
.add_many([
|
.add_many([
|
||||||
|
|
|
@ -27,7 +27,7 @@ fn tutorial_main() -> Result<(), Error> {
|
||||||
.expect("Could not create autoaudiosink element.");
|
.expect("Could not create autoaudiosink element.");
|
||||||
|
|
||||||
// Create the sink bin, add the elements and link them
|
// 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();
|
bin.add_many([&equalizer, &convert, &sink]).unwrap();
|
||||||
gst::Element::link_many([&equalizer, &convert, &sink]).expect("Failed to link elements.");
|
gst::Element::link_many([&equalizer, &convert, &sink]).expect("Failed to link elements.");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue