Update for new #[glib::object_subclass] attribute macro

This commit is contained in:
Sebastian Dröge 2021-03-07 18:22:24 +02:00
parent 5dd0a23986
commit dc0c5f7611
56 changed files with 233 additions and 621 deletions

View file

@ -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<Settings>,
state: Mutex<Option<State>>,
@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
Self {
settings: Mutex::new(Default::default()),
state: Mutex::new(None),
}
}
}
impl ObjectImpl for AudioEcho {

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<Option<State>>,
}
@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
Self {
state: Mutex::new(None),
}
}
}
impl ObjectImpl for AudioRNNoise {}

View file

@ -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<gst_audio::AudioInfo>,
}
#[derive(Default)]
pub struct ClaxonDec {
state: AtomicRefCell<Option<State>>,
}
#[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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
Self {
state: AtomicRefCell::new(None),
}
}
}
impl ObjectImpl for ClaxonDec {}

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
let csound = Csound::new();

View file

@ -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<gst::Buffer>,
@ -30,11 +31,11 @@ struct State {
reorder_map: Option<[usize; 8]>,
}
#[derive(Default)]
pub struct LewtonDec {
state: AtomicRefCell<Option<State>>,
}
use once_cell::sync::Lazy;
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
gst::DebugCategory::new(
"lewtondec",
@ -43,21 +44,12 @@ static CAT: Lazy<gst::DebugCategory> = 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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
Self {
state: AtomicRefCell::new(None),
}
}
}
impl ObjectImpl for LewtonDec {}

View file

@ -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<Settings>,
state: Mutex<State>,
@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
Self {
settings: Mutex::new(Default::default()),
state: Mutex::new(Default::default()),
}
}
}
impl ObjectImpl for FileSink {

View file

@ -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<Settings>,
state: Mutex<State>,
@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
Self {
settings: Mutex::new(Default::default()),
state: Mutex::new(Default::default()),
}
}
}
impl ObjectImpl for FileSrc {

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let src_pad_handler = AppSrcPadHandler::default();

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
Self {

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let sink_pad_handler = SinkHandler::default();

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
unreachable!()
}
fn with_class(klass: &Self::Class) -> Self {
Self {

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
Self {

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let src_pad_handler = TcpClientSrcPadHandler::default();

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let settings = Arc::new(StdMutex::new(Settings::default()));

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let src_pad_handler = UdpSrcPadHandler::default();

View file

@ -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<Self>;
type Class = glib::subclass::simple::ClassStruct<Self>;
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<Self>;
type Class = glib::subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
ElementSinkTest {

View file

@ -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<Option<ClientContext>>,
external_client: Mutex<Option<ClientContext>>,
@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
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),
}
}
}

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<Settings>,
state: Mutex<State>,
@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
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 {

View file

@ -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<Option<GstS3Url>>,
state: Mutex<StreamingState>,
@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
Self {
url: Mutex::new(None),
state: Mutex::new(StreamingState::Stopped),
canceller: Mutex::new(None),
}
}
}
impl ObjectImpl for S3Src {

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
// 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

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
// 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

View file

@ -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<Settings>,
state: Mutex<Option<State>>,
@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
// 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

View file

@ -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<Settings>,
state: Mutex<State>,
@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
// 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

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
// This macro provides some boilerplate
glib::object_subclass!();
fn new() -> Self {
Self {}
}
fn class_init(klass: &mut subclass::simple::ClassStruct<Self>) {
}
}
```
@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
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<Option<State>>
}
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<Settings>,
state: Mutex<Option<State>>,
@ -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<Vec<glib::ParamSpec>> = 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, thats why the `Mutex` is needed here to protect our struct. And were using a new mutex to be able to have it locked only for the shorted possible amount of time: we dont 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, thats why the `Mutex` is needed here to protect our struct. And were using a new mutex to be able to have it locked only for the shorted possible amount of time: we dont 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 were 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

View file

@ -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<Settings>,
state: Mutex<State>,
@ -146,28 +105,12 @@ static CAT: Lazy<gst::DebugCategory> = 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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
// 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<Vec<glib::ParamSpec>> = 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<Settings>,
state: Mutex<State>,

View file

@ -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<Stream>,
num_audio: usize,
num_video: usize,
}
#[derive(Default)]
pub struct CustomSource {
source: OnceCell<gst::Element>,
state: Mutex<State>,
}
#[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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
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 {

View file

@ -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<Settings>,
state: Mutex<Option<State>>,
}
#[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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
Self {
settings: Mutex::new(Settings::default()),
state: Mutex::new(None),
}
}
}
impl ObjectImpl for FallbackSrc {

View file

@ -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<Settings>,
}
#[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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("src").unwrap();

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<gst::DebugCategory> = Lazy::new(|| {
gst::DebugCategory::new("cdgdec", gst::DebugColorFlags::empty(), Some("CDG decoder"))
});
#[derive(Default)]
pub struct CdgDec {
cdg_inter: Mutex<Box<cdg_renderer::CdgInterpreter>>,
output_info: Mutex<Option<gst_video::VideoInfo>>,
}
#[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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
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 {}

View file

@ -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<gst::DebugCategory> = Lazy::new(|| {
@ -35,19 +35,12 @@ static CAT: Lazy<gst::DebugCategory> = 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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
Self
}
}
impl ObjectImpl for CdgParse {}

View file

@ -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<Settings>,
state: Mutex<Option<State>>,
@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
Self {
settings: Mutex::new(Default::default()),
state: Mutex::new(None),
}
}
}
impl ObjectImpl for CCDetect {

View file

@ -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::<gst_video::VideoTimeCodeMeta>() {
println!("timecode {}", meta.get_tc());
}
for meta in buffer.iter_meta::<gst_video::VideoCaptionMeta>() {
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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<gst_video::VideoCodecState<'static, gst_video::video_codec_state::Readable>>,
@ -28,6 +28,7 @@ struct NegotiationInfos {
video_meta_supported: bool,
}
#[derive(Default)]
pub struct Dav1dDec {
decoder: Mutex<dav1d::Decoder>,
negotiation_infos: Mutex<NegotiationInfos>,
@ -345,26 +346,12 @@ fn video_output_formats() -> Vec<glib::SendValue> {
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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
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 {}

View file

@ -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<u32>,
}
#[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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn with_class(klass: &Self::Class) -> Self {
let templ = klass.get_pad_template("sink").unwrap();

View file

@ -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<Option<State>>,
settings: Mutex<Settings>,
@ -130,22 +130,12 @@ static CAT: Lazy<gst::DebugCategory> = 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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
Self {
state: AtomicRefCell::new(None),
settings: Mutex::new(Default::default()),
}
}
}
impl ObjectImpl for GifEnc {

View file

@ -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<Settings>,
state: AtomicRefCell<Option<State>>,
@ -75,24 +75,12 @@ static CAT: Lazy<gst::DebugCategory> = 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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
// 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 {

View file

@ -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<Settings>,
state: AtomicRefCell<Option<State>>,
@ -70,24 +70,12 @@ static CAT: Lazy<gst::DebugCategory> = 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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
// 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 {

View file

@ -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<Option<State>>,
settings: Mutex<Settings>,
@ -204,22 +204,12 @@ static CAT: Lazy<gst::DebugCategory> = 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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
Self {
state: Mutex::new(None),
settings: Mutex::new(Default::default()),
}
}
}
impl ObjectImpl for Rav1Enc {

View file

@ -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<Option<State>>,
settings: Mutex<Settings>,
}
#[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<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
Self {
state: Mutex::new(None),
settings: Mutex::new(Default::default()),
}
}
}
impl ObjectImpl for PngEncoder {