gstreamer-audio: Generate bindings for AudioSink and AudioBaseSink

This commit is contained in:
Hans Ole Hatzel 2019-12-12 10:54:54 +01:00 committed by Sebastian Dröge
parent 14a55dc73d
commit da848d2946
6 changed files with 539 additions and 1 deletions

View file

@ -14,6 +14,7 @@ external_libraries = [
"GLib",
"GObject",
"Gst",
"GstBase",
]
generate = [
@ -24,6 +25,8 @@ generate = [
"GstAudio.AudioChannelPosition",
"GstAudio.StreamVolume",
"GstAudio.StreamVolumeFormat",
"GstAudio.AudioSink",
"GstAudio.AudioBaseSink",
]
manual = [
@ -34,6 +37,7 @@ manual = [
"Gst.AllocationParams",
"Gst.TagList",
"Gst.TagMergeMode",
"GstBase.BaseSink",
"GstAudio.AudioInfo",
"GstAudio.AudioFormatInfo",
]

View file

@ -0,0 +1,501 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::StaticType;
use glib::Value;
use glib_sys;
use gobject_sys;
use gst;
use gst_audio_sys;
use gst_base;
use std::boxed::Box as Box_;
use std::mem::transmute;
glib_wrapper! {
pub struct AudioBaseSink(Object<gst_audio_sys::GstAudioBaseSink, gst_audio_sys::GstAudioBaseSinkClass, AudioBaseSinkClass>) @extends gst_base::BaseSink, gst::Element, gst::Object;
match fn {
get_type => || gst_audio_sys::gst_audio_base_sink_get_type(),
}
}
unsafe impl Send for AudioBaseSink {}
unsafe impl Sync for AudioBaseSink {}
pub const NONE_AUDIO_BASE_SINK: Option<&AudioBaseSink> = None;
pub trait AudioBaseSinkExt: 'static {
//fn create_ringbuffer(&self) -> /*Ignored*/Option<AudioRingBuffer>;
fn get_alignment_threshold(&self) -> gst::ClockTime;
fn get_discont_wait(&self) -> gst::ClockTime;
fn get_drift_tolerance(&self) -> i64;
fn get_provide_clock(&self) -> bool;
//fn get_slave_method(&self) -> /*Ignored*/AudioBaseSinkSlaveMethod;
fn report_device_failure(&self);
fn set_alignment_threshold(&self, alignment_threshold: gst::ClockTime);
//fn set_custom_slaving_callback(&self, callback: /*Unimplemented*/Fn(&AudioBaseSink, gst::ClockTime, gst::ClockTime, /*Ignored*/gst::ClockTimeDiff, /*Ignored*/AudioBaseSinkDiscontReason), user_data: /*Unimplemented*/Option<Fundamental: Pointer>);
fn set_discont_wait(&self, discont_wait: gst::ClockTime);
fn set_drift_tolerance(&self, drift_tolerance: i64);
fn set_provide_clock(&self, provide: bool);
//fn set_slave_method(&self, method: /*Ignored*/AudioBaseSinkSlaveMethod);
fn get_property_buffer_time(&self) -> i64;
fn set_property_buffer_time(&self, buffer_time: i64);
fn get_property_can_activate_pull(&self) -> bool;
fn set_property_can_activate_pull(&self, can_activate_pull: bool);
fn get_property_latency_time(&self) -> i64;
fn set_property_latency_time(&self, latency_time: i64);
fn connect_property_alignment_threshold_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId;
fn connect_property_buffer_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId;
fn connect_property_can_activate_pull_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId;
fn connect_property_discont_wait_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId;
fn connect_property_drift_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId;
fn connect_property_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId;
fn connect_property_provide_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId;
fn connect_property_slave_method_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId;
}
impl<O: IsA<AudioBaseSink>> AudioBaseSinkExt for O {
//fn create_ringbuffer(&self) -> /*Ignored*/Option<AudioRingBuffer> {
// unsafe { TODO: call gst_audio_sys:gst_audio_base_sink_create_ringbuffer() }
//}
fn get_alignment_threshold(&self) -> gst::ClockTime {
unsafe {
from_glib(gst_audio_sys::gst_audio_base_sink_get_alignment_threshold(
self.as_ref().to_glib_none().0,
))
}
}
fn get_discont_wait(&self) -> gst::ClockTime {
unsafe {
from_glib(gst_audio_sys::gst_audio_base_sink_get_discont_wait(
self.as_ref().to_glib_none().0,
))
}
}
fn get_drift_tolerance(&self) -> i64 {
unsafe {
gst_audio_sys::gst_audio_base_sink_get_drift_tolerance(self.as_ref().to_glib_none().0)
}
}
fn get_provide_clock(&self) -> bool {
unsafe {
from_glib(gst_audio_sys::gst_audio_base_sink_get_provide_clock(
self.as_ref().to_glib_none().0,
))
}
}
//fn get_slave_method(&self) -> /*Ignored*/AudioBaseSinkSlaveMethod {
// unsafe { TODO: call gst_audio_sys:gst_audio_base_sink_get_slave_method() }
//}
fn report_device_failure(&self) {
unsafe {
gst_audio_sys::gst_audio_base_sink_report_device_failure(
self.as_ref().to_glib_none().0,
);
}
}
fn set_alignment_threshold(&self, alignment_threshold: gst::ClockTime) {
unsafe {
gst_audio_sys::gst_audio_base_sink_set_alignment_threshold(
self.as_ref().to_glib_none().0,
alignment_threshold.to_glib(),
);
}
}
//fn set_custom_slaving_callback(&self, callback: /*Unimplemented*/Fn(&AudioBaseSink, gst::ClockTime, gst::ClockTime, /*Ignored*/gst::ClockTimeDiff, /*Ignored*/AudioBaseSinkDiscontReason), user_data: /*Unimplemented*/Option<Fundamental: Pointer>) {
// unsafe { TODO: call gst_audio_sys:gst_audio_base_sink_set_custom_slaving_callback() }
//}
fn set_discont_wait(&self, discont_wait: gst::ClockTime) {
unsafe {
gst_audio_sys::gst_audio_base_sink_set_discont_wait(
self.as_ref().to_glib_none().0,
discont_wait.to_glib(),
);
}
}
fn set_drift_tolerance(&self, drift_tolerance: i64) {
unsafe {
gst_audio_sys::gst_audio_base_sink_set_drift_tolerance(
self.as_ref().to_glib_none().0,
drift_tolerance,
);
}
}
fn set_provide_clock(&self, provide: bool) {
unsafe {
gst_audio_sys::gst_audio_base_sink_set_provide_clock(
self.as_ref().to_glib_none().0,
provide.to_glib(),
);
}
}
//fn set_slave_method(&self, method: /*Ignored*/AudioBaseSinkSlaveMethod) {
// unsafe { TODO: call gst_audio_sys:gst_audio_base_sink_set_slave_method() }
//}
fn get_property_buffer_time(&self) -> i64 {
unsafe {
let mut value = Value::from_type(<i64 as StaticType>::static_type());
gobject_sys::g_object_get_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
b"buffer-time\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `buffer-time` getter")
.unwrap()
}
}
fn set_property_buffer_time(&self, buffer_time: i64) {
unsafe {
gobject_sys::g_object_set_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
b"buffer-time\0".as_ptr() as *const _,
Value::from(&buffer_time).to_glib_none().0,
);
}
}
fn get_property_can_activate_pull(&self) -> bool {
unsafe {
let mut value = Value::from_type(<bool as StaticType>::static_type());
gobject_sys::g_object_get_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
b"can-activate-pull\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `can-activate-pull` getter")
.unwrap()
}
}
fn set_property_can_activate_pull(&self, can_activate_pull: bool) {
unsafe {
gobject_sys::g_object_set_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
b"can-activate-pull\0".as_ptr() as *const _,
Value::from(&can_activate_pull).to_glib_none().0,
);
}
}
fn get_property_latency_time(&self) -> i64 {
unsafe {
let mut value = Value::from_type(<i64 as StaticType>::static_type());
gobject_sys::g_object_get_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
b"latency-time\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `latency-time` getter")
.unwrap()
}
}
fn set_property_latency_time(&self, latency_time: i64) {
unsafe {
gobject_sys::g_object_set_property(
self.to_glib_none().0 as *mut gobject_sys::GObject,
b"latency-time\0".as_ptr() as *const _,
Value::from(&latency_time).to_glib_none().0,
);
}
}
fn connect_property_alignment_threshold_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_alignment_threshold_trampoline<
P,
F: Fn(&P) + Send + Sync + 'static,
>(
this: *mut gst_audio_sys::GstAudioBaseSink,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
) where
P: IsA<AudioBaseSink>,
{
let f: &F = &*(f as *const F);
f(&AudioBaseSink::from_glib_borrow(this).unsafe_cast())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::alignment-threshold\0".as_ptr() as *const _,
Some(transmute(
notify_alignment_threshold_trampoline::<Self, F> as usize,
)),
Box_::into_raw(f),
)
}
}
fn connect_property_buffer_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_buffer_time_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
this: *mut gst_audio_sys::GstAudioBaseSink,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
) where
P: IsA<AudioBaseSink>,
{
let f: &F = &*(f as *const F);
f(&AudioBaseSink::from_glib_borrow(this).unsafe_cast())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::buffer-time\0".as_ptr() as *const _,
Some(transmute(notify_buffer_time_trampoline::<Self, F> as usize)),
Box_::into_raw(f),
)
}
}
fn connect_property_can_activate_pull_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_can_activate_pull_trampoline<
P,
F: Fn(&P) + Send + Sync + 'static,
>(
this: *mut gst_audio_sys::GstAudioBaseSink,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
) where
P: IsA<AudioBaseSink>,
{
let f: &F = &*(f as *const F);
f(&AudioBaseSink::from_glib_borrow(this).unsafe_cast())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::can-activate-pull\0".as_ptr() as *const _,
Some(transmute(
notify_can_activate_pull_trampoline::<Self, F> as usize,
)),
Box_::into_raw(f),
)
}
}
fn connect_property_discont_wait_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_discont_wait_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
this: *mut gst_audio_sys::GstAudioBaseSink,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
) where
P: IsA<AudioBaseSink>,
{
let f: &F = &*(f as *const F);
f(&AudioBaseSink::from_glib_borrow(this).unsafe_cast())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::discont-wait\0".as_ptr() as *const _,
Some(transmute(
notify_discont_wait_trampoline::<Self, F> as usize,
)),
Box_::into_raw(f),
)
}
}
fn connect_property_drift_tolerance_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_drift_tolerance_trampoline<
P,
F: Fn(&P) + Send + Sync + 'static,
>(
this: *mut gst_audio_sys::GstAudioBaseSink,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
) where
P: IsA<AudioBaseSink>,
{
let f: &F = &*(f as *const F);
f(&AudioBaseSink::from_glib_borrow(this).unsafe_cast())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::drift-tolerance\0".as_ptr() as *const _,
Some(transmute(
notify_drift_tolerance_trampoline::<Self, F> as usize,
)),
Box_::into_raw(f),
)
}
}
fn connect_property_latency_time_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_latency_time_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
this: *mut gst_audio_sys::GstAudioBaseSink,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
) where
P: IsA<AudioBaseSink>,
{
let f: &F = &*(f as *const F);
f(&AudioBaseSink::from_glib_borrow(this).unsafe_cast())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::latency-time\0".as_ptr() as *const _,
Some(transmute(
notify_latency_time_trampoline::<Self, F> as usize,
)),
Box_::into_raw(f),
)
}
}
fn connect_property_provide_clock_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_provide_clock_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
this: *mut gst_audio_sys::GstAudioBaseSink,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
) where
P: IsA<AudioBaseSink>,
{
let f: &F = &*(f as *const F);
f(&AudioBaseSink::from_glib_borrow(this).unsafe_cast())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::provide-clock\0".as_ptr() as *const _,
Some(transmute(
notify_provide_clock_trampoline::<Self, F> as usize,
)),
Box_::into_raw(f),
)
}
}
fn connect_property_slave_method_notify<F: Fn(&Self) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn notify_slave_method_trampoline<P, F: Fn(&P) + Send + Sync + 'static>(
this: *mut gst_audio_sys::GstAudioBaseSink,
_param_spec: glib_sys::gpointer,
f: glib_sys::gpointer,
) where
P: IsA<AudioBaseSink>,
{
let f: &F = &*(f as *const F);
f(&AudioBaseSink::from_glib_borrow(this).unsafe_cast())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::slave-method\0".as_ptr() as *const _,
Some(transmute(
notify_slave_method_trampoline::<Self, F> as usize,
)),
Box_::into_raw(f),
)
}
}
}

