Manual try_from_glib shortcuts + unsafe

This commit is contained in:
François Laignel 2021-05-13 14:54:41 +02:00
parent 03e8e6d22f
commit 8dda8def6e
27 changed files with 69 additions and 79 deletions

View file

@ -210,7 +210,7 @@ impl AppSrc {
#[doc(alias = "gst_app_src_push_buffer")] #[doc(alias = "gst_app_src_push_buffer")]
pub fn push_buffer(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> { pub fn push_buffer(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(ffi::gst_app_src_push_buffer( try_from_glib(ffi::gst_app_src_push_buffer(
self.to_glib_none().0, self.to_glib_none().0,
buffer.into_ptr(), buffer.into_ptr(),
)) ))
@ -225,7 +225,7 @@ impl AppSrc {
list: gst::BufferList, list: gst::BufferList,
) -> Result<gst::FlowSuccess, gst::FlowError> { ) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(ffi::gst_app_src_push_buffer_list( try_from_glib(ffi::gst_app_src_push_buffer_list(
self.to_glib_none().0, self.to_glib_none().0,
list.into_ptr(), list.into_ptr(),
)) ))

View file

@ -66,7 +66,7 @@ impl<O: IsA<AudioDecoder>> AudioDecoderExtManual for O {
frames: i32, frames: i32,
) -> Result<gst::FlowSuccess, gst::FlowError> { ) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(ffi::gst_audio_decoder_finish_frame( try_from_glib(ffi::gst_audio_decoder_finish_frame(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
buffer.map(|b| b.into_ptr()).unwrap_or(ptr::null_mut()), buffer.map(|b| b.into_ptr()).unwrap_or(ptr::null_mut()),
frames, frames,
@ -82,7 +82,7 @@ impl<O: IsA<AudioDecoder>> AudioDecoderExtManual for O {
buffer: Option<gst::Buffer>, buffer: Option<gst::Buffer>,
) -> Result<gst::FlowSuccess, gst::FlowError> { ) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(ffi::gst_audio_decoder_finish_subframe( try_from_glib(ffi::gst_audio_decoder_finish_subframe(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
buffer.map(|b| b.into_ptr()).unwrap_or(ptr::null_mut()), buffer.map(|b| b.into_ptr()).unwrap_or(ptr::null_mut()),
)) ))
@ -160,7 +160,7 @@ impl<O: IsA<AudioDecoder>> AudioDecoderExtManual for O {
line: u32, line: u32,
) -> Result<gst::FlowSuccess, gst::FlowError> { ) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(_gst_audio_decoder_error( try_from_glib(_gst_audio_decoder_error(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
weight, weight,
T::domain().into_glib(), T::domain().into_glib(),

View file

@ -36,7 +36,7 @@ impl<O: IsA<AudioEncoder>> AudioEncoderExtManual for O {
frames: i32, frames: i32,
) -> Result<gst::FlowSuccess, gst::FlowError> { ) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(ffi::gst_audio_encoder_finish_frame( try_from_glib(ffi::gst_audio_encoder_finish_frame(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
buffer.map(|b| b.into_ptr()).unwrap_or(ptr::null_mut()), buffer.map(|b| b.into_ptr()).unwrap_or(ptr::null_mut()),
frames, frames,

View file

@ -324,7 +324,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
(*parent_class) (*parent_class)
.handle_frame .handle_frame
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<AudioDecoder>().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::ffi::GstBuffer) .map(|buffer| buffer.as_mut_ptr() as *mut *mut gst::ffi::GstBuffer)

View file

@ -279,7 +279,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
(*parent_class) (*parent_class)
.handle_frame .handle_frame
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<AudioEncoder>().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::ffi::GstBuffer) .map(|buffer| buffer.as_mut_ptr() as *mut *mut gst::ffi::GstBuffer)

View file

@ -105,7 +105,7 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
fn finish_buffer(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> { fn finish_buffer(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(ffi::gst_aggregator_finish_buffer( try_from_glib(ffi::gst_aggregator_finish_buffer(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
buffer.into_ptr(), buffer.into_ptr(),
)) ))
@ -119,7 +119,7 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
bufferlist: gst::BufferList, bufferlist: gst::BufferList,
) -> Result<gst::FlowSuccess, gst::FlowError> { ) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(ffi::gst_aggregator_finish_buffer_list( try_from_glib(ffi::gst_aggregator_finish_buffer_list(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
bufferlist.into_ptr(), bufferlist.into_ptr(),
)) ))

View file

@ -132,7 +132,7 @@ impl<O: IsA<BaseParse>> BaseParseExtManual for O {
size: u32, size: u32,
) -> Result<gst::FlowSuccess, gst::FlowError> { ) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(ffi::gst_base_parse_finish_frame( try_from_glib(ffi::gst_base_parse_finish_frame(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
frame.to_glib_none().0, frame.to_glib_none().0,
i32::try_from(size).expect("size higher than i32::MAX"), i32::try_from(size).expect("size higher than i32::MAX"),

View file

@ -73,7 +73,7 @@ impl FlowCombiner {
) -> Result<gst::FlowSuccess, gst::FlowError> { ) -> Result<gst::FlowSuccess, gst::FlowError> {
let fret: gst::FlowReturn = fret.into(); let fret: gst::FlowReturn = fret.into();
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(ffi::gst_flow_combiner_update_flow( try_from_glib(ffi::gst_flow_combiner_update_flow(
self.to_glib_none().0, self.to_glib_none().0,
fret.into_glib(), fret.into_glib(),
)) ))
@ -88,7 +88,7 @@ impl FlowCombiner {
) -> Result<gst::FlowSuccess, gst::FlowError> { ) -> Result<gst::FlowSuccess, gst::FlowError> {
let fret: gst::FlowReturn = fret.into(); let fret: gst::FlowReturn = fret.into();
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(ffi::gst_flow_combiner_update_pad_flow( try_from_glib(ffi::gst_flow_combiner_update_pad_flow(
self.to_glib_none().0, self.to_glib_none().0,
pad.as_ref().to_glib_none().0, pad.as_ref().to_glib_none().0,
fret.into_glib(), fret.into_glib(),

View file

@ -288,7 +288,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
(*parent_class) (*parent_class)
.flush .flush
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f(aggregator try_from_glib(f(aggregator
.unsafe_cast_ref::<Aggregator>() .unsafe_cast_ref::<Aggregator>()
.to_glib_none() .to_glib_none()
.0)) .0))
@ -328,7 +328,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
let f = (*parent_class) let f = (*parent_class)
.finish_buffer .finish_buffer
.expect("Missing parent function `finish_buffer`"); .expect("Missing parent function `finish_buffer`");
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0, aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
buffer.into_ptr(), buffer.into_ptr(),
)) ))
@ -348,7 +348,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
let f = (*parent_class) let f = (*parent_class)
.finish_buffer_list .finish_buffer_list
.expect("Missing parent function `finish_buffer_list`"); .expect("Missing parent function `finish_buffer_list`");
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0, aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
buffer_list.into_ptr(), buffer_list.into_ptr(),
)) ))
@ -389,7 +389,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
let f = (*parent_class) let f = (*parent_class)
.sink_event_pre_queue .sink_event_pre_queue
.expect("Missing parent function `sink_event_pre_queue`"); .expect("Missing parent function `sink_event_pre_queue`");
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0, aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
aggregator_pad.to_glib_none().0, aggregator_pad.to_glib_none().0,
event.into_ptr(), event.into_ptr(),
@ -502,7 +502,7 @@ impl<T: AggregatorImpl> AggregatorImplExt for T {
let f = (*parent_class) let f = (*parent_class)
.aggregate .aggregate
.expect("Missing parent function `aggregate`"); .expect("Missing parent function `aggregate`");
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0, aggregator.unsafe_cast_ref::<Aggregator>().to_glib_none().0,
timeout.into_glib(), timeout.into_glib(),
)) ))

View file

@ -54,7 +54,7 @@ impl<T: AggregatorPadImpl> AggregatorPadImplExt for T {
(*parent_class) (*parent_class)
.flush .flush
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
aggregator_pad aggregator_pad
.unsafe_cast_ref::<AggregatorPad>() .unsafe_cast_ref::<AggregatorPad>()
.to_glib_none() .to_glib_none()

View file

@ -152,7 +152,7 @@ impl<T: BaseParseImpl> BaseParseImplExt for T {
(*parent_class) (*parent_class)
.handle_frame .handle_frame
.map(|f| { .map(|f| {
let res = gst::FlowSuccess::try_from_glib(f( let res = try_from_glib(f(
element.unsafe_cast_ref::<BaseParse>().to_glib_none().0, element.unsafe_cast_ref::<BaseParse>().to_glib_none().0,
frame.to_glib_none().0, frame.to_glib_none().0,
&mut skipsize, &mut skipsize,

View file

@ -179,7 +179,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
(*parent_class) (*parent_class)
.render .render
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0, element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
buffer.to_glib_none().0, buffer.to_glib_none().0,
)) ))
@ -199,7 +199,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
(*parent_class) (*parent_class)
.prepare .prepare
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0, element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
buffer.to_glib_none().0, buffer.to_glib_none().0,
)) ))
@ -219,7 +219,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
(*parent_class) (*parent_class)
.render_list .render_list
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0, element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
list.to_glib_none().0, list.to_glib_none().0,
)) ))
@ -244,7 +244,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
(*parent_class) (*parent_class)
.prepare_list .prepare_list
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0, element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
list.to_glib_none().0, list.to_glib_none().0,
)) ))

View file

@ -284,7 +284,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
(*parent_class) (*parent_class)
.fill .fill
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0, element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
offset, offset,
length, length,

View file

@ -601,7 +601,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
(*parent_class) (*parent_class)
.transform .transform
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0, element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
inbuf.to_glib_none().0, inbuf.to_glib_none().0,
outbuf.as_mut_ptr(), outbuf.as_mut_ptr(),
@ -642,7 +642,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
} }
}); });
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0, element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
buf.as_mut_ptr() as *mut _, buf.as_mut_ptr() as *mut _,
)) ))
@ -673,7 +673,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
// FIXME: Wrong signature in FFI // FIXME: Wrong signature in FFI
let buf: *mut gst::ffi::GstBuffer = buf.to_glib_none().0; let buf: *mut gst::ffi::GstBuffer = buf.to_glib_none().0;
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0, element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
buf as *mut _, buf as *mut _,
)) ))
@ -755,7 +755,7 @@ impl<T: BaseTransformImpl> BaseTransformImplExt for T {
.submit_input_buffer .submit_input_buffer
.expect("Missing parent function `submit_input_buffer`"); .expect("Missing parent function `submit_input_buffer`");
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0, element.unsafe_cast_ref::<BaseTransform>().to_glib_none().0,
is_discont.into_glib(), is_discont.into_glib(),
inbuf.into_ptr(), inbuf.into_ptr(),

View file

@ -51,7 +51,7 @@ impl<T: PushSrcImpl> PushSrcImplExt for T {
(*parent_class) (*parent_class)
.fill .fill
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<PushSrc>().to_glib_none().0, element.unsafe_cast_ref::<PushSrc>().to_glib_none().0,
buffer.as_mut_ptr(), buffer.as_mut_ptr(),
)) ))

View file

@ -301,12 +301,7 @@ impl Harness {
#[doc(alias = "gst_harness_push")] #[doc(alias = "gst_harness_push")]
pub fn push(&mut self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> { pub fn push(&mut self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe { try_from_glib(ffi::gst_harness_push(self.0.as_ptr(), buffer.into_ptr())) }
gst::FlowSuccess::try_from_glib(ffi::gst_harness_push(
self.0.as_ptr(),
buffer.into_ptr(),
))
}
} }
#[doc(alias = "gst_harness_push_and_pull")] #[doc(alias = "gst_harness_push_and_pull")]
@ -332,12 +327,12 @@ impl Harness {
#[doc(alias = "gst_harness_push_from_src")] #[doc(alias = "gst_harness_push_from_src")]
pub fn push_from_src(&mut self) -> Result<gst::FlowSuccess, gst::FlowError> { pub fn push_from_src(&mut self) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { gst::FlowSuccess::try_from_glib(ffi::gst_harness_push_from_src(self.0.as_ptr())) } unsafe { try_from_glib(ffi::gst_harness_push_from_src(self.0.as_ptr())) }
} }
#[doc(alias = "gst_harness_push_to_sink")] #[doc(alias = "gst_harness_push_to_sink")]
pub fn push_to_sink(&mut self) -> Result<gst::FlowSuccess, gst::FlowError> { pub fn push_to_sink(&mut self) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { gst::FlowSuccess::try_from_glib(ffi::gst_harness_push_to_sink(self.0.as_ptr())) } unsafe { try_from_glib(ffi::gst_harness_push_to_sink(self.0.as_ptr())) }
} }
#[doc(alias = "gst_harness_push_upstream_event")] #[doc(alias = "gst_harness_push_upstream_event")]
@ -457,7 +452,7 @@ impl Harness {
#[doc(alias = "gst_harness_sink_push_many")] #[doc(alias = "gst_harness_sink_push_many")]
pub fn sink_push_many(&mut self, pushes: u32) -> Result<gst::FlowSuccess, gst::FlowError> { pub fn sink_push_many(&mut self, pushes: u32) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(ffi::gst_harness_sink_push_many( try_from_glib(ffi::gst_harness_sink_push_many(
self.0.as_ptr(), self.0.as_ptr(),
pushes as i32, pushes as i32,
)) ))
@ -471,7 +466,7 @@ impl Harness {
pushes: u32, pushes: u32,
) -> Result<gst::FlowSuccess, gst::FlowError> { ) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(ffi::gst_harness_src_crank_and_push_many( try_from_glib(ffi::gst_harness_src_crank_and_push_many(
self.0.as_ptr(), self.0.as_ptr(),
cranks as i32, cranks as i32,
pushes as i32, pushes as i32,

View file

@ -269,7 +269,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
(*parent_class) (*parent_class)
.finish .finish
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f(element try_from_glib(f(element
.unsafe_cast_ref::<VideoDecoder>() .unsafe_cast_ref::<VideoDecoder>()
.to_glib_none() .to_glib_none()
.0)) .0))
@ -285,7 +285,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
(*parent_class) (*parent_class)
.drain .drain
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f(element try_from_glib(f(element
.unsafe_cast_ref::<VideoDecoder>() .unsafe_cast_ref::<VideoDecoder>()
.to_glib_none() .to_glib_none()
.0)) .0))
@ -331,7 +331,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
(*parent_class) (*parent_class)
.parse .parse
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0, element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
frame.to_glib_none().0, frame.to_glib_none().0,
adapter.to_glib_none().0, adapter.to_glib_none().0,
@ -353,7 +353,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
(*parent_class) (*parent_class)
.handle_frame .handle_frame
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0, element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
frame.to_glib_none().0, frame.to_glib_none().0,
)) ))

View file

@ -245,7 +245,7 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
(*parent_class) (*parent_class)
.finish .finish
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f(element try_from_glib(f(element
.unsafe_cast_ref::<VideoEncoder>() .unsafe_cast_ref::<VideoEncoder>()
.to_glib_none() .to_glib_none()
.0)) .0))
@ -289,7 +289,7 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
(*parent_class) (*parent_class)
.handle_frame .handle_frame
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0, element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
frame.to_glib_none().0, frame.to_glib_none().0,
)) ))

View file

@ -120,7 +120,7 @@ impl<T: VideoFilterImpl> VideoFilterImplExt for T {
(*parent_class) (*parent_class)
.transform_frame .transform_frame
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<VideoFilter>().to_glib_none().0, element.unsafe_cast_ref::<VideoFilter>().to_glib_none().0,
mut_override(inframe.as_ptr()), mut_override(inframe.as_ptr()),
outframe.as_mut_ptr(), outframe.as_mut_ptr(),
@ -167,7 +167,7 @@ impl<T: VideoFilterImpl> VideoFilterImplExt for T {
} }
}); });
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<VideoFilter>().to_glib_none().0, element.unsafe_cast_ref::<VideoFilter>().to_glib_none().0,
frame.as_mut_ptr(), frame.as_mut_ptr(),
)) ))
@ -199,7 +199,7 @@ impl<T: VideoFilterImpl> VideoFilterImplExt for T {
} }
}); });
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<VideoFilter>().to_glib_none().0, element.unsafe_cast_ref::<VideoFilter>().to_glib_none().0,
mut_override(frame.as_ptr()), mut_override(frame.as_ptr()),
)) ))

View file

@ -37,7 +37,7 @@ impl<T: VideoSinkImpl> VideoSinkImplExt for T {
(*parent_class) (*parent_class)
.show_frame .show_frame
.map(|f| { .map(|f| {
gst::FlowSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<VideoSink>().to_glib_none().0, element.unsafe_cast_ref::<VideoSink>().to_glib_none().0,
buffer.to_glib_none().0, buffer.to_glib_none().0,
)) ))

View file

@ -102,13 +102,11 @@ impl<O: IsA<VideoDecoder>> VideoDecoderExtManual for O {
) -> Result<gst::FlowSuccess, gst::FlowError> { ) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe {
let params_ptr = params.to_glib_none().0 as *mut _; let params_ptr = params.to_glib_none().0 as *mut _;
gst::FlowSuccess::try_from_glib( try_from_glib(ffi::gst_video_decoder_allocate_output_frame_with_params(
ffi::gst_video_decoder_allocate_output_frame_with_params( self.as_ref().to_glib_none().0,
self.as_ref().to_glib_none().0, frame.to_glib_none().0,
frame.to_glib_none().0, params_ptr,
params_ptr, ))
),
)
} }
} }
@ -129,7 +127,7 @@ impl<O: IsA<VideoDecoder>> VideoDecoderExtManual for O {
#[doc(alias = "gst_video_decoder_finish_frame")] #[doc(alias = "gst_video_decoder_finish_frame")]
fn finish_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> { fn finish_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(ffi::gst_video_decoder_finish_frame( try_from_glib(ffi::gst_video_decoder_finish_frame(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
frame.into_ptr(), frame.into_ptr(),
)) ))
@ -146,7 +144,7 @@ impl<O: IsA<VideoDecoder>> VideoDecoderExtManual for O {
#[doc(alias = "gst_video_decoder_drop_frame")] #[doc(alias = "gst_video_decoder_drop_frame")]
fn drop_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> { fn drop_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(ffi::gst_video_decoder_drop_frame( try_from_glib(ffi::gst_video_decoder_drop_frame(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
frame.into_ptr(), frame.into_ptr(),
)) ))
@ -330,7 +328,7 @@ impl<O: IsA<VideoDecoder>> VideoDecoderExtManual for O {
line: u32, line: u32,
) -> Result<gst::FlowSuccess, gst::FlowError> { ) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(_gst_video_decoder_error( try_from_glib(_gst_video_decoder_error(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
weight, weight,
T::domain().into_glib(), T::domain().into_glib(),

View file

@ -76,7 +76,7 @@ impl<O: IsA<VideoEncoder>> VideoEncoderExtManual for O {
size: usize, size: usize,
) -> Result<gst::FlowSuccess, gst::FlowError> { ) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(ffi::gst_video_encoder_allocate_output_frame( try_from_glib(ffi::gst_video_encoder_allocate_output_frame(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
frame.to_glib_none().0, frame.to_glib_none().0,
size, size,
@ -102,7 +102,7 @@ impl<O: IsA<VideoEncoder>> VideoEncoderExtManual for O {
frame: Option<VideoCodecFrame>, frame: Option<VideoCodecFrame>,
) -> Result<gst::FlowSuccess, gst::FlowError> { ) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(ffi::gst_video_encoder_finish_frame( try_from_glib(ffi::gst_video_encoder_finish_frame(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
frame.map(|f| f.into_ptr()).unwrap_or(ptr::null_mut()), frame.map(|f| f.into_ptr()).unwrap_or(ptr::null_mut()),
)) ))
@ -113,7 +113,7 @@ impl<O: IsA<VideoEncoder>> VideoEncoderExtManual for O {
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
fn finish_subframe(&self, frame: &VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> { fn finish_subframe(&self, frame: &VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
unsafe { unsafe {
gst::FlowSuccess::try_from_glib(ffi::gst_video_encoder_finish_subframe( try_from_glib(ffi::gst_video_encoder_finish_subframe(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
frame.to_glib_none().0, frame.to_glib_none().0,
)) ))

View file

@ -48,10 +48,7 @@ impl ClockId {
pub fn wait(&self) -> (Result<ClockSuccess, ClockError>, ClockTimeDiff) { pub fn wait(&self) -> (Result<ClockSuccess, ClockError>, ClockTimeDiff) {
unsafe { unsafe {
let mut jitter = 0; let mut jitter = 0;
let res = ClockSuccess::try_from_glib(ffi::gst_clock_id_wait( let res = try_from_glib(ffi::gst_clock_id_wait(self.to_glib_none().0, &mut jitter));
self.to_glib_none().0,
&mut jitter,
));
(res, jitter) (res, jitter)
} }
} }
@ -169,7 +166,7 @@ impl SingleShotClockId {
let func: Box<Option<F>> = Box::new(Some(func)); let func: Box<Option<F>> = Box::new(Some(func));
unsafe { unsafe {
ClockSuccess::try_from_glib(ffi::gst_clock_id_wait_async( try_from_glib(ffi::gst_clock_id_wait_async(
self.to_glib_none().0, self.to_glib_none().0,
Some(trampoline::<F>), Some(trampoline::<F>),
Box::into_raw(func) as gpointer, Box::into_raw(func) as gpointer,
@ -273,7 +270,7 @@ impl PeriodicClockId {
let func: Box<F> = Box::new(func); let func: Box<F> = Box::new(func);
unsafe { unsafe {
ClockSuccess::try_from_glib(ffi::gst_clock_id_wait_async( try_from_glib(ffi::gst_clock_id_wait_async(
self.to_glib_none().0, self.to_glib_none().0,
Some(trampoline::<F>), Some(trampoline::<F>),
Box::into_raw(func) as gpointer, Box::into_raw(func) as gpointer,

View file

@ -317,7 +317,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
fn chain(&self, buffer: Buffer) -> Result<FlowSuccess, FlowError> { fn chain(&self, buffer: Buffer) -> Result<FlowSuccess, FlowError> {
unsafe { unsafe {
FlowSuccess::try_from_glib(ffi::gst_pad_chain( try_from_glib(ffi::gst_pad_chain(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
buffer.into_ptr(), buffer.into_ptr(),
)) ))
@ -326,7 +326,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
fn push(&self, buffer: Buffer) -> Result<FlowSuccess, FlowError> { fn push(&self, buffer: Buffer) -> Result<FlowSuccess, FlowError> {
unsafe { unsafe {
FlowSuccess::try_from_glib(ffi::gst_pad_push( try_from_glib(ffi::gst_pad_push(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
buffer.into_ptr(), buffer.into_ptr(),
)) ))
@ -335,7 +335,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
fn chain_list(&self, list: BufferList) -> Result<FlowSuccess, FlowError> { fn chain_list(&self, list: BufferList) -> Result<FlowSuccess, FlowError> {
unsafe { unsafe {
FlowSuccess::try_from_glib(ffi::gst_pad_chain_list( try_from_glib(ffi::gst_pad_chain_list(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
list.into_ptr(), list.into_ptr(),
)) ))
@ -344,7 +344,7 @@ impl<O: IsA<Pad>> PadExtManual for O {
fn push_list(&self, list: BufferList) -> Result<FlowSuccess, FlowError> { fn push_list(&self, list: BufferList) -> Result<FlowSuccess, FlowError> {
unsafe { unsafe {
FlowSuccess::try_from_glib(ffi::gst_pad_push_list( try_from_glib(ffi::gst_pad_push_list(
self.as_ref().to_glib_none().0, self.as_ref().to_glib_none().0,
list.into_ptr(), list.into_ptr(),
)) ))
@ -1035,7 +1035,7 @@ unsafe fn create_probe_info<'a>(
info: *mut ffi::GstPadProbeInfo, info: *mut ffi::GstPadProbeInfo,
) -> (PadProbeInfo<'a>, Option<glib::Type>) { ) -> (PadProbeInfo<'a>, Option<glib::Type>) {
let mut data_type = None; let mut data_type = None;
let flow_res = FlowSuccess::try_from_glib((*info).ABI.abi.flow_ret); let flow_res = try_from_glib((*info).ABI.abi.flow_ret);
let info = PadProbeInfo { let info = PadProbeInfo {
mask: from_glib((*info).type_), mask: from_glib((*info).type_),
id: Some(PadProbeId(NonZeroU64::new_unchecked((*info).id as u64))), id: Some(PadProbeId(NonZeroU64::new_unchecked((*info).id as u64))),

View file

@ -50,7 +50,7 @@ impl<O: IsA<ProxyPad>> ProxyPadExtManual for O {
) -> Result<FlowSuccess, FlowError> { ) -> Result<FlowSuccess, FlowError> {
skip_assert_initialized!(); skip_assert_initialized!();
unsafe { unsafe {
FlowSuccess::try_from_glib(ffi::gst_proxy_pad_chain_default( try_from_glib(ffi::gst_proxy_pad_chain_default(
self.as_ptr() as *mut ffi::GstPad, self.as_ptr() as *mut ffi::GstPad,
parent.map(|p| p.as_ref()).to_glib_none().0, parent.map(|p| p.as_ref()).to_glib_none().0,
buffer.into_ptr(), buffer.into_ptr(),
@ -65,7 +65,7 @@ impl<O: IsA<ProxyPad>> ProxyPadExtManual for O {
) -> Result<FlowSuccess, FlowError> { ) -> Result<FlowSuccess, FlowError> {
skip_assert_initialized!(); skip_assert_initialized!();
unsafe { unsafe {
FlowSuccess::try_from_glib(ffi::gst_proxy_pad_chain_list_default( try_from_glib(ffi::gst_proxy_pad_chain_list_default(
self.as_ptr() as *mut ffi::GstPad, self.as_ptr() as *mut ffi::GstPad,
parent.map(|p| p.as_ref()).to_glib_none().0, parent.map(|p| p.as_ref()).to_glib_none().0,
list.into_ptr(), list.into_ptr(),

View file

@ -141,7 +141,7 @@ impl<T: ClockImpl> ClockImplExt for T {
let mut jitter = 0; let mut jitter = 0;
( (
ClockSuccess::try_from_glib( try_from_glib(
(*parent_class) (*parent_class)
.wait .wait
.map(|f| { .map(|f| {
@ -166,7 +166,7 @@ impl<T: ClockImpl> ClockImplExt for T {
unsafe { unsafe {
let data = Self::type_data(); let data = Self::type_data();
let parent_class = data.as_ref().parent_class() as *mut ffi::GstClockClass; let parent_class = data.as_ref().parent_class() as *mut ffi::GstClockClass;
ClockSuccess::try_from_glib( try_from_glib(
(*parent_class) (*parent_class)
.wait_async .wait_async
.map(|f| { .map(|f| {

View file

@ -170,7 +170,7 @@ impl<T: ElementImpl> ElementImplExt for T {
let f = (*parent_class) let f = (*parent_class)
.change_state .change_state
.expect("Missing parent function `change_state`"); .expect("Missing parent function `change_state`");
StateChangeSuccess::try_from_glib(f( try_from_glib(f(
element.unsafe_cast_ref::<Element>().to_glib_none().0, element.unsafe_cast_ref::<Element>().to_glib_none().0,
transition.into_glib(), transition.into_glib(),
)) ))