diff --git a/gst-plugin/src/lib.rs b/gst-plugin/src/lib.rs index 48b416b4..9166c8c6 100644 --- a/gst-plugin/src/lib.rs +++ b/gst-plugin/src/lib.rs @@ -75,6 +75,8 @@ pub mod element; #[macro_use] pub mod bin; #[macro_use] +pub mod pipeline; +#[macro_use] pub mod base_src; #[macro_use] pub mod base_sink; diff --git a/gst-plugin/src/pipeline.rs b/gst-plugin/src/pipeline.rs new file mode 100644 index 00000000..1140429e --- /dev/null +++ b/gst-plugin/src/pipeline.rs @@ -0,0 +1,94 @@ +// Copyright (C) 2017 Sebastian Dröge +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::ptr; +use std::mem; + +use glib_ffi; +use gobject_ffi; +use gst_ffi; + +use glib; +use glib::translate::*; +use gst; +use gst::prelude::*; + +use object::*; +use element::*; +use bin::*; +use anyimpl::*; + +pub trait PipelineImpl + : AnyImpl + ObjectImpl + ElementImpl + BinImpl + Send + Sync + 'static + { +} + +any_impl!(PipelineBase, PipelineImpl); + +pub unsafe trait PipelineBase + : IsA + IsA + IsA + ObjectType { +} + +pub unsafe trait PipelineClassExt +where + T::ImplType: PipelineImpl, +{ + fn override_vfuncs(&mut self, _: &ClassInitToken) {} +} + +glib_wrapper! { + pub struct Pipeline(Object>): [gst::Pipeline => gst_ffi::GstPipeline, + gst::Bin => gst_ffi::GstBin, + gst::Element => gst_ffi::GstElement, + gst::Object => gst_ffi::GstObject, + gst::ChildProxy => gst_ffi::GstChildProxy]; + + match fn { + get_type => || get_type::(), + } +} + +unsafe impl + IsA + IsA + ObjectType> PipelineBase + for T { +} +pub type PipelineClass = ClassStruct; + +// FIXME: Boilerplate +unsafe impl PipelineClassExt for PipelineClass {} +unsafe impl BinClassExt for PipelineClass {} +unsafe impl ElementClassExt for PipelineClass {} + +#[macro_export] +macro_rules! box_pipeline_impl( + ($name:ident) => { + box_bin_impl!($name); + + impl PipelineImpl for Box<$name> { + } + }; +); +box_pipeline_impl!(PipelineImpl); + +impl ObjectType for Pipeline { + const NAME: &'static str = "RsPipeline"; + type GlibType = gst_ffi::GstPipeline; + type GlibClassType = gst_ffi::GstPipelineClass; + type ImplType = Box>; + + fn glib_type() -> glib::Type { + unsafe { from_glib(gst_ffi::gst_pipeline_get_type()) } + } + + fn class_init(token: &ClassInitToken, klass: &mut PipelineClass) { + ElementClassExt::override_vfuncs(klass, token); + BinClassExt::override_vfuncs(klass, token); + PipelineClassExt::override_vfuncs(klass, token); + } + + object_type_fns!(); +}