diff options
author | Vivia Nikolaidou <vivia@ahiru.eu> | 2022-08-18 15:04:15 +0300 |
---|---|---|
committer | Vivia Nikolaidou <vivia@ahiru.eu> | 2022-08-22 17:58:43 +0300 |
commit | 560611134588f63270a569e92160ecac5ceabc37 (patch) | |
tree | ac5f4447c55c1e5dd4d8f15f92c335c36aa5bab8 /generic | |
parent | 84f6484140098826b3f074d806e0eb052198df43 (diff) |
plugins: Simplify code using ParamSpecBuilder
Diffstat (limited to 'generic')
-rw-r--r-- | generic/file/src/filesink/imp.rs | 11 | ||||
-rw-r--r-- | generic/file/src/filesrc/imp.rs | 12 | ||||
-rw-r--r-- | generic/fmp4/src/fmp4mux/imp.rs | 86 | ||||
-rw-r--r-- | generic/sodium/src/decrypter/imp.rs | 23 | ||||
-rw-r--r-- | generic/sodium/src/encrypter/imp.rs | 38 | ||||
-rw-r--r-- | generic/threadshare/examples/standalone/sink/imp.rs | 52 | ||||
-rw-r--r-- | generic/threadshare/examples/standalone/src/imp.rs | 42 | ||||
-rw-r--r-- | generic/threadshare/src/appsrc/imp.rs | 65 | ||||
-rw-r--r-- | generic/threadshare/src/inputselector/imp.rs | 42 | ||||
-rw-r--r-- | generic/threadshare/src/jitterbuffer/imp.rs | 93 | ||||
-rw-r--r-- | generic/threadshare/src/proxy/imp.rs | 94 | ||||
-rw-r--r-- | generic/threadshare/src/queue/imp.rs | 70 | ||||
-rw-r--r-- | generic/threadshare/src/tcpclientsrc/imp.rs | 80 | ||||
-rw-r--r-- | generic/threadshare/src/udpsink/imp.rs | 223 | ||||
-rw-r--r-- | generic/threadshare/src/udpsrc/imp.rs | 132 | ||||
-rw-r--r-- | generic/threadshare/tests/pad.rs | 28 |
16 files changed, 447 insertions, 644 deletions
diff --git a/generic/file/src/filesink/imp.rs b/generic/file/src/filesink/imp.rs index 444303754..334bc1394 100644 --- a/generic/file/src/filesink/imp.rs +++ b/generic/file/src/filesink/imp.rs @@ -118,13 +118,10 @@ impl ObjectSubclass for FileSink { impl ObjectImpl for FileSink { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { - vec![glib::ParamSpecString::new( - "location", - "File Location", - "Location of the file to write", - None, - glib::ParamFlags::READWRITE, - )] + vec![glib::ParamSpecString::builder("location") + .nick("File Location") + .blurb("Location of the file to write") + .build()] }); PROPERTIES.as_ref() diff --git a/generic/file/src/filesrc/imp.rs b/generic/file/src/filesrc/imp.rs index 72a709b6d..886db2e33 100644 --- a/generic/file/src/filesrc/imp.rs +++ b/generic/file/src/filesrc/imp.rs @@ -132,13 +132,11 @@ impl ObjectSubclass for FileSrc { impl ObjectImpl for FileSrc { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { - vec![glib::ParamSpecString::new( - "location", - "File Location", - "Location of the file to read from", - None, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - )] + vec![glib::ParamSpecString::builder("location") + .nick("File Location") + .blurb("Location of the file to read from") + .mutable_ready() + .build()] }); PROPERTIES.as_ref() diff --git a/generic/fmp4/src/fmp4mux/imp.rs b/generic/fmp4/src/fmp4mux/imp.rs index 7d9aa7302..11383f25e 100644 --- a/generic/fmp4/src/fmp4mux/imp.rs +++ b/generic/fmp4/src/fmp4mux/imp.rs @@ -1544,56 +1544,42 @@ impl ObjectImpl for FMP4Mux { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { vec![ // TODO: Add chunk-duration property separate from fragment-size - glib::ParamSpecUInt64::new( - "fragment-duration", - "Fragment Duration", - "Duration for each FMP4 fragment", - 0, - u64::MAX, - DEFAULT_FRAGMENT_DURATION.nseconds(), - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecEnum::new( - "header-update-mode", - "Header update mode", - "Mode for updating the header at the end of the stream", - super::HeaderUpdateMode::static_type(), - DEFAULT_HEADER_UPDATE_MODE as i32, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecBoolean::new( - "write-mfra", - "Write mfra box", - "Write fragment random access box at the end of the stream", - DEFAULT_WRITE_MFRA, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecBoolean::new( - "write-mehd", - "Write mehd box", - "Write movie extends header box with the duration at the end of the stream (needs a header-update-mode enabled)", - DEFAULT_WRITE_MFRA, - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecUInt64::new( - "interleave-bytes", - "Interleave Bytes", - "Interleave between streams in bytes", - 0, - u64::MAX, - DEFAULT_INTERLEAVE_BYTES.unwrap_or(0), - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - glib::ParamSpecUInt64::new( - "interleave-time", - "Interleave Time", - "Interleave between streams in nanoseconds", - 0, - u64::MAX, - DEFAULT_INTERLEAVE_TIME.map(gst::ClockTime::nseconds).unwrap_or(u64::MAX), - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, - ), - + glib::ParamSpecUInt64::builder("fragment-duration") + .nick("Fragment Duration") + .blurb("Duration for each FMP4 fragment") + .default_value(DEFAULT_FRAGMENT_DURATION.nseconds()) + .mutable_ready() + .build(), + glib::ParamSpecEnum::builder("header-update-mode", super::HeaderUpdateMode::static_type()) + .nick("Header update mode") + .blurb("Mode for updating the header at the end of the stream") + .default_value(DEFAULT_HEADER_UPDATE_MODE as i32) + .mutable_ready() + .build(), + glib::ParamSpecBoolean::builder("write-mfra") + .nick("Write mfra box") + .blurb("Write fragment random access box at the end of the stream") + .default_value(DEFAULT_WRITE_MFRA) + .mutable_ready() + .build(), + glib::ParamSpecBoolean::builder("write-mehd") + .nick("Write mehd box") + .blurb("Write movie extends header box with the duration at the end of the stream (needs a header-update-mode enabled)") + .default_value(DEFAULT_WRITE_MFRA) + .mutable_ready() + .build(), + glib::ParamSpecUInt64::builder("interleave-bytes") + .nick("Interleave Bytes") + .blurb("Interleave between streams in bytes") + .default_value(DEFAULT_INTERLEAVE_BYTES.unwrap_or(0)) + .mutable_ready() + .build(), + glib::ParamSpecUInt64::builder("interleave-time") + .nick("Interleave Time") + .blurb("Interleave between streams in nanoseconds") + .default_value(DEFAULT_INTERLEAVE_TIME.map(gst::ClockTime::nseconds).unwrap_or(u64::MAX)) + .mutable_ready() + .build(), ] }); diff --git a/generic/sodium/src/decrypter/imp.rs b/generic/sodium/src/decrypter/imp.rs index 333929fec..9e71d9ad7 100644 --- a/generic/sodium/src/decrypter/imp.rs +++ b/generic/sodium/src/decrypter/imp.rs @@ -597,20 +597,15 @@ impl ObjectImpl for Decrypter { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { vec![ - glib::ParamSpecBoxed::new( - "receiver-key", - "Receiver Key", - "The private key of the Reeiver", - glib::Bytes::static_type(), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecBoxed::new( - "sender-key", - "Sender Key", - "The public key of the Sender", - glib::Bytes::static_type(), - glib::ParamFlags::WRITABLE, - ), + glib::ParamSpecBoxed::builder("receiver-key", glib::Bytes::static_type()) + .nick("Receiver Key") + .blurb("The private key of the Receiver") + .build(), + glib::ParamSpecBoxed::builder("sender-key", glib::Bytes::static_type()) + .nick("Sender Key") + .blurb("The public key of the Sender") + .write_only() + .build(), ] }); diff --git a/generic/sodium/src/encrypter/imp.rs b/generic/sodium/src/encrypter/imp.rs index 9bcd5691a..e35b7dfa1 100644 --- a/generic/sodium/src/encrypter/imp.rs +++ b/generic/sodium/src/encrypter/imp.rs @@ -389,29 +389,21 @@ impl ObjectImpl for Encrypter { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { vec![ - glib::ParamSpecBoxed::new( - "receiver-key", - "Receiver Key", - "The public key of the Receiver", - glib::Bytes::static_type(), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecBoxed::new( - "sender-key", - "Sender Key", - "The private key of the Sender", - glib::Bytes::static_type(), - glib::ParamFlags::WRITABLE, - ), - glib::ParamSpecUInt::new( - "block-size", - "Block Size", - "The block-size of the chunks", - 1024, - std::u32::MAX, - 32768, - glib::ParamFlags::READWRITE, - ), + glib::ParamSpecBoxed::builder("receiver-key", glib::Bytes::static_type()) + .nick("Receiver Key") + .blurb("The public key of the Receiver") + .build(), + glib::ParamSpecBoxed::builder("sender-key", glib::Bytes::static_type()) + .nick("Sender Key") + .blurb("The private key of the Sender") + .write_only() + .build(), + glib::ParamSpecUInt::builder("block-size") + .nick("Block Size") + .blurb("The block-size of the chunks") + .minimum(1024) + .default_value(32768) + .build(), ] }); diff --git a/generic/threadshare/examples/standalone/sink/imp.rs b/generic/threadshare/examples/standalone/sink/imp.rs index 3b7e06f74..d2083037b 100644 --- a/generic/threadshare/examples/standalone/sink/imp.rs +++ b/generic/threadshare/examples/standalone/sink/imp.rs @@ -605,36 +605,28 @@ impl ObjectImpl for TestSink { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { vec![ - glib::ParamSpecString::new( - "context", - "Context", - "Context name to share threads with", - Some(DEFAULT_CONTEXT), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "context-wait", - "Context Wait", - "Throttle poll loop to run at most once every this many ms", - 0, - 1000, - DEFAULT_CONTEXT_WAIT.as_millis() as u32, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecBoolean::new( - "sync", - "Sync", - "Sync on the clock", - DEFAULT_SYNC, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecBoolean::new( - "must-log-stats", - "Must Log Stats", - "Whether statistics should be logged", - DEFAULT_MUST_LOG_STATS, - glib::ParamFlags::WRITABLE, - ), + glib::ParamSpecString::builder("context") + .nick("Context") + .blurb("Context name to share threads with") + .default_value(Some(DEFAULT_CONTEXT)) + .build(), + glib::ParamSpecUInt::builder("context-wait") + .nick("Context Wait") + .blurb("Throttle poll loop to run at most once every this many ms") + .maximum(1000) + .default_value(DEFAULT_CONTEXT_WAIT.as_millis() as u32) + .build(), + glib::ParamSpecBoolean::builder("sync") + .nick("Sync") + .blurb("Sync on the clock") + .default_value(DEFAULT_SYNC) + .build(), + glib::ParamSpecBoolean::builder("must-log-stats") + .nick("Must Log Stats") + .blurb("Whether statistics should be logged") + .default_value(DEFAULT_MUST_LOG_STATS) + .write_only() + .build(), ] }); diff --git a/generic/threadshare/examples/standalone/src/imp.rs b/generic/threadshare/examples/standalone/src/imp.rs index 6cb6ebba2..6b5f1d426 100644 --- a/generic/threadshare/examples/standalone/src/imp.rs +++ b/generic/threadshare/examples/standalone/src/imp.rs @@ -337,31 +337,23 @@ impl ObjectImpl for TestSrc { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { vec![ - glib::ParamSpecString::new( - "context", - "Context", - "Context name to share threads with", - Some(DEFAULT_CONTEXT), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "context-wait", - "Context Wait", - "Throttle poll loop to run at most once every this many ms", - 0, - 1000, - DEFAULT_CONTEXT_WAIT.as_millis() as u32, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecInt::new( - "num-buffers", - "Num Buffers", - "Number of buffers to output before sending EOS (-1 = unlimited)", - -1i32, - i32::MAX, - DEFAULT_NUM_BUFFERS, - glib::ParamFlags::READWRITE, - ), + glib::ParamSpecString::builder("context") + .nick("Context") + .blurb("Context name to share threads with") + .default_value(Some(DEFAULT_CONTEXT)) + .build(), + glib::ParamSpecUInt::builder("context-wait") + .nick("Context Wait") + .blurb("Throttle poll loop to run at most once every this many ms") + .maximum(1000) + .default_value(DEFAULT_CONTEXT_WAIT.as_millis() as u32) + .build(), + glib::ParamSpecInt::builder("num-buffers") + .nick("Num Buffers") + .blurb("Number of buffers to output before sending EOS (-1 = unlimited)") + .minimum(-1i32) + .default_value(DEFAULT_NUM_BUFFERS) + .build(), ] }); diff --git a/generic/threadshare/src/appsrc/imp.rs b/generic/threadshare/src/appsrc/imp.rs index 8389a21c3..10c696fb4 100644 --- a/generic/threadshare/src/appsrc/imp.rs +++ b/generic/threadshare/src/appsrc/imp.rs @@ -459,45 +459,32 @@ impl ObjectImpl for AppSrc { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { vec![ - glib::ParamSpecString::new( - "context", - "Context", - "Context name to share threads with", - Some(DEFAULT_CONTEXT), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "context-wait", - "Context Wait", - "Throttle poll loop to run at most once every this many ms", - 0, - 1000, - DEFAULT_CONTEXT_WAIT.as_millis() as u32, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "max-buffers", - "Max Buffers", - "Maximum number of buffers to queue up", - 1, - u32::MAX, - DEFAULT_MAX_BUFFERS, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecBoxed::new( - "caps", - "Caps", - "Caps to use", - gst::Caps::static_type(), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecBoolean::new( - "do-timestamp", - "Do Timestamp", - "Timestamp buffers with the current running time on arrival", - DEFAULT_DO_TIMESTAMP, - glib::ParamFlags::READWRITE, - ), + glib::ParamSpecString::builder("context") + .nick("Context") + .blurb("Context name to share threads with") + .default_value(Some(DEFAULT_CONTEXT)) + .build(), + glib::ParamSpecUInt::builder("context-wait") + .nick("Context Wait") + .blurb("Throttle poll loop to run at most once every this many ms") + .maximum(1000) + .default_value(DEFAULT_CONTEXT_WAIT.as_millis() as u32) + .build(), + glib::ParamSpecUInt::builder("max-buffers") + .nick("Max Buffers") + .blurb("Maximum number of buffers to queue up") + .minimum(1) + .default_value(DEFAULT_MAX_BUFFERS) + .build(), + glib::ParamSpecBoxed::builder("caps", gst::Caps::static_type()) + .nick("Caps") + .blurb("Caps to use") + .build(), + glib::ParamSpecBoolean::builder("do-timestamp") + .nick("Do Timestamp") + .blurb("Timestamp buffers with the current running time on arrival") + .default_value(DEFAULT_DO_TIMESTAMP) + .build(), ] }); diff --git a/generic/threadshare/src/inputselector/imp.rs b/generic/threadshare/src/inputselector/imp.rs index 8f3b959e2..f6ae8202d 100644 --- a/generic/threadshare/src/inputselector/imp.rs +++ b/generic/threadshare/src/inputselector/imp.rs @@ -406,29 +406,25 @@ impl ObjectImpl for InputSelector { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { vec![ - glib::ParamSpecString::new( - "context", - "Context", - "Context name to share threads with", - Some(DEFAULT_CONTEXT), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "context-wait", - "Context Wait", - "Throttle poll loop to run at most once every this many ms", - 0, - 1000, - DEFAULT_CONTEXT_WAIT.as_millis() as u32, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecObject::new( - "active-pad", - "Active Pad", - "Currently active pad", - gst::Pad::static_type(), - glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING, - ), + glib::ParamSpecString::builder("context") + .nick("Context") + .blurb("Context name to share threads with") + .default_value(Some(DEFAULT_CONTEXT)) + .readwrite() + .build(), + glib::ParamSpecUInt::builder("context-wait") + .nick("Context Wait") + .blurb("Throttle poll loop to run at most once every this many ms") + .maximum(1000) + .default_value(DEFAULT_CONTEXT_WAIT.as_millis() as u32) + .readwrite() + .build(), + glib::ParamSpecObject::builder("active-pad", gst::Pad::static_type()) + .nick("Active Pad") + .blurb("Currently active pad") + .readwrite() + .mutable_playing() + .build(), ] }); diff --git a/generic/threadshare/src/jitterbuffer/imp.rs b/generic/threadshare/src/jitterbuffer/imp.rs index cb96c963b..ffc8fd010 100644 --- a/generic/threadshare/src/jitterbuffer/imp.rs +++ b/generic/threadshare/src/jitterbuffer/imp.rs @@ -1362,63 +1362,42 @@ impl ObjectImpl for JitterBuffer { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { vec![ - glib::ParamSpecString::new( - "context", - "Context", - "Context name to share threads with", - Some(DEFAULT_CONTEXT), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "context-wait", - "Context Wait", - "Throttle poll loop to run at most once every this many ms", - 0, - 1000, - DEFAULT_CONTEXT_WAIT.mseconds() as u32, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "latency", - "Buffer latency in ms", - "Amount of ms to buffer", - 0, - std::u32::MAX, - DEFAULT_LATENCY.mseconds() as u32, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecBoolean::new( - "do-lost", - "Do Lost", - "Send an event downstream when a packet is lost", - DEFAULT_DO_LOST, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "max-dropout-time", - "Max dropout time", - "The maximum time (milliseconds) of missing packets tolerated.", - 0, - std::u32::MAX, - DEFAULT_MAX_DROPOUT_TIME, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "max-misorder-time", - "Max misorder time", - "The maximum time (milliseconds) of misordered packets tolerated.", - 0, - std::u32::MAX, - DEFAULT_MAX_MISORDER_TIME, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecBoxed::new( - "stats", - "Statistics", - "Various statistics", - gst::Structure::static_type(), - glib::ParamFlags::READABLE, - ), + glib::ParamSpecString::builder("context") + .nick("Context") + .blurb("Context name to share threads with") + .default_value(Some(DEFAULT_CONTEXT)) + .build(), + glib::ParamSpecUInt::builder("context-wait") + .nick("Context Wait") + .blurb("Throttle poll loop to run at most once every this many ms") + .maximum(1000) + .default_value(DEFAULT_CONTEXT_WAIT.mseconds() as u32) + .build(), + glib::ParamSpecUInt::builder("latency") + .nick("Buffer latency in ms") + .blurb("Amount of ms to buffer") + .default_value(DEFAULT_LATENCY.mseconds() as u32) + .build(), + glib::ParamSpecBoolean::builder("do-lost") + .nick("Do Lost") + .blurb("Send an event downstream when a packet is lost") + .default_value(DEFAULT_DO_LOST) + .build(), + glib::ParamSpecUInt::builder("max-dropout-time") + .nick("Max dropout time") + .blurb("The maximum time (milliseconds) of missing packets tolerated.") + .default_value(DEFAULT_MAX_DROPOUT_TIME) + .build(), + glib::ParamSpecUInt::builder("max-misorder-time") + .nick("Max misorder time") + .blurb("The maximum time (milliseconds) of misordered packets tolerated.") + .default_value(DEFAULT_MAX_MISORDER_TIME) + .build(), + glib::ParamSpecBoxed::builder("stats", gst::Structure::static_type()) + .nick("Statistics") + .blurb("Various statistics") + .read_only() + .build(), ] }); diff --git a/generic/threadshare/src/proxy/imp.rs b/generic/threadshare/src/proxy/imp.rs index 06e9e7d61..f706db702 100644 --- a/generic/threadshare/src/proxy/imp.rs +++ b/generic/threadshare/src/proxy/imp.rs @@ -589,13 +589,11 @@ impl ObjectSubclass for ProxySink { impl ObjectImpl for ProxySink { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { - vec![glib::ParamSpecString::new( - "proxy-context", - "Proxy Context", - "Context name of the proxy to share with", - Some(DEFAULT_PROXY_CONTEXT), - glib::ParamFlags::READWRITE, - )] + vec![glib::ParamSpecString::builder("proxy-context") + .nick("Proxy Context") + .blurb("Context name of the proxy to share with") + .default_value(Some(DEFAULT_PROXY_CONTEXT)) + .build()] }); PROPERTIES.as_ref() @@ -1117,56 +1115,38 @@ impl ObjectImpl for ProxySrc { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { vec![ - glib::ParamSpecString::new( - "context", - "Context", - "Context name to share threads with", - Some(DEFAULT_CONTEXT), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "context-wait", - "Context Wait", - "Throttle poll loop to run at most once every this many ms", - 0, - 1000, - DEFAULT_CONTEXT_WAIT.as_millis() as u32, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecString::new( - "proxy-context", - "Proxy Context", - "Context name of the proxy to share with", - Some(DEFAULT_PROXY_CONTEXT), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "max-size-buffers", - "Max Size Buffers", - "Maximum number of buffers to queue (0=unlimited)", - 0, - u32::MAX, - DEFAULT_MAX_SIZE_BUFFERS, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "max-size-bytes", - "Max Size Bytes", - "Maximum number of bytes to queue (0=unlimited)", - 0, - u32::MAX, - DEFAULT_MAX_SIZE_BYTES, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt64::new( - "max-size-time", - "Max Size Time", - "Maximum number of nanoseconds to queue (0=unlimited)", - 0, - u64::MAX - 1, - DEFAULT_MAX_SIZE_TIME.nseconds(), - glib::ParamFlags::READWRITE, - ), + glib::ParamSpecString::builder("context") + .nick("Context") + .blurb("Context name to share threads with") + .default_value(Some(DEFAULT_CONTEXT)) + .build(), + glib::ParamSpecUInt::builder("context-wait") + .nick("Context Wait") + .blurb("Throttle poll loop to run at most once every this many ms") + .maximum(1000) + .default_value(DEFAULT_CONTEXT_WAIT.as_millis() as u32) + .build(), + glib::ParamSpecString::builder("proxy-context") + .nick("Proxy Context") + .blurb("Context name of the proxy to share with") + .default_value(Some(DEFAULT_PROXY_CONTEXT)) + .build(), + glib::ParamSpecUInt::builder("max-size-buffers") + .nick("Max Size Buffers") + .blurb("Maximum number of buffers to queue (0=unlimited)") + .default_value(DEFAULT_MAX_SIZE_BUFFERS) + .build(), + glib::ParamSpecUInt::builder("max-size-bytes") + .nick("Max Size Bytes") + .blurb("Maximum number of bytes to queue (0=unlimited)") + .default_value(DEFAULT_MAX_SIZE_BYTES) + .build(), + glib::ParamSpecUInt64::builder("max-size-time") + .nick("Max Size Time") + .blurb("Maximum number of nanoseconds to queue (0=unlimited)") + .maximum(u64::MAX - 1) + .default_value(DEFAULT_MAX_SIZE_TIME.nseconds()) + .build(), ] }); diff --git a/generic/threadshare/src/queue/imp.rs b/generic/threadshare/src/queue/imp.rs index 5ee8fc1d6..a3c3b6a1c 100644 --- a/generic/threadshare/src/queue/imp.rs +++ b/generic/threadshare/src/queue/imp.rs @@ -705,49 +705,33 @@ impl ObjectImpl for Queue { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { vec![ - glib::ParamSpecString::new( - "context", - "Context", - "Context name to share threads with", - Some(DEFAULT_CONTEXT), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "context-wait", - "Context Wait", - "Throttle poll loop to run at most once every this many ms", - 0, - 1000, - DEFAULT_CONTEXT_WAIT.as_millis() as u32, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "max-size-buffers", - "Max Size Buffers", - "Maximum number of buffers to queue (0=unlimited)", - 0, - u32::MAX, - DEFAULT_MAX_SIZE_BUFFERS, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "max-size-bytes", - "Max Size Bytes", - "Maximum number of bytes to queue (0=unlimited)", - 0, - u32::MAX, - DEFAULT_MAX_SIZE_BYTES, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt64::new( - "max-size-time", - "Max Size Time", - "Maximum number of nanoseconds to queue (0=unlimited)", - 0, - u64::MAX - 1, - DEFAULT_MAX_SIZE_TIME.nseconds(), - glib::ParamFlags::READWRITE, - ), + glib::ParamSpecString::builder("context") + .nick("Context") + .blurb("Context name to share threads with") + .default_value(Some(DEFAULT_CONTEXT)) + .build(), + glib::ParamSpecUInt::builder("context-wait") + .nick("Context Wait") + .blurb("Throttle poll loop to run at most once every this many ms") + .maximum(1000) + .default_value(DEFAULT_CONTEXT_WAIT.as_millis() as u32) + .build(), + glib::ParamSpecUInt::builder("max-size-buffers") + .nick("Max Size Buffers") + .blurb("Maximum number of buffers to queue (0=unlimited)") + .default_value(DEFAULT_MAX_SIZE_BUFFERS) + .build(), + glib::ParamSpecUInt::builder("max-size-bytes") + .nick("Max Size Bytes") + .blurb("Maximum number of bytes to queue (0=unlimited)") + .default_value(DEFAULT_MAX_SIZE_BYTES) + .build(), + glib::ParamSpecUInt64::builder("max-size-time") + .nick("Max Size Time") + .blurb("Maximum number of nanoseconds to queue (0=unlimited)") + .maximum(u64::MAX - 1) + .default_value(DEFAULT_MAX_SIZE_TIME.nseconds()) + .build(), ] }); diff --git a/generic/threadshare/src/tcpclientsrc/imp.rs b/generic/threadshare/src/tcpclientsrc/imp.rs index 6ebe12535..7cb5aeb79 100644 --- a/generic/threadshare/src/tcpclientsrc/imp.rs +++ b/generic/threadshare/src/tcpclientsrc/imp.rs @@ -520,54 +520,38 @@ impl ObjectImpl for TcpClientSrc { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { vec![ - glib::ParamSpecString::new( - "context", - "Context", - "Context name to share threads with", - Some(DEFAULT_CONTEXT), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "context-wait", - "Context Wait", - "Throttle poll loop to run at most once every this many ms", - 0, - 1000, - DEFAULT_CONTEXT_WAIT.as_millis() as u32, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecString::new( - "host", - "Host", - "The host IP address to receive packets from", - DEFAULT_HOST, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecInt::new( - "port", - "Port", - "Port to receive packets from", - 0, - u16::MAX as i32, - DEFAULT_PORT, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecBoxed::new( - "caps", - "Caps", - "Caps to use", - gst::Caps::static_type(), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "blocksize", - "Blocksize", - "Size in bytes to read per buffer (-1 = default)", - 0, - u32::MAX, - DEFAULT_BLOCKSIZE, - glib::ParamFlags::READWRITE, - ), + glib::ParamSpecString::builder("context") + .nick("Context") + .blurb("Context name to share threads with") + .default_value(Some(DEFAULT_CONTEXT)) + .build(), + glib::ParamSpecUInt::builder("context-wait") + .nick("Context Wait") + .blurb("Throttle poll loop to run at most once every this many ms") + .maximum(1000) + .default_value(DEFAULT_CONTEXT_WAIT.as_millis() as u32) + .build(), + glib::ParamSpecString::builder("host") + .nick("Host") + .blurb("The host IP address to receive packets from") + .default_value(DEFAULT_HOST) + .build(), + glib::ParamSpecInt::builder("port") + .nick("Port") + .blurb("Port to receive packets from") + .minimum(0) + .maximum(u16::MAX as i32) + .default_value(DEFAULT_PORT) + .build(), + glib::ParamSpecBoxed::builder("caps", gst::Caps::static_type()) + .nick("Caps") + .blurb("Caps to use") + .build(), + glib::ParamSpecUInt::builder("blocksize") + .nick("Blocksize") + .blurb("Size in bytes to read per buffer (-1 = default)") + .default_value(DEFAULT_BLOCKSIZE) + .build(), ] }); diff --git a/generic/threadshare/src/udpsink/imp.rs b/generic/threadshare/src/udpsink/imp.rs index 624c4189d..5fedd3ef6 100644 --- a/generic/threadshare/src/udpsink/imp.rs +++ b/generic/threadshare/src/udpsink/imp.rs @@ -963,137 +963,98 @@ impl ObjectImpl for UdpSink { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { vec![ - glib::ParamSpecString::new( - "context", - "Context", - "Context name to share threads with", - Some(DEFAULT_CONTEXT), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "context-wait", - "Context Wait", - "Throttle poll loop to run at most once every this many ms", - 0, - 1000, - DEFAULT_CONTEXT_WAIT.as_millis() as u32, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecBoolean::new( - "sync", - "Sync", - "Sync on the clock", - DEFAULT_SYNC, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecString::new( - "bind-address", - "Bind Address", - "Address to bind the socket to", - Some(DEFAULT_BIND_ADDRESS), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecInt::new( - "bind-port", - "Bind Port", - "Port to bind the socket to", - 0, - u16::MAX as i32, - DEFAULT_BIND_PORT, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecString::new( - "bind-address-v6", - "Bind Address V6", - "Address to bind the V6 socket to", - Some(DEFAULT_BIND_ADDRESS_V6), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecInt::new( - "bind-port-v6", - "Bind Port", - "Port to bind the V6 socket to", - 0, - u16::MAX as i32, - DEFAULT_BIND_PORT_V6, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecObject::new( - "socket", - "Socket", - "Socket to use for UDP transmission. (None == allocate)", - gio::Socket::static_type(), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecObject::new( - "used-socket", - "Used Socket", - "Socket currently in use for UDP transmission. (None = no socket)", - gio::Socket::static_type(), - glib::ParamFlags::READABLE, - ), - glib::ParamSpecObject::new( - "socket-v6", - "Socket V6", - "IPV6 Socket to use for UDP transmission. (None == allocate)", - gio::Socket::static_type(), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecObject::new( - "used-socket-v6", - "Used Socket V6", - "V6 Socket currently in use for UDP transmission. (None = no socket)", - gio::Socket::static_type(), - glib::ParamFlags::READABLE, - ), - glib::ParamSpecBoolean::new( - "auto-multicast", - "Auto multicast", - "Automatically join/leave the multicast groups, FALSE means user has to do it himself", - DEFAULT_AUTO_MULTICAST, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecBoolean::new( - "loop", - "Loop", - "Set the multicast loop parameter.", - DEFAULT_LOOP, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "ttl", - "Time To Live", - "Used for setting the unicast TTL parameter", - 0, - u8::MAX as u32, - DEFAULT_TTL, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "ttl-mc", - "Time To Live Multicast", - "Used for setting the multicast TTL parameter", - 0, - u8::MAX as u32, - DEFAULT_TTL_MC, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecInt::new( - "qos-dscp", - "QoS DSCP", - "Quality of Service, differentiated services code point (-1 default)", - -1, - 63, - DEFAULT_QOS_DSCP, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecString::new( - "clients", - "Clients", - "A comma separated list of host:port pairs with destinations", - Some(DEFAULT_CLIENTS), - glib::ParamFlags::READWRITE, - ), + glib::ParamSpecString::builder("context") + .nick("Context") + .blurb("Context name to share threads with") + .default_value(Some(DEFAULT_CONTEXT)) + .build(), + glib::ParamSpecUInt::builder("context-wait") + .nick("Context Wait") + .blurb("Throttle poll loop to run at most once every this many ms") + .maximum(1000) + .default_value(DEFAULT_CONTEXT_WAIT.as_millis() as u32) + .build(), + glib::ParamSpecBoolean::builder("sync") + .nick("Sync") + .blurb("Sync on the clock") + .default_value(DEFAULT_SYNC) + .build(), + glib::ParamSpecString::builder("bind-address") + .nick("Bind Address") + .blurb("Address to bind the socket to") + .default_value(Some(DEFAULT_BIND_ADDRESS)) + .build(), + glib::ParamSpecInt::builder("bind-port") + .nick("Bind Port") + .blurb("Port to bind the socket to") + .minimum(0) + .maximum(u16::MAX as i32) + .default_value(DEFAULT_BIND_PORT) + .build(), + glib::ParamSpecString::builder("bind-address-v6") + .nick("Bind Address V6") + .blurb("Address to bind the V6 socket to") + .default_value(Some(DEFAULT_BIND_ADDRESS_V6)) + .build(), + glib::ParamSpecInt::builder("bind-port-v6") + .nick("Bind Port") + .blurb("Port to bind the V6 socket to") + .minimum(0) + .maximum(u16::MAX as i32) + .default_value(DEFAULT_BIND_PORT_V6) + .build(), + glib::ParamSpecObject::builder("socket", gio::Socket::static_type()) + .nick("Socket") + .blurb("Socket to use for UDP transmission. (None == allocate)") + .build(), + glib::ParamSpecObject::builder("used-socket", gio::Socket::static_type()) + .nick("Used Socket") + .blurb("Socket currently in use for UDP transmission. (None = no socket)") + .read_only() + .build(), + glib::ParamSpecObject::builder("socket-v6", gio::Socket::static_type()) + .nick("Socket V6") + .blurb("IPV6 Socket to use for UDP transmission. (None == allocate)") + .build(), + glib::ParamSpecObject::builder("used-socket-v6", gio::Socket::static_type()) + .nick("Used Socket V6") + .blurb("V6 Socket currently in use for UDP transmission. (None = no socket)") + .read_only() + .build(), + glib::ParamSpecBoolean::builder("auto-multicast") + .nick("Auto multicast") + .blurb("Automatically join/leave the multicast groups, FALSE means user has to do it himself") + .default_value(DEFAULT_AUTO_MULTICAST) + .build(), + glib::ParamSpecBoolean::builder("loop") + .nick("Loop") + .blurb("Set the multicast loop parameter.") + .default_value(DEFAULT_LOOP) + .build(), + glib::ParamSpecUInt::builder("ttl") + .nick("Time To Live") + .blurb("Used for setting the unicast TTL parameter") + .maximum(u8::MAX as u32) + .default_value(DEFAULT_TTL) + .build(), + glib::ParamSpecUInt::builder("ttl-mc") + .nick("Time To Live Multicast") + .blurb("Used for setting the multicast TTL parameter") + .maximum(u8::MAX as u32) + .default_value(DEFAULT_TTL_MC) + .build(), + glib::ParamSpecInt::builder("qos-dscp") + .nick("QoS DSCP") + .blurb("Quality of Service, differentiated services code point (-1 default)") + .minimum(-1) + .maximum(63) + .default_value(DEFAULT_QOS_DSCP) + .build(), + glib::ParamSpecString::builder("clients") + .nick("Clients") + .blurb("A comma separated list of host:port pairs with destinations") + .default_value(Some(DEFAULT_CLIENTS)) + .build(), ] }); diff --git a/generic/threadshare/src/udpsrc/imp.rs b/generic/threadshare/src/udpsrc/imp.rs index 1f6ded99d..e1160e454 100644 --- a/generic/threadshare/src/udpsrc/imp.rs +++ b/generic/threadshare/src/udpsrc/imp.rs @@ -648,86 +648,66 @@ impl ObjectImpl for UdpSrc { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { let mut properties = vec![ - glib::ParamSpecString::new( - "context", - "Context", - "Context name to share threads with", - Some(DEFAULT_CONTEXT), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "context-wait", - "Context Wait", - "Throttle poll loop to run at most once every this many ms", - 0, - 1000, - DEFAULT_CONTEXT_WAIT.as_millis() as u32, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecString::new( - "address", - "Address", - "Address/multicast group to listen on", - DEFAULT_ADDRESS, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecInt::new( - "port", - "Port", - "Port to listen on", - 0, - u16::MAX as i32, - DEFAULT_PORT, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecBoolean::new( - "reuse", - "Reuse", - "Allow reuse of the port", - DEFAULT_REUSE, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecBoxed::new( - "caps", - "Caps", - "Caps to use", - gst::Caps::static_type(), - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecUInt::new( - "mtu", - "MTU", - "Maximum expected packet size. This directly defines the allocation size of the receive buffer pool", - 0, - i32::MAX as u32, - DEFAULT_MTU, - glib::ParamFlags::READWRITE, - ), - glib::ParamSpecBoolean::new( - "retrieve-sender-address", - "Retrieve sender address", - "Whether to retrieve the sender address and add it to buffers as meta. Disabling this might result in minor performance improvements in certain scenarios", - DEFAULT_RETRIEVE_SENDER_ADDRESS, - glib::ParamFlags::READWRITE, - ), + glib::ParamSpecString::builder("context") + .nick("Context") + .blurb("Context name to share threads with") + .default_value(Some(DEFAULT_CONTEXT)) + .build(), + glib::ParamSpecUInt::builder("context-wait") + .nick("Context Wait") + .blurb("Throttle poll loop to run at most once every this many ms") + .maximum(1000) + .default_value(DEFAULT_CONTEXT_WAIT.as_millis() as u32) + .build(), + glib::ParamSpecString::builder("address") + .nick("Address") + .blurb("Address/multicast group to listen on") + .default_value(DEFAULT_ADDRESS) + .build(), + glib::ParamSpecInt::builder("port") + .nick("Port") + .blurb("Port to listen on") + .minimum(0) + .maximum(u16::MAX as i32) + .default_value(DEFAULT_PORT) + .build(), + glib::ParamSpecBoolean::builder("reuse") + .nick("Reuse") + .blurb("Allow reuse of the port") + .default_value(DEFAULT_REUSE) + .build(), + glib::ParamSpecBoxed::builder("caps", gst::Caps::static_type()) + .nick("Caps") + .blurb("Caps to use") + .build(), + glib::ParamSpecUInt::builder("mtu") + .nick("MTU") + .blurb("Maximum expected packet size. This directly defines the allocation size of the receive buffer pool") + .maximum(i32::MAX as u32) + .default_value(DEFAULT_MTU) + .build(), + glib::ParamSpecBoolean::builder("retrieve-sender-address") + .nick("Retrieve sender address") + .blurb("Whether to retrieve the sender address and add it to buffers as meta. Disabling this might result in minor performance improvements in certain scenarios") + .default_value(DEFAULT_RETRIEVE_SENDER_ADDRESS) + .build(), ]; #[cfg(not(windows))] { - properties.push(glib::ParamSpecObject::new( - "socket", - "Socket", - "Socket to use for UDP reception. (None == allocate)", - gio::Socket::static_type(), - glib::ParamFlags::READWRITE, - )); - properties.push(glib::ParamSpecObject::new( - "used-socket", - "Used Socket", - "Socket currently in use for UDP reception. (None = no socket)", - gio::Socket::static_type(), - glib::ParamFlags::READABLE, - )); + properties.push( + glib::ParamSpecObject::builder("socket", gio::Socket::static_type()) + .nick("Socket") + .blurb("Socket to use for UDP reception. (None == allocate)") + .build(), + ); + properties.push( + glib::ParamSpecObject::builder("used-socket", gio::Socket::static_type()) + .nick("Used Socket") + .blurb("Socket currently in use for UDP reception. (None = no socket)") + .read_only() + .build(), + ); } properties diff --git a/generic/threadshare/tests/pad.rs b/generic/threadshare/tests/pad.rs index 4920e2c78..93b131914 100644 --- a/generic/threadshare/tests/pad.rs +++ b/generic/threadshare/tests/pad.rs @@ -304,13 +304,12 @@ mod imp_src { impl ObjectImpl for ElementSrcTest { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { - vec![glib::ParamSpecString::new( - "context", - "Context", - "Context name to share threads with", - Some(DEFAULT_CONTEXT), - glib::ParamFlags::WRITABLE, - )] + vec![glib::ParamSpecString::builder("context") + .nick("Context") + .blurb("Context name to share threads with") + .default_value(Some(DEFAULT_CONTEXT)) + .write_only() + .build()] }); PROPERTIES.as_ref() @@ -637,13 +636,14 @@ mod imp_sink { impl ObjectImpl for ElementSinkTest { fn properties() -> &'static [glib::ParamSpec] { static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| { - vec![glib::ParamSpecBoxed::new( - "sender", - "Sender", - "Channel sender to forward the incoming items to", - ItemSender::static_type(), - glib::ParamFlags::WRITABLE | glib::ParamFlags::CONSTRUCT_ONLY, - )] + vec![ + glib::ParamSpecBoxed::builder("sender", ItemSender::static_type()) + .nick("Sender") + .blurb("Channel sender to forward the incoming items to") + .write_only() + .construct_only() + .build(), + ] }); PROPERTIES.as_ref() |