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

This commit is contained in:
Sebastian Dröge 2021-03-07 13:08:06 +02:00
parent c58f2b09d2
commit b8c20c07ce
4 changed files with 13 additions and 91 deletions

View file

@ -78,9 +78,7 @@ fn main_loop() -> Result<(), Error> {
mod media_factory {
use super::*;
use glib::subclass;
use glib::subclass::prelude::*;
use gst_rtsp_server::subclass::prelude::*;
// In the imp submodule we include the actual implementation
@ -88,27 +86,17 @@ mod media_factory {
use super::*;
// This is the private data of our factory
#[derive(Default)]
pub struct Factory {}
// 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 Factory {
const NAME: &'static str = "RsRTSPMediaFactory";
type Type = super::Factory;
type ParentType = gst_rtsp_server::RTSPMediaFactory;
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 {}
}
}
// Implementation of glib::Object virtual methods
@ -172,9 +160,7 @@ mod media_factory {
// Our custom media subclass that adds a custom attribute to the SDP returned by DESCRIBE
mod media {
use glib::subclass;
use glib::subclass::prelude::*;
use gst_rtsp_server::subclass::prelude::*;
// In the imp submodule we include the actual implementation
@ -182,27 +168,17 @@ mod media {
use super::*;
// This is the private data of our media
#[derive(Default)]
pub struct Media {}
// 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 Media {
const NAME: &'static str = "RsRTSPMedia";
type Type = super::Media;
type ParentType = gst_rtsp_server::RTSPMedia;
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 {}
}
}
// Implementation of glib::Object virtual methods
@ -241,9 +217,7 @@ mod media {
mod server {
use super::*;
use glib::subclass;
use glib::subclass::prelude::*;
use gst_rtsp_server::subclass::prelude::*;
// In the imp submodule we include the actual implementation
@ -251,27 +225,17 @@ mod server {
use super::*;
// This is the private data of our server
#[derive(Default)]
pub struct Server {}
// 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 Server {
const NAME: &'static str = "RsRTSPServer";
type Type = super::Server;
type ParentType = gst_rtsp_server::RTSPServer;
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 {}
}
}
// Implementation of glib::Object virtual methods
@ -318,9 +282,7 @@ mod server {
// Our custom RTSP client subclass.
mod client {
use glib::subclass;
use glib::subclass::prelude::*;
use gst_rtsp_server::subclass::prelude::*;
// In the imp submodule we include the actual implementation
@ -328,27 +290,17 @@ mod client {
use super::*;
// This is the private data of our server
#[derive(Default)]
pub struct Client {}
// 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 Client {
const NAME: &'static str = "RsRTSPClient";
type Type = super::Client;
type ParentType = gst_rtsp_server::RTSPClient;
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 {}
}
}
// Implementation of glib::Object virtual methods

View file

@ -19,11 +19,8 @@ mod examples_common;
mod fir_filter {
use super::*;
use glib::subclass;
use glib::subclass::prelude::*;
use gst::subclass::prelude::*;
use gst_base::subclass::prelude::*;
use byte_slice_cast::*;
@ -47,6 +44,7 @@ mod fir_filter {
use std::sync::Mutex;
// This is the private data of our filter
#[derive(Default)]
pub struct FirFilter {
pub(super) coeffs: Mutex<Vec<f32>>,
history: Mutex<VecDeque<f32>>,
@ -55,25 +53,12 @@ mod fir_filter {
// 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 FirFilter {
const NAME: &'static str = "RsFirFilter";
type Type = super::FirFilter;
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 {
coeffs: Mutex::new(Vec::new()),
history: Mutex::new(VecDeque::new()),
}
}
}
// Implementation of glib::Object virtual methods

View file

@ -589,7 +589,6 @@ where
#[cfg(test)]
mod tests {
use super::*;
use glib::subclass;
use std::sync::atomic;
use crate::ElementFactory;
@ -652,15 +651,12 @@ mod tests {
}
}
#[glib::object_subclass]
impl ObjectSubclass for TestElement {
const NAME: &'static str = "TestElement";
type Type = super::TestElement;
type ParentType = Element;
type Interfaces = ();
type Instance = crate::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

@ -87,7 +87,6 @@ unsafe extern "C" fn pad_unlinked<T: PadImpl>(ptr: *mut ffi::GstPad, peer: *mut
mod tests {
use super::*;
use crate::prelude::*;
use glib::subclass;
use std::sync::atomic;
use crate::PadDirection;
@ -95,27 +94,17 @@ mod tests {
pub mod imp {
use super::*;
#[derive(Default)]
pub struct TestPad {
pub(super) linked: atomic::AtomicBool,
pub(super) unlinked: atomic::AtomicBool,
}
#[glib::object_subclass]
impl ObjectSubclass for TestPad {
const NAME: &'static str = "TestPad";
type Type = super::TestPad;
type ParentType = Pad;
type Interfaces = ();
type Instance = subclass::simple::InstanceStruct<Self>;
type Class = subclass::simple::ClassStruct<Self>;
glib::object_subclass!();
fn new() -> Self {
Self {
linked: atomic::AtomicBool::new(false),
unlinked: atomic::AtomicBool::new(false),
}
}
}
impl ObjectImpl for TestPad {}