View file

@ -0,0 +1,24 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use glib::translate::*;
use gst;
use gst_audio_sys;
use gst_base;
use AudioBaseSink;
glib_wrapper! {
pub struct AudioSink(Object<gst_audio_sys::GstAudioSink, gst_audio_sys::GstAudioSinkClass, AudioSinkClass>) @extends AudioBaseSink, gst_base::BaseSink, gst::Element, gst::Object;
match fn {
get_type => || gst_audio_sys::gst_audio_sink_get_type(),
}
}
impl AudioSink {}
unsafe impl Send for AudioSink {}
unsafe impl Sync for AudioSink {}
pub const NONE_AUDIO_SINK: Option<&AudioSink> = None;

View file

@ -2,6 +2,10 @@
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
mod audio_base_sink;
pub use self::audio_base_sink::AudioBaseSinkExt;
pub use self::audio_base_sink::{AudioBaseSink, AudioBaseSinkClass, NONE_AUDIO_BASE_SINK};
mod audio_decoder;
pub use self::audio_decoder::AudioDecoderExt;
pub use self::audio_decoder::{AudioDecoder, AudioDecoderClass, NONE_AUDIO_DECODER};
@ -10,6 +14,9 @@ mod audio_encoder;
pub use self::audio_encoder::AudioEncoderExt;
pub use self::audio_encoder::{AudioEncoder, AudioEncoderClass, NONE_AUDIO_ENCODER};
mod audio_sink;
pub use self::audio_sink::{AudioSink, AudioSinkClass, NONE_AUDIO_SINK};
mod stream_volume;
pub use self::stream_volume::StreamVolumeExt;
pub use self::stream_volume::{StreamVolume, NONE_STREAM_VOLUME};
@ -32,6 +39,7 @@ pub use self::flags::AudioPackFlags;
#[doc(hidden)]
pub mod traits {
pub use super::AudioBaseSinkExt;
pub use super::AudioDecoderExt;
pub use super::AudioEncoderExt;
pub use super::StreamVolumeExt;

View file

@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 5836573)
from gir-files (https://github.com/gtk-rs/gir-files @ c067e63)
from gir-files (https://github.com/gtk-rs/gir-files @ 82d78da)

View file

@ -9,6 +9,7 @@
pub mod audio_decoder;
pub mod audio_encoder;
pub mod audio_sink;
pub mod prelude {
pub use super::audio_decoder::{AudioDecoderImpl, AudioDecoderImplExt};