forked from mirrors/gstreamer-rs
Port Pipeline subclassing
This commit is contained in:
parent
55dac7eeb4
commit
97211e869b
6 changed files with 78 additions and 2 deletions
|
@ -16,7 +16,6 @@ external_libraries = [
|
|||
|
||||
generate = [
|
||||
"Gst.ClockTimeDiff",
|
||||
"Gst.Pipeline",
|
||||
"Gst.State",
|
||||
"Gst.StateChange",
|
||||
"Gst.SeekFlags",
|
||||
|
@ -275,6 +274,11 @@ name = "Gst.TocEntry"
|
|||
status = "manual"
|
||||
ref_mode = "ref"
|
||||
|
||||
[[object]]
|
||||
name = "Gst.Pipeline"
|
||||
subclassing = true
|
||||
status = "generate"
|
||||
|
||||
[[object]]
|
||||
name = "Gst.Promise"
|
||||
status = "manual"
|
||||
|
|
|
@ -7,6 +7,7 @@ use ChildProxy;
|
|||
use Clock;
|
||||
use ClockTime;
|
||||
use Element;
|
||||
use PipelineClass;
|
||||
use Object;
|
||||
use ffi;
|
||||
use glib;
|
||||
|
@ -23,7 +24,7 @@ use std::mem::transmute;
|
|||
use std::ptr;
|
||||
|
||||
glib_wrapper! {
|
||||
pub struct Pipeline(Object<ffi::GstPipeline, ffi::GstPipelineClass>): Bin, Element, Object, ChildProxy;
|
||||
pub struct Pipeline(Object<ffi::GstPipeline, ffi::GstPipelineClass, PipelineClass>): Bin, Element, Object, ChildProxy;
|
||||
|
||||
match fn {
|
||||
get_type => || ffi::gst_pipeline_get_type(),
|
||||
|
|
|
@ -152,6 +152,9 @@ pub use element::ElementClass;
|
|||
mod bin;
|
||||
pub use bin::BinClass;
|
||||
|
||||
mod pipeline;
|
||||
pub use pipeline::PipelineClass;
|
||||
|
||||
// OS dependent Bus extensions (also import the other plateform mod for doc)
|
||||
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
||||
cfg_if! {
|
||||
|
|
37
gstreamer/src/pipeline.rs
Normal file
37
gstreamer/src/pipeline.rs
Normal file
|
@ -0,0 +1,37 @@
|
|||
// Copyright (C) 2018 Sebastian Dröge <sebastian@centricular.com>
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use ffi;
|
||||
|
||||
use std::ops;
|
||||
|
||||
use glib::IsClassFor;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct PipelineClass(ffi::GstPipelineClass);
|
||||
|
||||
unsafe impl IsClassFor for PipelineClass {
|
||||
type Instance = ::Pipeline;
|
||||
}
|
||||
|
||||
unsafe impl Send for PipelineClass {}
|
||||
unsafe impl Sync for PipelineClass {}
|
||||
|
||||
impl ops::Deref for PipelineClass {
|
||||
type Target = ::BinClass;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.upcast_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::DerefMut for PipelineClass {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
self.upcast_ref_mut()
|
||||
}
|
||||
}
|
|
@ -16,12 +16,14 @@ pub mod plugin;
|
|||
pub mod bin;
|
||||
pub mod child_proxy;
|
||||
pub mod element;
|
||||
pub mod pipeline;
|
||||
pub mod uri_handler;
|
||||
|
||||
pub mod prelude {
|
||||
pub use super::bin::BinImpl;
|
||||
pub use super::child_proxy::ChildProxyImpl;
|
||||
pub use super::element::{ElementClassSubclassExt, ElementImpl, ElementImplExt};
|
||||
pub use super::pipeline::PipelineImpl;
|
||||
pub use super::uri_handler::URIHandlerImpl;
|
||||
pub use super::PanicPoison;
|
||||
pub use glib::subclass::prelude::*;
|
||||
|
|
29
gstreamer/src/subclass/pipeline.rs
Normal file
29
gstreamer/src/subclass/pipeline.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
// Copyright (C) 2017,2018 Sebastian Dröge <sebastian@centricular.com>
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use ffi;
|
||||
|
||||
use super::prelude::*;
|
||||
use glib::subclass::prelude::*;
|
||||
|
||||
use PipelineClass;
|
||||
|
||||
pub trait PipelineImpl: BinImpl + Send + Sync + 'static {}
|
||||
|
||||
unsafe impl<T: ObjectSubclass + PipelineImpl> IsSubclassable<T> for PipelineClass
|
||||
where
|
||||
<T as ObjectSubclass>::Instance: PanicPoison,
|
||||
{
|
||||
fn override_vfuncs(&mut self) {
|
||||
<::BinClass as IsSubclassable<T>>::override_vfuncs(self);
|
||||
unsafe {
|
||||
let _klass = &mut *(self as *const Self as *mut ffi::GstPipelineClass);
|
||||
// Nothing to do here
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue