forked from mirrors/gstreamer-rs
gstreamer-audio: Make virtual methods take wrapper of type, not parent
This commit is contained in:
parent
145f0ed6f5
commit
29c9bcf667
4 changed files with 370 additions and 255 deletions
|
@ -10,9 +10,9 @@ use glib_sys;
|
||||||
use gst_audio_sys;
|
use gst_audio_sys;
|
||||||
use gst_sys;
|
use gst_sys;
|
||||||
|
|
||||||
|
use glib::subclass::prelude::*;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
|
|
||||||
use glib::subclass::prelude::*;
|
|
||||||
use gst;
|
use gst;
|
||||||
use gst::subclass::prelude::*;
|
use gst::subclass::prelude::*;
|
||||||
use gst_base;
|
use gst_base;
|
||||||
|
@ -25,33 +25,29 @@ use crate::prelude::*;
|
||||||
use AudioDecoder;
|
use AudioDecoder;
|
||||||
|
|
||||||
pub trait AudioDecoderImpl: AudioDecoderImplExt + ElementImpl {
|
pub trait AudioDecoderImpl: AudioDecoderImplExt + ElementImpl {
|
||||||
fn open(&self, element: &AudioDecoder) -> Result<(), gst::ErrorMessage> {
|
fn open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_open(element)
|
self.parent_open(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close(&self, element: &AudioDecoder) -> Result<(), gst::ErrorMessage> {
|
fn close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_close(element)
|
self.parent_close(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start(&self, element: &AudioDecoder) -> Result<(), gst::ErrorMessage> {
|
fn start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_start(element)
|
self.parent_start(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stop(&self, element: &AudioDecoder) -> Result<(), gst::ErrorMessage> {
|
fn stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_stop(element)
|
self.parent_stop(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_format(
|
fn set_format(&self, element: &Self::Type, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||||
&self,
|
|
||||||
element: &AudioDecoder,
|
|
||||||
caps: &gst::Caps,
|
|
||||||
) -> Result<(), gst::LoggableError> {
|
|
||||||
self.parent_set_format(element, caps)
|
self.parent_set_format(element, caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse(
|
fn parse(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioDecoder,
|
element: &Self::Type,
|
||||||
adapter: &gst_base::Adapter,
|
adapter: &gst_base::Adapter,
|
||||||
) -> Result<(u32, u32), gst::FlowError> {
|
) -> Result<(u32, u32), gst::FlowError> {
|
||||||
self.parent_parse(element, adapter)
|
self.parent_parse(element, adapter)
|
||||||
|
@ -59,7 +55,7 @@ pub trait AudioDecoderImpl: AudioDecoderImplExt + ElementImpl {
|
||||||
|
|
||||||
fn handle_frame(
|
fn handle_frame(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioDecoder,
|
element: &Self::Type,
|
||||||
buffer: Option<&gst::Buffer>,
|
buffer: Option<&gst::Buffer>,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
self.parent_handle_frame(element, buffer)
|
self.parent_handle_frame(element, buffer)
|
||||||
|
@ -67,43 +63,43 @@ pub trait AudioDecoderImpl: AudioDecoderImplExt + ElementImpl {
|
||||||
|
|
||||||
fn pre_push(
|
fn pre_push(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioDecoder,
|
element: &Self::Type,
|
||||||
buffer: gst::Buffer,
|
buffer: gst::Buffer,
|
||||||
) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
||||||
self.parent_pre_push(element, buffer)
|
self.parent_pre_push(element, buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush(&self, element: &AudioDecoder, hard: bool) {
|
fn flush(&self, element: &Self::Type, hard: bool) {
|
||||||
self.parent_flush(element, hard)
|
self.parent_flush(element, hard)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn negotiate(&self, element: &AudioDecoder) -> Result<(), gst::LoggableError> {
|
fn negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||||
self.parent_negotiate(element)
|
self.parent_negotiate(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_caps(&self, element: &AudioDecoder, filter: Option<&gst::Caps>) -> gst::Caps {
|
fn get_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||||
self.parent_get_caps(element, filter)
|
self.parent_get_caps(element, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sink_event(&self, element: &AudioDecoder, event: gst::Event) -> bool {
|
fn sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||||
self.parent_sink_event(element, event)
|
self.parent_sink_event(element, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sink_query(&self, element: &AudioDecoder, query: &mut gst::QueryRef) -> bool {
|
fn sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||||
self.parent_sink_query(element, query)
|
self.parent_sink_query(element, query)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn src_event(&self, element: &AudioDecoder, event: gst::Event) -> bool {
|
fn src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||||
self.parent_src_event(element, event)
|
self.parent_src_event(element, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn src_query(&self, element: &AudioDecoder, query: &mut gst::QueryRef) -> bool {
|
fn src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||||
self.parent_src_query(element, query)
|
self.parent_src_query(element, query)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn propose_allocation(
|
fn propose_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioDecoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage> {
|
) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_propose_allocation(element, query)
|
self.parent_propose_allocation(element, query)
|
||||||
|
@ -111,75 +107,75 @@ pub trait AudioDecoderImpl: AudioDecoderImplExt + ElementImpl {
|
||||||
|
|
||||||
fn decide_allocation(
|
fn decide_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioDecoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage> {
|
) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_decide_allocation(element, query)
|
self.parent_decide_allocation(element, query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait AudioDecoderImplExt {
|
pub trait AudioDecoderImplExt: ObjectSubclass {
|
||||||
fn parent_open(&self, element: &AudioDecoder) -> Result<(), gst::ErrorMessage>;
|
fn parent_open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_close(&self, element: &AudioDecoder) -> Result<(), gst::ErrorMessage>;
|
fn parent_close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_start(&self, element: &AudioDecoder) -> Result<(), gst::ErrorMessage>;
|
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_stop(&self, element: &AudioDecoder) -> Result<(), gst::ErrorMessage>;
|
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_set_format(
|
fn parent_set_format(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioDecoder,
|
element: &Self::Type,
|
||||||
caps: &gst::Caps,
|
caps: &gst::Caps,
|
||||||
) -> Result<(), gst::LoggableError>;
|
) -> Result<(), gst::LoggableError>;
|
||||||
|
|
||||||
fn parent_parse(
|
fn parent_parse(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioDecoder,
|
element: &Self::Type,
|
||||||
adapter: &gst_base::Adapter,
|
adapter: &gst_base::Adapter,
|
||||||
) -> Result<(u32, u32), gst::FlowError>;
|
) -> Result<(u32, u32), gst::FlowError>;
|
||||||
|
|
||||||
fn parent_handle_frame(
|
fn parent_handle_frame(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioDecoder,
|
element: &Self::Type,
|
||||||
buffer: Option<&gst::Buffer>,
|
buffer: Option<&gst::Buffer>,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||||
|
|
||||||
fn parent_pre_push(
|
fn parent_pre_push(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioDecoder,
|
element: &Self::Type,
|
||||||
buffer: gst::Buffer,
|
buffer: gst::Buffer,
|
||||||
) -> Result<Option<gst::Buffer>, gst::FlowError>;
|
) -> Result<Option<gst::Buffer>, gst::FlowError>;
|
||||||
|
|
||||||
fn parent_flush(&self, element: &AudioDecoder, hard: bool);
|
fn parent_flush(&self, element: &Self::Type, hard: bool);
|
||||||
|
|
||||||
fn parent_negotiate(&self, element: &AudioDecoder) -> Result<(), gst::LoggableError>;
|
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError>;
|
||||||
|
|
||||||
fn parent_get_caps(&self, element: &AudioDecoder, filter: Option<&gst::Caps>) -> gst::Caps;
|
fn parent_get_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps;
|
||||||
|
|
||||||
fn parent_sink_event(&self, element: &AudioDecoder, event: gst::Event) -> bool;
|
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||||
|
|
||||||
fn parent_sink_query(&self, element: &AudioDecoder, query: &mut gst::QueryRef) -> bool;
|
fn parent_sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool;
|
||||||
|
|
||||||
fn parent_src_event(&self, element: &AudioDecoder, event: gst::Event) -> bool;
|
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||||
|
|
||||||
fn parent_src_query(&self, element: &AudioDecoder, query: &mut gst::QueryRef) -> bool;
|
fn parent_src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool;
|
||||||
|
|
||||||
fn parent_propose_allocation(
|
fn parent_propose_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioDecoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage>;
|
) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_decide_allocation(
|
fn parent_decide_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioDecoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage>;
|
) -> Result<(), gst::ErrorMessage>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
fn parent_open(&self, element: &AudioDecoder) -> Result<(), gst::ErrorMessage> {
|
fn parent_open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -187,7 +183,11 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.open
|
.open
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0)) {
|
if from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<AudioDecoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -200,7 +200,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_close(&self, element: &AudioDecoder) -> Result<(), gst::ErrorMessage> {
|
fn parent_close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -208,7 +208,11 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.close
|
.close
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0)) {
|
if from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<AudioDecoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -221,7 +225,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_start(&self, element: &AudioDecoder) -> Result<(), gst::ErrorMessage> {
|
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -229,7 +233,11 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.start
|
.start
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0)) {
|
if from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<AudioDecoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -242,7 +250,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_stop(&self, element: &AudioDecoder) -> Result<(), gst::ErrorMessage> {
|
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -250,7 +258,11 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.stop
|
.stop
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0)) {
|
if from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<AudioDecoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -265,7 +277,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
|
|
||||||
fn parent_set_format(
|
fn parent_set_format(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioDecoder,
|
element: &Self::Type,
|
||||||
caps: &gst::Caps,
|
caps: &gst::Caps,
|
||||||
) -> Result<(), gst::LoggableError> {
|
) -> Result<(), gst::LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -276,7 +288,10 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
.set_format
|
.set_format
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(element.to_glib_none().0, caps.to_glib_none().0),
|
f(
|
||||||
|
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||||
|
caps.to_glib_none().0
|
||||||
|
),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"parent function `set_format` failed"
|
"parent function `set_format` failed"
|
||||||
)
|
)
|
||||||
|
@ -287,7 +302,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
|
|
||||||
fn parent_parse(
|
fn parent_parse(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioDecoder,
|
element: &Self::Type,
|
||||||
adapter: &gst_base::Adapter,
|
adapter: &gst_base::Adapter,
|
||||||
) -> Result<(u32, u32), gst::FlowError> {
|
) -> Result<(u32, u32), gst::FlowError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -300,7 +315,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
let mut offset = mem::MaybeUninit::uninit();
|
let mut offset = mem::MaybeUninit::uninit();
|
||||||
let mut len = mem::MaybeUninit::uninit();
|
let mut len = mem::MaybeUninit::uninit();
|
||||||
match gst::FlowReturn::from_glib(f(
|
match gst::FlowReturn::from_glib(f(
|
||||||
element.to_glib_none().0,
|
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||||
adapter.to_glib_none().0,
|
adapter.to_glib_none().0,
|
||||||
offset.as_mut_ptr(),
|
offset.as_mut_ptr(),
|
||||||
len.as_mut_ptr(),
|
len.as_mut_ptr(),
|
||||||
|
@ -323,7 +338,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
|
|
||||||
fn parent_handle_frame(
|
fn parent_handle_frame(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioDecoder,
|
element: &Self::Type,
|
||||||
buffer: Option<&gst::Buffer>,
|
buffer: Option<&gst::Buffer>,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -334,7 +349,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
.handle_frame
|
.handle_frame
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst::FlowReturn::from_glib(f(
|
gst::FlowReturn::from_glib(f(
|
||||||
element.to_glib_none().0,
|
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||||
buffer
|
buffer
|
||||||
.map(|buffer| buffer.as_mut_ptr() as *mut *mut gst_sys::GstBuffer)
|
.map(|buffer| buffer.as_mut_ptr() as *mut *mut gst_sys::GstBuffer)
|
||||||
.unwrap_or(ptr::null_mut()),
|
.unwrap_or(ptr::null_mut()),
|
||||||
|
@ -347,7 +362,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
|
|
||||||
fn parent_pre_push(
|
fn parent_pre_push(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioDecoder,
|
element: &Self::Type,
|
||||||
buffer: gst::Buffer,
|
buffer: gst::Buffer,
|
||||||
) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -356,7 +371,10 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||||
if let Some(f) = (*parent_class).pre_push {
|
if let Some(f) = (*parent_class).pre_push {
|
||||||
let mut buffer = buffer.into_ptr();
|
let mut buffer = buffer.into_ptr();
|
||||||
match gst::FlowReturn::from_glib(f(element.to_glib_none().0, &mut buffer))
|
match gst::FlowReturn::from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||||
|
&mut buffer,
|
||||||
|
))
|
||||||
.into_result()
|
.into_result()
|
||||||
{
|
{
|
||||||
Ok(_) => Ok(from_glib_full(buffer)),
|
Ok(_) => Ok(from_glib_full(buffer)),
|
||||||
|
@ -368,19 +386,24 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_flush(&self, element: &AudioDecoder, hard: bool) {
|
fn parent_flush(&self, element: &Self::Type, hard: bool) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.flush
|
.flush
|
||||||
.map(|f| f(element.to_glib_none().0, hard.to_glib()))
|
.map(|f| {
|
||||||
|
f(
|
||||||
|
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||||
|
hard.to_glib(),
|
||||||
|
)
|
||||||
|
})
|
||||||
.unwrap_or(())
|
.unwrap_or(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_negotiate(&self, element: &AudioDecoder) -> Result<(), gst::LoggableError> {
|
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -389,7 +412,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
.negotiate
|
.negotiate
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(element.to_glib_none().0),
|
f(element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"Parent function `negotiate` failed"
|
"Parent function `negotiate` failed"
|
||||||
)
|
)
|
||||||
|
@ -398,19 +421,28 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_get_caps(&self, element: &AudioDecoder, filter: Option<&gst::Caps>) -> gst::Caps {
|
fn parent_get_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioDecoderClass;
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.getcaps
|
.getcaps
|
||||||
.map(|f| from_glib_full(f(element.to_glib_none().0, filter.to_glib_none().0)))
|
.map(|f| {
|
||||||
.unwrap_or_else(|| element.proxy_getcaps(None, filter))
|
from_glib_full(f(
|
||||||
|
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||||
|
filter.to_glib_none().0,
|
||||||
|
))
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|| {
|
||||||
|
element
|
||||||
|
.unsafe_cast_ref::<AudioDecoder>()
|
||||||
|
.proxy_getcaps(None, filter)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_sink_event(&self, element: &AudioDecoder, event: gst::Event) -> bool {
|
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -418,11 +450,14 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
let f = (*parent_class)
|
let f = (*parent_class)
|
||||||
.sink_event
|
.sink_event
|
||||||
.expect("Missing parent function `sink_event`");
|
.expect("Missing parent function `sink_event`");
|
||||||
from_glib(f(element.to_glib_none().0, event.into_ptr()))
|
from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||||
|
event.into_ptr(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_sink_query(&self, element: &AudioDecoder, query: &mut gst::QueryRef) -> bool {
|
fn parent_sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -430,11 +465,14 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
let f = (*parent_class)
|
let f = (*parent_class)
|
||||||
.sink_query
|
.sink_query
|
||||||
.expect("Missing parent function `sink_query`");
|
.expect("Missing parent function `sink_query`");
|
||||||
from_glib(f(element.to_glib_none().0, query.as_mut_ptr()))
|
from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||||
|
query.as_mut_ptr(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_src_event(&self, element: &AudioDecoder, event: gst::Event) -> bool {
|
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -442,11 +480,14 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
let f = (*parent_class)
|
let f = (*parent_class)
|
||||||
.src_event
|
.src_event
|
||||||
.expect("Missing parent function `src_event`");
|
.expect("Missing parent function `src_event`");
|
||||||
from_glib(f(element.to_glib_none().0, event.into_ptr()))
|
from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||||
|
event.into_ptr(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_src_query(&self, element: &AudioDecoder, query: &mut gst::QueryRef) -> bool {
|
fn parent_src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -454,13 +495,16 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
let f = (*parent_class)
|
let f = (*parent_class)
|
||||||
.src_query
|
.src_query
|
||||||
.expect("Missing parent function `src_query`");
|
.expect("Missing parent function `src_query`");
|
||||||
from_glib(f(element.to_glib_none().0, query.as_mut_ptr()))
|
from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||||
|
query.as_mut_ptr(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_propose_allocation(
|
fn parent_propose_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioDecoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage> {
|
) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -470,7 +514,10 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.propose_allocation
|
.propose_allocation
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0, query.as_mut_ptr())) {
|
if from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||||
|
query.as_mut_ptr(),
|
||||||
|
)) {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -485,7 +532,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
|
|
||||||
fn parent_decide_allocation(
|
fn parent_decide_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioDecoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage> {
|
) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -495,7 +542,10 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.decide_allocation
|
.decide_allocation
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0, query.as_mut_ptr())) {
|
if from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||||
|
query.as_mut_ptr(),
|
||||||
|
)) {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -547,7 +597,7 @@ where
|
||||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.open(&wrap) {
|
match imp.open(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -569,7 +619,7 @@ where
|
||||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.close(&wrap) {
|
match imp.close(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -591,7 +641,7 @@ where
|
||||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.start(&wrap) {
|
match imp.start(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -613,7 +663,7 @@ where
|
||||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.stop(&wrap) {
|
match imp.stop(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -636,7 +686,7 @@ where
|
||||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.set_format(&wrap, &from_glib_borrow(caps)) {
|
match imp.set_format(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&*wrap);
|
err.log_with_object(&*wrap);
|
||||||
|
@ -661,7 +711,7 @@ where
|
||||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||||
match imp.parse(&wrap, &from_glib_borrow(adapter)) {
|
match imp.parse(wrap.unsafe_cast_ref(), &from_glib_borrow(adapter)) {
|
||||||
Ok((new_offset, new_len)) => {
|
Ok((new_offset, new_len)) => {
|
||||||
assert!(new_offset <= std::i32::MAX as u32);
|
assert!(new_offset <= std::i32::MAX as u32);
|
||||||
assert!(new_len <= std::i32::MAX as u32);
|
assert!(new_len <= std::i32::MAX as u32);
|
||||||
|
@ -691,7 +741,7 @@ where
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||||
imp.handle_frame(
|
imp.handle_frame(
|
||||||
&wrap,
|
wrap.unsafe_cast_ref(),
|
||||||
Option::<gst::Buffer>::from_glib_none(buffer).as_ref(),
|
Option::<gst::Buffer>::from_glib_none(buffer).as_ref(),
|
||||||
)
|
)
|
||||||
.into()
|
.into()
|
||||||
|
@ -711,7 +761,7 @@ where
|
||||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||||
match imp.pre_push(&wrap, from_glib_full(*buffer)) {
|
match imp.pre_push(wrap.unsafe_cast_ref(), from_glib_full(*buffer)) {
|
||||||
Ok(Some(new_buffer)) => {
|
Ok(Some(new_buffer)) => {
|
||||||
*buffer = new_buffer.into_ptr();
|
*buffer = new_buffer.into_ptr();
|
||||||
Ok(gst::FlowSuccess::Ok)
|
Ok(gst::FlowSuccess::Ok)
|
||||||
|
@ -738,7 +788,7 @@ unsafe extern "C" fn audio_decoder_flush<T: AudioDecoderImpl>(
|
||||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), (), {
|
gst_panic_to_error!(&wrap, &instance.panicked(), (), {
|
||||||
AudioDecoderImpl::flush(imp, &wrap, from_glib(hard))
|
AudioDecoderImpl::flush(imp, wrap.unsafe_cast_ref(), from_glib(hard))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -753,7 +803,7 @@ where
|
||||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.negotiate(&wrap) {
|
match imp.negotiate(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&*wrap);
|
err.log_with_object(&*wrap);
|
||||||
|
@ -778,7 +828,7 @@ where
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
|
||||||
AudioDecoderImpl::get_caps(
|
AudioDecoderImpl::get_caps(
|
||||||
imp,
|
imp,
|
||||||
&wrap,
|
wrap.unsafe_cast_ref(),
|
||||||
Option::<gst::Caps>::from_glib_borrow(filter)
|
Option::<gst::Caps>::from_glib_borrow(filter)
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.as_ref(),
|
.as_ref(),
|
||||||
|
@ -799,7 +849,7 @@ where
|
||||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
imp.sink_event(&wrap, from_glib_full(event))
|
imp.sink_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -816,7 +866,7 @@ where
|
||||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
imp.sink_query(&wrap, gst::QueryRef::from_mut_ptr(query))
|
imp.sink_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -833,7 +883,7 @@ where
|
||||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
imp.src_event(&wrap, from_glib_full(event))
|
imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -850,7 +900,7 @@ where
|
||||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
imp.src_query(&wrap, gst::QueryRef::from_mut_ptr(query))
|
imp.src_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -868,7 +918,7 @@ where
|
||||||
let query = gst::QueryRef::from_mut_ptr(query);
|
let query = gst::QueryRef::from_mut_ptr(query);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.propose_allocation(&wrap, query) {
|
match imp.propose_allocation(wrap.unsafe_cast_ref(), query) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -892,7 +942,7 @@ where
|
||||||
let query = gst::QueryRef::from_mut_ptr(query);
|
let query = gst::QueryRef::from_mut_ptr(query);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.decide_allocation(&wrap, query) {
|
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
|
|
@ -10,9 +10,9 @@ use glib_sys;
|
||||||
use gst_audio_sys;
|
use gst_audio_sys;
|
||||||
use gst_sys;
|
use gst_sys;
|
||||||
|
|
||||||
|
use glib::subclass::prelude::*;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
|
|
||||||
use glib::subclass::prelude::*;
|
|
||||||
use gst;
|
use gst;
|
||||||
use gst::subclass::prelude::*;
|
use gst::subclass::prelude::*;
|
||||||
|
|
||||||
|
@ -24,33 +24,29 @@ use AudioEncoder;
|
||||||
use AudioInfo;
|
use AudioInfo;
|
||||||
|
|
||||||
pub trait AudioEncoderImpl: AudioEncoderImplExt + ElementImpl {
|
pub trait AudioEncoderImpl: AudioEncoderImplExt + ElementImpl {
|
||||||
fn open(&self, element: &AudioEncoder) -> Result<(), gst::ErrorMessage> {
|
fn open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_open(element)
|
self.parent_open(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close(&self, element: &AudioEncoder) -> Result<(), gst::ErrorMessage> {
|
fn close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_close(element)
|
self.parent_close(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start(&self, element: &AudioEncoder) -> Result<(), gst::ErrorMessage> {
|
fn start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_start(element)
|
self.parent_start(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stop(&self, element: &AudioEncoder) -> Result<(), gst::ErrorMessage> {
|
fn stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_stop(element)
|
self.parent_stop(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_format(
|
fn set_format(&self, element: &Self::Type, info: &AudioInfo) -> Result<(), gst::LoggableError> {
|
||||||
&self,
|
|
||||||
element: &AudioEncoder,
|
|
||||||
info: &AudioInfo,
|
|
||||||
) -> Result<(), gst::LoggableError> {
|
|
||||||
self.parent_set_format(element, info)
|
self.parent_set_format(element, info)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_frame(
|
fn handle_frame(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioEncoder,
|
element: &Self::Type,
|
||||||
buffer: Option<&gst::Buffer>,
|
buffer: Option<&gst::Buffer>,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
self.parent_handle_frame(element, buffer)
|
self.parent_handle_frame(element, buffer)
|
||||||
|
@ -58,43 +54,43 @@ pub trait AudioEncoderImpl: AudioEncoderImplExt + ElementImpl {
|
||||||
|
|
||||||
fn pre_push(
|
fn pre_push(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioEncoder,
|
element: &Self::Type,
|
||||||
buffer: gst::Buffer,
|
buffer: gst::Buffer,
|
||||||
) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
||||||
self.parent_pre_push(element, buffer)
|
self.parent_pre_push(element, buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush(&self, element: &AudioEncoder) {
|
fn flush(&self, element: &Self::Type) {
|
||||||
self.parent_flush(element)
|
self.parent_flush(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn negotiate(&self, element: &AudioEncoder) -> Result<(), gst::LoggableError> {
|
fn negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||||
self.parent_negotiate(element)
|
self.parent_negotiate(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_caps(&self, element: &AudioEncoder, filter: Option<&gst::Caps>) -> gst::Caps {
|
fn get_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||||
self.parent_get_caps(element, filter)
|
self.parent_get_caps(element, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sink_event(&self, element: &AudioEncoder, event: gst::Event) -> bool {
|
fn sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||||
self.parent_sink_event(element, event)
|
self.parent_sink_event(element, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sink_query(&self, element: &AudioEncoder, query: &mut gst::QueryRef) -> bool {
|
fn sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||||
self.parent_sink_query(element, query)
|
self.parent_sink_query(element, query)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn src_event(&self, element: &AudioEncoder, event: gst::Event) -> bool {
|
fn src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||||
self.parent_src_event(element, event)
|
self.parent_src_event(element, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn src_query(&self, element: &AudioEncoder, query: &mut gst::QueryRef) -> bool {
|
fn src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||||
self.parent_src_query(element, query)
|
self.parent_src_query(element, query)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn propose_allocation(
|
fn propose_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioEncoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage> {
|
) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_propose_allocation(element, query)
|
self.parent_propose_allocation(element, query)
|
||||||
|
@ -102,69 +98,69 @@ pub trait AudioEncoderImpl: AudioEncoderImplExt + ElementImpl {
|
||||||
|
|
||||||
fn decide_allocation(
|
fn decide_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioEncoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage> {
|
) -> Result<(), gst::ErrorMessage> {
|
||||||
self.parent_decide_allocation(element, query)
|
self.parent_decide_allocation(element, query)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait AudioEncoderImplExt {
|
pub trait AudioEncoderImplExt: ObjectSubclass {
|
||||||
fn parent_open(&self, element: &AudioEncoder) -> Result<(), gst::ErrorMessage>;
|
fn parent_open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_close(&self, element: &AudioEncoder) -> Result<(), gst::ErrorMessage>;
|
fn parent_close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_start(&self, element: &AudioEncoder) -> Result<(), gst::ErrorMessage>;
|
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_stop(&self, element: &AudioEncoder) -> Result<(), gst::ErrorMessage>;
|
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_set_format(
|
fn parent_set_format(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioEncoder,
|
element: &Self::Type,
|
||||||
info: &AudioInfo,
|
info: &AudioInfo,
|
||||||
) -> Result<(), gst::LoggableError>;
|
) -> Result<(), gst::LoggableError>;
|
||||||
|
|
||||||
fn parent_handle_frame(
|
fn parent_handle_frame(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioEncoder,
|
element: &Self::Type,
|
||||||
buffer: Option<&gst::Buffer>,
|
buffer: Option<&gst::Buffer>,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||||
|
|
||||||
fn parent_pre_push(
|
fn parent_pre_push(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioEncoder,
|
element: &Self::Type,
|
||||||
buffer: gst::Buffer,
|
buffer: gst::Buffer,
|
||||||
) -> Result<Option<gst::Buffer>, gst::FlowError>;
|
) -> Result<Option<gst::Buffer>, gst::FlowError>;
|
||||||
|
|
||||||
fn parent_flush(&self, element: &AudioEncoder);
|
fn parent_flush(&self, element: &Self::Type);
|
||||||
|
|
||||||
fn parent_negotiate(&self, element: &AudioEncoder) -> Result<(), gst::LoggableError>;
|
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError>;
|
||||||
|
|
||||||
fn parent_get_caps(&self, element: &AudioEncoder, filter: Option<&gst::Caps>) -> gst::Caps;
|
fn parent_get_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps;
|
||||||
|
|
||||||
fn parent_sink_event(&self, element: &AudioEncoder, event: gst::Event) -> bool;
|
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||||
|
|
||||||
fn parent_sink_query(&self, element: &AudioEncoder, query: &mut gst::QueryRef) -> bool;
|
fn parent_sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool;
|
||||||
|
|
||||||
fn parent_src_event(&self, element: &AudioEncoder, event: gst::Event) -> bool;
|
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||||
|
|
||||||
fn parent_src_query(&self, element: &AudioEncoder, query: &mut gst::QueryRef) -> bool;
|
fn parent_src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool;
|
||||||
|
|
||||||
fn parent_propose_allocation(
|
fn parent_propose_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioEncoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage>;
|
) -> Result<(), gst::ErrorMessage>;
|
||||||
|
|
||||||
fn parent_decide_allocation(
|
fn parent_decide_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioEncoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage>;
|
) -> Result<(), gst::ErrorMessage>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
fn parent_open(&self, element: &AudioEncoder) -> Result<(), gst::ErrorMessage> {
|
fn parent_open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -172,7 +168,11 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.open
|
.open
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0)) {
|
if from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<AudioEncoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -185,7 +185,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_close(&self, element: &AudioEncoder) -> Result<(), gst::ErrorMessage> {
|
fn parent_close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -193,7 +193,11 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.close
|
.close
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0)) {
|
if from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<AudioEncoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -206,7 +210,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_start(&self, element: &AudioEncoder) -> Result<(), gst::ErrorMessage> {
|
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -214,7 +218,11 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.start
|
.start
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0)) {
|
if from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<AudioEncoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -227,7 +235,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_stop(&self, element: &AudioEncoder) -> Result<(), gst::ErrorMessage> {
|
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -235,7 +243,11 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.stop
|
.stop
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0)) {
|
if from_glib(f(element
|
||||||
|
.unsafe_cast_ref::<AudioEncoder>()
|
||||||
|
.to_glib_none()
|
||||||
|
.0))
|
||||||
|
{
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -250,7 +262,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
|
|
||||||
fn parent_set_format(
|
fn parent_set_format(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioEncoder,
|
element: &Self::Type,
|
||||||
info: &AudioInfo,
|
info: &AudioInfo,
|
||||||
) -> Result<(), gst::LoggableError> {
|
) -> Result<(), gst::LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -261,7 +273,10 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
.set_format
|
.set_format
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(element.to_glib_none().0, info.to_glib_none().0 as *mut _),
|
f(
|
||||||
|
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||||
|
info.to_glib_none().0 as *mut _
|
||||||
|
),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"parent function `set_format` failed"
|
"parent function `set_format` failed"
|
||||||
)
|
)
|
||||||
|
@ -272,7 +287,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
|
|
||||||
fn parent_handle_frame(
|
fn parent_handle_frame(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioEncoder,
|
element: &Self::Type,
|
||||||
buffer: Option<&gst::Buffer>,
|
buffer: Option<&gst::Buffer>,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -283,7 +298,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
.handle_frame
|
.handle_frame
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst::FlowReturn::from_glib(f(
|
gst::FlowReturn::from_glib(f(
|
||||||
element.to_glib_none().0,
|
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||||
buffer
|
buffer
|
||||||
.map(|buffer| buffer.as_mut_ptr() as *mut *mut gst_sys::GstBuffer)
|
.map(|buffer| buffer.as_mut_ptr() as *mut *mut gst_sys::GstBuffer)
|
||||||
.unwrap_or(ptr::null_mut()),
|
.unwrap_or(ptr::null_mut()),
|
||||||
|
@ -296,7 +311,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
|
|
||||||
fn parent_pre_push(
|
fn parent_pre_push(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioEncoder,
|
element: &Self::Type,
|
||||||
buffer: gst::Buffer,
|
buffer: gst::Buffer,
|
||||||
) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -305,7 +320,10 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||||
if let Some(f) = (*parent_class).pre_push {
|
if let Some(f) = (*parent_class).pre_push {
|
||||||
let mut buffer = buffer.into_ptr();
|
let mut buffer = buffer.into_ptr();
|
||||||
match gst::FlowReturn::from_glib(f(element.to_glib_none().0, &mut buffer))
|
match gst::FlowReturn::from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||||
|
&mut buffer,
|
||||||
|
))
|
||||||
.into_result()
|
.into_result()
|
||||||
{
|
{
|
||||||
Ok(_) => Ok(from_glib_full(buffer)),
|
Ok(_) => Ok(from_glib_full(buffer)),
|
||||||
|
@ -317,19 +335,19 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_flush(&self, element: &AudioEncoder) {
|
fn parent_flush(&self, element: &Self::Type) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.flush
|
.flush
|
||||||
.map(|f| f(element.to_glib_none().0))
|
.map(|f| f(element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0))
|
||||||
.unwrap_or(())
|
.unwrap_or(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_negotiate(&self, element: &AudioEncoder) -> Result<(), gst::LoggableError> {
|
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -338,7 +356,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
.negotiate
|
.negotiate
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(element.to_glib_none().0),
|
f(element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"Parent function `negotiate` failed"
|
"Parent function `negotiate` failed"
|
||||||
)
|
)
|
||||||
|
@ -347,19 +365,28 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_get_caps(&self, element: &AudioEncoder, filter: Option<&gst::Caps>) -> gst::Caps {
|
fn parent_get_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioEncoderClass;
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.getcaps
|
.getcaps
|
||||||
.map(|f| from_glib_full(f(element.to_glib_none().0, filter.to_glib_none().0)))
|
.map(|f| {
|
||||||
.unwrap_or_else(|| element.proxy_getcaps(None, filter))
|
from_glib_full(f(
|
||||||
|
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||||
|
filter.to_glib_none().0,
|
||||||
|
))
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|| {
|
||||||
|
element
|
||||||
|
.unsafe_cast_ref::<AudioEncoder>()
|
||||||
|
.proxy_getcaps(None, filter)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_sink_event(&self, element: &AudioEncoder, event: gst::Event) -> bool {
|
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -367,11 +394,14 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
let f = (*parent_class)
|
let f = (*parent_class)
|
||||||
.sink_event
|
.sink_event
|
||||||
.expect("Missing parent function `sink_event`");
|
.expect("Missing parent function `sink_event`");
|
||||||
from_glib(f(element.to_glib_none().0, event.into_ptr()))
|
from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||||
|
event.into_ptr(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_sink_query(&self, element: &AudioEncoder, query: &mut gst::QueryRef) -> bool {
|
fn parent_sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -379,11 +409,14 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
let f = (*parent_class)
|
let f = (*parent_class)
|
||||||
.sink_query
|
.sink_query
|
||||||
.expect("Missing parent function `sink_query`");
|
.expect("Missing parent function `sink_query`");
|
||||||
from_glib(f(element.to_glib_none().0, query.as_mut_ptr()))
|
from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||||
|
query.as_mut_ptr(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_src_event(&self, element: &AudioEncoder, event: gst::Event) -> bool {
|
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -391,11 +424,14 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
let f = (*parent_class)
|
let f = (*parent_class)
|
||||||
.src_event
|
.src_event
|
||||||
.expect("Missing parent function `src_event`");
|
.expect("Missing parent function `src_event`");
|
||||||
from_glib(f(element.to_glib_none().0, event.into_ptr()))
|
from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||||
|
event.into_ptr(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_src_query(&self, element: &AudioEncoder, query: &mut gst::QueryRef) -> bool {
|
fn parent_src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -403,13 +439,16 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
let f = (*parent_class)
|
let f = (*parent_class)
|
||||||
.src_query
|
.src_query
|
||||||
.expect("Missing parent function `src_query`");
|
.expect("Missing parent function `src_query`");
|
||||||
from_glib(f(element.to_glib_none().0, query.as_mut_ptr()))
|
from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||||
|
query.as_mut_ptr(),
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_propose_allocation(
|
fn parent_propose_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioEncoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage> {
|
) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -419,7 +458,10 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.propose_allocation
|
.propose_allocation
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0, query.as_mut_ptr())) {
|
if from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||||
|
query.as_mut_ptr(),
|
||||||
|
)) {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -434,7 +476,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
|
|
||||||
fn parent_decide_allocation(
|
fn parent_decide_allocation(
|
||||||
&self,
|
&self,
|
||||||
element: &AudioEncoder,
|
element: &Self::Type,
|
||||||
query: &mut gst::QueryRef,
|
query: &mut gst::QueryRef,
|
||||||
) -> Result<(), gst::ErrorMessage> {
|
) -> Result<(), gst::ErrorMessage> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -444,7 +486,10 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.decide_allocation
|
.decide_allocation
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if from_glib(f(element.to_glib_none().0, query.as_mut_ptr())) {
|
if from_glib(f(
|
||||||
|
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||||
|
query.as_mut_ptr(),
|
||||||
|
)) {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(gst_error_msg!(
|
Err(gst_error_msg!(
|
||||||
|
@ -495,7 +540,7 @@ where
|
||||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.open(&wrap) {
|
match imp.open(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -517,7 +562,7 @@ where
|
||||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.close(&wrap) {
|
match imp.close(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -539,7 +584,7 @@ where
|
||||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.start(&wrap) {
|
match imp.start(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -561,7 +606,7 @@ where
|
||||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.stop(&wrap) {
|
match imp.stop(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -584,7 +629,7 @@ where
|
||||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.set_format(&wrap, &from_glib_none(info)) {
|
match imp.set_format(wrap.unsafe_cast_ref(), &from_glib_none(info)) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&*wrap);
|
err.log_with_object(&*wrap);
|
||||||
|
@ -610,7 +655,7 @@ where
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||||
imp.handle_frame(
|
imp.handle_frame(
|
||||||
&wrap,
|
wrap.unsafe_cast_ref(),
|
||||||
Option::<gst::Buffer>::from_glib_none(buffer).as_ref(),
|
Option::<gst::Buffer>::from_glib_none(buffer).as_ref(),
|
||||||
)
|
)
|
||||||
.into()
|
.into()
|
||||||
|
@ -630,7 +675,7 @@ where
|
||||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||||
match imp.pre_push(&wrap, from_glib_full(*buffer)) {
|
match imp.pre_push(wrap.unsafe_cast_ref(), from_glib_full(*buffer)) {
|
||||||
Ok(Some(new_buffer)) => {
|
Ok(Some(new_buffer)) => {
|
||||||
*buffer = new_buffer.into_ptr();
|
*buffer = new_buffer.into_ptr();
|
||||||
Ok(gst::FlowSuccess::Ok)
|
Ok(gst::FlowSuccess::Ok)
|
||||||
|
@ -656,7 +701,7 @@ unsafe extern "C" fn audio_encoder_flush<T: AudioEncoderImpl>(
|
||||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), (), {
|
gst_panic_to_error!(&wrap, &instance.panicked(), (), {
|
||||||
AudioEncoderImpl::flush(imp, &wrap)
|
AudioEncoderImpl::flush(imp, wrap.unsafe_cast_ref())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -671,7 +716,7 @@ where
|
||||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.negotiate(&wrap) {
|
match imp.negotiate(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&*wrap);
|
err.log_with_object(&*wrap);
|
||||||
|
@ -696,7 +741,7 @@ where
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::Caps::new_empty(), {
|
||||||
AudioEncoderImpl::get_caps(
|
AudioEncoderImpl::get_caps(
|
||||||
imp,
|
imp,
|
||||||
&wrap,
|
wrap.unsafe_cast_ref(),
|
||||||
Option::<gst::Caps>::from_glib_borrow(filter)
|
Option::<gst::Caps>::from_glib_borrow(filter)
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.as_ref(),
|
.as_ref(),
|
||||||
|
@ -717,7 +762,7 @@ where
|
||||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
imp.sink_event(&wrap, from_glib_full(event))
|
imp.sink_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -734,7 +779,7 @@ where
|
||||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
imp.sink_query(&wrap, gst::QueryRef::from_mut_ptr(query))
|
imp.sink_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -751,7 +796,7 @@ where
|
||||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
imp.src_event(&wrap, from_glib_full(event))
|
imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -768,7 +813,7 @@ where
|
||||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
imp.src_query(&wrap, gst::QueryRef::from_mut_ptr(query))
|
imp.src_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -786,7 +831,7 @@ where
|
||||||
let query = gst::QueryRef::from_mut_ptr(query);
|
let query = gst::QueryRef::from_mut_ptr(query);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.propose_allocation(&wrap, query) {
|
match imp.propose_allocation(wrap.unsafe_cast_ref(), query) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
@ -810,7 +855,7 @@ where
|
||||||
let query = gst::QueryRef::from_mut_ptr(query);
|
let query = gst::QueryRef::from_mut_ptr(query);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.decide_allocation(&wrap, query) {
|
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
wrap.post_error_message(err);
|
wrap.post_error_message(err);
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
use glib_sys;
|
use glib_sys;
|
||||||
use gst_audio_sys;
|
use gst_audio_sys;
|
||||||
|
|
||||||
|
use glib::prelude::*;
|
||||||
|
use glib::subclass::prelude::*;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
|
|
||||||
use glib::subclass::prelude::*;
|
|
||||||
use gst::subclass::prelude::*;
|
use gst::subclass::prelude::*;
|
||||||
use gst::LoggableError;
|
use gst::LoggableError;
|
||||||
use gst_base::subclass::prelude::*;
|
use gst_base::subclass::prelude::*;
|
||||||
|
@ -12,55 +13,55 @@ use AudioRingBufferSpec;
|
||||||
use AudioSink;
|
use AudioSink;
|
||||||
|
|
||||||
pub trait AudioSinkImpl: AudioSinkImplExt + BaseSinkImpl {
|
pub trait AudioSinkImpl: AudioSinkImplExt + BaseSinkImpl {
|
||||||
fn close(&self, sink: &AudioSink) -> Result<(), LoggableError> {
|
fn close(&self, sink: &Self::Type) -> Result<(), LoggableError> {
|
||||||
self.parent_close(sink)
|
self.parent_close(sink)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delay(&self, sink: &AudioSink) -> u32 {
|
fn delay(&self, sink: &Self::Type) -> u32 {
|
||||||
self.parent_delay(sink)
|
self.parent_delay(sink)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open(&self, sink: &AudioSink) -> Result<(), LoggableError> {
|
fn open(&self, sink: &Self::Type) -> Result<(), LoggableError> {
|
||||||
self.parent_open(sink)
|
self.parent_open(sink)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare(
|
fn prepare(
|
||||||
&self,
|
&self,
|
||||||
sink: &AudioSink,
|
sink: &Self::Type,
|
||||||
spec: &mut AudioRingBufferSpec,
|
spec: &mut AudioRingBufferSpec,
|
||||||
) -> Result<(), LoggableError> {
|
) -> Result<(), LoggableError> {
|
||||||
AudioSinkImplExt::parent_prepare(self, sink, spec)
|
AudioSinkImplExt::parent_prepare(self, sink, spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unprepare(&self, sink: &AudioSink) -> Result<(), LoggableError> {
|
fn unprepare(&self, sink: &Self::Type) -> Result<(), LoggableError> {
|
||||||
self.parent_unprepare(sink)
|
self.parent_unprepare(sink)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write(&self, sink: &AudioSink, audio_data: &[u8]) -> Result<i32, LoggableError> {
|
fn write(&self, sink: &Self::Type, audio_data: &[u8]) -> Result<i32, LoggableError> {
|
||||||
self.parent_write(sink, audio_data)
|
self.parent_write(sink, audio_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reset(&self, sink: &AudioSink) {
|
fn reset(&self, sink: &Self::Type) {
|
||||||
self.parent_reset(sink)
|
self.parent_reset(sink)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait AudioSinkImplExt {
|
pub trait AudioSinkImplExt: ObjectSubclass {
|
||||||
fn parent_close(&self, sink: &AudioSink) -> Result<(), LoggableError>;
|
fn parent_close(&self, sink: &Self::Type) -> Result<(), LoggableError>;
|
||||||
fn parent_delay(&self, sink: &AudioSink) -> u32;
|
fn parent_delay(&self, sink: &Self::Type) -> u32;
|
||||||
fn parent_open(&self, sink: &AudioSink) -> Result<(), LoggableError>;
|
fn parent_open(&self, sink: &Self::Type) -> Result<(), LoggableError>;
|
||||||
fn parent_prepare(
|
fn parent_prepare(
|
||||||
&self,
|
&self,
|
||||||
sink: &AudioSink,
|
sink: &Self::Type,
|
||||||
spec: &mut AudioRingBufferSpec,
|
spec: &mut AudioRingBufferSpec,
|
||||||
) -> Result<(), LoggableError>;
|
) -> Result<(), LoggableError>;
|
||||||
fn parent_unprepare(&self, sink: &AudioSink) -> Result<(), LoggableError>;
|
fn parent_unprepare(&self, sink: &Self::Type) -> Result<(), LoggableError>;
|
||||||
fn parent_write(&self, sink: &AudioSink, audio_data: &[u8]) -> Result<i32, LoggableError>;
|
fn parent_write(&self, sink: &Self::Type, audio_data: &[u8]) -> Result<i32, LoggableError>;
|
||||||
fn parent_reset(&self, sink: &AudioSink);
|
fn parent_reset(&self, sink: &Self::Type);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
||||||
fn parent_close(&self, sink: &AudioSink) -> Result<(), LoggableError> {
|
fn parent_close(&self, sink: &Self::Type) -> Result<(), LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -70,14 +71,14 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
||||||
Some(f) => f,
|
Some(f) => f,
|
||||||
};
|
};
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(sink.to_glib_none().0),
|
f(sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"Failed to close element using the parent function"
|
"Failed to close element using the parent function"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_delay(&self, sink: &AudioSink) -> u32 {
|
fn parent_delay(&self, sink: &Self::Type) -> u32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -86,11 +87,11 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
||||||
Some(f) => f,
|
Some(f) => f,
|
||||||
None => return 0,
|
None => return 0,
|
||||||
};
|
};
|
||||||
f(sink.to_glib_none().0)
|
f(sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_open(&self, sink: &AudioSink) -> Result<(), LoggableError> {
|
fn parent_open(&self, sink: &Self::Type) -> Result<(), LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -100,7 +101,7 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
||||||
None => return Ok(()),
|
None => return Ok(()),
|
||||||
};
|
};
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(sink.to_glib_none().0),
|
f(sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"Failed to open element using the parent function"
|
"Failed to open element using the parent function"
|
||||||
)
|
)
|
||||||
|
@ -109,7 +110,7 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
||||||
|
|
||||||
fn parent_prepare(
|
fn parent_prepare(
|
||||||
&self,
|
&self,
|
||||||
sink: &AudioSink,
|
sink: &Self::Type,
|
||||||
spec: &mut AudioRingBufferSpec,
|
spec: &mut AudioRingBufferSpec,
|
||||||
) -> Result<(), LoggableError> {
|
) -> Result<(), LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -121,14 +122,17 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
||||||
None => return Ok(()),
|
None => return Ok(()),
|
||||||
};
|
};
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(sink.to_glib_none().0, &mut spec.0),
|
f(
|
||||||
|
sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0,
|
||||||
|
&mut spec.0
|
||||||
|
),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"Failed to prepare element using the parent function"
|
"Failed to prepare element using the parent function"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_unprepare(&self, sink: &AudioSink) -> Result<(), LoggableError> {
|
fn parent_unprepare(&self, sink: &Self::Type) -> Result<(), LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -143,14 +147,14 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(sink.to_glib_none().0),
|
f(sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"Failed to unprepare element using the parent function"
|
"Failed to unprepare element using the parent function"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_write(&self, sink: &AudioSink, buffer: &[u8]) -> Result<i32, LoggableError> {
|
fn parent_write(&self, sink: &Self::Type, buffer: &[u8]) -> Result<i32, LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -160,7 +164,11 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
||||||
None => return Ok(-1),
|
None => return Ok(-1),
|
||||||
};
|
};
|
||||||
let buffer_ptr = buffer.as_ptr() as *const _ as *mut _;
|
let buffer_ptr = buffer.as_ptr() as *const _ as *mut _;
|
||||||
let ret = f(sink.to_glib_none().0, buffer_ptr, buffer.len() as u32);
|
let ret = f(
|
||||||
|
sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0,
|
||||||
|
buffer_ptr,
|
||||||
|
buffer.len() as u32,
|
||||||
|
);
|
||||||
if ret > 0 {
|
if ret > 0 {
|
||||||
Ok(ret)
|
Ok(ret)
|
||||||
} else {
|
} else {
|
||||||
|
@ -172,13 +180,13 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_reset(&self, sink: &AudioSink) {
|
fn parent_reset(&self, sink: &Self::Type) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioSinkClass;
|
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioSinkClass;
|
||||||
if let Some(f) = (*parent_class).reset {
|
if let Some(f) = (*parent_class).reset {
|
||||||
f(sink.to_glib_none().0)
|
f(sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,7 +220,7 @@ where
|
||||||
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.close(&wrap) {
|
match imp.close(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&*wrap);
|
err.log_with_object(&*wrap);
|
||||||
|
@ -231,7 +239,9 @@ where
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), 0, { imp.delay(&wrap) })
|
gst_panic_to_error!(&wrap, &instance.panicked(), 0, {
|
||||||
|
imp.delay(wrap.unsafe_cast_ref())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn audiosink_open<T: AudioSinkImpl>(
|
unsafe extern "C" fn audiosink_open<T: AudioSinkImpl>(
|
||||||
|
@ -245,7 +255,7 @@ where
|
||||||
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.open(&wrap) {
|
match imp.open(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&*wrap);
|
err.log_with_object(&*wrap);
|
||||||
|
@ -270,7 +280,7 @@ where
|
||||||
let spec = &mut *(spec as *mut AudioRingBufferSpec);
|
let spec = &mut *(spec as *mut AudioRingBufferSpec);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match AudioSinkImpl::prepare(imp, &wrap, spec) {
|
match AudioSinkImpl::prepare(imp, wrap.unsafe_cast_ref(), spec) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&*wrap);
|
err.log_with_object(&*wrap);
|
||||||
|
@ -292,7 +302,7 @@ where
|
||||||
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.unprepare(&wrap) {
|
match imp.unprepare(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&*wrap);
|
err.log_with_object(&*wrap);
|
||||||
|
@ -317,7 +327,7 @@ where
|
||||||
let data_slice = std::slice::from_raw_parts(data as *const u8, length as usize);
|
let data_slice = std::slice::from_raw_parts(data as *const u8, length as usize);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), -1, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), -1, {
|
||||||
imp.write(&wrap, data_slice).unwrap_or(-1)
|
imp.write(wrap.unsafe_cast_ref(), data_slice).unwrap_or(-1)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,6 +340,6 @@ where
|
||||||
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), (), {
|
gst_panic_to_error!(&wrap, &instance.panicked(), (), {
|
||||||
imp.reset(&wrap);
|
imp.reset(wrap.unsafe_cast_ref());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,9 +3,10 @@ use gst_audio_sys;
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
|
use glib::prelude::*;
|
||||||
|
use glib::subclass::prelude::*;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
|
|
||||||
use glib::subclass::prelude::*;
|
|
||||||
use gst::subclass::prelude::*;
|
use gst::subclass::prelude::*;
|
||||||
use gst::LoggableError;
|
use gst::LoggableError;
|
||||||
use gst_base::subclass::prelude::*;
|
use gst_base::subclass::prelude::*;
|
||||||
|
@ -14,59 +15,63 @@ use AudioRingBufferSpec;
|
||||||
use AudioSrc;
|
use AudioSrc;
|
||||||
|
|
||||||
pub trait AudioSrcImpl: AudioSrcImplExt + BaseSrcImpl {
|
pub trait AudioSrcImpl: AudioSrcImplExt + BaseSrcImpl {
|
||||||
fn close(&self, src: &AudioSrc) -> Result<(), LoggableError> {
|
fn close(&self, src: &Self::Type) -> Result<(), LoggableError> {
|
||||||
self.parent_close(src)
|
self.parent_close(src)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delay(&self, src: &AudioSrc) -> u32 {
|
fn delay(&self, src: &Self::Type) -> u32 {
|
||||||
self.parent_delay(src)
|
self.parent_delay(src)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn open(&self, src: &AudioSrc) -> Result<(), LoggableError> {
|
fn open(&self, src: &Self::Type) -> Result<(), LoggableError> {
|
||||||
self.parent_open(src)
|
self.parent_open(src)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare(&self, src: &AudioSrc, spec: &mut AudioRingBufferSpec) -> Result<(), LoggableError> {
|
fn prepare(
|
||||||
|
&self,
|
||||||
|
src: &Self::Type,
|
||||||
|
spec: &mut AudioRingBufferSpec,
|
||||||
|
) -> Result<(), LoggableError> {
|
||||||
AudioSrcImplExt::parent_prepare(self, src, spec)
|
AudioSrcImplExt::parent_prepare(self, src, spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unprepare(&self, src: &AudioSrc) -> Result<(), LoggableError> {
|
fn unprepare(&self, src: &Self::Type) -> Result<(), LoggableError> {
|
||||||
self.parent_unprepare(src)
|
self.parent_unprepare(src)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read(
|
fn read(
|
||||||
&self,
|
&self,
|
||||||
src: &AudioSrc,
|
src: &Self::Type,
|
||||||
audio_data: &mut [u8],
|
audio_data: &mut [u8],
|
||||||
) -> Result<(u32, gst::ClockTime), LoggableError> {
|
) -> Result<(u32, gst::ClockTime), LoggableError> {
|
||||||
self.parent_read(src, audio_data)
|
self.parent_read(src, audio_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn reset(&self, src: &AudioSrc) {
|
fn reset(&self, src: &Self::Type) {
|
||||||
self.parent_reset(src)
|
self.parent_reset(src)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait AudioSrcImplExt {
|
pub trait AudioSrcImplExt: ObjectSubclass {
|
||||||
fn parent_close(&self, src: &AudioSrc) -> Result<(), LoggableError>;
|
fn parent_close(&self, src: &Self::Type) -> Result<(), LoggableError>;
|
||||||
fn parent_delay(&self, src: &AudioSrc) -> u32;
|
fn parent_delay(&self, src: &Self::Type) -> u32;
|
||||||
fn parent_open(&self, src: &AudioSrc) -> Result<(), LoggableError>;
|
fn parent_open(&self, src: &Self::Type) -> Result<(), LoggableError>;
|
||||||
fn parent_prepare(
|
fn parent_prepare(
|
||||||
&self,
|
&self,
|
||||||
src: &AudioSrc,
|
src: &Self::Type,
|
||||||
spec: &mut AudioRingBufferSpec,
|
spec: &mut AudioRingBufferSpec,
|
||||||
) -> Result<(), LoggableError>;
|
) -> Result<(), LoggableError>;
|
||||||
fn parent_unprepare(&self, src: &AudioSrc) -> Result<(), LoggableError>;
|
fn parent_unprepare(&self, src: &Self::Type) -> Result<(), LoggableError>;
|
||||||
fn parent_read(
|
fn parent_read(
|
||||||
&self,
|
&self,
|
||||||
src: &AudioSrc,
|
src: &Self::Type,
|
||||||
audio_data: &mut [u8],
|
audio_data: &mut [u8],
|
||||||
) -> Result<(u32, gst::ClockTime), LoggableError>;
|
) -> Result<(u32, gst::ClockTime), LoggableError>;
|
||||||
fn parent_reset(&self, src: &AudioSrc);
|
fn parent_reset(&self, src: &Self::Type);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
||||||
fn parent_close(&self, src: &AudioSrc) -> Result<(), LoggableError> {
|
fn parent_close(&self, src: &Self::Type) -> Result<(), LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -76,14 +81,14 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
||||||
Some(f) => f,
|
Some(f) => f,
|
||||||
};
|
};
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(src.to_glib_none().0),
|
f(src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"Failed to close element using the parent function"
|
"Failed to close element using the parent function"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_delay(&self, src: &AudioSrc) -> u32 {
|
fn parent_delay(&self, src: &Self::Type) -> u32 {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -92,11 +97,11 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
||||||
Some(f) => f,
|
Some(f) => f,
|
||||||
None => return 0,
|
None => return 0,
|
||||||
};
|
};
|
||||||
f(src.to_glib_none().0)
|
f(src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_open(&self, src: &AudioSrc) -> Result<(), LoggableError> {
|
fn parent_open(&self, src: &Self::Type) -> Result<(), LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -106,7 +111,7 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
||||||
None => return Ok(()),
|
None => return Ok(()),
|
||||||
};
|
};
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(src.to_glib_none().0),
|
f(src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"Failed to open element using the parent function"
|
"Failed to open element using the parent function"
|
||||||
)
|
)
|
||||||
|
@ -115,7 +120,7 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
||||||
|
|
||||||
fn parent_prepare(
|
fn parent_prepare(
|
||||||
&self,
|
&self,
|
||||||
src: &AudioSrc,
|
src: &Self::Type,
|
||||||
spec: &mut AudioRingBufferSpec,
|
spec: &mut AudioRingBufferSpec,
|
||||||
) -> Result<(), LoggableError> {
|
) -> Result<(), LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -127,14 +132,17 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
||||||
None => return Ok(()),
|
None => return Ok(()),
|
||||||
};
|
};
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(src.to_glib_none().0, &mut spec.0),
|
f(
|
||||||
|
src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0,
|
||||||
|
&mut spec.0
|
||||||
|
),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"Failed to prepare element using the parent function"
|
"Failed to prepare element using the parent function"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_unprepare(&self, src: &AudioSrc) -> Result<(), LoggableError> {
|
fn parent_unprepare(&self, src: &Self::Type) -> Result<(), LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
|
@ -149,7 +157,7 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(src.to_glib_none().0),
|
f(src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"Failed to unprepare element using the parent function"
|
"Failed to unprepare element using the parent function"
|
||||||
)
|
)
|
||||||
|
@ -158,7 +166,7 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
||||||
|
|
||||||
fn parent_read(
|
fn parent_read(
|
||||||
&self,
|
&self,
|
||||||
src: &AudioSrc,
|
src: &Self::Type,
|
||||||
buffer: &mut [u8],
|
buffer: &mut [u8],
|
||||||
) -> Result<(u32, gst::ClockTime), LoggableError> {
|
) -> Result<(u32, gst::ClockTime), LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -172,7 +180,7 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
||||||
let buffer_ptr = buffer.as_mut_ptr() as *mut _;
|
let buffer_ptr = buffer.as_mut_ptr() as *mut _;
|
||||||
let mut timestamp = mem::MaybeUninit::uninit();
|
let mut timestamp = mem::MaybeUninit::uninit();
|
||||||
let ret = f(
|
let ret = f(
|
||||||
src.to_glib_none().0,
|
src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0,
|
||||||
buffer_ptr,
|
buffer_ptr,
|
||||||
buffer.len() as u32,
|
buffer.len() as u32,
|
||||||
timestamp.as_mut_ptr(),
|
timestamp.as_mut_ptr(),
|
||||||
|
@ -188,13 +196,13 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_reset(&self, src: &AudioSrc) {
|
fn parent_reset(&self, src: &Self::Type) {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = T::type_data();
|
let data = T::type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioSrcClass;
|
data.as_ref().get_parent_class() as *mut gst_audio_sys::GstAudioSrcClass;
|
||||||
if let Some(f) = (*parent_class).reset {
|
if let Some(f) = (*parent_class).reset {
|
||||||
f(src.to_glib_none().0)
|
f(src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -228,7 +236,7 @@ where
|
||||||
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.close(&wrap) {
|
match imp.close(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&*wrap);
|
err.log_with_object(&*wrap);
|
||||||
|
@ -247,7 +255,9 @@ where
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), 0, { imp.delay(&wrap) })
|
gst_panic_to_error!(&wrap, &instance.panicked(), 0, {
|
||||||
|
imp.delay(wrap.unsafe_cast_ref())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe extern "C" fn audiosrc_open<T: AudioSrcImpl>(
|
unsafe extern "C" fn audiosrc_open<T: AudioSrcImpl>(
|
||||||
|
@ -261,7 +271,7 @@ where
|
||||||
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.open(&wrap) {
|
match imp.open(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&*wrap);
|
err.log_with_object(&*wrap);
|
||||||
|
@ -286,7 +296,7 @@ where
|
||||||
let spec = &mut *(spec as *mut AudioRingBufferSpec);
|
let spec = &mut *(spec as *mut AudioRingBufferSpec);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match AudioSrcImpl::prepare(imp, &wrap, spec) {
|
match AudioSrcImpl::prepare(imp, wrap.unsafe_cast_ref(), spec) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&*wrap);
|
err.log_with_object(&*wrap);
|
||||||
|
@ -308,7 +318,7 @@ where
|
||||||
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.unprepare(&wrap) {
|
match imp.unprepare(wrap.unsafe_cast_ref()) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&*wrap);
|
err.log_with_object(&*wrap);
|
||||||
|
@ -335,7 +345,7 @@ where
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), 0, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), 0, {
|
||||||
let (res, timestamp_res) = imp
|
let (res, timestamp_res) = imp
|
||||||
.read(&wrap, data_slice)
|
.read(wrap.unsafe_cast_ref(), data_slice)
|
||||||
.unwrap_or((0, gst::CLOCK_TIME_NONE));
|
.unwrap_or((0, gst::CLOCK_TIME_NONE));
|
||||||
*timestamp = timestamp_res.to_glib();
|
*timestamp = timestamp_res.to_glib();
|
||||||
|
|
||||||
|
@ -352,6 +362,6 @@ where
|
||||||
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), (), {
|
gst_panic_to_error!(&wrap, &instance.panicked(), (), {
|
||||||
imp.reset(&wrap);
|
imp.reset(wrap.unsafe_cast_ref());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue