diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2022-10-19 19:18:43 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2022-10-19 19:43:29 +0300 |
commit | 12400b6b87e75cfdfa7701b62cf8698c11e14a73 (patch) | |
tree | df8f49f8258a34e961b8f9710671fc0d97bf7c58 /generic | |
parent | 9ce8e93c6374a712a6c8981557c726a3fc04273b (diff) |
Update everything for element factory builder API changes
And set properties as part of object construction wherever it makes
sense.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/fmp4/examples/hls_live.rs | 79 | ||||
-rw-r--r-- | generic/fmp4/examples/hls_vod.rs | 62 | ||||
-rw-r--r-- | generic/sodium/examples/decrypt_example.rs | 24 | ||||
-rw-r--r-- | generic/sodium/examples/encrypt_example.rs | 22 | ||||
-rw-r--r-- | generic/sodium/tests/decrypter.rs | 64 | ||||
-rw-r--r-- | generic/sodium/tests/encrypter.rs | 42 | ||||
-rw-r--r-- | generic/threadshare/examples/benchmark.rs | 117 | ||||
-rw-r--r-- | generic/threadshare/examples/standalone/main.rs | 32 | ||||
-rw-r--r-- | generic/threadshare/examples/udpsrc_benchmark_sender.rs | 30 | ||||
-rw-r--r-- | generic/threadshare/tests/inputselector.rs | 4 | ||||
-rw-r--r-- | generic/threadshare/tests/jitterbuffer.rs | 109 | ||||
-rw-r--r-- | generic/threadshare/tests/pad.rs | 32 | ||||
-rw-r--r-- | generic/threadshare/tests/pipeline.rs | 172 | ||||
-rw-r--r-- | generic/threadshare/tests/proxy.rs | 82 | ||||
-rw-r--r-- | generic/threadshare/tests/queue.rs | 13 | ||||
-rw-r--r-- | generic/threadshare/tests/tcpclientsrc.rs | 21 |
16 files changed, 523 insertions, 382 deletions
diff --git a/generic/fmp4/examples/hls_live.rs b/generic/fmp4/examples/hls_live.rs index f29ec157..f9459325 100644 --- a/generic/fmp4/examples/hls_live.rs +++ b/generic/fmp4/examples/hls_live.rs @@ -15,7 +15,7 @@ use std::collections::VecDeque; use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; -use anyhow::{anyhow, Error}; +use anyhow::Error; use chrono::{DateTime, Duration, Utc}; use m3u8_rs::{ AlternativeMedia, AlternativeMediaType, MasterPlaylist, MediaPlaylist, MediaSegment, @@ -139,11 +139,6 @@ struct AudioStream { wave: String, } -pub fn make_element(element: &str, name: Option<&str>) -> Result<gst::Element, Error> { - gst::ElementFactory::make(element, name) - .map_err(|_| anyhow!("Failed to make element {}", element)) -} - fn trim_segments(state: &mut StreamState) { // Arbitrary 5 segments window while state.segments.len() > 5 { @@ -396,13 +391,24 @@ impl VideoStream { pipeline: &gst::Pipeline, path: &Path, ) -> Result<(), Error> { - let src = make_element("videotestsrc", None)?; - let raw_capsfilter = make_element("capsfilter", None)?; - let timeoverlay = make_element("timeoverlay", None)?; - let enc = make_element("x264enc", None)?; - let h264_capsfilter = make_element("capsfilter", None)?; - let mux = make_element("cmafmux", None)?; - let appsink = make_element("appsink", None)?; + let src = gst::ElementFactory::make("videotestsrc") + .property("is-live", true) + .build()?; + + let raw_capsfilter = gst::ElementFactory::make("capsfilter").build()?; + let timeoverlay = gst::ElementFactory::make("timeoverlay").build()?; + let enc = gst::ElementFactory::make("x264enc") + .property("bframes", 0u32) + .property("bitrate", self.bitrate as u32 / 1000u32) + .property_from_str("tune", "zerolatency") + .build()?; + let h264_capsfilter = gst::ElementFactory::make("capsfilter").build()?; + let mux = gst::ElementFactory::make("cmafmux") + .property("fragment-duration", 2500.mseconds()) + .property_from_str("header-update-mode", "update") + .property("write-mehd", true) + .build()?; + let appsink = gst::ElementFactory::make("appsink").build()?; pipeline.add_many(&[ &src, @@ -414,16 +420,6 @@ impl VideoStream { &appsink, ])?; - gst::Element::link_many(&[ - &src, - &raw_capsfilter, - &timeoverlay, - &enc, - &h264_capsfilter, - &mux, - &appsink, - ])?; - raw_capsfilter.set_property( "caps", gst_video::VideoCapsBuilder::new() @@ -441,13 +437,15 @@ impl VideoStream { .build(), ); - src.set_property("is-live", true); - enc.set_property("bframes", 0u32); - enc.set_property("bitrate", self.bitrate as u32 / 1000u32); - enc.set_property_from_str("tune", "zerolatency"); - mux.set_property("fragment-duration", 2500.mseconds()); - mux.set_property_from_str("header-update-mode", "update"); - mux.set_property("write-mehd", true); + gst::Element::link_many(&[ + &src, + &raw_capsfilter, + &timeoverlay, + &enc, + &h264_capsfilter, + &mux, + &appsink, + ])?; probe_encoder(state, enc); @@ -466,21 +464,22 @@ impl AudioStream { pipeline: &gst::Pipeline, path: &Path, ) -> Result<(), Error> { - let src = make_element("audiotestsrc", None)?; - let enc = make_element("avenc_aac", None)?; - let mux = make_element("cmafmux", None)?; - let appsink = make_element("appsink", None)?; + let src = gst::ElementFactory::make("audiotestsrc") + .property("is-live", true) + .property_from_str("wave", &self.wave) + .property("fragment-duration", 2500.mseconds()) + .build()?; + let enc = gst::ElementFactory::make("avenc_aac").build()?; + let mux = gst::ElementFactory::make("cmafmux") + .property_from_str("header-update-mode", "update") + .property("write-mehd", true) + .build()?; + let appsink = gst::ElementFactory::make("appsink").build()?; pipeline.add_many(&[&src, &enc, &mux, &appsink])?; gst::Element::link_many(&[&src, &enc, &mux, &appsink])?; - src.set_property("is-live", true); - src.set_property_from_str("wave", &self.wave); - mux.set_property("fragment-duration", 2500.mseconds()); - mux.set_property_from_str("header-update-mode", "update"); - mux.set_property("write-mehd", true); - probe_encoder(state, enc); let appsink = appsink.downcast::<gst_app::AppSink>().unwrap(); diff --git a/generic/fmp4/examples/hls_vod.rs b/generic/fmp4/examples/hls_vod.rs index 730c5a6f..50a164a4 100644 --- a/generic/fmp4/examples/hls_vod.rs +++ b/generic/fmp4/examples/hls_vod.rs @@ -14,7 +14,7 @@ use gst::prelude::*; use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; -use anyhow::{anyhow, Error}; +use anyhow::Error; use m3u8_rs::{ AlternativeMedia, AlternativeMediaType, MasterPlaylist, MediaPlaylist, MediaPlaylistType, @@ -127,11 +127,6 @@ impl State { } } -pub fn make_element(element: &str, name: Option<&str>) -> Result<gst::Element, Error> { - gst::ElementFactory::make(element, name) - .map_err(|_| anyhow!("Failed to make element {}", element)) -} - fn setup_appsink(appsink: &gst_app::AppSink, name: &str, path: &Path, is_video: bool) { let mut path: PathBuf = path.into(); path.push(name); @@ -291,13 +286,22 @@ impl VideoStream { pipeline: &gst::Pipeline, path: &Path, ) -> Result<(), Error> { - let src = make_element("videotestsrc", None)?; - let raw_capsfilter = make_element("capsfilter", None)?; - let timeoverlay = make_element("timeoverlay", None)?; - let enc = make_element("x264enc", None)?; - let h264_capsfilter = make_element("capsfilter", None)?; - let mux = make_element("cmafmux", None)?; - let appsink = make_element("appsink", None)?; + let src = gst::ElementFactory::make("videotestsrc") + .property("num-buffers", 300) + .build()?; + let raw_capsfilter = gst::ElementFactory::make("capsfilter").build()?; + let timeoverlay = gst::ElementFactory::make("timeoverlay").build()?; + let enc = gst::ElementFactory::make("x264enc") + .property("bframes", 0u32) + .property("bitrate", self.bitrate as u32 / 1000u32) + .build()?; + let h264_capsfilter = gst::ElementFactory::make("capsfilter").build()?; + let mux = gst::ElementFactory::make("cmafmux") + .property("fragment-duration", 2500.mseconds()) + .property_from_str("header-update-mode", "update") + .property("write-mehd", true) + .build()?; + let appsink = gst::ElementFactory::make("appsink").build()?; pipeline.add_many(&[ &src, @@ -336,13 +340,6 @@ impl VideoStream { .build(), ); - src.set_property("num-buffers", 300); - enc.set_property("bframes", 0u32); - enc.set_property("bitrate", self.bitrate as u32 / 1000u32); - mux.set_property("fragment-duration", 2500.mseconds()); - mux.set_property_from_str("header-update-mode", "update"); - mux.set_property("write-mehd", true); - probe_encoder(state, enc); let appsink = appsink.downcast::<gst_app::AppSink>().unwrap(); @@ -360,28 +357,29 @@ impl AudioStream { pipeline: &gst::Pipeline, path: &Path, ) -> Result<(), Error> { - let src = make_element("audiotestsrc", None)?; - let raw_capsfilter = make_element("capsfilter", None)?; - let enc = make_element("avenc_aac", None)?; - let mux = make_element("cmafmux", None)?; - let appsink = make_element("appsink", None)?; + let src = gst::ElementFactory::make("audiotestsrc") + .property("num-buffers", 100) + .property("samplesperbuffer", 4410) + .property_from_str("wave", &self.wave) + .build()?; + let raw_capsfilter = gst::ElementFactory::make("capsfilter").build()?; + let enc = gst::ElementFactory::make("avenc_aac").build()?; + let mux = gst::ElementFactory::make("cmafmux") + .property("fragment-duration", 2500.mseconds()) + .property_from_str("header-update-mode", "update") + .property("write-mehd", true) + .build()?; + let appsink = gst::ElementFactory::make("appsink").build()?; pipeline.add_many(&[&src, &raw_capsfilter, &enc, &mux, &appsink])?; gst::Element::link_many(&[&src, &raw_capsfilter, &enc, &mux, &appsink])?; - src.set_property("num-buffers", 100); - src.set_property("samplesperbuffer", 4410); - src.set_property_from_str("wave", &self.wave); raw_capsfilter.set_property( "caps", gst_audio::AudioCapsBuilder::new().rate(44100).build(), ); - mux.set_property("fragment-duration", 2500.mseconds()); - mux.set_property_from_str("header-update-mode", "update"); - mux.set_property("write-mehd", true); - probe_encoder(state, enc); let appsink = appsink.downcast::<gst_app::AppSink>().unwrap(); diff --git a/generic/sodium/examples/decrypt_example.rs b/generic/sodium/examples/decrypt_example.rs index 5a0a9d2f..1da10de1 100644 --- a/generic/sodium/examples/decrypt_example.rs +++ b/generic/sodium/examples/decrypt_example.rs @@ -85,16 +85,20 @@ fn main() -> Result<(), Box<dyn Error>> { let receiver = &Keys::from_file(&receiver_keys)?; let sender = &Keys::from_file(&sender_keys)?; - let filesrc = gst::ElementFactory::make("filesrc", None).unwrap(); - let decrypter = gst::ElementFactory::make("sodiumdecrypter", None).unwrap(); - let typefind = gst::ElementFactory::make("typefind", None).unwrap(); - let filesink = gst::ElementFactory::make("filesink", None).unwrap(); - - filesrc.set_property("location", &args.input); - filesink.set_property("location", &args.output); - - decrypter.set_property("receiver-key", glib::Bytes::from_owned(receiver.private.0)); - decrypter.set_property("sender-key", glib::Bytes::from_owned(sender.public)); + let filesrc = gst::ElementFactory::make("filesrc") + .property("location", &args.input) + .build() + .unwrap(); + let decrypter = gst::ElementFactory::make("sodiumdecrypter") + .property("receiver-key", glib::Bytes::from_owned(receiver.private.0)) + .property("sender-key", glib::Bytes::from_owned(sender.public)) + .build() + .unwrap(); + let typefind = gst::ElementFactory::make("typefind").build().unwrap(); + let filesink = gst::ElementFactory::make("filesink") + .property("location", &args.output) + .build() + .unwrap(); let pipeline = gst::Pipeline::new(Some("test-pipeline")); pipeline diff --git a/generic/sodium/examples/encrypt_example.rs b/generic/sodium/examples/encrypt_example.rs index c8cd97bf..ff578b0d 100644 --- a/generic/sodium/examples/encrypt_example.rs +++ b/generic/sodium/examples/encrypt_example.rs @@ -89,15 +89,19 @@ fn main() -> Result<(), Box<dyn Error>> { let receiver = &Keys::from_file(&receiver_keys)?; let sender = &Keys::from_file(&sender_keys)?; - let filesrc = gst::ElementFactory::make("filesrc", None).unwrap(); - let encrypter = gst::ElementFactory::make("sodiumencrypter", None).unwrap(); - let filesink = gst::ElementFactory::make("filesink", None).unwrap(); - - filesrc.set_property("location", &args.input); - filesink.set_property("location", &args.output); - - encrypter.set_property("receiver-key", glib::Bytes::from_owned(receiver.public)); - encrypter.set_property("sender-key", glib::Bytes::from_owned(sender.private.0)); + let filesrc = gst::ElementFactory::make("filesrc") + .property("location", &args.input) + .build() + .unwrap(); + let encrypter = gst::ElementFactory::make("sodiumencrypter") + .property("receiver-key", glib::Bytes::from_owned(receiver.public)) + .property("sender-key", glib::Bytes::from_owned(sender.private.0)) + .build() + .unwrap(); + let filesink = gst::ElementFactory::make("filesink") + .property("location", &args.output) + .build() + .unwrap(); let pipeline = gst::Pipeline::new(Some("test-pipeline")); pipeline diff --git a/generic/sodium/tests/decrypter.rs b/generic/sodium/tests/decrypter.rs index 3243ffea..a489d188 100644 --- a/generic/sodium/tests/decrypter.rs +++ b/generic/sodium/tests/decrypter.rs @@ -72,17 +72,21 @@ fn test_pipeline() { r }; - let filesrc = gst::ElementFactory::make("filesrc", None).unwrap(); - filesrc.set_property("location", &input_path.to_str().unwrap()); + let filesrc = gst::ElementFactory::make("filesrc") + .property("location", &input_path.to_str().unwrap()) + .build() + .unwrap(); - let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap(); - dec.set_property("sender-key", &*SENDER_PUBLIC); - dec.set_property("receiver-key", &*RECEIVER_PRIVATE); + let dec = gst::ElementFactory::make("sodiumdecrypter") + .property("sender-key", &*SENDER_PUBLIC) + .property("receiver-key", &*RECEIVER_PRIVATE) + .build() + .unwrap(); // the typefind element here is cause the decrypter only supports // operating in pull mode bu the filesink wants push-mode. - let typefind = gst::ElementFactory::make("typefind", None).unwrap(); - let sink = gst::ElementFactory::make("appsink", None).unwrap(); + let typefind = gst::ElementFactory::make("typefind").build().unwrap(); + let sink = gst::ElementFactory::make("appsink").build().unwrap(); pipeline .add_many(&[&filesrc, &dec, &typefind, &sink]) @@ -160,12 +164,16 @@ fn test_pull_range() { r }; - let filesrc = gst::ElementFactory::make("filesrc", None).unwrap(); - filesrc.set_property("location", input_path.to_str().unwrap()); + let filesrc = gst::ElementFactory::make("filesrc") + .property("location", input_path.to_str().unwrap()) + .build() + .unwrap(); - let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap(); - dec.set_property("sender-key", &*SENDER_PUBLIC); - dec.set_property("receiver-key", &*RECEIVER_PRIVATE); + let dec = gst::ElementFactory::make("sodiumdecrypter") + .property("sender-key", &*SENDER_PUBLIC) + .property("receiver-key", &*RECEIVER_PRIVATE) + .build() + .unwrap(); pipeline .add_many(&[&filesrc, &dec]) @@ -265,33 +273,43 @@ fn test_state_changes() { // NullToReady without keys provided { - let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap(); + let dec = gst::ElementFactory::make("sodiumdecrypter") + .build() + .unwrap(); assert!(dec.change_state(gst::StateChange::NullToReady).is_err()); // Set only receiver key - let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap(); - dec.set_property("receiver-key", &*RECEIVER_PRIVATE); + let dec = gst::ElementFactory::make("sodiumdecrypter") + .property("receiver-key", &*RECEIVER_PRIVATE) + .build() + .unwrap(); assert!(dec.change_state(gst::StateChange::NullToReady).is_err()); // Set only sender key - let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap(); - dec.set_property("sender-key", &*SENDER_PUBLIC); + let dec = gst::ElementFactory::make("sodiumdecrypter") + .property("sender-key", &*SENDER_PUBLIC) + .build() + .unwrap(); assert!(dec.change_state(gst::StateChange::NullToReady).is_err()); } // NullToReady, no nonce provided { - let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap(); - dec.set_property("sender-key", &*SENDER_PUBLIC); - dec.set_property("receiver-key", &*RECEIVER_PRIVATE); + let dec = gst::ElementFactory::make("sodiumdecrypter") + .property("sender-key", &*SENDER_PUBLIC) + .property("receiver-key", &*RECEIVER_PRIVATE) + .build() + .unwrap(); assert!(dec.change_state(gst::StateChange::NullToReady).is_ok()); } // ReadyToNull { - let dec = gst::ElementFactory::make("sodiumdecrypter", None).unwrap(); - dec.set_property("sender-key", &*SENDER_PUBLIC); - dec.set_property("receiver-key", &*RECEIVER_PRIVATE); + let dec = gst::ElementFactory::make("sodiumdecrypter") + .property("sender-key", &*SENDER_PUBLIC) + .property("receiver-key", &*RECEIVER_PRIVATE) + .build() + .unwrap(); assert!(dec.change_state(gst::StateChange::NullToReady).is_ok()); } } diff --git a/generic/sodium/tests/encrypter.rs b/generic/sodium/tests/encrypter.rs index c17cb3ae..e0c18faf 100644 --- a/generic/sodium/tests/encrypter.rs +++ b/generic/sodium/tests/encrypter.rs @@ -73,10 +73,12 @@ fn encrypt_file() { let mut adapter = gst_base::UniqueAdapter::new(); - let enc = gst::ElementFactory::make("sodiumencrypter", None).unwrap(); - enc.set_property("sender-key", &*SENDER_PRIVATE); - enc.set_property("receiver-key", &*RECEIVER_PUBLIC); - enc.set_property("block-size", 1024u32); + let enc = gst::ElementFactory::make("sodiumencrypter") + .property("sender-key", &*SENDER_PRIVATE) + .property("receiver-key", &*RECEIVER_PUBLIC) + .property("block-size", 1024u32) + .build() + .unwrap(); let mut h = gst_check::Harness::with_element(&enc, None, None); h.add_element_src_pad(&enc.static_pad("src").expect("failed to get src pad")); @@ -109,33 +111,43 @@ fn test_state_changes() { // NullToReady without keys provided { - let enc = gst::ElementFactory::make("sodiumencrypter", None).unwrap(); + let enc = gst::ElementFactory::make("sodiumencrypter") + .build() + .unwrap(); assert!(enc.change_state(gst::StateChange::NullToReady).is_err()); // Set only receiver key - let enc = gst::ElementFactory::make("sodiumencrypter", None).unwrap(); - enc.set_property("receiver-key", &*RECEIVER_PUBLIC); + let enc = gst::ElementFactory::make("sodiumencrypter") + .property("receiver-key", &*RECEIVER_PUBLIC) + .build() + .unwrap(); assert!(enc.change_state(gst::StateChange::NullToReady).is_err()); // Set only sender key - let enc = gst::ElementFactory::make("sodiumencrypter", None).unwrap(); - enc.set_property("sender-key", &*SENDER_PRIVATE); + let enc = gst::ElementFactory::make("sodiumencrypter") + .property("sender-key", &*SENDER_PRIVATE) + .build() + .unwrap(); assert!(enc.change_state(gst::StateChange::NullToReady).is_err()); } // NullToReady { - let enc = gst::ElementFactory::make("sodiumencrypter", None).unwrap(); - enc.set_property("sender-key", &*SENDER_PRIVATE); - enc.set_property("receiver-key", &*RECEIVER_PUBLIC); + let enc = gst::ElementFactory::make("sodiumencrypter") + .property("sender-key", &*SENDER_PRIVATE) + .property("receiver-key", &*RECEIVER_PUBLIC) + .build() + .unwrap(); assert!(enc.change_state(gst::StateChange::NullToReady).is_ok()); } // ReadyToNull { - let enc = gst::ElementFactory::make("sodiumencrypter", None).unwrap(); - enc.set_property("sender-key", &*SENDER_PRIVATE); - enc.set_property("receiver-key", &*RECEIVER_PUBLIC); + let enc = gst::ElementFactory::make("sodiumencrypter") + .property("sender-key", &*SENDER_PRIVATE) + .property("receiver-key", &*RECEIVER_PUBLIC) + .build() + .unwrap(); assert!(enc.change_state(gst::StateChange::NullToReady).is_ok()); } } diff --git a/generic/threadshare/examples/benchmark.rs b/generic/threadshare/examples/benchmark.rs index 32b00ed2..4fb5c0c5 100644 --- a/generic/threadshare/examples/benchmark.rs +++ b/generic/threadshare/examples/benchmark.rs @@ -77,11 +77,13 @@ fn main() { for i in 0..n_streams { let build_context = || format!("context-{}", (i as u32) % n_groups); - let sink = - gst::ElementFactory::make("fakesink", Some(format!("sink-{}", i).as_str())).unwrap(); - sink.set_property("sync", false); - sink.set_property("async", false); - sink.set_property("signal-handoffs", true); + let sink = gst::ElementFactory::make("fakesink") + .name(format!("sink-{}", i).as_str()) + .property("sync", false) + .property("async", false) + .property("signal-handoffs", true) + .build() + .unwrap(); sink.connect( "handoff", true, @@ -93,22 +95,24 @@ fn main() { let (source, context) = match source.as_str() { "udpsrc" => { - let source = - gst::ElementFactory::make("udpsrc", Some(format!("source-{}", i).as_str())) - .unwrap(); - source.set_property("port", 40000i32 + i as i32); - source.set_property("retrieve-sender-address", false); + let source = gst::ElementFactory::make("udpsrc") + .name(format!("source-{}", i).as_str()) + .property("port", 40000i32 + i as i32) + .property("retrieve-sender-address", false) + .build() + .unwrap(); (source, None) } "ts-udpsrc" => { let context = build_context(); - let source = - gst::ElementFactory::make("ts-udpsrc", Some(format!("source-{}", i).as_str())) - .unwrap(); - source.set_property("port", 40000i32 + i as i32); - source.set_property("context", &context); - source.set_property("context-wait", wait); + let source = gst::ElementFactory::make("ts-udpsrc") + .name(format!("source-{}", i).as_str()) + .property("port", 40000i32 + i as i32) + .property("context", &context) + .property("context-wait", wait) + .build() + .unwrap(); if is_rtp { source.set_property("caps", &rtp_caps); @@ -117,37 +121,34 @@ fn main() { (source, Some(context)) } "tcpclientsrc" => { - let source = gst::ElementFactory::make( - "tcpclientsrc", - Some(format!("source-{}", i).as_str()), - ) - .unwrap(); - source.set_property("host", "127.0.0.1"); - source.set_property("port", 40000i32); + let source = gst::ElementFactory::make("tcpclientsrc") + .name(format!("source-{}", i).as_str()) + .property("host", "127.0.0.1") + .property("port", 40000i32) + .build() + .unwrap(); (source, None) } "ts-tcpclientsrc" => { let context = build_context(); - let source = gst::ElementFactory::make( - "ts-tcpclientsrc", - Some(format!("source-{}", i).as_str()), - ) - .unwrap(); - source.set_property("host", "127.0.0.1"); - source.set_property("port", 40000i32); - source.set_property("context", &context); - source.set_property("context-wait", wait); + let source = gst::ElementFactory::make("ts-tcpclientsrc") + .name(format!("source-{}", i).as_str()) + .property("host", "127.0.0.1") + .property("port", 40000i32) + .property("context", &context) + .property("context-wait", wait) + .build() + .unwrap(); (source, Some(context)) } "tonegeneratesrc" => { - let source = gst::ElementFactory::make( - "tonegeneratesrc", - Some(format!("source-{}", i).as_str()), - ) - .unwrap(); - source.set_property("samplesperbuffer", (wait as i32) * 8000 / 1000); + let source = gst::ElementFactory::make("tonegeneratesrc") + .name(format!("source-{}", i).as_str()) + .property("samplesperbuffer", (wait as i32) * 8000 / 1000) + .build() + .unwrap(); sink.set_property("sync", true); @@ -155,12 +156,13 @@ fn main() { } "ts-tonesrc" => { let context = build_context(); - let source = - gst::ElementFactory::make("ts-tonesrc", Some(format!("source-{}", i).as_str())) - .unwrap(); - source.set_property("samples-per-buffer", (wait as u32) * 8000 / 1000); - source.set_property("context", &context); - source.set_property("context-wait", wait); + let source = gst::ElementFactory::make("ts-tonesrc") + .name(format!("source-{}", i).as_str()) + .property("samples-per-buffer", (wait as u32) * 8000 / 1000) + .property("context", &context) + .property("context-wait", wait) + .build() + .unwrap(); (source, Some(context)) } @@ -168,28 +170,33 @@ fn main() { }; if is_rtp { - let jb = - gst::ElementFactory::make("ts-jitterbuffer", Some(format!("jb-{}", i).as_str())) - .unwrap(); + let jb = gst::ElementFactory::make("ts-jitterbuffer") + .name(format!("jb-{}", i).as_str()) + .property("context-wait", wait) + .property("latency", wait) + .build() + .unwrap(); if let Some(context) = context { jb.set_property("context", &context); } - jb.set_property("context-wait", wait); - jb.set_property("latency", wait); let elements = &[&source, &jb, &sink]; pipeline.add_many(elements).unwrap(); gst::Element::link_many(elements).unwrap(); } else { let queue = if let Some(context) = context { - let queue = - gst::ElementFactory::make("ts-queue", Some(format!("queue-{}", i).as_str())) - .unwrap(); - queue.set_property("context", &context); - queue.set_property("context-wait", wait); + let queue = gst::ElementFactory::make("ts-queue") + .name(format!("queue-{}", i).as_str()) + .property("context", &context) + .property("context-wait", wait) + .build() + .unwrap(); queue } else { - gst::ElementFactory::make("queue2", Some(format!("queue-{}", i).as_str())).unwrap() + gst::ElementFactory::make("queue") + .name(format!("queue-{}", i).as_str()) + .build() + .unwrap() }; let elements = &[&source, &queue, &sink]; diff --git a/generic/threadshare/examples/standalone/main.rs b/generic/threadshare/examples/standalone/main.rs index 8852d9f7..23f60279 100644 --- a/generic/threadshare/examples/standalone/main.rs +++ b/generic/threadshare/examples/standalone/main.rs @@ -133,23 +133,21 @@ fn main() { for i in 0..args.streams { let ctx_name = format!("standalone {}", i % args.groups); - let src = gst::ElementFactory::make( - "ts-standalone-test-src", - Some(format!("src-{}", i).as_str()), - ) - .unwrap(); - src.set_property("context", &ctx_name); - src.set_property("context-wait", args.wait); - src.set_property("push-period", args.push_period); - src.set_property("num-buffers", args.num_buffers); - - let sink = gst::ElementFactory::make( - "ts-standalone-test-sink", - Some(format!("sink-{}", i).as_str()), - ) - .unwrap(); - sink.set_property("context", &ctx_name); - sink.set_property("context-wait", args.wait); + let src = gst::ElementFactory::make("ts-standalone-test-src") + .name(format!("src-{}", i).as_str()) + .property("context", &ctx_name) + .property("context-wait", args.wait) + .property("push-period", args.push_period) + .property("num-buffers", args.num_buffers) + .build() + .unwrap(); + + let sink = gst::ElementFactory::make("ts-standalone-test-sink") + .name(format!("sink-{}", i).as_str()) + .property("context", &ctx_name) + .property("context-wait", args.wait) + .build() + .unwrap(); if i == 0 { src.set_property("raise-log-level", true); diff --git a/generic/threadshare/examples/udpsrc_benchmark_sender.rs b/generic/threadshare/examples/udpsrc_benchmark_sender.rs index 995bc23f..5dfbf523 100644 --- a/generic/threadshare/examples/udpsrc_benchmark_sender.rs +++ b/generic/threadshare/examples/udpsrc_benchmark_sender.rs @@ -92,21 +92,27 @@ fn send_rtp_buffers(n_streams: u16) { let l = glib::MainLoop::new(None, false); let pipeline = gst::Pipeline::new(None); for i in 0..n_streams { - let src = - gst::ElementFactory::make("audiotestsrc", Some(format!("audiotestsrc-{}", i).as_str())) - .unwrap(); + let src = gst::ElementFactory::make("audiotestsrc") + .name(format!("audiotestsrc-{}", i).as_str()) + .build() + .unwrap(); src.set_property("is-live", true); - let enc = - gst::ElementFactory::make("alawenc", Some(format!("alawenc-{}", i).as_str())).unwrap(); - let pay = - gst::ElementFactory::make("rtppcmapay", Some(format!("rtppcmapay-{}", i).as_str())) - .unwrap(); - let sink = gst::ElementFactory::make("ts-udpsink", Some(format!("udpsink-{}", i).as_str())) + let enc = gst::ElementFactory::make("alawenc") + .name(format!("alawenc-{}", i).as_str()) + .build() + .unwrap(); + let pay = gst::ElementFactory::make("rtppcmapay") + .name(format!("rtppcmapay-{}", i).as_str()) + .build() + .unwrap(); + let sink = gst::ElementFactory::make("ts-udpsink") + .name(format!("udpsink-{}", i).as_str()) + .property("clients", format!("127.0.0.1:{}", i + 40000)) + .property("context", "context-udpsink") + .property("context-wait", 20u32) + .build() .unwrap(); - sink.set_property("clients", format!("127.0.0.1:{}", i + 40000)); - sink.set_property("context", "context-udpsink"); - sink.set_property("context-wait", 20u32); let elements = &[&src, &enc, &pay, &sink]; pipeline.add_many(elements).unwrap(); diff --git a/generic/threadshare/tests/inputselector.rs b/generic/threadshare/tests/inputselector.rs index 4dd3427a..c7e2d6fa 100644 --- a/generic/threadshare/tests/inputselector.rs +++ b/generic/threadshare/tests/inputselector.rs @@ -33,7 +33,9 @@ fn init() { fn test_active_pad() { init(); - let is = gst::ElementFactory::make("ts-input-selector", None).unwrap(); + let is = gst::ElementFactory::make("ts-input-selector") + .build() + .unwrap(); let mut h1 = gst_check::Harness::with_element(&is, Some("sink_%u"), Some("src")); let mut h2 = gst_check::Harness::with_element(&is, Some("sink_%u"), None); diff --git a/generic/threadshare/tests/jitterbuffer.rs b/generic/threadshare/tests/jitterbuffer.rs index b5d5a6b9..2904384b 100644 --- a/generic/threadshare/tests/jitterbuffer.rs +++ b/generic/threadshare/tests/jitterbuffer.rs @@ -51,25 +51,45 @@ fn jb_pipeline() { let pipeline = gst::Pipeline::new(None); - let src = gst::ElementFactory::make("audiotestsrc", Some("audiotestsrc")).unwrap(); - src.set_property("is-live", true); - src.set_property("num-buffers", BUFFER_NB); + let src = gst::ElementFactory::make("audiotestsrc") + .name("audiotestsrc") + .property("is-live", true) + .property("num-buffers", BUFFER_NB) + .build() + .unwrap(); - let enc = gst::ElementFactory::make("alawenc", Some("alawenc")).unwrap(); - let pay = gst::ElementFactory::make("rtppcmapay", Some("rtppcmapay")).unwrap(); + let enc = gst::ElementFactory::make("alawenc") + .name("alawenc") + .build() + .unwrap(); + let pay = gst::ElementFactory::make("rtppcmapay") + .name("rtppcmapay") + .build() + .unwrap(); - let jb = gst::ElementFactory::make("ts-jitterbuffer", Some("ts-jitterbuffer")).unwrap(); - jb.set_property("context", "jb_pipeline"); - jb.set_property("context-wait", CONTEXT_WAIT); - jb.set_property("latency", LATENCY); + let jb = gst::ElementFactory::make("ts-jitterbuffer") + .name("ts-jitterbuffer") + .property("context", "jb_pipeline") + .property("context-wait", CONTEXT_WAIT) + .property("latency", LATENCY) + .build() + .unwrap(); - let depay = gst::ElementFactory::make("rtppcmadepay", Some("rtppcmadepay")).unwrap(); - let dec = gst::ElementFactory::make("alawdec", Some("alawdec")).unwrap(); + let depay = gst::ElementFactory::make("rtppcmadepay") + .name("rtppcmadepay") + .build() + .unwrap(); + let dec = gst::ElementFactory::make("alawdec") + .name("alawdec") + .build() + .unwrap(); - let sink = gst::ElementFactory::make("appsink", Some("appsink")).unwrap(); - sink.set_property("sync", false); - sink.set_property("async", false); - sink.set_property("emit-signals", true); + let sink = gst::ElementFactory::make("appsink") + .name("appsink") + .property("sync", false) + .property("async", false) + .build() + .unwrap(); pipeline .add_many(&[&src, &enc, &pay, &jb, &depay, &dec, &sink]) @@ -110,29 +130,52 @@ fn jb_ts_pipeline() { let pipeline = gst::Pipeline::new(None); - let src = gst::ElementFactory::make("audiotestsrc", Some("audiotestsrc")).unwrap(); - src.set_property("is-live", true); - src.set_property("num-buffers", BUFFER_NB); + let src = gst::ElementFactory::make("audiotestsrc") + .name("audiotestsrc") + .property("is-live", true) + .property("num-buffers", BUFFER_NB) + .build() + .unwrap(); - let queue = gst::ElementFactory::make("ts-queue", Some("ts-queue")).unwrap(); - queue.set_property("context", "jb_ts_pipeline_queue"); - queue.set_property("context-wait", CONTEXT_WAIT); + let queue = gst::ElementFactory::make("ts-queue") + .name("ts-queue") + .property("context", "jb_ts_pipeline_queue") + .property("context-wait", CONTEXT_WAIT) + .build() + .unwrap(); - let enc = gst::ElementFactory::make("alawenc", Some("alawenc")).unwrap(); - let pay = gst::ElementFactory::make("rtppcmapay", Some("rtppcmapay")).unwrap(); + let enc = gst::ElementFactory::make("alawenc") + .name("alawenc") + .build() + .unwrap(); + let pay = gst::ElementFactory::make("rtppcmapay") + .name("rtppcmapay") + .build() + .unwrap(); - let jb = gst::ElementFactory::make("ts-jitterbuffer", Some("ts-jitterbuffer")).unwrap(); - jb.set_property("context", "jb_ts_pipeline"); - jb.set_property("context-wait", CONTEXT_WAIT); - jb.set_property("latency", LATENCY); + let jb = gst::ElementFactory::make("ts-jitterbuffer") + .name("ts-jitterbuffer") + .property("context", "jb_ts_pipeline") + .property("context-wait", CONTEXT_WAIT) + .property("latency", LATENCY) + .build() + .unwrap(); - let depay = gst::ElementFactory::make("rtppcmadepay", Some("rtppcmadepay")).unwrap(); - let dec = gst::ElementFactory::make("alawdec", Some("alawdec")).unwrap(); + let depay = gst::ElementFactory::make("rtppcmadepay") + .name("rtppcmadepay") + .build() + .unwrap(); + let dec = gst::ElementFactory::make("alawdec") + .name("alawdec") + .build() + .unwrap(); - let sink = gst::ElementFactory::make("appsink", Some("appsink")).unwrap(); - sink.set_property("sync", false); - sink.set_property("async", false); - sink.set_property("emit-signals", true); + let sink = gst::ElementFactory::make("appsink") + .name("appsink") + .property("sync", false) + .property("async", false) + .build() + .unwrap(); pipeline .add_many(&[&src, &queue, &enc, &pay, &jb, &depay, &dec, &sink]) diff --git a/generic/threadshare/tests/pad.rs b/generic/threadshare/tests/pad.rs index e1ca62f3..e293a2d3 100644 --- a/generic/threadshare/tests/pad.rs +++ b/generic/threadshare/tests/pad.rs @@ -892,9 +892,12 @@ fn src_tsqueue_sink_nominal() { let name = "src_tsqueue_sink"; - let ts_queue = gst::ElementFactory::make("ts-queue", Some("ts-queue")).unwrap(); - ts_queue.set_property("context", format!("{}_queue", name)); - ts_queue.set_property("context-wait", THROTTLING_DURATION.as_millis() as u32); + let ts_queue = gst::ElementFactory::make("ts-queue") + .name("ts-queue") + .property("context", format!("{}_queue", name)) + .property("context-wait", THROTTLING_DURATION.as_millis() as u32) + .build() + .unwrap(); let (pipeline, src_element, _sink_element, receiver) = setup(name, Some(ts_queue), None); @@ -907,7 +910,10 @@ fn src_queue_sink_nominal() { let name = "src_queue_sink"; - let queue = gst::ElementFactory::make("queue", Some("queue")).unwrap(); + let queue = gst::ElementFactory::make("queue") + .name("queue") + .build() + .unwrap(); let (pipeline, src_element, _sink_element, receiver) = setup(name, Some(queue), None); nominal_scenario(name, pipeline, src_element, receiver); @@ -919,13 +925,19 @@ fn src_tsproxy_sink_nominal() { let name = "src_tsproxy_sink"; - let ts_proxy_sink = gst::ElementFactory::make("ts-proxysink", Some("ts-proxysink")).unwrap(); - ts_proxy_sink.set_property("proxy-context", format!("{}_proxy_context", name)); + let ts_proxy_sink = gst::ElementFactory::make("ts-proxysink") + .name("ts-proxysink") + .property("proxy-context", format!("{}_proxy_context", name)) + .build() + .unwrap(); - let ts_proxy_src = gst::ElementFactory::make("ts-proxysrc", Some("ts-proxysrc")).unwrap(); - ts_proxy_src.set_property("proxy-context", format!("{}_proxy_context", name)); - ts_proxy_src.set_property("context", format!("{}_context", name)); - ts_proxy_src.set_property("context-wait", THROTTLING_DURATION.as_millis() as u32); + let ts_proxy_src = gst::ElementFactory::make("ts-proxysrc") + .name("ts-proxysrc") + .property("proxy-context", format!("{}_proxy_context", name)) + .property("context", format!("{}_context", name)) + .property("context-wait", THROTTLING_DURATION.as_millis() as u32) + .build() + .unwrap(); let (pipeline, src_element, _sink_element, receiver) = setup(name, Some(ts_proxy_sink), Some(ts_proxy_src)); diff --git a/generic/threadshare/tests/pipeline.rs b/generic/threadshare/tests/pipeline.rs index fa60755d..137d4dc4 100644 --- a/generic/threadshare/tests/pipeline.rs +++ b/generic/threadshare/tests/pipeline.rs @@ -63,22 +63,27 @@ fn multiple_contexts_queue() { let (sender, receiver) = mpsc::channel(); for i in 0..SRC_NB { - let src = - gst::ElementFactory::make("ts-udpsrc", Some(format!("src-{}", i).as_str())).unwrap(); - src.set_property("context", format!("context-{}", (i as u32) % CONTEXT_NB)); - src.set_property("context-wait", CONTEXT_WAIT); - src.set_property("port", (FIRST_PORT + i) as i32); - - let queue = - gst::ElementFactory::make("ts-queue", Some(format!("queue-{}", i).as_str())).unwrap(); - queue.set_property("context", format!("context-{}", (i as u32) % CONTEXT_NB)); - queue.set_property("context-wait", CONTEXT_WAIT); - - let sink = - gst::ElementFactory::make("appsink", Some(format!("sink-{}", i).as_str())).unwrap(); - sink.set_property("sync", false); - sink.set_property("async", false); - sink.set_property("emit-signals", true); + let src = gst::ElementFactory::make("ts-udpsrc") + .name(format!("src-{}", i).as_str()) + .property("context", format!("context-{}", (i as u32) % CONTEXT_NB)) + .property("context-wait", CONTEXT_WAIT) + .property("port", (FIRST_PORT + i) as i32) + .build() + .unwrap(); + + let queue = gst::ElementFactory::make("ts-queue") + .name(format!("queue-{}", i).as_str()) + .property("context", format!("context-{}", (i as u32) % CONTEXT_NB)) + .property("context-wait", CONTEXT_WAIT) + .build() + .unwrap(); + + let sink = gst::ElementFactory::make("appsink") + .name(format!("sink-{}", i).as_str()) + .property("sync", false) + .property("async", false) + .build() + .unwrap(); pipeline.add_many(&[&src, &queue, &sink]).unwrap(); gst::Element::link_many(&[&src, &queue, &sink]).unwrap(); @@ -194,38 +199,36 @@ fn multiple_contexts_proxy() { for i in 0..SRC_NB { let pipeline_index = i + OFFSET; - let src = gst::ElementFactory::make( - "ts-udpsrc", - Some(format!("src-{}", pipeline_index).as_str()), - ) - .unwrap(); - src.set_property("context", format!("context-{}", (i as u32) % CONTEXT_NB)); - src.set_property("context-wait", CONTEXT_WAIT); - src.set_property("port", (FIRST_PORT + i) as i32); + let src = gst::ElementFactory::make("ts-udpsrc") + .name(format!("src-{}", pipeline_index).as_str()) + .property("context", format!("context-{}", (i as u32) % CONTEXT_NB)) + .property("context-wait", CONTEXT_WAIT) + .property("port", (FIRST_PORT + i) as i32) + .build() + .unwrap(); - let proxysink = gst::ElementFactory::make( - "ts-proxysink", - Some(format!("proxysink-{}", pipeline_index).as_str()), - ) - .unwrap(); - proxysink.set_property("proxy-context", format!("proxy-{}", pipeline_index)); - let proxysrc = gst::ElementFactory::make( - "ts-proxysrc", - Some(format!("proxysrc-{}", pipeline_index).as_str()), - ) - .unwrap(); - proxysrc.set_property( - "context", - &format!("context-{}", (pipeline_index as u32) % CONTEXT_NB), - ); - proxysrc.set_property("proxy-context", format!("proxy-{}", pipeline_index)); + let proxysink = gst::ElementFactory::make("ts-proxysink") + .name(format!("proxysink-{}", pipeline_index).as_str()) + .property("proxy-context", format!("proxy-{}", pipeline_index)) + .build() + .unwrap(); - let sink = - gst::ElementFactory::make("appsink", Some(format!("sink-{}", pipeline_index).as_str())) - .unwrap(); - sink.set_property("sync", false); - sink.set_property("async", false); - sink.set_property("emit-signals", true); + let proxysrc = gst::ElementFactory::make("ts-proxysrc") + .name(format!("proxysrc-{}", pipeline_index).as_str()) + .property( + "context", + &format!("context-{}", (pipeline_index as u32) % CONTEXT_NB), + ) + .property("proxy-context", format!("proxy-{}", pipeline_index)) + .build() + .unwrap(); + + let sink = gst::ElementFactory::make("appsink") + .name(format!("sink-{}", pipeline_index).as_str()) + .property("sync", false) + .property("async", false) + .build() + .unwrap(); pipeline .add_many(&[&src, &proxysink, &proxysrc, &sink]) @@ -331,23 +334,30 @@ fn eos() { let caps = gst::Caps::builder("foo/bar").build(); - let src = gst::ElementFactory::make("ts-appsrc", Some("src-eos")).unwrap(); - src.set_property("caps", &caps); - src.set_property("do-timestamp", true); - src.set_property("context", &CONTEXT); + let src = gst::ElementFactory::make("ts-appsrc") + .name("src-eos") + .property("caps", &caps) + .property("do-timestamp", true) + .property("context", &CONTEXT) + .build() + .unwrap(); - let queue = gst::ElementFactory::make("ts-queue", Some("queue-eos")).unwrap(); - queue.set_property("context", &CONTEXT); + let queue = gst::ElementFactory::make("ts-queue") + .name("queue-eos") + .property("context", &CONTEXT) + .build() + .unwrap(); - let appsink = gst::ElementFactory::make("appsink", Some("sink-eos")).unwrap(); + let appsink = gst::ElementFactory::make("appsink") + .name("sink-eos") + .property("sync", false) + .property("async", false) + .build() + .unwrap(); pipeline.add_many(&[&src, &queue, &appsink]).unwrap(); gst::Element::link_many(&[&src, &queue, &appsink]).unwrap(); - appsink.set_property("sync", false); - appsink.set_property("async", false); - - appsink.set_property("emit-signals", true); let (sample_notifier, sample_notif_rcv) = mpsc::channel(); let (eos_notifier, eos_notif_rcv) = mpsc::channel(); let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap(); @@ -455,26 +465,33 @@ fn premature_shutdown() { let caps = gst::Caps::builder("foo/bar").build(); - let src = gst::ElementFactory::make("ts-appsrc", Some("src-ps")).unwrap(); - src.set_property("caps", &caps); - src.set_property("do-timestamp", true); - src.set_property("context", "appsrc-context"); - src.set_property("context-wait", APPSRC_CONTEXT_WAIT); + let src = gst::ElementFactory::make("ts-appsrc") + .name("src-ps") + .property("caps", &caps) + .property("do-timestamp", true) + .property("context", "appsrc-context") + .property("context-wait", APPSRC_CONTEXT_WAIT) + .build() + .unwrap(); - let queue = gst::ElementFactory::make("ts-queue", Some("queue-ps")).unwrap(); - queue.set_property("context", "queue-context"); - queue.set_property("context-wait", QUEUE_CONTEXT_WAIT); - queue.set_property("max-size-buffers", QUEUE_ITEMS_CAPACITY); + let queue = gst::ElementFactory::make("ts-queue") + .name("queue-ps") + .property("context", "queue-context") + .property("context-wait", QUEUE_CONTEXT_WAIT) + .property("max-size-buffers", QUEUE_ITEMS_CAPACITY) + .build() + .unwrap(); - let appsink = gst::ElementFactory::make("appsink", Some("sink-ps")).unwrap(); + let appsink = gst::ElementFactory::make("appsink") + .name("sink-ps") + .property("sync", false) + .property("async", false) + .build() + .unwrap(); pipeline.add_many(&[&src, &queue, &appsink]).unwrap(); gst::Element::link_many(&[&src, &queue, &appsink]).unwrap(); - appsink.set_property("emit-signals", true); - appsink.set_property("sync", false); - appsink.set_property("async", false); - let (appsink_sender, appsink_receiver) = mpsc::channel(); let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap(); @@ -605,9 +622,6 @@ fn socket_play_null_play() { let l = glib::MainLoop::new(None, false); let pipeline = gst::Pipeline::new(None); - let sink = - gst::ElementFactory::make("ts-udpsink", Some(format!("sink-{}", TEST).as_str())).unwrap(); - let socket = gio::Socket::new( SocketFamily::Ipv4, SocketType::Datagram, @@ -621,9 +635,13 @@ fn socket_play_null_play() { ) .unwrap(); - sink.set_property("socket", &socket); - sink.set_property("context", &TEST); - sink.set_property("context-wait", 20u32); + let sink = gst::ElementFactory::make("ts-udpsink") + .name(format!("sink-{}", TEST).as_str()) + .property("socket", &socket) + .property("context", &TEST) + .property("context-wait", 20u32) + .build() + .unwrap(); pipeline.add(&sink).unwrap(); diff --git a/generic/threadshare/tests/proxy.rs b/generic/threadshare/tests/proxy.rs index 19888919..5b68a869 100644 --- a/generic/threadshare/tests/proxy.rs +++ b/generic/threadshare/tests/proxy.rs @@ -36,10 +36,22 @@ fn test_push() { init(); let pipeline = gst::Pipeline::new(None); - let fakesrc = gst::ElementFactory::make("fakesrc", None).unwrap(); - let proxysink = gst::ElementFactory::make("ts-proxysink", Some("proxysink::test1")).unwrap(); - let proxysrc = gst::ElementFactory::make("ts-proxysrc", Some("proxysrc::test1")).unwrap(); - let appsink = gst::ElementFactory::make("appsink", None).unwrap(); + let fakesrc = gst::ElementFactory::make("fakesrc") + .property("num-buffers", 3i32) + .build() + .unwrap(); + let proxysink = gst::ElementFactory::make("ts-proxysink") + .name("proxysink::test1") + .property("proxy-context", "proxy::test1_proxy") + .build() + .unwrap(); + let proxysrc = gst::ElementFactory::make("ts-proxysrc") + .name("proxysrc::test1") + .property("proxy-context", "proxy::test1_proxy") + .property("context", "proxy::test") + .build() + .unwrap(); + let appsink = gst::ElementFactory::make("appsink").build().unwrap(); pipeline .add_many(&[&fakesrc, &proxysink, &proxysrc, &appsink]) @@ -47,13 +59,6 @@ fn test_push() { fakesrc.link(&proxysink).unwrap(); proxysrc.link(&appsink).unwrap(); - fakesrc.set_property("num-buffers", 3i32); - proxysink.set_property("proxy-context", "proxy::test1_proxy"); - proxysrc.set_property("proxy-context", "proxy::test1_proxy"); - proxysrc.set_property("context", "proxy::test"); - - appsink.set_property("emit-signals", true); - let samples = Arc::new(Mutex::new(Vec::new())); let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap(); @@ -102,12 +107,21 @@ fn test_from_pipeline_to_pipeline() { init(); let pipe_1 = gst::Pipeline::new(None); - let fakesrc = gst::ElementFactory::make("fakesrc", None).unwrap(); - let pxsink = gst::ElementFactory::make("ts-proxysink", Some("proxysink::test2")).unwrap(); + let fakesrc = gst::ElementFactory::make("fakesrc").build().unwrap(); + let pxsink = gst::ElementFactory::make("ts-proxysink") + .name("proxysink::test2") + .property("proxy-context", "proxy::test2_proxy") + .build() + .unwrap(); let pipe_2 = gst::Pipeline::new(None); - let pxsrc = gst::ElementFactory::make("ts-proxysrc", Some("proxysrc::test2")).unwrap(); - let fakesink = gst::ElementFactory::make("fakesink", None).unwrap(); + let pxsrc = gst::ElementFactory::make("ts-proxysrc") + .name("proxysrc::test2") + .property("proxy-context", "proxy::test2_proxy") + .property("context", "proxy::test") + .build() + .unwrap(); + let fakesink = gst::ElementFactory::make("fakesink").build().unwrap(); pipe_1.add_many(&[&fakesrc, &pxsink]).unwrap(); fakesrc.link(&pxsink).unwrap(); @@ -115,10 +129,6 @@ fn test_from_pipeline_to_pipeline() { pipe_2.add_many(&[&pxsrc, &fakesink]).unwrap(); pxsrc.link(&fakesink).unwrap(); - pxsink.set_property("proxy-context", "proxy::test2_proxy"); - pxsrc.set_property("proxy-context", "proxy::test2_proxy"); - pxsrc.set_property("context", "proxy::test"); - pipe_1.set_state(gst::State::Paused).unwrap(); pipe_2.set_state(gst::State::Paused).unwrap(); @@ -135,12 +145,30 @@ fn test_from_pipeline_to_pipeline_and_back() { init(); let pipe_1 = gst::Pipeline::new(None); - let pxsrc_1 = gst::ElementFactory::make("ts-proxysrc", Some("proxysrc1::test3")).unwrap(); - let pxsink_1 = gst::ElementFactory::make("ts-proxysink", Some("proxysink1::test3")).unwrap(); + let pxsrc_1 = gst::ElementFactory::make("ts-proxysrc") + .name("proxysrc1::test3") + .property("proxy-context", "proxy::test3_proxy1") + .property("context", "proxy::test") + .build() + .unwrap(); + let pxsink_1 = gst::ElementFactory::make("ts-proxysink") + .name("proxysink1::test3") + .property("proxy-context", "proxy::test3_proxy2") + .build() + .unwrap(); let pipe_2 = gst::Pipeline::new(None); - let pxsrc_2 = gst::ElementFactory::make("ts-proxysrc", Some("proxysrc2::test3")).unwrap(); - let pxsink_2 = gst::ElementFactory::make("ts-proxysink", Some("proxysink2::test3")).unwrap(); + let pxsrc_2 = gst::ElementFactory::make("ts-proxysrc") + .name("proxysrc2::test3") + .property("proxy-context", "proxy::test3_proxy2") + .property("context", "proxy::test") + .build() + .unwrap(); + let pxsink_2 = gst::ElementFactory::make("ts-proxysink") + .name("proxysink2::test3") + .property("proxy-context", "proxy::test3_proxy1") + .build() + .unwrap(); pipe_1.add_many(&[&pxsrc_1, &pxsink_1]).unwrap(); pxsrc_1.link(&pxsink_1).unwrap(); @@ -148,14 +176,6 @@ fn test_from_pipeline_to_pipeline_and_back() { pipe_2.add_many(&[&pxsrc_2, &pxsink_2]).unwrap(); pxsrc_2.link(&pxsink_2).unwrap(); - pxsrc_1.set_property("proxy-context", "proxy::test3_proxy1"); - pxsrc_1.set_property("context", "proxy::test"); - pxsink_2.set_property("proxy-context", "proxy::test3_proxy1"); - - pxsrc_2.set_property("proxy-context", "proxy::test3_proxy2"); - pxsrc_2.set_property("context", "proxy::test"); - pxsink_1.set_property("proxy-context", "proxy::test3_proxy2"); - pipe_1.set_state(gst::State::Paused).unwrap(); pipe_2.set_state(gst::State::Paused).unwrap(); diff --git a/generic/threadshare/tests/queue.rs b/generic/threadshare/tests/queue.rs index 003412ed..682f7175 100644 --- a/generic/threadshare/tests/queue.rs +++ b/generic/threadshare/tests/queue.rs @@ -36,18 +36,17 @@ fn test_push() { init(); let pipeline = gst::Pipeline::new(None); - let fakesrc = gst::ElementFactory::make("fakesrc", None).unwrap(); - let queue = gst::ElementFactory::make("ts-queue", None).unwrap(); - let appsink = gst::ElementFactory::make("appsink", None).unwrap(); + let fakesrc = gst::ElementFactory::make("fakesrc") + .property("num-buffers", 3i32) + .build() + .unwrap(); + let queue = gst::ElementFactory::make("ts-queue").build().unwrap(); + let appsink = gst::ElementFactory::make("appsink").build().unwrap(); pipeline.add_many(&[&fakesrc, &queue, &appsink]).unwrap(); fakesrc.link(&queue).unwrap(); queue.link(&appsink).unwrap(); - fakesrc.set_property("num-buffers", 3i32); - - appsink.set_property("emit-signals", true); - let samples = Arc::new(Mutex::new(Vec::new())); let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap(); diff --git a/generic/threadshare/tests/tcpclientsrc.rs b/generic/threadshare/tests/tcpclientsrc.rs index a0d3766e..3ad1330d 100644 --- a/generic/threadshare/tests/tcpclientsrc.rs +++ b/generic/threadshare/tests/tcpclientsrc.rs @@ -56,20 +56,21 @@ fn test_push() { let pipeline = gst::Pipeline::new(None); - let tcpclientsrc = gst::ElementFactory::make("ts-tcpclientsrc", None).unwrap(); - let appsink = gst::ElementFactory::make("appsink", None).unwrap(); - appsink.set_property("sync", false); - appsink.set_property("async", false); + let caps = gst::Caps::builder("foo/bar").build(); + let tcpclientsrc = gst::ElementFactory::make("ts-tcpclientsrc") + .property("caps", &caps) + .property("port", 5000i32) + .build() + .unwrap(); + let appsink = gst::ElementFactory::make("appsink") + .property("sync", false) + .property("async", false) + .build() + .unwrap(); pipeline.add_many(&[&tcpclientsrc, &appsink]).unwrap(); tcpclientsrc.link(&appsink).unwrap(); - let caps = gst::Caps::builder("foo/bar").build(); - tcpclientsrc.set_property("caps", &caps); - tcpclientsrc.set_property("port", 5000i32); - - appsink.set_property("emit-signals", true); - let samples = Arc::new(Mutex::new(Vec::new())); let appsink = appsink.dynamic_cast::<gst_app::AppSink>().unwrap(); |