forked from mirrors/gstreamer-rs
Manual code updates for *Return types
This commit is contained in:
parent
2364361f6b
commit
5505715cc4
35 changed files with 290 additions and 783 deletions
|
@ -2,13 +2,8 @@
|
|||
|
||||
use crate::AppSink;
|
||||
use glib::ffi::gpointer;
|
||||
use glib::object::ObjectType;
|
||||
use glib::signal::connect_raw;
|
||||
use glib::signal::SignalHandlerId;
|
||||
use glib::translate::*;
|
||||
use std::boxed::Box as Box_;
|
||||
use std::cell::RefCell;
|
||||
use std::mem::transmute;
|
||||
use std::panic;
|
||||
use std::ptr;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
@ -277,72 +272,12 @@ impl AppSink {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn connect_new_sample<
|
||||
F: Fn(&AppSink) -> Result<gst::FlowSuccess, gst::FlowError> + Send + 'static,
|
||||
>(
|
||||
&self,
|
||||
f: F,
|
||||
) -> SignalHandlerId {
|
||||
unsafe {
|
||||
let f: Box_<F> = Box_::new(f);
|
||||
connect_raw(
|
||||
self.as_ptr() as *mut _,
|
||||
b"new-sample\0".as_ptr() as *const _,
|
||||
Some(transmute::<_, unsafe extern "C" fn()>(
|
||||
new_sample_trampoline::<F> as *const (),
|
||||
)),
|
||||
Box_::into_raw(f),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn connect_new_preroll<
|
||||
F: Fn(&AppSink) -> Result<gst::FlowSuccess, gst::FlowError> + Send + 'static,
|
||||
>(
|
||||
&self,
|
||||
f: F,
|
||||
) -> SignalHandlerId {
|
||||
unsafe {
|
||||
let f: Box_<F> = Box_::new(f);
|
||||
connect_raw(
|
||||
self.as_ptr() as *mut _,
|
||||
b"new-preroll\0".as_ptr() as *const _,
|
||||
Some(transmute::<_, unsafe extern "C" fn()>(
|
||||
new_preroll_trampoline::<F> as *const (),
|
||||
)),
|
||||
Box_::into_raw(f),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_10"))]
|
||||
pub fn stream(&self) -> AppSinkStream {
|
||||
AppSinkStream::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
unsafe extern "C" fn new_sample_trampoline<
|
||||
F: Fn(&AppSink) -> Result<gst::FlowSuccess, gst::FlowError> + Send + 'static,
|
||||
>(
|
||||
this: *mut ffi::GstAppSink,
|
||||
f: glib::ffi::gpointer,
|
||||
) -> gst::ffi::GstFlowReturn {
|
||||
let f: &F = &*(f as *const F);
|
||||
let ret: gst::FlowReturn = f(&from_glib_borrow(this)).into();
|
||||
ret.into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn new_preroll_trampoline<
|
||||
F: Fn(&AppSink) -> Result<gst::FlowSuccess, gst::FlowError> + Send + 'static,
|
||||
>(
|
||||
this: *mut ffi::GstAppSink,
|
||||
f: glib::ffi::gpointer,
|
||||
) -> gst::ffi::GstFlowReturn {
|
||||
let f: &F = &*(f as *const F);
|
||||
let ret: gst::FlowReturn = f(&from_glib_borrow(this)).into();
|
||||
ret.into_glib()
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_10"))]
|
||||
#[derive(Debug)]
|
||||
pub struct AppSinkStream {
|
||||
|
|
|
@ -207,20 +207,13 @@ unsafe extern "C" fn destroy_callbacks(ptr: gpointer) {
|
|||
}
|
||||
|
||||
impl AppSrc {
|
||||
pub fn end_of_stream(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn =
|
||||
unsafe { from_glib(ffi::gst_app_src_end_of_stream(self.to_glib_none().0)) };
|
||||
ret.into_result()
|
||||
}
|
||||
|
||||
pub fn push_buffer(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_app_src_push_buffer(
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(ffi::gst_app_src_push_buffer(
|
||||
self.to_glib_none().0,
|
||||
buffer.into_ptr(),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
||||
|
@ -229,23 +222,12 @@ impl AppSrc {
|
|||
&self,
|
||||
list: gst::BufferList,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_app_src_push_buffer_list(
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(ffi::gst_app_src_push_buffer_list(
|
||||
self.to_glib_none().0,
|
||||
list.into_ptr(),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
|
||||
pub fn push_sample(&self, sample: &gst::Sample) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_app_src_push_sample(
|
||||
self.to_glib_none().0,
|
||||
sample.to_glib_none().0,
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
|
||||
pub fn set_callbacks(&self, callbacks: AppSrcCallbacks) {
|
||||
|
|
|
@ -65,14 +65,13 @@ impl<O: IsA<AudioDecoder>> AudioDecoderExtManual for O {
|
|||
buffer: Option<gst::Buffer>,
|
||||
frames: i32,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_audio_decoder_finish_frame(
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(ffi::gst_audio_decoder_finish_frame(
|
||||
self.as_ref().to_glib_none().0,
|
||||
buffer.map(|b| b.into_ptr()).unwrap_or(ptr::null_mut()),
|
||||
frames,
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
|
@ -81,13 +80,12 @@ impl<O: IsA<AudioDecoder>> AudioDecoderExtManual for O {
|
|||
&self,
|
||||
buffer: Option<gst::Buffer>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_audio_decoder_finish_subframe(
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(ffi::gst_audio_decoder_finish_subframe(
|
||||
self.as_ref().to_glib_none().0,
|
||||
buffer.map(|b| b.into_ptr()).unwrap_or(ptr::null_mut()),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
fn negotiate(&self) -> Result<(), gst::FlowError> {
|
||||
|
@ -156,8 +154,8 @@ impl<O: IsA<AudioDecoder>> AudioDecoderExtManual for O {
|
|||
function: &str,
|
||||
line: u32,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(_gst_audio_decoder_error(
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(_gst_audio_decoder_error(
|
||||
self.as_ref().to_glib_none().0,
|
||||
weight,
|
||||
T::domain().into_glib(),
|
||||
|
@ -168,8 +166,7 @@ impl<O: IsA<AudioDecoder>> AudioDecoderExtManual for O {
|
|||
function.to_glib_none().0,
|
||||
line as i32,
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,14 +30,13 @@ impl<O: IsA<AudioEncoder>> AudioEncoderExtManual for O {
|
|||
buffer: Option<gst::Buffer>,
|
||||
frames: i32,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_audio_encoder_finish_frame(
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(ffi::gst_audio_encoder_finish_frame(
|
||||
self.as_ref().to_glib_none().0,
|
||||
buffer.map(|b| b.into_ptr()).unwrap_or(ptr::null_mut()),
|
||||
frames,
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
fn negotiate(&self) -> Result<(), gst::FlowError> {
|
||||
|
|
|
@ -295,23 +295,19 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
.map(|f| {
|
||||
let mut offset = mem::MaybeUninit::uninit();
|
||||
let mut len = mem::MaybeUninit::uninit();
|
||||
match gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||
adapter.to_glib_none().0,
|
||||
offset.as_mut_ptr(),
|
||||
len.as_mut_ptr(),
|
||||
))
|
||||
.into_result()
|
||||
{
|
||||
Ok(_) => {
|
||||
.map(|_| {
|
||||
let offset = offset.assume_init();
|
||||
let len = len.assume_init();
|
||||
assert!(offset >= 0);
|
||||
assert!(len >= 0);
|
||||
Ok((offset as u32, len as u32))
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
(offset as u32, len as u32)
|
||||
})
|
||||
})
|
||||
.unwrap_or_else(|| Ok((0, adapter.available() as u32)))
|
||||
}
|
||||
|
@ -328,15 +324,14 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
(*parent_class)
|
||||
.handle_frame
|
||||
.map(|f| {
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||
buffer
|
||||
.map(|buffer| buffer.as_mut_ptr() as *mut *mut gst::ffi::GstBuffer)
|
||||
.unwrap_or(ptr::null_mut()),
|
||||
))
|
||||
})
|
||||
.unwrap_or(gst::FlowReturn::Error)
|
||||
.into_result()
|
||||
.unwrap_or(Err(gst::FlowError::Error))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,15 +345,11 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
if let Some(f) = (*parent_class).pre_push {
|
||||
let mut buffer = buffer.into_ptr();
|
||||
match gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||
&mut buffer,
|
||||
))
|
||||
.into_result()
|
||||
{
|
||||
Ok(_) => Ok(from_glib_full(buffer)),
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
.map(|_| from_glib_full(buffer))
|
||||
} else {
|
||||
Ok(Some(buffer))
|
||||
}
|
||||
|
|
|
@ -279,15 +279,14 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
(*parent_class)
|
||||
.handle_frame
|
||||
.map(|f| {
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||
buffer
|
||||
.map(|buffer| buffer.as_mut_ptr() as *mut *mut gst::ffi::GstBuffer)
|
||||
.unwrap_or(ptr::null_mut()),
|
||||
))
|
||||
})
|
||||
.unwrap_or(gst::FlowReturn::Error)
|
||||
.into_result()
|
||||
.unwrap_or(Err(gst::FlowError::Error))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,15 +300,11 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
if let Some(f) = (*parent_class).pre_push {
|
||||
let mut buffer = buffer.into_ptr();
|
||||
match gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||
&mut buffer,
|
||||
))
|
||||
.into_result()
|
||||
{
|
||||
Ok(_) => Ok(from_glib_full(buffer)),
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
.map(|_| from_glib_full(buffer))
|
||||
} else {
|
||||
Ok(Some(buffer))
|
||||
}
|
||||
|
|
|
@ -99,13 +99,12 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
|
|||
}
|
||||
|
||||
fn finish_buffer(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_aggregator_finish_buffer(
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(ffi::gst_aggregator_finish_buffer(
|
||||
self.as_ref().to_glib_none().0,
|
||||
buffer.into_ptr(),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_18", feature = "dox"))]
|
||||
|
@ -114,13 +113,12 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
|
|||
&self,
|
||||
bufferlist: gst::BufferList,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_aggregator_finish_buffer_list(
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(ffi::gst_aggregator_finish_buffer_list(
|
||||
self.as_ref().to_glib_none().0,
|
||||
bufferlist.into_ptr(),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
|
|
|
@ -128,12 +128,11 @@ impl<O: IsA<BaseParse>> BaseParseExtManual for O {
|
|||
size: u32,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
gst::FlowReturn::from_glib(ffi::gst_base_parse_finish_frame(
|
||||
gst::FlowSuccess::try_from_glib(ffi::gst_base_parse_finish_frame(
|
||||
self.as_ref().to_glib_none().0,
|
||||
frame.to_glib_none().0,
|
||||
i32::try_from(size).expect("size higher than i32::MAX"),
|
||||
))
|
||||
.into_result()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,20 +9,6 @@ pub trait BaseSinkExtManual: 'static {
|
|||
#[doc(alias = "get_segment")]
|
||||
fn segment(&self) -> gst::Segment;
|
||||
|
||||
fn wait(
|
||||
&self,
|
||||
time: gst::ClockTime,
|
||||
) -> (Result<gst::FlowSuccess, gst::FlowError>, gst::ClockTimeDiff);
|
||||
|
||||
fn wait_preroll(&self) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
fn wait_clock(
|
||||
&self,
|
||||
time: gst::ClockTime,
|
||||
) -> (
|
||||
Result<gst::ClockSuccess, gst::ClockError>,
|
||||
gst::ClockTimeDiff,
|
||||
);
|
||||
|
||||
fn query_latency(
|
||||
&self,
|
||||
) -> Result<(bool, bool, gst::ClockTime, gst::ClockTime), glib::BoolError>;
|
||||
|
@ -37,48 +23,6 @@ impl<O: IsA<BaseSink>> BaseSinkExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn wait(
|
||||
&self,
|
||||
time: gst::ClockTime,
|
||||
) -> (Result<gst::FlowSuccess, gst::FlowError>, gst::ClockTimeDiff) {
|
||||
unsafe {
|
||||
let mut jitter = 0;
|
||||
let ret: gst::FlowReturn = from_glib(ffi::gst_base_sink_wait(
|
||||
self.as_ref().to_glib_none().0,
|
||||
time.into_glib(),
|
||||
&mut jitter,
|
||||
));
|
||||
(ret.into_result(), jitter)
|
||||
}
|
||||
}
|
||||
|
||||
fn wait_preroll(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_base_sink_wait_preroll(
|
||||
self.as_ref().to_glib_none().0,
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
|
||||
fn wait_clock(
|
||||
&self,
|
||||
time: gst::ClockTime,
|
||||
) -> (
|
||||
Result<gst::ClockSuccess, gst::ClockError>,
|
||||
gst::ClockTimeDiff,
|
||||
) {
|
||||
unsafe {
|
||||
let mut jitter = 0;
|
||||
let ret: gst::ClockReturn = from_glib(ffi::gst_base_sink_wait_clock(
|
||||
self.as_ref().to_glib_none().0,
|
||||
time.into_glib(),
|
||||
&mut jitter,
|
||||
));
|
||||
(ret.into_result(), jitter)
|
||||
}
|
||||
}
|
||||
|
||||
fn query_latency(
|
||||
&self,
|
||||
) -> Result<(bool, bool, gst::ClockTime, gst::ClockTime), glib::BoolError> {
|
||||
|
|
|
@ -14,12 +14,6 @@ pub trait BaseSrcExtManual: 'static {
|
|||
#[doc(alias = "get_segment")]
|
||||
fn segment(&self) -> gst::Segment;
|
||||
|
||||
fn start_complete(&self, ret: Result<gst::FlowSuccess, gst::FlowError>);
|
||||
|
||||
fn start_wait(&self) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn wait_playing(&self) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn query_latency(&self) -> Result<(bool, gst::ClockTime, gst::ClockTime), glib::BoolError>;
|
||||
|
||||
#[cfg(any(feature = "v1_18", feature = "dox"))]
|
||||
|
@ -49,28 +43,6 @@ impl<O: IsA<BaseSrc>> BaseSrcExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn start_complete(&self, ret: Result<gst::FlowSuccess, gst::FlowError>) {
|
||||
let ret: gst::FlowReturn = ret.into();
|
||||
unsafe {
|
||||
ffi::gst_base_src_start_complete(self.as_ref().to_glib_none().0, ret.into_glib());
|
||||
}
|
||||
}
|
||||
|
||||
fn start_wait(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn =
|
||||
unsafe { from_glib(ffi::gst_base_src_start_wait(self.as_ref().to_glib_none().0)) };
|
||||
ret.into_result()
|
||||
}
|
||||
|
||||
fn wait_playing(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_base_src_wait_playing(
|
||||
self.as_ref().to_glib_none().0,
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
|
||||
fn query_latency(&self) -> Result<(bool, gst::ClockTime, gst::ClockTime), glib::BoolError> {
|
||||
unsafe {
|
||||
let mut live = mem::MaybeUninit::uninit();
|
||||
|
|
|
@ -65,13 +65,12 @@ impl FlowCombiner {
|
|||
fret: FRet,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let fret: gst::FlowReturn = fret.into();
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_flow_combiner_update_flow(
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(ffi::gst_flow_combiner_update_flow(
|
||||
self.to_glib_none().0,
|
||||
fret.into_glib(),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_pad_flow<P: IsA<gst::Pad>, FRet: Into<gst::FlowReturn>>(
|
||||
|
@ -80,14 +79,13 @@ impl FlowCombiner {
|
|||
fret: FRet,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let fret: gst::FlowReturn = fret.into();
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_flow_combiner_update_pad_flow(
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(ffi::gst_flow_combiner_update_pad_flow(
|
||||
self.to_glib_none().0,
|
||||
pad.as_ref().to_glib_none().0,
|
||||
fret.into_glib(),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -288,13 +288,12 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
|
|||
(*parent_class)
|
||||
.flush
|
||||
.map(|f| {
|
||||
from_glib(f(aggregator
|
||||
gst::FlowSuccess::try_from_glib(f(aggregator
|
||||
.unsafe_cast_ref::<Aggregator>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
})
|
||||
.unwrap_or(gst::FlowReturn::Ok)
|
||||
.into_result()
|
||||
.unwrap_or(Ok(gst::FlowSuccess::Ok))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -329,11 +328,10 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
|
|||
let f = (*parent_class)
|
||||
.finish_buffer
|
||||
.expect("Missing parent function `finish_buffer`");
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
|
||||
buffer.into_ptr(),
|
||||
))
|
||||
.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,11 +348,10 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
|
|||
let f = (*parent_class)
|
||||
.finish_buffer_list
|
||||
.expect("Missing parent function `finish_buffer_list`");
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
|
||||
buffer_list.into_ptr(),
|
||||
))
|
||||
.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -392,12 +389,11 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
|
|||
let f = (*parent_class)
|
||||
.sink_event_pre_queue
|
||||
.expect("Missing parent function `sink_event_pre_queue`");
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
|
||||
aggregator_pad.to_glib_none().0,
|
||||
event.into_ptr(),
|
||||
))
|
||||
.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -506,11 +502,10 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
|
|||
let f = (*parent_class)
|
||||
.aggregate
|
||||
.expect("Missing parent function `aggregate`");
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
|
||||
timeout.into_glib(),
|
||||
))
|
||||
.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -613,12 +608,12 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
|
|||
.expect("Missing parent function `update_src_caps`");
|
||||
|
||||
let mut out_caps = ptr::null_mut();
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
|
||||
caps.as_mut_ptr(),
|
||||
&mut out_caps,
|
||||
))
|
||||
.into_result_value(|| from_glib_full(out_caps))
|
||||
.map(|_| from_glib_full(out_caps))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ impl<T: AggregatorPadImpl> AggregatorPadImplExt for T {
|
|||
(*parent_class)
|
||||
.flush
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
aggregator_pad
|
||||
.unsafe_cast_ref::<AggregatorPad>()
|
||||
.to_glib_none()
|
||||
|
@ -62,8 +62,7 @@ impl<T: AggregatorPadImpl> AggregatorPadImplExt for T {
|
|||
aggregator.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
.unwrap_or(gst::FlowReturn::Ok)
|
||||
.into_result()
|
||||
.unwrap_or(Ok(gst::FlowSuccess::Ok))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -149,22 +149,17 @@ impl<T: BaseParseImpl> BaseParseImplExt for T {
|
|||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseParseClass;
|
||||
let mut skipsize = 0;
|
||||
let res = (*parent_class).handle_frame.map(|f| {
|
||||
let res = gst::FlowReturn::from_glib(f(
|
||||
(*parent_class)
|
||||
.handle_frame
|
||||
.map(|f| {
|
||||
let res = gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseParse>().to_glib_none().0,
|
||||
frame.to_glib_none().0,
|
||||
&mut skipsize,
|
||||
));
|
||||
(res, skipsize as u32)
|
||||
});
|
||||
|
||||
match res {
|
||||
Some((res, skipsize)) => {
|
||||
let res = res.into_result();
|
||||
Ok((res.unwrap(), skipsize))
|
||||
}
|
||||
None => Err(gst::FlowError::Error),
|
||||
}
|
||||
(res.unwrap(), skipsize as u32)
|
||||
})
|
||||
.ok_or(gst::FlowError::Error)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -179,13 +179,12 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
(*parent_class)
|
||||
.render
|
||||
.map(|f| {
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
|
||||
buffer.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
.unwrap_or(gst::FlowReturn::Ok)
|
||||
.into_result()
|
||||
.unwrap_or(Ok(gst::FlowSuccess::Ok))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,13 +199,12 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
(*parent_class)
|
||||
.prepare
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
|
||||
buffer.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
.unwrap_or(gst::FlowReturn::Ok)
|
||||
.into_result()
|
||||
.unwrap_or(Ok(gst::FlowSuccess::Ok))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,11 +219,10 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
(*parent_class)
|
||||
.render_list
|
||||
.map(|f| {
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
|
||||
list.to_glib_none().0,
|
||||
))
|
||||
.into_result()
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
for buffer in list.iter() {
|
||||
|
@ -247,11 +244,10 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
(*parent_class)
|
||||
.prepare_list
|
||||
.map(|f| {
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
|
||||
list.to_glib_none().0,
|
||||
))
|
||||
.into_result()
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
for buffer in list.iter() {
|
||||
|
|
|
@ -284,15 +284,14 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
(*parent_class)
|
||||
.fill
|
||||
.map(|f| {
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
|
||||
offset,
|
||||
length,
|
||||
buffer.as_mut_ptr(),
|
||||
))
|
||||
})
|
||||
.unwrap_or(gst::FlowReturn::NotSupported)
|
||||
.into_result()
|
||||
.unwrap_or(Err(gst::FlowError::NotSupported))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -314,13 +313,13 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3
|
||||
let buffer_ref = &mut buffer_ptr as *mut _ as *mut gst::ffi::GstBuffer;
|
||||
|
||||
let res = gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
|
||||
offset,
|
||||
length,
|
||||
buffer_ref,
|
||||
));
|
||||
res.into_result_value(|| from_glib_full(buffer_ptr))
|
||||
))
|
||||
.map(|_| from_glib_full(buffer_ptr))
|
||||
})
|
||||
.unwrap_or(Err(gst::FlowError::NotSupported))
|
||||
}
|
||||
|
@ -349,14 +348,14 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3
|
||||
let buffer_ref = &mut buffer_ptr as *mut _ as *mut gst::ffi::GstBuffer;
|
||||
|
||||
gst::FlowReturn::from_glib(
|
||||
gst::FlowSuccess::try_from_glib(
|
||||
f(
|
||||
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
|
||||
offset,
|
||||
length,
|
||||
buffer_ref,
|
||||
)
|
||||
).into_result()?;
|
||||
)?;
|
||||
|
||||
if let Some(passed_buffer) = buffer {
|
||||
if buffer_ptr != orig_buffer_ptr {
|
||||
|
|
|
@ -572,23 +572,19 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
|
|||
.map(|f| {
|
||||
let mut outbuf: *mut gst::ffi::GstBuffer = ptr::null_mut();
|
||||
// FIXME: Wrong signature in FFI
|
||||
let res = from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
||||
inbuf.as_ptr() as *mut gst::ffi::GstBuffer,
|
||||
(&mut outbuf) as *mut *mut gst::ffi::GstBuffer as *mut gst::ffi::GstBuffer,
|
||||
));
|
||||
|
||||
match gst::FlowReturn::into_result(res) {
|
||||
Err(err) => Err(err),
|
||||
Ok(_) => {
|
||||
))
|
||||
.map(|_| {
|
||||
if outbuf == inbuf.as_ptr() as *mut _ {
|
||||
Ok(PrepareOutputBufferSuccess::InputBuffer)
|
||||
PrepareOutputBufferSuccess::InputBuffer
|
||||
} else {
|
||||
Ok(PrepareOutputBufferSuccess::Buffer(from_glib_full(outbuf)))
|
||||
}
|
||||
}
|
||||
PrepareOutputBufferSuccess::Buffer(from_glib_full(outbuf))
|
||||
}
|
||||
})
|
||||
})
|
||||
.unwrap_or(Err(gst::FlowError::NotSupported))
|
||||
}
|
||||
}
|
||||
|
@ -605,7 +601,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
|
|||
(*parent_class)
|
||||
.transform
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
||||
inbuf.to_glib_none().0,
|
||||
outbuf.as_mut_ptr(),
|
||||
|
@ -613,7 +609,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
|
|||
})
|
||||
.unwrap_or_else(|| {
|
||||
if !element.unsafe_cast_ref::<BaseTransform>().is_in_place() {
|
||||
gst::FlowReturn::NotSupported
|
||||
Err(gst::FlowError::NotSupported)
|
||||
} else {
|
||||
unreachable!(concat!(
|
||||
"parent `transform` called ",
|
||||
|
@ -621,7 +617,6 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
|
|||
));
|
||||
}
|
||||
})
|
||||
.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -647,11 +642,10 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
|
|||
}
|
||||
});
|
||||
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
||||
buf.as_mut_ptr() as *mut _,
|
||||
))
|
||||
.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -679,11 +673,10 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
|
|||
|
||||
// FIXME: Wrong signature in FFI
|
||||
let buf: *mut gst::ffi::GstBuffer = buf.to_glib_none().0;
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
||||
buf as *mut _,
|
||||
))
|
||||
.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -762,12 +755,11 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
|
|||
.submit_input_buffer
|
||||
.expect("Missing parent function `submit_input_buffer`");
|
||||
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
||||
is_discont.into_glib(),
|
||||
inbuf.into_ptr(),
|
||||
))
|
||||
.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -783,11 +775,10 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
|
|||
.expect("Missing parent function `generate_output`");
|
||||
|
||||
let mut outbuf = ptr::null_mut();
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
|
||||
&mut outbuf,
|
||||
))
|
||||
.into_result()
|
||||
.map(|res| {
|
||||
if res == crate::BASE_TRANSFORM_FLOW_DROPPED {
|
||||
GenerateOutputSuccess::Dropped
|
||||
|
|
|
@ -51,13 +51,12 @@ impl<T: PushSrcImpl> PushSrcImplExt for T {
|
|||
(*parent_class)
|
||||
.fill
|
||||
.map(|f| {
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<PushSrc>().to_glib_none().0,
|
||||
buffer.as_mut_ptr(),
|
||||
))
|
||||
})
|
||||
.unwrap_or(gst::FlowReturn::NotSupported)
|
||||
.into_result()
|
||||
.unwrap_or(Err(gst::FlowError::NotSupported))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,11 +73,11 @@ impl<T: PushSrcImpl> PushSrcImplExt for T {
|
|||
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3
|
||||
let buffer_ref = &mut buffer_ptr as *mut _ as *mut gst::ffi::GstBuffer;
|
||||
|
||||
let res = gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<PushSrc>().to_glib_none().0,
|
||||
buffer_ref,
|
||||
));
|
||||
res.into_result_value(|| from_glib_full(buffer_ref))
|
||||
))
|
||||
.map(|_| from_glib_full(buffer_ref))
|
||||
})
|
||||
.unwrap_or(Err(gst::FlowError::NotSupported))
|
||||
}
|
||||
|
@ -97,11 +96,11 @@ impl<T: PushSrcImpl> PushSrcImplExt for T {
|
|||
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3
|
||||
let buffer_ref = &mut buffer_ptr as *mut _ as *mut gst::ffi::GstBuffer;
|
||||
|
||||
let res = gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<PushSrc>().to_glib_none().0,
|
||||
buffer_ref,
|
||||
));
|
||||
res.into_result_value(|| from_glib_full(buffer_ref))
|
||||
))
|
||||
.map(|_| from_glib_full(buffer_ref))
|
||||
})
|
||||
.unwrap_or(Err(gst::FlowError::NotSupported))
|
||||
}
|
||||
|
|
|
@ -272,9 +272,12 @@ impl Harness {
|
|||
}
|
||||
|
||||
pub fn push(&mut self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn =
|
||||
unsafe { from_glib(ffi::gst_harness_push(self.0.as_ptr(), buffer.into_ptr())) };
|
||||
ret.into_result()
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(ffi::gst_harness_push(
|
||||
self.0.as_ptr(),
|
||||
buffer.into_ptr(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn push_and_pull(&mut self, buffer: gst::Buffer) -> Result<gst::Buffer, glib::BoolError> {
|
||||
|
@ -297,15 +300,11 @@ impl Harness {
|
|||
}
|
||||
|
||||
pub fn push_from_src(&mut self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn =
|
||||
unsafe { from_glib(ffi::gst_harness_push_from_src(self.0.as_ptr())) };
|
||||
ret.into_result()
|
||||
unsafe { gst::FlowSuccess::try_from_glib(ffi::gst_harness_push_from_src(self.0.as_ptr())) }
|
||||
}
|
||||
|
||||
pub fn push_to_sink(&mut self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn =
|
||||
unsafe { from_glib(ffi::gst_harness_push_to_sink(self.0.as_ptr())) };
|
||||
ret.into_result()
|
||||
unsafe { gst::FlowSuccess::try_from_glib(ffi::gst_harness_push_to_sink(self.0.as_ptr())) }
|
||||
}
|
||||
|
||||
pub fn push_upstream_event(&mut self, event: gst::Event) -> bool {
|
||||
|
@ -403,13 +402,12 @@ impl Harness {
|
|||
}
|
||||
|
||||
pub fn sink_push_many(&mut self, pushes: u32) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_harness_sink_push_many(
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(ffi::gst_harness_sink_push_many(
|
||||
self.0.as_ptr(),
|
||||
pushes as i32,
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn src_crank_and_push_many(
|
||||
|
@ -417,14 +415,13 @@ impl Harness {
|
|||
cranks: u32,
|
||||
pushes: u32,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_harness_src_crank_and_push_many(
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(ffi::gst_harness_src_crank_and_push_many(
|
||||
self.0.as_ptr(),
|
||||
cranks as i32,
|
||||
pushes as i32,
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn src_push_event(&mut self) -> bool {
|
||||
|
|
|
@ -39,8 +39,6 @@ mod rtsp_media;
|
|||
mod rtsp_media_factory;
|
||||
mod rtsp_server;
|
||||
mod rtsp_session_pool;
|
||||
mod rtsp_stream;
|
||||
mod rtsp_stream_transport;
|
||||
mod rtsp_thread;
|
||||
mod rtsp_token;
|
||||
|
||||
|
@ -129,6 +127,4 @@ pub mod prelude {
|
|||
pub use crate::rtsp_media_factory::RTSPMediaFactoryExtManual;
|
||||
pub use crate::rtsp_server::RTSPServerExtManual;
|
||||
pub use crate::rtsp_session_pool::RTSPSessionPoolExtManual;
|
||||
pub use crate::rtsp_stream::RTSPStreamExtManual;
|
||||
pub use crate::rtsp_stream_transport::RTSPStreamTransportExtManual;
|
||||
}
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
|
||||
use crate::RTSPStream;
|
||||
use glib::prelude::*;
|
||||
use glib::translate::*;
|
||||
|
||||
pub trait RTSPStreamExtManual: 'static {
|
||||
fn recv_rtcp(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn recv_rtp(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
}
|
||||
|
||||
impl<O: IsA<RTSPStream>> RTSPStreamExtManual for O {
|
||||
fn recv_rtcp(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_rtsp_stream_recv_rtcp(
|
||||
self.as_ref().to_glib_none().0,
|
||||
buffer.to_glib_full(),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
|
||||
fn recv_rtp(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_rtsp_stream_recv_rtp(
|
||||
self.as_ref().to_glib_none().0,
|
||||
buffer.to_glib_full(),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
|
||||
use crate::RTSPStreamTransport;
|
||||
use glib::prelude::*;
|
||||
use glib::translate::*;
|
||||
|
||||
pub trait RTSPStreamTransportExtManual: 'static {
|
||||
fn recv_data(
|
||||
&self,
|
||||
channel: u32,
|
||||
buffer: &gst::Buffer,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
}
|
||||
|
||||
impl<O: IsA<RTSPStreamTransport>> RTSPStreamTransportExtManual for O {
|
||||
fn recv_data(
|
||||
&self,
|
||||
channel: u32,
|
||||
buffer: &gst::Buffer,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_rtsp_stream_transport_recv_data(
|
||||
self.as_ref().to_glib_none().0,
|
||||
channel,
|
||||
buffer.to_glib_full(),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
|
@ -269,13 +269,12 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
(*parent_class)
|
||||
.finish
|
||||
.map(|f| {
|
||||
gst::FlowReturn::from_glib(f(element
|
||||
gst::FlowSuccess::try_from_glib(f(element
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
})
|
||||
.unwrap_or(gst::FlowReturn::Ok)
|
||||
.into_result()
|
||||
.unwrap_or(Ok(gst::FlowSuccess::Ok))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,13 +285,12 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
(*parent_class)
|
||||
.drain
|
||||
.map(|f| {
|
||||
gst::FlowReturn::from_glib(f(element
|
||||
gst::FlowSuccess::try_from_glib(f(element
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
})
|
||||
.unwrap_or(gst::FlowReturn::Ok)
|
||||
.into_result()
|
||||
.unwrap_or(Ok(gst::FlowSuccess::Ok))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -333,15 +331,14 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
(*parent_class)
|
||||
.parse
|
||||
.map(|f| {
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||
frame.to_glib_none().0,
|
||||
adapter.to_glib_none().0,
|
||||
at_eos.into_glib(),
|
||||
))
|
||||
})
|
||||
.unwrap_or(gst::FlowReturn::Ok)
|
||||
.into_result()
|
||||
.unwrap_or(Ok(gst::FlowSuccess::Ok))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -356,13 +353,12 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
(*parent_class)
|
||||
.handle_frame
|
||||
.map(|f| {
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||
frame.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
.unwrap_or(gst::FlowReturn::Error)
|
||||
.into_result()
|
||||
.unwrap_or(Err(gst::FlowError::Error))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -245,13 +245,12 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
(*parent_class)
|
||||
.finish
|
||||
.map(|f| {
|
||||
gst::FlowReturn::from_glib(f(element
|
||||
gst::FlowSuccess::try_from_glib(f(element
|
||||
.unsafe_cast_ref::<VideoEncoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
})
|
||||
.unwrap_or(gst::FlowReturn::Ok)
|
||||
.into_result()
|
||||
.unwrap_or(Ok(gst::FlowSuccess::Ok))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -290,13 +289,12 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
(*parent_class)
|
||||
.handle_frame
|
||||
.map(|f| {
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||
frame.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
.unwrap_or(gst::FlowReturn::Error)
|
||||
.into_result()
|
||||
.unwrap_or(Err(gst::FlowError::Error))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,13 +37,12 @@ impl<T: VideoSinkImpl> VideoSinkImplExt for T {
|
|||
(*parent_class)
|
||||
.show_frame
|
||||
.map(|f| {
|
||||
gst::FlowReturn::from_glib(f(
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoSink>().to_glib_none().0,
|
||||
buffer.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
.unwrap_or(gst::FlowReturn::Error)
|
||||
.into_result()
|
||||
.unwrap_or(Err(gst::FlowError::Error))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,6 @@ pub trait VideoDecoderExtManual: 'static {
|
|||
#[doc(alias = "get_allocator")]
|
||||
fn allocator(&self) -> (Option<gst::Allocator>, gst::AllocationParams);
|
||||
|
||||
fn have_frame(&self) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
fn finish_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
fn release_frame(&self, frame: VideoCodecFrame);
|
||||
fn drop_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
@ -101,15 +100,16 @@ impl<O: IsA<VideoDecoder>> VideoDecoderExtManual for O {
|
|||
frame: &mut VideoCodecFrame,
|
||||
params: Option<&gst::BufferPoolAcquireParams>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
unsafe {
|
||||
let params_ptr = params.to_glib_none().0 as *mut _;
|
||||
from_glib(ffi::gst_video_decoder_allocate_output_frame_with_params(
|
||||
gst::FlowSuccess::try_from_glib(
|
||||
ffi::gst_video_decoder_allocate_output_frame_with_params(
|
||||
self.as_ref().to_glib_none().0,
|
||||
frame.to_glib_none().0,
|
||||
params_ptr,
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn allocator(&self) -> (Option<gst::Allocator>, gst::AllocationParams) {
|
||||
|
@ -125,23 +125,13 @@ impl<O: IsA<VideoDecoder>> VideoDecoderExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn have_frame(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_video_decoder_have_frame(
|
||||
self.as_ref().to_glib_none().0,
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
|
||||
fn finish_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_video_decoder_finish_frame(
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(ffi::gst_video_decoder_finish_frame(
|
||||
self.as_ref().to_glib_none().0,
|
||||
frame.into_ptr(),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
fn release_frame(&self, frame: VideoCodecFrame) {
|
||||
|
@ -151,13 +141,12 @@ impl<O: IsA<VideoDecoder>> VideoDecoderExtManual for O {
|
|||
}
|
||||
|
||||
fn drop_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_video_decoder_drop_frame(
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(ffi::gst_video_decoder_drop_frame(
|
||||
self.as_ref().to_glib_none().0,
|
||||
frame.into_ptr(),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
fn latency(&self) -> (gst::ClockTime, gst::ClockTime) {
|
||||
|
@ -327,8 +316,8 @@ impl<O: IsA<VideoDecoder>> VideoDecoderExtManual for O {
|
|||
function: &str,
|
||||
line: u32,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(_gst_video_decoder_error(
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(_gst_video_decoder_error(
|
||||
self.as_ref().to_glib_none().0,
|
||||
weight,
|
||||
T::domain().into_glib(),
|
||||
|
@ -339,8 +328,7 @@ impl<O: IsA<VideoDecoder>> VideoDecoderExtManual for O {
|
|||
function.to_glib_none().0,
|
||||
line as i32,
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,14 +63,13 @@ impl<O: IsA<VideoEncoder>> VideoEncoderExtManual for O {
|
|||
frame: &mut VideoCodecFrame,
|
||||
size: usize,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_video_encoder_allocate_output_frame(
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(ffi::gst_video_encoder_allocate_output_frame(
|
||||
self.as_ref().to_glib_none().0,
|
||||
frame.to_glib_none().0,
|
||||
size,
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
fn allocator(&self) -> (Option<gst::Allocator>, gst::AllocationParams) {
|
||||
|
@ -90,25 +89,23 @@ impl<O: IsA<VideoEncoder>> VideoEncoderExtManual for O {
|
|||
&self,
|
||||
frame: Option<VideoCodecFrame>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_video_encoder_finish_frame(
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(ffi::gst_video_encoder_finish_frame(
|
||||
self.as_ref().to_glib_none().0,
|
||||
frame.map(|f| f.into_ptr()).unwrap_or(ptr::null_mut()),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_18", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
|
||||
fn finish_subframe(&self, frame: &VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let ret: gst::FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_video_encoder_finish_subframe(
|
||||
unsafe {
|
||||
gst::FlowSuccess::try_from_glib(ffi::gst_video_encoder_finish_subframe(
|
||||
self.as_ref().to_glib_none().0,
|
||||
frame.to_glib_none().0,
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
fn latency(&self) -> (gst::ClockTime, gst::ClockTime) {
|
||||
|
|
|
@ -6,9 +6,7 @@ use crate::BufferPool;
|
|||
use crate::Structure;
|
||||
|
||||
use glib::prelude::*;
|
||||
use glib::translate::{
|
||||
from_glib, from_glib_full, from_glib_none, IntoGlib, ToGlibPtr, ToGlibPtrMut,
|
||||
};
|
||||
use glib::translate::*;
|
||||
|
||||
use std::mem;
|
||||
use std::ops;
|
||||
|
@ -334,13 +332,12 @@ impl<O: IsA<BufferPool>> BufferPoolExtManual for O {
|
|||
|
||||
unsafe {
|
||||
let mut buffer = ptr::null_mut();
|
||||
let ret: crate::FlowReturn = from_glib(ffi::gst_buffer_pool_acquire_buffer(
|
||||
crate::FlowSuccess::try_from_glib(ffi::gst_buffer_pool_acquire_buffer(
|
||||
self.as_ref().to_glib_none().0,
|
||||
&mut buffer,
|
||||
params_ptr,
|
||||
));
|
||||
|
||||
ret.into_result_value(|| from_glib_full(buffer))
|
||||
))
|
||||
.map(|_| from_glib_full(buffer))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,9 +45,11 @@ impl ClockId {
|
|||
pub fn wait(&self) -> (Result<ClockSuccess, ClockError>, ClockTimeDiff) {
|
||||
unsafe {
|
||||
let mut jitter = 0;
|
||||
let res: ClockReturn =
|
||||
from_glib(ffi::gst_clock_id_wait(self.to_glib_none().0, &mut jitter));
|
||||
(res.into_result(), jitter)
|
||||
let res = ClockSuccess::try_from_glib(ffi::gst_clock_id_wait(
|
||||
self.to_glib_none().0,
|
||||
&mut jitter,
|
||||
));
|
||||
(res, jitter)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,15 +162,14 @@ impl SingleShotClockId {
|
|||
|
||||
let func: Box<Option<F>> = Box::new(Some(func));
|
||||
|
||||
let ret: ClockReturn = unsafe {
|
||||
from_glib(ffi::gst_clock_id_wait_async(
|
||||
unsafe {
|
||||
ClockSuccess::try_from_glib(ffi::gst_clock_id_wait_async(
|
||||
self.to_glib_none().0,
|
||||
Some(trampoline::<F>),
|
||||
Box::into_raw(func) as gpointer,
|
||||
Some(destroy_notify::<F>),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
|
@ -264,15 +265,14 @@ impl PeriodicClockId {
|
|||
}
|
||||
|
||||
let func: Box<F> = Box::new(func);
|
||||
let ret: ClockReturn = unsafe {
|
||||
from_glib(ffi::gst_clock_id_wait_async(
|
||||
unsafe {
|
||||
ClockSuccess::try_from_glib(ffi::gst_clock_id_wait_async(
|
||||
self.to_glib_none().0,
|
||||
Some(trampoline::<F>),
|
||||
Box::into_raw(func) as gpointer,
|
||||
Some(destroy_notify::<F>),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
|
|
|
@ -18,10 +18,6 @@ use crate::QueryRef;
|
|||
use crate::Rank;
|
||||
use crate::SpecificFormattedValue;
|
||||
use crate::State;
|
||||
use crate::StateChange;
|
||||
use crate::StateChangeError;
|
||||
use crate::StateChangeReturn;
|
||||
use crate::StateChangeSuccess;
|
||||
|
||||
use glib::translate::*;
|
||||
|
||||
|
@ -116,29 +112,11 @@ pub trait ElementExtManual: 'static {
|
|||
#[doc(alias = "get_element_class")]
|
||||
fn element_class(&self) -> &glib::Class<Element>;
|
||||
|
||||
fn change_state(&self, transition: StateChange)
|
||||
-> Result<StateChangeSuccess, StateChangeError>;
|
||||
fn continue_state(
|
||||
&self,
|
||||
ret: StateChangeReturn,
|
||||
) -> Result<StateChangeSuccess, StateChangeError>;
|
||||
|
||||
#[doc(alias = "get_state")]
|
||||
fn state(
|
||||
&self,
|
||||
timeout: ClockTime,
|
||||
) -> (Result<StateChangeSuccess, StateChangeError>, State, State);
|
||||
fn set_state(&self, state: State) -> Result<StateChangeSuccess, StateChangeError>;
|
||||
|
||||
#[doc(alias = "get_current_state")]
|
||||
fn current_state(&self) -> State {
|
||||
self.state(ClockTime::from(0)).1
|
||||
}
|
||||
fn current_state(&self) -> State;
|
||||
|
||||
#[doc(alias = "get_pending_state")]
|
||||
fn pending_state(&self) -> State {
|
||||
self.state(ClockTime::from(0)).2
|
||||
}
|
||||
fn pending_state(&self) -> State;
|
||||
|
||||
fn query(&self, query: &mut QueryRef) -> bool;
|
||||
|
||||
|
@ -283,61 +261,12 @@ impl<O: IsA<Element>> ElementExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn change_state(
|
||||
&self,
|
||||
transition: StateChange,
|
||||
) -> Result<StateChangeSuccess, StateChangeError> {
|
||||
let ret: StateChangeReturn = unsafe {
|
||||
from_glib(ffi::gst_element_change_state(
|
||||
self.as_ref().to_glib_none().0,
|
||||
transition.into_glib(),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
fn current_state(&self) -> State {
|
||||
self.state(ClockTime::zero()).1
|
||||
}
|
||||
|
||||
fn continue_state(
|
||||
&self,
|
||||
ret: StateChangeReturn,
|
||||
) -> Result<StateChangeSuccess, StateChangeError> {
|
||||
let ret: StateChangeReturn = unsafe {
|
||||
from_glib(ffi::gst_element_continue_state(
|
||||
self.as_ref().to_glib_none().0,
|
||||
ret.into_glib(),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
|
||||
fn state(
|
||||
&self,
|
||||
timeout: ClockTime,
|
||||
) -> (Result<StateChangeSuccess, StateChangeError>, State, State) {
|
||||
unsafe {
|
||||
let mut state = mem::MaybeUninit::uninit();
|
||||
let mut pending = mem::MaybeUninit::uninit();
|
||||
let ret: StateChangeReturn = from_glib(ffi::gst_element_get_state(
|
||||
self.as_ref().to_glib_none().0,
|
||||
state.as_mut_ptr(),
|
||||
pending.as_mut_ptr(),
|
||||
timeout.into_glib(),
|
||||
));
|
||||
(
|
||||
ret.into_result(),
|
||||
from_glib(state.assume_init()),
|
||||
from_glib(pending.assume_init()),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn set_state(&self, state: State) -> Result<StateChangeSuccess, StateChangeError> {
|
||||
let ret: StateChangeReturn = unsafe {
|
||||
from_glib(ffi::gst_element_set_state(
|
||||
self.as_ref().to_glib_none().0,
|
||||
state.into_glib(),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
fn pending_state(&self) -> State {
|
||||
self.state(ClockTime::zero()).2
|
||||
}
|
||||
|
||||
fn query(&self, query: &mut QueryRef) -> bool {
|
||||
|
|
|
@ -16,6 +16,58 @@ use glib::value::Value;
|
|||
use glib::StaticType;
|
||||
use glib::Type;
|
||||
|
||||
macro_rules! impl_return_result_traits {
|
||||
($ffi_type:ident, $ret_type:ident, $ok_type:ident, $err_type:ident) => {
|
||||
impl From<$ok_type> for $ret_type {
|
||||
fn from(value: $ok_type) -> Self {
|
||||
skip_assert_initialized!();
|
||||
$ret_type::from_ok(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoGlib for $ok_type {
|
||||
type GlibType = <$ret_type as IntoGlib>::GlibType;
|
||||
|
||||
fn into_glib(self) -> Self::GlibType {
|
||||
$ret_type::from_ok(self).into_glib()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<$err_type> for $ret_type {
|
||||
fn from(value: $err_type) -> Self {
|
||||
skip_assert_initialized!();
|
||||
$ret_type::from_error(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl IntoGlib for $err_type {
|
||||
type GlibType = <$ret_type as IntoGlib>::GlibType;
|
||||
|
||||
fn into_glib(self) -> Self::GlibType {
|
||||
$ret_type::from_error(self).into_glib()
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Result<$ok_type, $err_type>> for $ret_type {
|
||||
fn from(res: Result<$ok_type, $err_type>) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match res {
|
||||
Ok(success) => $ret_type::from_ok(success),
|
||||
Err(error) => $ret_type::from_error(error),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFromGlib<ffi::$ffi_type> for $ok_type {
|
||||
type Error = $err_type;
|
||||
fn try_from_glib(val: ffi::$ffi_type) -> Result<$ok_type, $err_type> {
|
||||
skip_assert_initialized!();
|
||||
unsafe { $ret_type::from_glib(val) }.into_result()
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
impl StateChangeReturn {
|
||||
pub fn into_result(self) -> Result<StateChangeSuccess, StateChangeError> {
|
||||
match self {
|
||||
|
@ -49,34 +101,17 @@ pub enum StateChangeSuccess {
|
|||
NoPreroll,
|
||||
}
|
||||
|
||||
impl From<StateChangeSuccess> for StateChangeReturn {
|
||||
fn from(value: StateChangeSuccess) -> Self {
|
||||
skip_assert_initialized!();
|
||||
StateChangeReturn::from_ok(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Error)]
|
||||
#[must_use]
|
||||
#[error("Element failed to change its state")]
|
||||
pub struct StateChangeError;
|
||||
|
||||
impl From<StateChangeError> for StateChangeReturn {
|
||||
fn from(value: StateChangeError) -> Self {
|
||||
skip_assert_initialized!();
|
||||
StateChangeReturn::from_error(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Result<StateChangeSuccess, StateChangeError>> for StateChangeReturn {
|
||||
fn from(res: Result<StateChangeSuccess, StateChangeError>) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match res {
|
||||
Ok(success) => StateChangeReturn::from_ok(success),
|
||||
Err(error) => StateChangeReturn::from_error(error),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl_return_result_traits!(
|
||||
GstStateChangeReturn,
|
||||
StateChangeReturn,
|
||||
StateChangeSuccess,
|
||||
StateChangeError
|
||||
);
|
||||
|
||||
impl FlowReturn {
|
||||
pub fn into_result(self) -> Result<FlowSuccess, FlowError> {
|
||||
|
@ -98,13 +133,6 @@ impl FlowReturn {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn into_result_value<T, F: FnOnce() -> T>(self, func: F) -> Result<T, FlowError> {
|
||||
match self.into_result() {
|
||||
Ok(_) => Ok(func()),
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_error(v: FlowError) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match v {
|
||||
|
@ -139,13 +167,6 @@ pub enum FlowSuccess {
|
|||
Ok,
|
||||
}
|
||||
|
||||
impl From<FlowSuccess> for FlowReturn {
|
||||
fn from(value: FlowSuccess) -> Self {
|
||||
skip_assert_initialized!();
|
||||
FlowReturn::from_ok(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Error)]
|
||||
#[must_use]
|
||||
pub enum FlowError {
|
||||
|
@ -169,22 +190,7 @@ pub enum FlowError {
|
|||
CustomError2,
|
||||
}
|
||||
|
||||
impl From<FlowError> for FlowReturn {
|
||||
fn from(value: FlowError) -> Self {
|
||||
skip_assert_initialized!();
|
||||
FlowReturn::from_error(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Result<FlowSuccess, FlowError>> for FlowReturn {
|
||||
fn from(res: Result<FlowSuccess, FlowError>) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match res {
|
||||
Ok(success) => FlowReturn::from_ok(success),
|
||||
Err(error) => FlowReturn::from_error(error),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl_return_result_traits!(GstFlowReturn, FlowReturn, FlowSuccess, FlowError);
|
||||
|
||||
impl PadLinkReturn {
|
||||
pub fn into_result(self) -> Result<PadLinkSuccess, PadLinkError> {
|
||||
|
@ -221,13 +227,6 @@ impl PadLinkReturn {
|
|||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
|
||||
pub struct PadLinkSuccess;
|
||||
|
||||
impl From<PadLinkSuccess> for PadLinkReturn {
|
||||
fn from(value: PadLinkSuccess) -> Self {
|
||||
skip_assert_initialized!();
|
||||
PadLinkReturn::from_ok(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Error)]
|
||||
#[must_use]
|
||||
pub enum PadLinkError {
|
||||
|
@ -245,22 +244,12 @@ pub enum PadLinkError {
|
|||
Refused,
|
||||
}
|
||||
|
||||
impl From<PadLinkError> for PadLinkReturn {
|
||||
fn from(value: PadLinkError) -> Self {
|
||||
skip_assert_initialized!();
|
||||
PadLinkReturn::from_error(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Result<PadLinkSuccess, PadLinkError>> for PadLinkReturn {
|
||||
fn from(res: Result<PadLinkSuccess, PadLinkError>) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match res {
|
||||
Ok(success) => PadLinkReturn::from_ok(success),
|
||||
Err(error) => PadLinkReturn::from_error(error),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl_return_result_traits!(
|
||||
GstPadLinkReturn,
|
||||
PadLinkReturn,
|
||||
PadLinkSuccess,
|
||||
PadLinkError
|
||||
);
|
||||
|
||||
impl ClockReturn {
|
||||
pub fn into_result(self) -> Result<ClockSuccess, ClockError> {
|
||||
|
@ -304,13 +293,6 @@ pub enum ClockSuccess {
|
|||
Done,
|
||||
}
|
||||
|
||||
impl From<ClockSuccess> for ClockReturn {
|
||||
fn from(value: ClockSuccess) -> Self {
|
||||
skip_assert_initialized!();
|
||||
ClockReturn::from_ok(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Error)]
|
||||
#[must_use]
|
||||
pub enum ClockError {
|
||||
|
@ -328,22 +310,7 @@ pub enum ClockError {
|
|||
Unsupported,
|
||||
}
|
||||
|
||||
impl From<ClockError> for ClockReturn {
|
||||
fn from(value: ClockError) -> Self {
|
||||
skip_assert_initialized!();
|
||||
ClockReturn::from_error(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Result<ClockSuccess, ClockError>> for ClockReturn {
|
||||
fn from(res: Result<ClockSuccess, ClockError>) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match res {
|
||||
Ok(success) => ClockReturn::from_ok(success),
|
||||
Err(error) => ClockReturn::from_error(error),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl_return_result_traits!(GstClockReturn, ClockReturn, ClockSuccess, ClockError);
|
||||
|
||||
impl PartialEq for crate::TypeFindProbability {
|
||||
fn eq(&self, other: &crate::TypeFindProbability) -> bool {
|
||||
|
|
|
@ -12,10 +12,6 @@ use crate::GenericFormattedValue;
|
|||
use crate::LoggableError;
|
||||
use crate::Pad;
|
||||
use crate::PadFlags;
|
||||
use crate::PadLinkCheck;
|
||||
use crate::PadLinkError;
|
||||
use crate::PadLinkReturn;
|
||||
use crate::PadLinkSuccess;
|
||||
use crate::PadProbeReturn;
|
||||
use crate::PadProbeType;
|
||||
use crate::Query;
|
||||
|
@ -30,9 +26,7 @@ use std::ptr;
|
|||
|
||||
use glib::ffi::gpointer;
|
||||
use glib::prelude::*;
|
||||
use glib::translate::{
|
||||
from_glib, from_glib_borrow, from_glib_full, FromGlib, FromGlibPtrBorrow, IntoGlib, ToGlibPtr,
|
||||
};
|
||||
use glib::translate::*;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct PadProbeId(NonZeroU64);
|
||||
|
@ -137,22 +131,12 @@ pub trait PadExtManual: 'static {
|
|||
fn push_event(&self, event: Event) -> bool;
|
||||
fn send_event(&self, event: Event) -> bool;
|
||||
|
||||
#[doc(alias = "get_last_flow_result")]
|
||||
fn last_flow_result(&self) -> Result<FlowSuccess, FlowError>;
|
||||
|
||||
fn iterate_internal_links(&self) -> crate::Iterator<Pad>;
|
||||
fn iterate_internal_links_default<P: IsA<crate::Object>>(
|
||||
&self,
|
||||
parent: Option<&P>,
|
||||
) -> crate::Iterator<Pad>;
|
||||
|
||||
fn link<P: IsA<Pad>>(&self, sinkpad: &P) -> Result<PadLinkSuccess, PadLinkError>;
|
||||
fn link_full<P: IsA<Pad>>(
|
||||
&self,
|
||||
sinkpad: &P,
|
||||
flags: PadLinkCheck,
|
||||
) -> Result<PadLinkSuccess, PadLinkError>;
|
||||
|
||||
fn stream_lock(&self) -> StreamLock;
|
||||
|
||||
unsafe fn set_activate_function<F>(&self, func: F)
|
||||
|
@ -269,8 +253,6 @@ pub trait PadExtManual: 'static {
|
|||
func: F,
|
||||
);
|
||||
|
||||
fn store_sticky_event(&self, event: &Event) -> Result<FlowSuccess, FlowError>;
|
||||
|
||||
fn set_pad_flags(&self, flags: PadFlags);
|
||||
|
||||
fn unset_pad_flags(&self, flags: PadFlags);
|
||||
|
@ -310,54 +292,50 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
|
||||
fn chain(&self, buffer: Buffer) -> Result<FlowSuccess, FlowError> {
|
||||
unsafe {
|
||||
FlowReturn::from_glib(ffi::gst_pad_chain(
|
||||
FlowSuccess::try_from_glib(ffi::gst_pad_chain(
|
||||
self.as_ref().to_glib_none().0,
|
||||
buffer.into_ptr(),
|
||||
))
|
||||
.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
fn push(&self, buffer: Buffer) -> Result<FlowSuccess, FlowError> {
|
||||
unsafe {
|
||||
FlowReturn::from_glib(ffi::gst_pad_push(
|
||||
FlowSuccess::try_from_glib(ffi::gst_pad_push(
|
||||
self.as_ref().to_glib_none().0,
|
||||
buffer.into_ptr(),
|
||||
))
|
||||
.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
fn chain_list(&self, list: BufferList) -> Result<FlowSuccess, FlowError> {
|
||||
unsafe {
|
||||
FlowReturn::from_glib(ffi::gst_pad_chain_list(
|
||||
FlowSuccess::try_from_glib(ffi::gst_pad_chain_list(
|
||||
self.as_ref().to_glib_none().0,
|
||||
list.into_ptr(),
|
||||
))
|
||||
.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
fn push_list(&self, list: BufferList) -> Result<FlowSuccess, FlowError> {
|
||||
unsafe {
|
||||
FlowReturn::from_glib(ffi::gst_pad_push_list(
|
||||
FlowSuccess::try_from_glib(ffi::gst_pad_push_list(
|
||||
self.as_ref().to_glib_none().0,
|
||||
list.into_ptr(),
|
||||
))
|
||||
.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
fn range(&self, offset: u64, size: u32) -> Result<Buffer, FlowError> {
|
||||
unsafe {
|
||||
let mut buffer = ptr::null_mut();
|
||||
let ret: FlowReturn = from_glib(ffi::gst_pad_get_range(
|
||||
FlowSuccess::try_from_glib(ffi::gst_pad_get_range(
|
||||
self.as_ref().to_glib_none().0,
|
||||
offset,
|
||||
size,
|
||||
&mut buffer,
|
||||
));
|
||||
ret.into_result_value(|| from_glib_full(buffer))
|
||||
))
|
||||
.map(|_| from_glib_full(buffer))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -371,36 +349,33 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
|
||||
unsafe {
|
||||
let mut buffer_ref = buffer.as_mut_ptr();
|
||||
let ret: FlowReturn = from_glib(ffi::gst_pad_get_range(
|
||||
FlowSuccess::try_from_glib(ffi::gst_pad_get_range(
|
||||
self.as_ref().to_glib_none().0,
|
||||
offset,
|
||||
size,
|
||||
&mut buffer_ref,
|
||||
));
|
||||
match ret.into_result_value(|| ()) {
|
||||
Ok(_) => {
|
||||
))
|
||||
.and_then(|_| {
|
||||
if buffer.as_mut_ptr() != buffer_ref {
|
||||
ffi::gst_mini_object_unref(buffer_ref as *mut _);
|
||||
Err(crate::FlowError::Error)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn pull_range(&self, offset: u64, size: u32) -> Result<Buffer, FlowError> {
|
||||
unsafe {
|
||||
let mut buffer = ptr::null_mut();
|
||||
let ret: FlowReturn = from_glib(ffi::gst_pad_pull_range(
|
||||
FlowSuccess::try_from_glib(ffi::gst_pad_pull_range(
|
||||
self.as_ref().to_glib_none().0,
|
||||
offset,
|
||||
size,
|
||||
&mut buffer,
|
||||
));
|
||||
ret.into_result_value(|| from_glib_full(buffer))
|
||||
))
|
||||
.map(|_| from_glib_full(buffer))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -414,23 +389,20 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
|
||||
unsafe {
|
||||
let mut buffer_ref = buffer.as_mut_ptr();
|
||||
let ret: FlowReturn = from_glib(ffi::gst_pad_pull_range(
|
||||
FlowSuccess::try_from_glib(ffi::gst_pad_pull_range(
|
||||
self.as_ref().to_glib_none().0,
|
||||
offset,
|
||||
size,
|
||||
&mut buffer_ref,
|
||||
));
|
||||
match ret.into_result_value(|| ()) {
|
||||
Ok(_) => {
|
||||
))
|
||||
.and_then(|_| {
|
||||
if buffer.as_mut_ptr() != buffer_ref {
|
||||
ffi::gst_mini_object_unref(buffer_ref as *mut _);
|
||||
Err(crate::FlowError::Error)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -514,15 +486,6 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn last_flow_result(&self) -> Result<FlowSuccess, FlowError> {
|
||||
let ret: FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_pad_get_last_flow_return(
|
||||
self.as_ref().to_glib_none().0,
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
|
||||
fn iterate_internal_links(&self) -> crate::Iterator<Pad> {
|
||||
unsafe {
|
||||
from_glib_full(ffi::gst_pad_iterate_internal_links(
|
||||
|
@ -543,31 +506,6 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn link<P: IsA<Pad>>(&self, sinkpad: &P) -> Result<PadLinkSuccess, PadLinkError> {
|
||||
let ret: PadLinkReturn = unsafe {
|
||||
from_glib(ffi::gst_pad_link(
|
||||
self.as_ref().to_glib_none().0,
|
||||
sinkpad.as_ref().to_glib_none().0,
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
|
||||
fn link_full<P: IsA<Pad>>(
|
||||
&self,
|
||||
sinkpad: &P,
|
||||
flags: PadLinkCheck,
|
||||
) -> Result<PadLinkSuccess, PadLinkError> {
|
||||
let ret: PadLinkReturn = unsafe {
|
||||
from_glib(ffi::gst_pad_link_full(
|
||||
self.as_ref().to_glib_none().0,
|
||||
sinkpad.as_ref().to_glib_none().0,
|
||||
flags.into_glib(),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
|
||||
fn stream_lock(&self) -> StreamLock {
|
||||
unsafe {
|
||||
let ptr: &mut ffi::GstPad = &mut *(self.as_ptr() as *mut _);
|
||||
|
@ -1043,16 +981,6 @@ impl<O: IsA<Pad>> PadExtManual for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn store_sticky_event(&self, event: &Event) -> Result<FlowSuccess, FlowError> {
|
||||
let ret: FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_pad_store_sticky_event(
|
||||
self.as_ref().to_glib_none().0,
|
||||
event.to_glib_none().0,
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
|
||||
fn set_pad_flags(&self, flags: PadFlags) {
|
||||
unsafe {
|
||||
let ptr: *mut ffi::GstObject = self.as_ptr() as *mut _;
|
||||
|
@ -1082,7 +1010,7 @@ unsafe fn create_probe_info<'a>(
|
|||
info: *mut ffi::GstPadProbeInfo,
|
||||
) -> (PadProbeInfo<'a>, Option<glib::Type>) {
|
||||
let mut data_type = None;
|
||||
let flow_ret: FlowReturn = from_glib((*info).ABI.abi.flow_ret);
|
||||
let flow_res = FlowSuccess::try_from_glib((*info).ABI.abi.flow_ret);
|
||||
let info = PadProbeInfo {
|
||||
mask: from_glib((*info).type_),
|
||||
id: Some(PadProbeId(NonZeroU64::new_unchecked((*info).id as u64))),
|
||||
|
@ -1117,7 +1045,7 @@ unsafe fn create_probe_info<'a>(
|
|||
Some(PadProbeData::__Unknown(data))
|
||||
}
|
||||
},
|
||||
flow_res: flow_ret.into_result(),
|
||||
flow_res,
|
||||
};
|
||||
(info, data_type)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
use crate::Buffer;
|
||||
use crate::BufferList;
|
||||
use crate::FlowError;
|
||||
use crate::FlowReturn;
|
||||
use crate::FlowSuccess;
|
||||
use crate::Object;
|
||||
use crate::Pad;
|
||||
|
@ -11,7 +10,7 @@ use crate::ProxyPad;
|
|||
use std::ptr;
|
||||
|
||||
use glib::prelude::*;
|
||||
use glib::translate::{from_glib, from_glib_full, ToGlibPtr};
|
||||
use glib::translate::*;
|
||||
|
||||
pub trait ProxyPadExtManual: 'static {
|
||||
fn chain_default<P: IsA<Object>>(
|
||||
|
@ -46,14 +45,13 @@ impl<O: IsA<ProxyPad>> ProxyPadExtManual for O {
|
|||
buffer: Buffer,
|
||||
) -> Result<FlowSuccess, FlowError> {
|
||||
skip_assert_initialized!();
|
||||
let ret: FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_proxy_pad_chain_default(
|
||||
unsafe {
|
||||
FlowSuccess::try_from_glib(ffi::gst_proxy_pad_chain_default(
|
||||
self.as_ptr() as *mut ffi::GstPad,
|
||||
parent.map(|p| p.as_ref()).to_glib_none().0,
|
||||
buffer.into_ptr(),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
fn chain_list_default<P: IsA<Object>>(
|
||||
|
@ -62,14 +60,13 @@ impl<O: IsA<ProxyPad>> ProxyPadExtManual for O {
|
|||
list: BufferList,
|
||||
) -> Result<FlowSuccess, FlowError> {
|
||||
skip_assert_initialized!();
|
||||
let ret: FlowReturn = unsafe {
|
||||
from_glib(ffi::gst_proxy_pad_chain_list_default(
|
||||
unsafe {
|
||||
FlowSuccess::try_from_glib(ffi::gst_proxy_pad_chain_list_default(
|
||||
self.as_ptr() as *mut ffi::GstPad,
|
||||
parent.map(|p| p.as_ref()).to_glib_none().0,
|
||||
list.into_ptr(),
|
||||
))
|
||||
};
|
||||
ret.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
fn getrange_default<P: IsA<Object>>(
|
||||
|
@ -81,14 +78,14 @@ impl<O: IsA<ProxyPad>> ProxyPadExtManual for O {
|
|||
skip_assert_initialized!();
|
||||
unsafe {
|
||||
let mut buffer = ptr::null_mut();
|
||||
let ret: FlowReturn = from_glib(ffi::gst_proxy_pad_getrange_default(
|
||||
FlowSuccess::try_from_glib(ffi::gst_proxy_pad_getrange_default(
|
||||
self.as_ptr() as *mut ffi::GstPad,
|
||||
parent.map(|p| p.as_ref()).to_glib_none().0,
|
||||
offset,
|
||||
size,
|
||||
&mut buffer,
|
||||
));
|
||||
ret.into_result_value(|| from_glib_full(buffer))
|
||||
))
|
||||
.map(|_| from_glib_full(buffer))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ impl<T: ClockImpl> ClockImplExt for T {
|
|||
let mut jitter = 0;
|
||||
|
||||
(
|
||||
ClockReturn::from_glib(
|
||||
ClockSuccess::try_from_glib(
|
||||
(*parent_class)
|
||||
.wait
|
||||
.map(|f| {
|
||||
|
@ -152,8 +152,7 @@ impl<T: ClockImpl> ClockImplExt for T {
|
|||
)
|
||||
})
|
||||
.unwrap_or(ffi::GST_CLOCK_UNSUPPORTED),
|
||||
)
|
||||
.into_result(),
|
||||
),
|
||||
jitter,
|
||||
)
|
||||
}
|
||||
|
@ -167,7 +166,7 @@ impl<T: ClockImpl> ClockImplExt for T {
|
|||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstClockClass;
|
||||
ClockReturn::from_glib(
|
||||
ClockSuccess::try_from_glib(
|
||||
(*parent_class)
|
||||
.wait_async
|
||||
.map(|f| {
|
||||
|
@ -178,7 +177,6 @@ impl<T: ClockImpl> ClockImplExt for T {
|
|||
})
|
||||
.unwrap_or(ffi::GST_CLOCK_UNSUPPORTED),
|
||||
)
|
||||
.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -170,11 +170,10 @@ impl<T: ElementImpl> ElementImplExt for T {
|
|||
let f = (*parent_class)
|
||||
.change_state
|
||||
.expect("Missing parent function `change_state`");
|
||||
StateChangeReturn::from_glib(f(
|
||||
StateChangeSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<Element>().to_glib_none().0,
|
||||
transition.into_glib(),
|
||||
))
|
||||
.into_result()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue