From dc0c5f7611d5896f9fcfa9e141fabe02dea16ea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 7 Mar 2021 18:22:24 +0200 Subject: [PATCH] Update for new #[glib::object_subclass] attribute macro --- audio/audiofx/src/audioecho/imp.rs | 14 +- audio/audiofx/src/audioloudnorm/imp.rs | 6 +- audio/audiofx/src/audiornnoise/imp.rs | 13 +- audio/claxon/src/claxondec/imp.rs | 13 +- audio/csound/src/filter/imp.rs | 6 +- audio/lewton/src/lewtondec/imp.rs | 16 +- generic/file/src/filesink/imp.rs | 13 +- generic/file/src/filesrc/imp.rs | 13 +- generic/sodium/src/decrypter/imp.rs | 6 +- generic/sodium/src/encrypter/imp.rs | 6 +- generic/threadshare/src/appsrc/imp.rs | 6 +- generic/threadshare/src/inputselector/imp.rs | 6 +- generic/threadshare/src/jitterbuffer/imp.rs | 6 +- generic/threadshare/src/proxy/imp.rs | 15 +- generic/threadshare/src/queue/imp.rs | 6 +- generic/threadshare/src/tcpclientsrc/imp.rs | 6 +- generic/threadshare/src/udpsink/imp.rs | 6 +- generic/threadshare/src/udpsrc/imp.rs | 6 +- generic/threadshare/tests/pad.rs | 10 +- net/reqwest/src/reqwesthttpsrc/imp.rs | 17 +- net/rusoto/src/aws_transcriber/imp.rs | 6 +- net/rusoto/src/s3sink/imp.rs | 15 +- net/rusoto/src/s3src/imp.rs | 20 +-- text/json/src/jsongstenc/imp.rs | 6 +- text/json/src/jsongstparse/imp.rs | 6 +- text/regex/src/gstregex/imp.rs | 6 +- text/wrap/src/gsttextwrap/imp.rs | 6 +- tutorial/src/identity/imp.rs | 7 +- tutorial/src/progressbin/imp.rs | 7 +- tutorial/src/rgb2gray/imp.rs | 17 +- tutorial/src/sinesrc/imp.rs | 30 ++-- tutorial/tutorial-1.md | 130 +++++--------- tutorial/tutorial-2.md | 166 +++++++++--------- .../src/fallbacksrc/custom_source/imp.rs | 19 +- utils/fallbackswitch/src/fallbacksrc/imp.rs | 14 +- .../src/fallbacksrc/video_fallback/imp.rs | 6 +- .../fallbackswitch/src/fallbackswitch/imp.rs | 6 +- utils/togglerecord/src/togglerecord/imp.rs | 6 +- video/cdg/src/cdgdec/imp.rs | 14 +- video/cdg/src/cdgparse/imp.rs | 11 +- video/closedcaption/src/ccdetect/imp.rs | 14 +- video/closedcaption/src/cea608overlay/imp.rs | 11 +- video/closedcaption/src/cea608tott/imp.rs | 6 +- video/closedcaption/src/mcc_enc/imp.rs | 6 +- video/closedcaption/src/mcc_parse/imp.rs | 6 +- video/closedcaption/src/scc_enc/imp.rs | 6 +- video/closedcaption/src/scc_parse/imp.rs | 6 +- video/closedcaption/src/tttocea608/imp.rs | 6 +- video/closedcaption/src/tttojson/imp.rs | 6 +- video/dav1d/src/dav1ddec/imp.rs | 19 +- video/flavors/src/flvdemux/imp.rs | 6 +- video/gif/src/gifenc/imp.rs | 14 +- video/hsv/src/hsvdetector/imp.rs | 16 +- video/hsv/src/hsvfilter/imp.rs | 16 +- video/rav1e/src/rav1enc/imp.rs | 14 +- video/rspng/src/pngenc/imp.rs | 14 +- 56 files changed, 233 insertions(+), 621 deletions(-) diff --git a/audio/audiofx/src/audioecho/imp.rs b/audio/audiofx/src/audioecho/imp.rs index 8abf4de7..106316f0 100644 --- a/audio/audiofx/src/audioecho/imp.rs +++ b/audio/audiofx/src/audioecho/imp.rs @@ -6,7 +6,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -60,6 +59,7 @@ struct State { buffer: RingBuffer, } +#[derive(Default)] pub struct AudioEcho { settings: Mutex, state: Mutex>, @@ -85,22 +85,12 @@ impl AudioEcho { } } +#[glib::object_subclass] impl ObjectSubclass for AudioEcho { const NAME: &'static str = "RsAudioEcho"; type Type = super::AudioEcho; type ParentType = gst_base::BaseTransform; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - Self { - settings: Mutex::new(Default::default()), - state: Mutex::new(None), - } - } } impl ObjectImpl for AudioEcho { diff --git a/audio/audiofx/src/audioloudnorm/imp.rs b/audio/audiofx/src/audioloudnorm/imp.rs index 55530164..543ec70a 100644 --- a/audio/audiofx/src/audioloudnorm/imp.rs +++ b/audio/audiofx/src/audioloudnorm/imp.rs @@ -18,7 +18,6 @@ // License along with FFmpeg; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -1701,15 +1700,12 @@ impl AudioLoudNorm { } } +#[glib::object_subclass] impl ObjectSubclass for AudioLoudNorm { const NAME: &'static str = "RsAudioLoudNorm"; type Type = super::AudioLoudNorm; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/audio/audiofx/src/audiornnoise/imp.rs b/audio/audiofx/src/audiornnoise/imp.rs index 02a23a75..8e11d303 100644 --- a/audio/audiofx/src/audiornnoise/imp.rs +++ b/audio/audiofx/src/audiornnoise/imp.rs @@ -8,7 +8,6 @@ // except according to those terms. use byte_slice_cast::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -42,6 +41,7 @@ struct State { adapter: gst_base::UniqueAdapter, } +#[derive(Default)] pub struct AudioRNNoise { state: Mutex>, } @@ -189,21 +189,12 @@ impl AudioRNNoise { } } +#[glib::object_subclass] impl ObjectSubclass for AudioRNNoise { const NAME: &'static str = "AudioRNNoise"; type Type = super::AudioRNNoise; type ParentType = gst_base::BaseTransform; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - Self { - state: Mutex::new(None), - } - } } impl ObjectImpl for AudioRNNoise {} diff --git a/audio/claxon/src/claxondec/imp.rs b/audio/claxon/src/claxondec/imp.rs index bbec688d..b880ca92 100644 --- a/audio/claxon/src/claxondec/imp.rs +++ b/audio/claxon/src/claxondec/imp.rs @@ -6,7 +6,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib::subclass; use glib::subclass::prelude::*; use gst::subclass::prelude::*; use gst::{gst_debug, gst_error}; @@ -34,25 +33,17 @@ struct State { audio_info: Option, } +#[derive(Default)] pub struct ClaxonDec { state: AtomicRefCell>, } +#[glib::object_subclass] impl ObjectSubclass for ClaxonDec { const NAME: &'static str = "ClaxonDec"; type Type = super::ClaxonDec; type ParentType = gst_audio::AudioDecoder; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - Self { - state: AtomicRefCell::new(None), - } - } } impl ObjectImpl for ClaxonDec {} diff --git a/audio/csound/src/filter/imp.rs b/audio/csound/src/filter/imp.rs index 3a5c492a..dcc0ea57 100644 --- a/audio/csound/src/filter/imp.rs +++ b/audio/csound/src/filter/imp.rs @@ -15,7 +15,6 @@ // Free Software Foundation, Inc., 51 Franklin Street, Suite 500, // Boston, MA 02110-1335, USA. -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -314,15 +313,12 @@ impl CsoundFilter { } } +#[glib::object_subclass] impl ObjectSubclass for CsoundFilter { const NAME: &'static str = "CsoundFilter"; type Type = super::CsoundFilter; type ParentType = gst_base::BaseTransform; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn new() -> Self { let csound = Csound::new(); diff --git a/audio/lewton/src/lewtondec/imp.rs b/audio/lewton/src/lewtondec/imp.rs index c0816775..d5a09584 100644 --- a/audio/lewton/src/lewtondec/imp.rs +++ b/audio/lewton/src/lewtondec/imp.rs @@ -6,7 +6,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib::subclass; use glib::subclass::prelude::*; use gst::subclass::prelude::*; use gst::{gst_debug, gst_error, gst_warning}; @@ -18,6 +17,8 @@ use atomic_refcell::AtomicRefCell; use byte_slice_cast::*; +use once_cell::sync::Lazy; + struct State { header_bufs: ( Option, @@ -30,11 +31,11 @@ struct State { reorder_map: Option<[usize; 8]>, } +#[derive(Default)] pub struct LewtonDec { state: AtomicRefCell>, } -use once_cell::sync::Lazy; static CAT: Lazy = Lazy::new(|| { gst::DebugCategory::new( "lewtondec", @@ -43,21 +44,12 @@ static CAT: Lazy = Lazy::new(|| { ) }); +#[glib::object_subclass] impl ObjectSubclass for LewtonDec { const NAME: &'static str = "LewtonDec"; type Type = super::LewtonDec; type ParentType = gst_audio::AudioDecoder; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - Self { - state: AtomicRefCell::new(None), - } - } } impl ObjectImpl for LewtonDec {} diff --git a/generic/file/src/filesink/imp.rs b/generic/file/src/filesink/imp.rs index 13d9015a..87eff33c 100644 --- a/generic/file/src/filesink/imp.rs +++ b/generic/file/src/filesink/imp.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -49,6 +48,7 @@ impl Default for State { } } +#[derive(Default)] pub struct FileSink { settings: Mutex, state: Mutex, @@ -106,22 +106,13 @@ impl FileSink { } } +#[glib::object_subclass] impl ObjectSubclass for FileSink { const NAME: &'static str = "RsFileSink"; type Type = super::FileSink; type ParentType = gst_base::BaseSink; type Interfaces = (gst::URIHandler,); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - Self { - settings: Mutex::new(Default::default()), - state: Mutex::new(Default::default()), - } - } } impl ObjectImpl for FileSink { diff --git a/generic/file/src/filesrc/imp.rs b/generic/file/src/filesrc/imp.rs index 742e0a17..1abdd88e 100644 --- a/generic/file/src/filesrc/imp.rs +++ b/generic/file/src/filesrc/imp.rs @@ -7,7 +7,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -49,6 +48,7 @@ impl Default for State { } } +#[derive(Default)] pub struct FileSrc { settings: Mutex, state: Mutex, @@ -120,22 +120,13 @@ impl FileSrc { } } +#[glib::object_subclass] impl ObjectSubclass for FileSrc { const NAME: &'static str = "RsFileSrc"; type Type = super::FileSrc; type ParentType = gst_base::BaseSrc; type Interfaces = (gst::URIHandler,); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - Self { - settings: Mutex::new(Default::default()), - state: Mutex::new(Default::default()), - } - } } impl ObjectImpl for FileSrc { diff --git a/generic/sodium/src/decrypter/imp.rs b/generic/sodium/src/decrypter/imp.rs index 9aa80b86..adc9896d 100644 --- a/generic/sodium/src/decrypter/imp.rs +++ b/generic/sodium/src/decrypter/imp.rs @@ -23,7 +23,6 @@ // SPDX-License-Identifier: MIT use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -545,15 +544,12 @@ impl Decrypter { } } +#[glib::object_subclass] impl ObjectSubclass for Decrypter { const NAME: &'static str = "RsSodiumDecryptor"; type Type = super::Decrypter; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/generic/sodium/src/encrypter/imp.rs b/generic/sodium/src/encrypter/imp.rs index 1ccb792c..a2c7a9df 100644 --- a/generic/sodium/src/encrypter/imp.rs +++ b/generic/sodium/src/encrypter/imp.rs @@ -23,7 +23,6 @@ // SPDX-License-Identifier: MIT use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -335,15 +334,12 @@ impl Encrypter { } } +#[glib::object_subclass] impl ObjectSubclass for Encrypter { const NAME: &'static str = "RsSodiumEncrypter"; type Type = super::Encrypter; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/generic/threadshare/src/appsrc/imp.rs b/generic/threadshare/src/appsrc/imp.rs index f264bb30..c44c659d 100644 --- a/generic/threadshare/src/appsrc/imp.rs +++ b/generic/threadshare/src/appsrc/imp.rs @@ -22,7 +22,6 @@ use futures::lock::Mutex as FutMutex; use futures::prelude::*; use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; @@ -504,15 +503,12 @@ impl AppSrc { } } +#[glib::object_subclass] impl ObjectSubclass for AppSrc { const NAME: &'static str = "RsTsAppSrc"; type Type = super::AppSrc; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let src_pad_handler = AppSrcPadHandler::default(); diff --git a/generic/threadshare/src/inputselector/imp.rs b/generic/threadshare/src/inputselector/imp.rs index a490a464..c625886c 100644 --- a/generic/threadshare/src/inputselector/imp.rs +++ b/generic/threadshare/src/inputselector/imp.rs @@ -20,7 +20,6 @@ use futures::future::{abortable, AbortHandle}; use futures::prelude::*; use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; @@ -391,15 +390,12 @@ impl InputSelector { } } +#[glib::object_subclass] impl ObjectSubclass for InputSelector { const NAME: &'static str = "RsTsInputSelector"; type Type = super::InputSelector; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { Self { diff --git a/generic/threadshare/src/jitterbuffer/imp.rs b/generic/threadshare/src/jitterbuffer/imp.rs index f679a03b..1c679ea6 100644 --- a/generic/threadshare/src/jitterbuffer/imp.rs +++ b/generic/threadshare/src/jitterbuffer/imp.rs @@ -20,7 +20,6 @@ use futures::future::{abortable, AbortHandle, Aborted}; use futures::prelude::*; use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; @@ -1335,15 +1334,12 @@ impl JitterBuffer { } } +#[glib::object_subclass] impl ObjectSubclass for JitterBuffer { const NAME: &'static str = "RsTsJitterBuffer"; type Type = super::JitterBuffer; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let sink_pad_handler = SinkHandler::default(); diff --git a/generic/threadshare/src/proxy/imp.rs b/generic/threadshare/src/proxy/imp.rs index bc13654d..15e5e1ba 100644 --- a/generic/threadshare/src/proxy/imp.rs +++ b/generic/threadshare/src/proxy/imp.rs @@ -20,7 +20,6 @@ use futures::future::BoxFuture; use futures::prelude::*; use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; @@ -572,15 +571,12 @@ impl ProxySink { } } +#[glib::object_subclass] impl ObjectSubclass for ProxySink { const NAME: &'static str = "RsTsProxySink"; type Type = super::ProxySink; - type Interfaces = (); type ParentType = gst::Element; type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { Self { @@ -1113,19 +1109,12 @@ impl ProxySrc { } } +#[glib::object_subclass] impl ObjectSubclass for ProxySrc { const NAME: &'static str = "RsTsProxySrc"; type Type = super::ProxySrc; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - unreachable!() - } fn with_class(klass: &Self::Class) -> Self { Self { diff --git a/generic/threadshare/src/queue/imp.rs b/generic/threadshare/src/queue/imp.rs index dd257cad..3426b3c6 100644 --- a/generic/threadshare/src/queue/imp.rs +++ b/generic/threadshare/src/queue/imp.rs @@ -20,7 +20,6 @@ use futures::future::BoxFuture; use futures::prelude::*; use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; @@ -692,15 +691,12 @@ impl Queue { } } +#[glib::object_subclass] impl ObjectSubclass for Queue { const NAME: &'static str = "RsTsQueue"; type Type = super::Queue; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { Self { diff --git a/generic/threadshare/src/tcpclientsrc/imp.rs b/generic/threadshare/src/tcpclientsrc/imp.rs index 4b584b07..331dbaa7 100644 --- a/generic/threadshare/src/tcpclientsrc/imp.rs +++ b/generic/threadshare/src/tcpclientsrc/imp.rs @@ -21,7 +21,6 @@ use futures::lock::Mutex as FutMutex; use futures::prelude::*; use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; @@ -545,15 +544,12 @@ impl TcpClientSrc { } } +#[glib::object_subclass] impl ObjectSubclass for TcpClientSrc { const NAME: &'static str = "RsTsTcpClientSrc"; type Type = super::TcpClientSrc; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let src_pad_handler = TcpClientSrcPadHandler::default(); diff --git a/generic/threadshare/src/udpsink/imp.rs b/generic/threadshare/src/udpsink/imp.rs index ad1333bf..477f27b8 100644 --- a/generic/threadshare/src/udpsink/imp.rs +++ b/generic/threadshare/src/udpsink/imp.rs @@ -21,7 +21,6 @@ use futures::lock::Mutex; use futures::prelude::*; use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; @@ -944,15 +943,12 @@ fn try_into_socket_addr(element: &super::UdpSink, host: &str, port: i32) -> Resu Ok(SocketAddr::new(addr, port)) } +#[glib::object_subclass] impl ObjectSubclass for UdpSink { const NAME: &'static str = "RsTsUdpSink"; type Type = super::UdpSink; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let settings = Arc::new(StdMutex::new(Settings::default())); diff --git a/generic/threadshare/src/udpsrc/imp.rs b/generic/threadshare/src/udpsrc/imp.rs index b8d92e14..07e9d136 100644 --- a/generic/threadshare/src/udpsrc/imp.rs +++ b/generic/threadshare/src/udpsrc/imp.rs @@ -20,7 +20,6 @@ use futures::lock::Mutex as FutMutex; use futures::prelude::*; use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; @@ -686,15 +685,12 @@ impl UdpSrc { } } +#[glib::object_subclass] impl ObjectSubclass for UdpSrc { const NAME: &'static str = "RsTsUdpSrc"; type Type = super::UdpSrc; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let src_pad_handler = UdpSrcPadHandler::default(); diff --git a/generic/threadshare/tests/pad.rs b/generic/threadshare/tests/pad.rs index d5574464..65f27957 100644 --- a/generic/threadshare/tests/pad.rs +++ b/generic/threadshare/tests/pad.rs @@ -301,15 +301,12 @@ mod imp_src { } } + #[glib::object_subclass] impl ObjectSubclass for ElementSrcTest { const NAME: &'static str = "TsElementSrcTest"; type Type = super::ElementSrcTest; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = glib::subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { ElementSrcTest { @@ -636,15 +633,12 @@ mod imp_sink { ) }); + #[glib::object_subclass] impl ObjectSubclass for ElementSinkTest { const NAME: &'static str = "TsElementSinkTest"; type Type = super::ElementSinkTest; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = glib::subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { ElementSinkTest { diff --git a/net/reqwest/src/reqwesthttpsrc/imp.rs b/net/reqwest/src/reqwesthttpsrc/imp.rs index 453b6dd3..5767538d 100644 --- a/net/reqwest/src/reqwesthttpsrc/imp.rs +++ b/net/reqwest/src/reqwesthttpsrc/imp.rs @@ -17,7 +17,6 @@ use url::Url; use once_cell::sync::Lazy; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -103,7 +102,7 @@ impl Default for State { } } -#[derive(Debug)] +#[derive(Debug, Default)] pub struct ReqwestHttpSrc { client: Mutex>, external_client: Mutex>, @@ -1112,23 +1111,11 @@ impl URIHandlerImpl for ReqwestHttpSrc { } } +#[glib::object_subclass] impl ObjectSubclass for ReqwestHttpSrc { const NAME: &'static str = "ReqwestHttpSrc"; type Type = super::ReqwestHttpSrc; type ParentType = gst_base::PushSrc; type Interfaces = (gst::URIHandler,); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - Self { - client: Mutex::new(None), - external_client: Mutex::new(None), - settings: Mutex::new(Default::default()), - state: Mutex::new(Default::default()), - canceller: Mutex::new(None), - } - } } diff --git a/net/rusoto/src/aws_transcriber/imp.rs b/net/rusoto/src/aws_transcriber/imp.rs index 4cb213fe..01715146 100644 --- a/net/rusoto/src/aws_transcriber/imp.rs +++ b/net/rusoto/src/aws_transcriber/imp.rs @@ -16,7 +16,6 @@ // Boston, MA 02110-1335, USA. use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -965,15 +964,12 @@ impl Transcriber { } } +#[glib::object_subclass] impl ObjectSubclass for Transcriber { const NAME: &'static str = "RsAwsTranscriber"; type Type = super::Transcriber; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/net/rusoto/src/s3sink/imp.rs b/net/rusoto/src/s3sink/imp.rs index dd9ec469..3a30bdd6 100644 --- a/net/rusoto/src/s3sink/imp.rs +++ b/net/rusoto/src/s3sink/imp.rs @@ -7,7 +7,6 @@ // except according to those terms. use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; @@ -90,6 +89,7 @@ struct Settings { buffer_size: u64, } +#[derive(Default)] pub struct S3Sink { settings: Mutex, state: Mutex, @@ -341,23 +341,12 @@ impl S3Sink { } } +#[glib::object_subclass] impl ObjectSubclass for S3Sink { const NAME: &'static str = "RusotoS3Sink"; type Type = super::S3Sink; type ParentType = gst_base::BaseSink; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - Self { - settings: Mutex::new(Default::default()), - state: Mutex::new(Default::default()), - canceller: Mutex::new(None), - } - } } impl ObjectImpl for S3Sink { diff --git a/net/rusoto/src/s3src/imp.rs b/net/rusoto/src/s3src/imp.rs index 736f1a13..156e6b6d 100644 --- a/net/rusoto/src/s3src/imp.rs +++ b/net/rusoto/src/s3src/imp.rs @@ -14,7 +14,6 @@ use once_cell::sync::Lazy; use rusoto_s3::*; use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::subclass::prelude::*; @@ -37,6 +36,13 @@ enum StreamingState { }, } +impl Default for StreamingState { + fn default() -> StreamingState { + StreamingState::Stopped + } +} + +#[derive(Default)] pub struct S3Src { url: Mutex>, state: Mutex, @@ -196,23 +202,13 @@ impl S3Src { } } +#[glib::object_subclass] impl ObjectSubclass for S3Src { const NAME: &'static str = "RusotoS3Src"; type Type = super::S3Src; type ParentType = gst_base::BaseSrc; type Interfaces = (gst::URIHandler,); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - Self { - url: Mutex::new(None), - state: Mutex::new(StreamingState::Stopped), - canceller: Mutex::new(None), - } - } } impl ObjectImpl for S3Src { diff --git a/text/json/src/jsongstenc/imp.rs b/text/json/src/jsongstenc/imp.rs index 5844eb93..b8be23d6 100644 --- a/text/json/src/jsongstenc/imp.rs +++ b/text/json/src/jsongstenc/imp.rs @@ -15,7 +15,6 @@ // Free Software Foundation, Inc., 51 Franklin Street, Suite 500, // Boston, MA 02110-1335, USA. -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -201,15 +200,12 @@ impl JsonGstEnc { } } +#[glib::object_subclass] impl ObjectSubclass for JsonGstEnc { const NAME: &'static str = "RsJsonGstEnc"; type Type = super::JsonGstEnc; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/text/json/src/jsongstparse/imp.rs b/text/json/src/jsongstparse/imp.rs index 440483d2..4db24cf6 100644 --- a/text/json/src/jsongstparse/imp.rs +++ b/text/json/src/jsongstparse/imp.rs @@ -16,7 +16,6 @@ // Boston, MA 02110-1335, USA. use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -863,15 +862,12 @@ impl JsonGstParse { } } +#[glib::object_subclass] impl ObjectSubclass for JsonGstParse { const NAME: &'static str = "RsJsonGstParse"; type Type = super::JsonGstParse; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/text/regex/src/gstregex/imp.rs b/text/regex/src/gstregex/imp.rs index 025749b4..56ef21e5 100644 --- a/text/regex/src/gstregex/imp.rs +++ b/text/regex/src/gstregex/imp.rs @@ -16,7 +16,6 @@ // Boston, MA 02110-1335, USA. use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::gst_error; use gst::prelude::*; @@ -119,15 +118,12 @@ impl RegEx { } } +#[glib::object_subclass] impl ObjectSubclass for RegEx { const NAME: &'static str = "RsRegEx"; type Type = super::RegEx; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/text/wrap/src/gsttextwrap/imp.rs b/text/wrap/src/gsttextwrap/imp.rs index 35692472..de4a2d6d 100644 --- a/text/wrap/src/gsttextwrap/imp.rs +++ b/text/wrap/src/gsttextwrap/imp.rs @@ -16,7 +16,6 @@ // Boston, MA 02110-1335, USA. use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -422,15 +421,12 @@ impl TextWrap { } } +#[glib::object_subclass] impl ObjectSubclass for TextWrap { const NAME: &'static str = "RsTextWrap"; type Type = super::TextWrap; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/tutorial/src/identity/imp.rs b/tutorial/src/identity/imp.rs index 7a256e60..cddb491a 100644 --- a/tutorial/src/identity/imp.rs +++ b/tutorial/src/identity/imp.rs @@ -6,7 +6,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -114,16 +113,12 @@ impl Identity { // This trait registers our type with the GObject object system and // provides the entry points for creating a new instance and setting // up the class data +#[glib::object_subclass] impl ObjectSubclass for Identity { const NAME: &'static str = "RsIdentity"; type Type = super::Identity; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - // This macro provides some boilerplate. - glib::object_subclass!(); // Called when a new instance is to be created. We need to return an instance // of our struct here and also get the class struct passed in case it's needed diff --git a/tutorial/src/progressbin/imp.rs b/tutorial/src/progressbin/imp.rs index e00d6c0a..9499147b 100644 --- a/tutorial/src/progressbin/imp.rs +++ b/tutorial/src/progressbin/imp.rs @@ -7,7 +7,6 @@ // except according to those terms. use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::gst_info; use gst::prelude::*; @@ -44,16 +43,12 @@ pub struct ProgressBin { // This trait registers our type with the GObject object system and // provides the entry points for creating a new instance and setting // up the class data +#[glib::object_subclass] impl ObjectSubclass for ProgressBin { const NAME: &'static str = "RsProgressBin"; type Type = super::ProgressBin; type ParentType = gst::Bin; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - // This macro provides some boilerplate. - glib::object_subclass!(); // Called when a new instance is to be created. We need to return an instance // of our struct here and also get the class struct passed in case it's needed diff --git a/tutorial/src/rgb2gray/imp.rs b/tutorial/src/rgb2gray/imp.rs index 4db88fd8..db4ac16d 100644 --- a/tutorial/src/rgb2gray/imp.rs +++ b/tutorial/src/rgb2gray/imp.rs @@ -6,7 +6,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -55,6 +54,7 @@ struct State { } // Struct containing all the element data +#[derive(Default)] pub struct Rgb2Gray { settings: Mutex, state: Mutex>, @@ -90,25 +90,12 @@ impl Rgb2Gray { // This trait registers our type with the GObject object system and // provides the entry points for creating a new instance and setting // up the class data +#[glib::object_subclass] impl ObjectSubclass for Rgb2Gray { const NAME: &'static str = "RsRgb2Gray"; type Type = super::Rgb2Gray; type ParentType = gst_base::BaseTransform; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - // This macro provides some boilerplate - glib::object_subclass!(); - - // Called when a new instance is to be created. We need to return an instance - // of our struct here. - fn new() -> Self { - Self { - settings: Mutex::new(Default::default()), - state: Mutex::new(None), - } - } } // Implementation of glib::Object virtual methods diff --git a/tutorial/src/sinesrc/imp.rs b/tutorial/src/sinesrc/imp.rs index e18c5a02..90bb1812 100644 --- a/tutorial/src/sinesrc/imp.rs +++ b/tutorial/src/sinesrc/imp.rs @@ -6,7 +6,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -89,7 +88,17 @@ struct ClockWait { flushing: bool, } +impl Default for ClockWait { + fn default() -> ClockWait { + ClockWait { + clock_id: None, + flushing: true, + } + } +} + // Struct containing all the element data +#[derive(Default)] pub struct SineSrc { settings: Mutex, state: Mutex, @@ -144,29 +153,12 @@ impl SineSrc { // This trait registers our type with the GObject object system and // provides the entry points for creating a new instance and setting // up the class data +#[glib::object_subclass] impl ObjectSubclass for SineSrc { const NAME: &'static str = "RsSineSrc"; type Type = super::SineSrc; type ParentType = gst_base::PushSrc; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - // This macro provides some boilerplate. - glib::object_subclass!(); - - // Called when a new instance is to be created. We need to return an instance - // of our struct here. - fn new() -> Self { - Self { - settings: Mutex::new(Default::default()), - state: Mutex::new(Default::default()), - clock_wait: Mutex::new(ClockWait { - clock_id: None, - flushing: true, - }), - } - } } // Implementation of glib::Object virtual methods diff --git a/tutorial/tutorial-1.md b/tutorial/tutorial-1.md index 2d036d91..7c5127fb 100644 --- a/tutorial/tutorial-1.md +++ b/tutorial/tutorial-1.md @@ -163,27 +163,17 @@ GStreamer is based on the GLib object system ([GObject](https://developer.gnome. So, as a next step we need to register a new type for our RGB to Grayscale converter GStreamer element with the GObject type system, and then register that type with GStreamer to be able to create new instances of it. We do this with the following code ```rust -pub struct Rgb2Gray{} +#[derive(Default)] +pub struct Rgb2Gray {} -impl Rgb2Gray{} +impl Rgb2Gray {} +#[glib::object_subclass] impl ObjectSubclass for Rgb2Gray { const NAME: &'static str = "RsRgb2Gray"; type Type = super::Rgb2Gray; type ParentType = gst_base::BaseTransform; type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - // This macro provides some boilerplate - glib::object_subclass!(); - - fn new() -> Self { - Self {} - } - - fn class_init(klass: &mut subclass::simple::ClassStruct) { - - } } ``` @@ -231,19 +221,15 @@ In addition, we also define a `register` function (the one that is already calle As a next step we implement the `new` funtion and `class_init` functions. In the first version, this struct is empty for now but we will later use it to store all state of our element. ```rust -pub struct Rgb2Gray { -} +#[derive(Default)] +pub struct Rgb2Gray {} -impl Rgb2Gray{} +impl Rgb2Gray {} +#[glib::object_subclass] impl ObjectSubclass for Rgb2Gray { [...] - fn new() -> Self { - Self { - } - } - fn class_init(klass: &mut Self::Class) { klass.set_metadata( "RGB-GRAY Converter", @@ -281,18 +267,17 @@ With all this defined, `gst-inspect-1.0` should be able to show some more inform ```rust // all imports... +#[derive(Default)] pub struct Rgb2Gray {} impl Rgb2Gray {} +#[glib::object_subclass] impl ObjectSubclass for Rgb2Gray { const NAME: &'static str = "RsRgb2Gray"; type Type = super::Rgb2Gray; type ParentType = gst_base::BaseTransform; type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); } impl ObjectImpl for Rgb2Gray {} @@ -424,20 +409,16 @@ struct State { out_info: gst_video::VideoInfo, } +#[derive(Default)] pub struct Rgb2Gray { state: Mutex> } impl Rgb2Gray{} +#[glib::object_subclass] impl ObjectSubclass for Rgb2Gray { [...] - - fn new() -> Self { - Self { - state: Mutex::new(None), - } - } } ``` @@ -752,29 +733,7 @@ impl Default for Settings { } } -static PROPERTIES: [subclass::Property; 2] = [ - subclass::Property("invert", |name| { - glib::ParamSpec::boolean( - name, - "Invert", - "Invert grayscale output", - DEFAULT_INVERT, - glib::ParamFlags::READWRITE, - ) - }), - subclass::Property("shift", |name| { - glib::ParamSpec::uint( - name, - "Shift", - "Shift grayscale output (wrapping around)", - 0, - 255, - DEFAULT_SHIFT, - glib::ParamFlags::READWRITE, - ) - }), -]; - +#[derive(Default)] pub struct Rgb2Gray { settings: Mutex, state: Mutex>, @@ -782,39 +741,46 @@ pub struct Rgb2Gray { impl Rgb2Gray{...} -impl ObjectSubclass for Rgb2Gray { - [...] +impl ObjectImpl for Rgb2Gray { + fn properties() -> &'static [glib::ParamSpec] { + // Metadata for the properties + static PROPERTIES: Lazy> = Lazy::new(|| { + vec![ + glib::ParamSpec::boolean( + "invert", + "Invert", + "Invert grayscale output", + DEFAULT_INVERT, + glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING, + ), + glib::ParamSpec::uint( + "shift", + "Shift", + "Shift grayscale output (wrapping around)", + 0, + 255, + DEFAULT_SHIFT, + glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING, + ), + ] + }); - fn new() -> Self { - Self { - settings: Mutex::new(Default::default()), - state: Mutex::new(None), - } + PROPERTIES.as_ref() } } ``` This should all be rather straightforward: we define a `Settings` struct that stores the two values, implement the [`Default`](https://doc.rust-lang.org/nightly/std/default/trait.Default.html) trait for it, then define a two-element array with property metadata (names, description, ranges, default value, writability), and then store the default value of our `Settings` struct inside another `Mutex` inside the element struct. -In the next step we have to make use of these: we need to tell the GObject type system about the properties, and we need to implement functions that are called whenever a property value is set or get. +In the next step we have to implement functions that are called whenever a property value is set or get. ```rust -impl ObjectSubclass for Rgb2Gray { - fn class_init(klass: &mut Self::Class) { - [...] - klass.install_properties(&PROPERTIES); - [...] - } -} - impl ObjectImpl for Rgb2Gray { [...] - fn set_property(&self, obj: &Self::Type, id: usize, value: &glib::Value) { - let prop = &PROPERTIES[id]; - - match *prop { - subclass::Property("invert", ..) => { + fn set_property(&self, obj: &Self::Type, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) { + match pspec.get_name() { + "invert" => { let mut settings = self.settings.lock().unwrap(); let invert = value.get_some().expect("type checked upstream"); gst_info!( @@ -826,7 +792,7 @@ impl ObjectImpl for Rgb2Gray { ); settings.invert = invert; } - subclass::Property("shift", ..) => { + "shift" => { let mut settings = self.settings.lock().unwrap(); let shift = value.get_some().expect("type checked upstream"); gst_info!( @@ -842,15 +808,13 @@ impl ObjectImpl for Rgb2Gray { } } - fn get_property(&self, _obj: &Self::Type, id: usize) -> glib::Value { - let prop = &PROPERTIES[id]; - - match *prop { - subclass::Property("invert", ..) => { + fn get_property(&self, _obj: &Self::Type, _id: usize, pspec: &glib::ParamSpec) -> glib::Value { + match pspec.get_name() { + "invert" => { let settings = self.settings.lock().unwrap(); settings.invert.to_value() } - subclass::Property("shift", ..) => { + "shift" => { let settings = self.settings.lock().unwrap(); settings.shift.to_value() } @@ -860,7 +824,7 @@ impl ObjectImpl for Rgb2Gray { } ``` -`Property` values can be changed from any thread at any time, that’s why the `Mutex` is needed here to protect our struct. And we’re using a new mutex to be able to have it locked only for the shorted possible amount of time: we don’t want to keep it locked for the whole time of the `transform` function, otherwise applications trying to set/get values would block for up to the processing time of one frame. +Property values can be changed from any thread at any time, that’s why the `Mutex` is needed here to protect our struct. And we’re using a new mutex to be able to have it locked only for the shorted possible amount of time: we don’t want to keep it locked for the whole time of the `transform` function, otherwise applications trying to set/get values would block for up to the processing time of one frame. In the property setter/getter functions we are working with a `glib::Value`. This is a dynamically typed value type that can contain values of any type, together with the type information of the contained value. Here we’re using it to handle an unsigned integer (`u32`) and a boolean for our two properties. To know which property is currently set/get, we get an identifier passed which is the index into our `PROPERTIES` array. We then simply match on the name of that to decide which property was meant diff --git a/tutorial/tutorial-2.md b/tutorial/tutorial-2.md index ce70695f..c735a92b 100644 --- a/tutorial/tutorial-2.md +++ b/tutorial/tutorial-2.md @@ -70,48 +70,6 @@ impl Default for Settings { } } -// Metadata for the properties -static PROPERTIES: [Property; 5] = [ - Property::UInt( - "samples-per-buffer", - "Samples Per Buffer", - "Number of samples per output buffer", - (1, u32::MAX), - DEFAULT_SAMPLES_PER_BUFFER, - PropertyMutability::ReadWrite, - ), - Property::UInt( - "freq", - "Frequency", - "Frequency", - (1, u32::MAX), - DEFAULT_FREQ, - PropertyMutability::ReadWrite, - ), - Property::Double( - "volume", - "Volume", - "Output volume", - (0.0, 10.0), - DEFAULT_VOLUME, - PropertyMutability::ReadWrite, - ), - Property::Boolean( - "mute", - "Mute", - "Mute", - DEFAULT_MUTE, - PropertyMutability::ReadWrite, - ), - Property::Boolean( - "is-live", - "Is Live", - "(Pseudo) live output", - DEFAULT_IS_LIVE, - PropertyMutability::ReadWrite, - ), -]; - // Stream-specific state, i.e. audio format configuration // and sample offset struct State { @@ -133,6 +91,7 @@ impl Default for State { } // Struct containing all the element data +#[derive(Default)] pub struct SineSrc { settings: Mutex, state: Mutex, @@ -146,28 +105,12 @@ static CAT: Lazy = Lazy::new(|| { ) }); +#[glib::object_subclass] impl ObjectSubclass for SineSrc { const NAME: &'static str = "RsSineSrc"; type Type = super::SineSrc; type ParentType = gst_base::PushSrc; type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - // This macro provides some boilerplate. - glib::object_subclass!(); - - // Called when a new instance is to be created. We need to return an instance - // of our struct here. - fn new() -> Self { - Self { - settings: Mutex::new(Default::default()), - state: Mutex::new(Default::default()), - clock_wait: Mutex::new(ClockWait { - clock_id: None, - flushing: true, - }), - } - } // Called exactly once when registering the type. Used for // setting up metadata for all instances, e.g. the name and @@ -223,13 +166,61 @@ impl ObjectSubclass for SineSrc { ) .unwrap(); klass.add_pad_template(src_pad_template); - - // Install all our properties - klass.install_properties(&PROPERTIES); } } impl ObjectImpl for SineSrc { + // Metadata for the properties + fn properties() -> &'static [glib::ParamSpec] { + static PROPERTIES: Lazy> = Lazy::new(|| { + vec![ + glib::ParamSpec::uint( + "samples-per-buffer", + "Samples Per Buffer", + "Number of samples per output buffer", + 1, + u32::MAX, + DEFAULT_SAMPLES_PER_BUFFER, + glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, + ), + glib::ParamSpec::uint( + "freq", + "Frequency", + "Frequency", + 1, + u32::MAX, + DEFAULT_FREQ, + glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING, + ), + glib::ParamSpec::double( + "volume", + "Volume", + "Output volume", + 0.0, + 10.0, + DEFAULT_VOLUME, + glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING, + ), + glib::ParamSpec::boolean( + "mute", + "Mute", + "Mute", + DEFAULT_MUTE, + glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING, + ), + glib::ParamSpec::boolean( + "is-live", + "Is Live", + "(Pseudo) live output", + DEFAULT_IS_LIVE, + glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_READY, + ), + ] + }); + + PROPERTIES.as_ref() + } + // Called right after construction of a new instance fn constructed(&self, obj: &Self::Type) { // Call the parent class' ::constructed() implementation first @@ -243,11 +234,15 @@ impl ObjectImpl for SineSrc { // Called whenever a value of a property is changed. It can be called // at any time from any thread. - fn set_property(&self, obj: &Self::Type, id: u32, value: &glib::Value) { - let prop = &PROPERTIES[id as usize]; - - match *prop { - Property::UInt("samples-per-buffer", ..) => { + fn set_property( + &self, + obj: &Self::Type, + _id: usize, + value: &glib::Value, + pspec: &glib::ParamSpec, + ) { + match pspec.get_name() { + "samples-per-buffer" => { let mut settings = self.settings.lock().unwrap(); let samples_per_buffer = value.get_some().expect("type checked upstream"); gst_info!( @@ -260,10 +255,9 @@ impl ObjectImpl for SineSrc { settings.samples_per_buffer = samples_per_buffer; drop(settings); - let _ = - obj.post_message(&gst::Message::new_latency().src(Some(obj)).build()); + let _ = obj.post_message(gst::message::Latency::builder().src(obj).build()); } - Property::UInt("freq", ..) => { + "freq" => { let mut settings = self.settings.lock().unwrap(); let freq = value.get_some().expect("type checked upstream"); gst_info!( @@ -275,7 +269,7 @@ impl ObjectImpl for SineSrc { ); settings.freq = freq; } - Property::Double("volume", ..) => { + "volume" => { let mut settings = self.settings.lock().unwrap(); let volume = value.get_some().expect("type checked upstream"); gst_info!( @@ -287,7 +281,7 @@ impl ObjectImpl for SineSrc { ); settings.volume = volume; } - Property::Boolean("mute", ..) => { + "mute" => { let mut settings = self.settings.lock().unwrap(); let mute = value.get_some().expect("type checked upstream"); gst_info!( @@ -299,7 +293,7 @@ impl ObjectImpl for SineSrc { ); settings.mute = mute; } - Property::Boolean("is-live", ..) => { + "is-live" => { let mut settings = self.settings.lock().unwrap(); let is_live = value.get_some().expect("type checked upstream"); gst_info!( @@ -317,27 +311,25 @@ impl ObjectImpl for SineSrc { // Called whenever a value of a property is read. It can be called // at any time from any thread. - fn get_property(&self, _obj: &Self::Type, id: u32) -> glib::Value { - let prop = &PROPERTIES[id as usize]; - - match *prop { - Property::UInt("samples-per-buffer", ..) => { + fn get_property(&self, _obj: &Self::Type, _id: usize, pspec: &glib::ParamSpec) -> glib::Value { + match pspec.get_name() { + "samples-per-buffer" => { let settings = self.settings.lock().unwrap(); settings.samples_per_buffer.to_value() } - Property::UInt("freq", ..) => { + "freq" => { let settings = self.settings.lock().unwrap(); settings.freq.to_value() } - Property::Double("volume", ..) => { + "volume" => { let settings = self.settings.lock().unwrap(); settings.volume.to_value() } - Property::Boolean("mute", ..) => { + "mute" => { let settings = self.settings.lock().unwrap(); settings.mute.to_value() } - Property::Boolean("is-live", ..) => { + "is-live" => { let settings = self.settings.lock().unwrap(); settings.is_live.to_value() } @@ -827,6 +819,16 @@ struct ClockWait { flushing: bool, } +impl Default for ClockWait { + fn default() -> Self { + ClockWait { + clock_id: None, + flushing: true, + } + } +} + +#[derive(Default)] struct SineSrc { settings: Mutex, state: Mutex, diff --git a/utils/fallbackswitch/src/fallbacksrc/custom_source/imp.rs b/utils/fallbackswitch/src/fallbacksrc/custom_source/imp.rs index fa5a5c07..ce7059e3 100644 --- a/utils/fallbackswitch/src/fallbacksrc/custom_source/imp.rs +++ b/utils/fallbackswitch/src/fallbacksrc/custom_source/imp.rs @@ -16,7 +16,6 @@ // Boston, MA 02110-1335, USA. use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -42,37 +41,25 @@ struct Stream { stream: gst::Stream, } +#[derive(Default)] struct State { pads: Vec, num_audio: usize, num_video: usize, } +#[derive(Default)] pub struct CustomSource { source: OnceCell, state: Mutex, } +#[glib::object_subclass] impl ObjectSubclass for CustomSource { const NAME: &'static str = "FallbackSrcCustomSource"; type Type = super::CustomSource; type ParentType = gst::Bin; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - Self { - source: OnceCell::default(), - state: Mutex::new(State { - pads: vec![], - num_audio: 0, - num_video: 0, - }), - } - } } impl ObjectImpl for CustomSource { diff --git a/utils/fallbackswitch/src/fallbacksrc/imp.rs b/utils/fallbackswitch/src/fallbacksrc/imp.rs index 2280016e..7c2e4f31 100644 --- a/utils/fallbackswitch/src/fallbacksrc/imp.rs +++ b/utils/fallbackswitch/src/fallbacksrc/imp.rs @@ -16,7 +16,6 @@ // Boston, MA 02110-1335, USA. use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -172,27 +171,18 @@ struct State { stats: Stats, } +#[derive(Default)] pub struct FallbackSrc { settings: Mutex, state: Mutex>, } +#[glib::object_subclass] impl ObjectSubclass for FallbackSrc { const NAME: &'static str = "FallbackSrc"; type Type = super::FallbackSrc; type ParentType = gst::Bin; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - Self { - settings: Mutex::new(Settings::default()), - state: Mutex::new(None), - } - } } impl ObjectImpl for FallbackSrc { diff --git a/utils/fallbackswitch/src/fallbacksrc/video_fallback/imp.rs b/utils/fallbackswitch/src/fallbacksrc/video_fallback/imp.rs index 6fe8dd71..fed4ebd3 100644 --- a/utils/fallbackswitch/src/fallbacksrc/video_fallback/imp.rs +++ b/utils/fallbackswitch/src/fallbacksrc/video_fallback/imp.rs @@ -17,7 +17,6 @@ // Boston, MA 02110-1335, USA. use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -62,15 +61,12 @@ pub struct VideoFallbackSource { settings: Mutex, } +#[glib::object_subclass] impl ObjectSubclass for VideoFallbackSource { const NAME: &'static str = "FallbackSrcVideoFallbackSource"; type Type = super::VideoFallbackSource; type ParentType = gst::Bin; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("src").unwrap(); diff --git a/utils/fallbackswitch/src/fallbackswitch/imp.rs b/utils/fallbackswitch/src/fallbackswitch/imp.rs index b114b68f..e498d0b9 100644 --- a/utils/fallbackswitch/src/fallbackswitch/imp.rs +++ b/utils/fallbackswitch/src/fallbackswitch/imp.rs @@ -27,7 +27,6 @@ use gst_base::prelude::*; #[cfg(feature = "v1_18")] use gst_base::subclass::prelude::*; -use glib::subclass; #[cfg(not(feature = "v1_18"))] use glib::subclass::prelude::*; #[cfg(not(feature = "v1_18"))] @@ -643,15 +642,12 @@ impl FallbackSwitch { } } +#[glib::object_subclass] impl ObjectSubclass for FallbackSwitch { const NAME: &'static str = "FallbackSwitch"; type Type = super::FallbackSwitch; type ParentType = gst_base::Aggregator; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/utils/togglerecord/src/togglerecord/imp.rs b/utils/togglerecord/src/togglerecord/imp.rs index cb28e408..3e3d212d 100644 --- a/utils/togglerecord/src/togglerecord/imp.rs +++ b/utils/togglerecord/src/togglerecord/imp.rs @@ -16,7 +16,6 @@ // Boston, MA 02110-1335, USA. use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -1617,15 +1616,12 @@ impl ToggleRecord { } } +#[glib::object_subclass] impl ObjectSubclass for ToggleRecord { const NAME: &'static str = "RsToggleRecord"; type Type = super::ToggleRecord; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/video/cdg/src/cdgdec/imp.rs b/video/cdg/src/cdgdec/imp.rs index 4f892c42..40cde0c6 100644 --- a/video/cdg/src/cdgdec/imp.rs +++ b/video/cdg/src/cdgdec/imp.rs @@ -6,7 +6,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib::subclass; use glib::subclass::prelude::*; use gst::gst_debug; use gst::subclass::prelude::*; @@ -23,27 +22,18 @@ static CAT: Lazy = Lazy::new(|| { gst::DebugCategory::new("cdgdec", gst::DebugColorFlags::empty(), Some("CDG decoder")) }); +#[derive(Default)] pub struct CdgDec { cdg_inter: Mutex>, output_info: Mutex>, } +#[glib::object_subclass] impl ObjectSubclass for CdgDec { const NAME: &'static str = "CdgDec"; type Type = super::CdgDec; type ParentType = gst_video::VideoDecoder; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - Self { - cdg_inter: Mutex::new(Box::new(cdg_renderer::CdgInterpreter::new())), - output_info: Mutex::new(None), - } - } } impl ObjectImpl for CdgDec {} diff --git a/video/cdg/src/cdgparse/imp.rs b/video/cdg/src/cdgparse/imp.rs index 756dee53..6aebb708 100644 --- a/video/cdg/src/cdgparse/imp.rs +++ b/video/cdg/src/cdgparse/imp.rs @@ -6,7 +6,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib::subclass; use glib::subclass::prelude::*; use gst::format::Bytes; use gst::gst_debug; @@ -25,6 +24,7 @@ const CDG_CMD_MEMORY_PRESET: u8 = 1; const CDG_CMD_MEMORY_LOAD_COLOR_TABLE_1: u8 = 30; const CDG_CMD_MEMORY_LOAD_COLOR_TABLE_2: u8 = 31; +#[derive(Default)] pub struct CdgParse; static CAT: Lazy = Lazy::new(|| { @@ -35,19 +35,12 @@ static CAT: Lazy = Lazy::new(|| { ) }); +#[glib::object_subclass] impl ObjectSubclass for CdgParse { const NAME: &'static str = "CdgParse"; type Type = super::CdgParse; type ParentType = gst_base::BaseParse; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - Self - } } impl ObjectImpl for CdgParse {} diff --git a/video/closedcaption/src/ccdetect/imp.rs b/video/closedcaption/src/ccdetect/imp.rs index 597dbf35..da7cd806 100644 --- a/video/closedcaption/src/ccdetect/imp.rs +++ b/video/closedcaption/src/ccdetect/imp.rs @@ -15,7 +15,6 @@ // Free Software Foundation, Inc., 51 Franklin Street, Suite 500, // Boston, MA 02110-1335, USA. -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -70,6 +69,7 @@ struct State { last_cc708_change: gst::ClockTime, } +#[derive(Default)] pub struct CCDetect { settings: Mutex, state: Mutex>, @@ -214,22 +214,12 @@ impl CCDetect { } } +#[glib::object_subclass] impl ObjectSubclass for CCDetect { const NAME: &'static str = "CCDetect"; type Type = super::CCDetect; type ParentType = gst_base::BaseTransform; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - Self { - settings: Mutex::new(Default::default()), - state: Mutex::new(None), - } - } } impl ObjectImpl for CCDetect { diff --git a/video/closedcaption/src/cea608overlay/imp.rs b/video/closedcaption/src/cea608overlay/imp.rs index 4e6d153d..e9afe270 100644 --- a/video/closedcaption/src/cea608overlay/imp.rs +++ b/video/closedcaption/src/cea608overlay/imp.rs @@ -15,7 +15,6 @@ // Free Software Foundation, Inc., 51 Franklin Street, Suite 500, // Boston, MA 02110-1335, USA. -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -436,10 +435,15 @@ impl Cea608Overlay { self.negotiate(element, &mut state)?; } + for meta in buffer.iter_meta::() { + println!("timecode {}", meta.get_tc()); + } + for meta in buffer.iter_meta::() { if meta.get_caption_type() == gst_video::VideoCaptionType::Cea708Cdp { match extract_cdp(meta.get_data()) { Ok(data) => { + println!("meh {:?}", meta.get_data()); self.decode_cc_data(pad, element, &mut state, data); } Err(e) => { @@ -536,15 +540,12 @@ impl Cea608Overlay { } } +#[glib::object_subclass] impl ObjectSubclass for Cea608Overlay { const NAME: &'static str = "RsCea608Overlay"; type Type = super::Cea608Overlay; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/video/closedcaption/src/cea608tott/imp.rs b/video/closedcaption/src/cea608tott/imp.rs index cbd4e35c..79e7f259 100644 --- a/video/closedcaption/src/cea608tott/imp.rs +++ b/video/closedcaption/src/cea608tott/imp.rs @@ -6,7 +6,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -371,15 +370,12 @@ impl Cea608ToTt { } } +#[glib::object_subclass] impl ObjectSubclass for Cea608ToTt { const NAME: &'static str = "Cea608ToTt"; type Type = super::Cea608ToTt; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/video/closedcaption/src/mcc_enc/imp.rs b/video/closedcaption/src/mcc_enc/imp.rs index 76a1792a..7aa4cf4a 100644 --- a/video/closedcaption/src/mcc_enc/imp.rs +++ b/video/closedcaption/src/mcc_enc/imp.rs @@ -16,7 +16,6 @@ // Boston, MA 02110-1335, USA. use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::structure; @@ -445,15 +444,12 @@ impl MccEnc { } } +#[glib::object_subclass] impl ObjectSubclass for MccEnc { const NAME: &'static str = "RsMccEnc"; type Type = super::MccEnc; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/video/closedcaption/src/mcc_parse/imp.rs b/video/closedcaption/src/mcc_parse/imp.rs index 2c35b33b..691a2ae6 100644 --- a/video/closedcaption/src/mcc_parse/imp.rs +++ b/video/closedcaption/src/mcc_parse/imp.rs @@ -16,7 +16,6 @@ // Boston, MA 02110-1335, USA. use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -1118,15 +1117,12 @@ impl MccParse { } } +#[glib::object_subclass] impl ObjectSubclass for MccParse { const NAME: &'static str = "RsMccParse"; type Type = super::MccParse; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/video/closedcaption/src/scc_enc/imp.rs b/video/closedcaption/src/scc_enc/imp.rs index caca4d0d..8bb1a45b 100644 --- a/video/closedcaption/src/scc_enc/imp.rs +++ b/video/closedcaption/src/scc_enc/imp.rs @@ -16,7 +16,6 @@ // Free Software Foundation, Inc., 51 Franklin Street, Suite 500, // Boston, MA 02110-1335, USA. -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::structure; @@ -333,15 +332,12 @@ impl SccEnc { } } +#[glib::object_subclass] impl ObjectSubclass for SccEnc { const NAME: &'static str = "RsSccEnc"; type Type = super::SccEnc; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/video/closedcaption/src/scc_parse/imp.rs b/video/closedcaption/src/scc_parse/imp.rs index 8f5a2d57..eda5b663 100644 --- a/video/closedcaption/src/scc_parse/imp.rs +++ b/video/closedcaption/src/scc_parse/imp.rs @@ -16,7 +16,6 @@ // Free Software Foundation, Inc., 51 Franklin Street, Suite 500, // Boston, MA 02110-1335, USA. -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -998,15 +997,12 @@ impl SccParse { } } +#[glib::object_subclass] impl ObjectSubclass for SccParse { const NAME: &'static str = "RsSccParse"; type Type = super::SccParse; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/video/closedcaption/src/tttocea608/imp.rs b/video/closedcaption/src/tttocea608/imp.rs index f6d61d53..facb9a9d 100644 --- a/video/closedcaption/src/tttocea608/imp.rs +++ b/video/closedcaption/src/tttocea608/imp.rs @@ -16,7 +16,6 @@ // Boston, MA 02110-1335, USA. use glib::prelude::*; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -975,15 +974,12 @@ impl TtToCea608 { } } +#[glib::object_subclass] impl ObjectSubclass for TtToCea608 { const NAME: &'static str = "TtToCea608"; type Type = super::TtToCea608; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/video/closedcaption/src/tttojson/imp.rs b/video/closedcaption/src/tttojson/imp.rs index f7e4df7d..76cac1c7 100644 --- a/video/closedcaption/src/tttojson/imp.rs +++ b/video/closedcaption/src/tttojson/imp.rs @@ -15,7 +15,6 @@ // Free Software Foundation, Inc., 51 Franklin Street, Suite 500, // Boston, MA 02110-1335, USA. -use glib::subclass; use glib::subclass::prelude::*; use gst::gst_log; use gst::prelude::*; @@ -188,15 +187,12 @@ impl ElementImpl for TtToJson { } } +#[glib::object_subclass] impl ObjectSubclass for TtToJson { const NAME: &'static str = "RsTtToJson"; type Type = super::TtToJson; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/video/dav1d/src/dav1ddec/imp.rs b/video/dav1d/src/dav1ddec/imp.rs index b2b6c9f1..b9b803ec 100644 --- a/video/dav1d/src/dav1ddec/imp.rs +++ b/video/dav1d/src/dav1ddec/imp.rs @@ -6,7 +6,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -21,6 +20,7 @@ use std::i32; use std::str::FromStr; use std::sync::Mutex; +#[derive(Default)] struct NegotiationInfos { input_state: Option>, @@ -28,6 +28,7 @@ struct NegotiationInfos { video_meta_supported: bool, } +#[derive(Default)] pub struct Dav1dDec { decoder: Mutex, negotiation_infos: Mutex, @@ -345,26 +346,12 @@ fn video_output_formats() -> Vec { values.iter().map(|i| i.to_str().to_send_value()).collect() } +#[glib::object_subclass] impl ObjectSubclass for Dav1dDec { const NAME: &'static str = "RsDav1dDec"; type Type = super::Dav1dDec; type ParentType = gst_video::VideoDecoder; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - Self { - decoder: Mutex::new(dav1d::Decoder::new()), - negotiation_infos: Mutex::new(NegotiationInfos { - input_state: None, - output_info: None, - video_meta_supported: false, - }), - } - } } impl ObjectImpl for Dav1dDec {} diff --git a/video/flavors/src/flvdemux/imp.rs b/video/flavors/src/flvdemux/imp.rs index 216df3d3..3e49765b 100644 --- a/video/flavors/src/flvdemux/imp.rs +++ b/video/flavors/src/flvdemux/imp.rs @@ -13,7 +13,6 @@ use std::sync::Mutex; #[rustfmt::skip] use ::flavors::parser as flavors; -use glib::subclass; use gst::prelude::*; use gst::subclass::prelude::*; use gst::{gst_debug, gst_error, gst_log, gst_trace, gst_warning}; @@ -120,15 +119,12 @@ struct Metadata { video_bitrate: Option, } +#[glib::object_subclass] impl ObjectSubclass for FlvDemux { const NAME: &'static str = "RsFlvDemux"; type Type = super::FlvDemux; type ParentType = gst::Element; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); fn with_class(klass: &Self::Class) -> Self { let templ = klass.get_pad_template("sink").unwrap(); diff --git a/video/gif/src/gifenc/imp.rs b/video/gif/src/gifenc/imp.rs index 6ae6db60..0d949b35 100644 --- a/video/gif/src/gifenc/imp.rs +++ b/video/gif/src/gifenc/imp.rs @@ -7,7 +7,6 @@ // except according to those terms. use atomic_refcell::AtomicRefCell; -use glib::subclass; use glib::subclass::prelude::*; use gst::gst_debug; use gst::subclass::prelude::*; @@ -121,6 +120,7 @@ impl State { } } +#[derive(Default)] pub struct GifEnc { state: AtomicRefCell>, settings: Mutex, @@ -130,22 +130,12 @@ static CAT: Lazy = Lazy::new(|| { gst::DebugCategory::new("gifenc", gst::DebugColorFlags::empty(), Some("GIF encoder")) }); +#[glib::object_subclass] impl ObjectSubclass for GifEnc { const NAME: &'static str = "GifEnc"; type Type = super::GifEnc; type ParentType = gst_video::VideoEncoder; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - Self { - state: AtomicRefCell::new(None), - settings: Mutex::new(Default::default()), - } - } } impl ObjectImpl for GifEnc { diff --git a/video/hsv/src/hsvdetector/imp.rs b/video/hsv/src/hsvdetector/imp.rs index 82338c94..445e0831 100644 --- a/video/hsv/src/hsvdetector/imp.rs +++ b/video/hsv/src/hsvdetector/imp.rs @@ -6,7 +6,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -62,6 +61,7 @@ struct State { } // Struct containing all the element data +#[derive(Default)] pub struct HsvDetector { settings: Mutex, state: AtomicRefCell>, @@ -75,24 +75,12 @@ static CAT: Lazy = Lazy::new(|| { ) }); +#[glib::object_subclass] impl ObjectSubclass for HsvDetector { const NAME: &'static str = "HsvDetector"; type Type = super::HsvDetector; type ParentType = gst_base::BaseTransform; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - // Boilerplate macro - glib::object_subclass!(); - - // Creates a new instance. - fn new() -> Self { - Self { - settings: Mutex::new(Default::default()), - state: AtomicRefCell::new(None), - } - } } impl ObjectImpl for HsvDetector { diff --git a/video/hsv/src/hsvfilter/imp.rs b/video/hsv/src/hsvfilter/imp.rs index 747e4e5c..21070532 100644 --- a/video/hsv/src/hsvfilter/imp.rs +++ b/video/hsv/src/hsvfilter/imp.rs @@ -6,7 +6,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; use gst::subclass::prelude::*; @@ -57,6 +56,7 @@ struct State { } // Struct containing all the element data +#[derive(Default)] pub struct HsvFilter { settings: Mutex, state: AtomicRefCell>, @@ -70,24 +70,12 @@ static CAT: Lazy = Lazy::new(|| { ) }); +#[glib::object_subclass] impl ObjectSubclass for HsvFilter { const NAME: &'static str = "HsvFilter"; type Type = super::HsvFilter; type ParentType = gst_base::BaseTransform; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - // Boilerplate macro - glib::object_subclass!(); - - // Creates a new instance. - fn new() -> Self { - Self { - settings: Mutex::new(Default::default()), - state: AtomicRefCell::new(None), - } - } } impl ObjectImpl for HsvFilter { diff --git a/video/rav1e/src/rav1enc/imp.rs b/video/rav1e/src/rav1enc/imp.rs index 6516f6ce..591812b1 100644 --- a/video/rav1e/src/rav1enc/imp.rs +++ b/video/rav1e/src/rav1enc/imp.rs @@ -6,7 +6,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use glib::subclass; use glib::subclass::prelude::*; use gst::gst_debug; use gst::subclass::prelude::*; @@ -191,6 +190,7 @@ struct State { video_info: gst_video::VideoInfo, } +#[derive(Default)] pub struct Rav1Enc { state: Mutex>, settings: Mutex, @@ -204,22 +204,12 @@ static CAT: Lazy = Lazy::new(|| { ) }); +#[glib::object_subclass] impl ObjectSubclass for Rav1Enc { const NAME: &'static str = "Rav1Enc"; type Type = super::Rav1Enc; type ParentType = gst_video::VideoEncoder; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - Self { - state: Mutex::new(None), - settings: Mutex::new(Default::default()), - } - } } impl ObjectImpl for Rav1Enc { diff --git a/video/rspng/src/pngenc/imp.rs b/video/rspng/src/pngenc/imp.rs index 145c6054..c89dfb94 100644 --- a/video/rspng/src/pngenc/imp.rs +++ b/video/rspng/src/pngenc/imp.rs @@ -8,7 +8,6 @@ use std::{io, io::Write, sync::Arc}; -use glib::subclass; use glib::subclass::prelude::*; use gst::prelude::*; @@ -160,27 +159,18 @@ impl State { } } +#[derive(Default)] pub struct PngEncoder { state: Mutex>, settings: Mutex, } +#[glib::object_subclass] impl ObjectSubclass for PngEncoder { const NAME: &'static str = "PngEncoder"; type Type = super::PngEncoder; type ParentType = gst_video::VideoEncoder; - type Interfaces = (); type Instance = gst::subclass::ElementInstanceStruct; - type Class = subclass::simple::ClassStruct; - - glib::object_subclass!(); - - fn new() -> Self { - Self { - state: Mutex::new(None), - settings: Mutex::new(Default::default()), - } - } } impl ObjectImpl for PngEncoder {