mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 09:31:06 +00:00
Change *Impl trait methods to only take &self and not Self::Type in addition
This commit is contained in:
parent
25c53c4276
commit
f17781e188
52 changed files with 2979 additions and 3899 deletions
|
@ -73,13 +73,7 @@ mod cairo_compositor {
|
|||
}
|
||||
|
||||
// Called by the application whenever the value of a property should be changed.
|
||||
fn set_property(
|
||||
&self,
|
||||
_obj: &Self::Type,
|
||||
_id: usize,
|
||||
value: &glib::Value,
|
||||
pspec: &glib::ParamSpec,
|
||||
) {
|
||||
fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) {
|
||||
let mut settings = self.settings.lock().unwrap();
|
||||
|
||||
match pspec.name() {
|
||||
|
@ -91,12 +85,7 @@ mod cairo_compositor {
|
|||
}
|
||||
|
||||
// Called by the application whenever the value of a property should be retrieved.
|
||||
fn property(
|
||||
&self,
|
||||
_obj: &Self::Type,
|
||||
_id: usize,
|
||||
pspec: &glib::ParamSpec,
|
||||
) -> glib::Value {
|
||||
fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
|
||||
let settings = self.settings.lock().unwrap();
|
||||
|
||||
match pspec.name() {
|
||||
|
@ -180,19 +169,20 @@ mod cairo_compositor {
|
|||
// Notify via the child proxy interface whenever a new pad is added or removed.
|
||||
fn request_new_pad(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
templ: &gst::PadTemplate,
|
||||
name: Option<String>,
|
||||
caps: Option<&gst::Caps>,
|
||||
) -> Option<gst::Pad> {
|
||||
let pad = self.parent_request_new_pad(element, templ, name, caps)?;
|
||||
let element = self.instance();
|
||||
let pad = self.parent_request_new_pad(templ, name, caps)?;
|
||||
element.child_added(&pad, &pad.name());
|
||||
Some(pad)
|
||||
}
|
||||
|
||||
fn release_pad(&self, element: &Self::Type, pad: &gst::Pad) {
|
||||
fn release_pad(&self, pad: &gst::Pad) {
|
||||
let element = self.instance();
|
||||
element.child_removed(pad, &pad.name());
|
||||
self.parent_release_pad(element, pad);
|
||||
self.parent_release_pad(pad);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,7 +191,6 @@ mod cairo_compositor {
|
|||
// Called whenever a query arrives at the given sink pad of the compositor.
|
||||
fn sink_query(
|
||||
&self,
|
||||
aggregator: &Self::Type,
|
||||
aggregator_pad: &gst_base::AggregatorPad,
|
||||
query: &mut gst::QueryRef,
|
||||
) -> bool {
|
||||
|
@ -232,7 +221,7 @@ mod cairo_compositor {
|
|||
|
||||
true
|
||||
}
|
||||
_ => self.parent_sink_query(aggregator, aggregator_pad, query),
|
||||
_ => self.parent_sink_query(aggregator_pad, query),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -242,7 +231,6 @@ mod cairo_compositor {
|
|||
// Called by videoaggregator whenever the output format should be determined.
|
||||
fn find_best_format(
|
||||
&self,
|
||||
_element: &Self::Type,
|
||||
_downstream_caps: &gst::Caps,
|
||||
) -> Option<(gst_video::VideoInfo, bool)> {
|
||||
// Let videoaggregator select whatever format downstream wants.
|
||||
|
@ -257,10 +245,10 @@ mod cairo_compositor {
|
|||
// time.
|
||||
fn aggregate_frames(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
token: &gst_video::subclass::AggregateFramesToken,
|
||||
outbuf: &mut gst::BufferRef,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let element = self.instance();
|
||||
let pads = element.sink_pads();
|
||||
|
||||
// Map the output frame writable.
|
||||
|
@ -326,11 +314,13 @@ mod cairo_compositor {
|
|||
//
|
||||
// This allows accessing the pads and their properties from e.g. gst-launch.
|
||||
impl ChildProxyImpl for CairoCompositor {
|
||||
fn children_count(&self, object: &Self::Type) -> u32 {
|
||||
fn children_count(&self) -> u32 {
|
||||
let object = self.instance();
|
||||
object.num_pads() as u32
|
||||
}
|
||||
|
||||
fn child_by_name(&self, object: &Self::Type, name: &str) -> Option<glib::Object> {
|
||||
fn child_by_name(&self, name: &str) -> Option<glib::Object> {
|
||||
let object = self.instance();
|
||||
object
|
||||
.pads()
|
||||
.into_iter()
|
||||
|
@ -338,7 +328,8 @@ mod cairo_compositor {
|
|||
.map(|p| p.upcast())
|
||||
}
|
||||
|
||||
fn child_by_index(&self, object: &Self::Type, index: u32) -> Option<glib::Object> {
|
||||
fn child_by_index(&self, index: u32) -> Option<glib::Object> {
|
||||
let object = self.instance();
|
||||
object
|
||||
.pads()
|
||||
.into_iter()
|
||||
|
@ -522,13 +513,7 @@ mod cairo_compositor {
|
|||
}
|
||||
|
||||
// Called by the application whenever the value of a property should be changed.
|
||||
fn set_property(
|
||||
&self,
|
||||
_obj: &Self::Type,
|
||||
_id: usize,
|
||||
value: &glib::Value,
|
||||
pspec: &glib::ParamSpec,
|
||||
) {
|
||||
fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) {
|
||||
let mut settings = self.settings.lock().unwrap();
|
||||
|
||||
match pspec.name() {
|
||||
|
@ -552,12 +537,7 @@ mod cairo_compositor {
|
|||
}
|
||||
|
||||
// Called by the application whenever the value of a property should be retrieved.
|
||||
fn property(
|
||||
&self,
|
||||
_obj: &Self::Type,
|
||||
_id: usize,
|
||||
pspec: &glib::ParamSpec,
|
||||
) -> glib::Value {
|
||||
fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
|
||||
let settings = self.settings.lock().unwrap();
|
||||
|
||||
match pspec.name() {
|
||||
|
|
|
@ -389,16 +389,9 @@ mod video_filter {
|
|||
use std::{cmp, mem::ManuallyDrop, os::unix::prelude::FromRawFd};
|
||||
|
||||
use anyhow::Error;
|
||||
use glib::subclass::{object::ObjectImpl, types::ObjectSubclass};
|
||||
use gst::{
|
||||
subclass::prelude::{ElementImpl, GstObjectImpl},
|
||||
PadDirection, PadPresence, PadTemplate,
|
||||
};
|
||||
use gst::{subclass::prelude::*, PadDirection, PadPresence, PadTemplate};
|
||||
use gst_app::gst_base::subclass::BaseTransformMode;
|
||||
use gst_video::{
|
||||
subclass::prelude::{BaseTransformImpl, VideoFilterImpl},
|
||||
VideoFrameRef,
|
||||
};
|
||||
use gst_video::{subclass::prelude::*, VideoFrameRef};
|
||||
use memmap2::MmapMut;
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
|
@ -490,11 +483,10 @@ mod video_filter {
|
|||
impl VideoFilterImpl for FdMemoryFadeInVideoFilter {
|
||||
fn transform_frame_ip(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
frame: &mut VideoFrameRef<&mut gst::BufferRef>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.transform_fd_mem_ip(frame).map_err(|err| {
|
||||
gst::error!(CAT, obj: element, "Failed to transform frame`: {}", err);
|
||||
gst::error!(CAT, imp: self, "Failed to transform frame`: {}", err);
|
||||
gst::FlowError::Error
|
||||
})?;
|
||||
|
||||
|
|
|
@ -67,11 +67,7 @@ mod mirror {
|
|||
}
|
||||
|
||||
impl GLMirrorFilter {
|
||||
fn create_shader(
|
||||
&self,
|
||||
filter: &<Self as ObjectSubclass>::Type,
|
||||
context: &GLContext,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
fn create_shader(&self, context: &GLContext) -> Result<(), gst::LoggableError> {
|
||||
let shader = GLShader::new(context);
|
||||
|
||||
let vertex = GLSLStage::new_default_vertex(context);
|
||||
|
@ -80,7 +76,7 @@ mod mirror {
|
|||
|
||||
gst::debug!(
|
||||
CAT,
|
||||
obj: filter,
|
||||
imp: self,
|
||||
"Compiling fragment shader {}",
|
||||
FRAGMENT_SHADER
|
||||
);
|
||||
|
@ -99,7 +95,7 @@ mod mirror {
|
|||
|
||||
gst::debug!(
|
||||
CAT,
|
||||
obj: filter,
|
||||
imp: self,
|
||||
"Successfully compiled and linked {:?}",
|
||||
shader
|
||||
);
|
||||
|
@ -127,12 +123,14 @@ mod mirror {
|
|||
const TRANSFORM_IP_ON_PASSTHROUGH: bool = false;
|
||||
}
|
||||
impl GLBaseFilterImpl for GLMirrorFilter {
|
||||
fn gl_start(&self, filter: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
fn gl_start(&self) -> Result<(), gst::LoggableError> {
|
||||
let filter = self.instance();
|
||||
|
||||
// Create a shader when GL is started, knowing that the OpenGL context is
|
||||
// available.
|
||||
let context = GLBaseFilterExt::context(filter).unwrap();
|
||||
self.create_shader(filter, &context)?;
|
||||
self.parent_gl_start(filter)
|
||||
let context = GLBaseFilterExt::context(&*filter).unwrap();
|
||||
self.create_shader(&context)?;
|
||||
self.parent_gl_start()
|
||||
}
|
||||
}
|
||||
impl GLFilterImpl for GLMirrorFilter {
|
||||
|
@ -140,10 +138,11 @@ mod mirror {
|
|||
|
||||
fn filter_texture(
|
||||
&self,
|
||||
filter: &Self::Type,
|
||||
input: &gst_gl::GLMemory,
|
||||
output: &gst_gl::GLMemory,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
let filter = self.instance();
|
||||
|
||||
let shader = self.shader.lock().unwrap();
|
||||
// Use the underlying filter implementation to transform the input texture into
|
||||
// an output texture with the shader.
|
||||
|
@ -154,7 +153,7 @@ mod mirror {
|
|||
.as_ref()
|
||||
.expect("No shader, call `create_shader` first!"),
|
||||
);
|
||||
self.parent_filter_texture(filter, input, output)
|
||||
self.parent_filter_texture(input, output)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,9 +105,10 @@ mod media_factory {
|
|||
|
||||
// Implementation of glib::Object virtual methods
|
||||
impl ObjectImpl for Factory {
|
||||
fn constructed(&self, factory: &Self::Type) {
|
||||
self.parent_constructed(factory);
|
||||
fn constructed(&self) {
|
||||
self.parent_constructed();
|
||||
|
||||
let factory = self.instance();
|
||||
// All media created by this factory are our custom media type. This would
|
||||
// not require a media factory subclass and can also be called on the normal
|
||||
// RTSPMediaFactory.
|
||||
|
@ -117,11 +118,7 @@ mod media_factory {
|
|||
|
||||
// Implementation of gst_rtsp_server::RTSPMediaFactory virtual methods
|
||||
impl RTSPMediaFactoryImpl for Factory {
|
||||
fn create_element(
|
||||
&self,
|
||||
_factory: &Self::Type,
|
||||
_url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<gst::Element> {
|
||||
fn create_element(&self, _url: &gst_rtsp::RTSPUrl) -> Option<gst::Element> {
|
||||
// Create a simple VP8 videotestsrc input
|
||||
let bin = gst::Bin::new(None);
|
||||
let src = gst::ElementFactory::make("videotestsrc", None).unwrap();
|
||||
|
@ -187,11 +184,10 @@ mod media {
|
|||
impl RTSPMediaImpl for Media {
|
||||
fn setup_sdp(
|
||||
&self,
|
||||
media: &Self::Type,
|
||||
sdp: &mut gst_sdp::SDPMessageRef,
|
||||
info: &gst_rtsp_server::subclass::SDPInfo,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_setup_sdp(media, sdp, info)?;
|
||||
self.parent_setup_sdp(sdp, info)?;
|
||||
|
||||
sdp.add_attribute("my-custom-attribute", Some("has-a-value"));
|
||||
|
||||
|
@ -237,7 +233,8 @@ mod server {
|
|||
|
||||
// Implementation of gst_rtsp_server::RTSPServer virtual methods
|
||||
impl RTSPServerImpl for Server {
|
||||
fn create_client(&self, server: &Self::Type) -> Option<gst_rtsp_server::RTSPClient> {
|
||||
fn create_client(&self) -> Option<gst_rtsp_server::RTSPClient> {
|
||||
let server = self.instance();
|
||||
let client = super::client::Client::default();
|
||||
|
||||
// Duplicated from the default implementation
|
||||
|
@ -249,8 +246,8 @@ mod server {
|
|||
Some(client.upcast())
|
||||
}
|
||||
|
||||
fn client_connected(&self, server: &Self::Type, client: &gst_rtsp_server::RTSPClient) {
|
||||
self.parent_client_connected(server, client);
|
||||
fn client_connected(&self, client: &gst_rtsp_server::RTSPClient) {
|
||||
self.parent_client_connected(client);
|
||||
println!("Client {:?} connected", client);
|
||||
}
|
||||
}
|
||||
|
@ -297,8 +294,9 @@ mod client {
|
|||
|
||||
// Implementation of gst_rtsp_server::RTSPClient virtual methods
|
||||
impl RTSPClientImpl for Client {
|
||||
fn closed(&self, client: &Self::Type) {
|
||||
self.parent_closed(client);
|
||||
fn closed(&self) {
|
||||
let client = self.instance();
|
||||
self.parent_closed();
|
||||
println!("Client {:?} closed", client);
|
||||
}
|
||||
}
|
||||
|
@ -343,13 +341,9 @@ mod mount_points {
|
|||
|
||||
// Implementation of gst_rtsp_server::RTSPClient virtual methods
|
||||
impl RTSPMountPointsImpl for MountPoints {
|
||||
fn make_path(
|
||||
&self,
|
||||
mount_points: &Self::Type,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<glib::GString> {
|
||||
fn make_path(&self, url: &gst_rtsp::RTSPUrl) -> Option<glib::GString> {
|
||||
println!("Make path called for {:?} ", url);
|
||||
self.parent_make_path(mount_points, url)
|
||||
self.parent_make_path(url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,18 +135,18 @@ mod fir_filter {
|
|||
// Returns the size of one processing unit (i.e. a frame in our case) corresponding
|
||||
// to the given caps. This is used for allocating a big enough output buffer and
|
||||
// sanity checking the input buffer size, among other things.
|
||||
fn unit_size(&self, _element: &Self::Type, caps: &gst::Caps) -> Option<usize> {
|
||||
fn unit_size(&self, caps: &gst::Caps) -> Option<usize> {
|
||||
let audio_info = gst_audio::AudioInfo::from_caps(caps).ok();
|
||||
audio_info.map(|info| info.bpf() as usize)
|
||||
}
|
||||
|
||||
// Called when shutting down the element so we can release all stream-related state
|
||||
// There's also start(), which is called whenever starting the element again
|
||||
fn stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
// Drop state
|
||||
self.history.lock().unwrap().clear();
|
||||
|
||||
gst::info!(CAT, obj: element, "Stopped");
|
||||
gst::info!(CAT, imp: self, "Stopped");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -154,9 +154,10 @@ mod fir_filter {
|
|||
// Does the actual transformation of the input buffer to the output buffer
|
||||
fn transform_ip(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buf: &mut gst::BufferRef,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
let element = self.instance();
|
||||
|
||||
// Get coefficients and return directly if we have none
|
||||
let coeffs = self.coeffs.lock().unwrap();
|
||||
if coeffs.is_empty() {
|
||||
|
|
|
@ -11,14 +11,13 @@ use crate::AudioAggregator;
|
|||
use crate::AudioAggregatorPad;
|
||||
|
||||
pub trait AudioAggregatorImpl: AudioAggregatorImplExt + AggregatorImpl {
|
||||
fn create_output_buffer(&self, element: &Self::Type, num_frames: u32) -> Option<gst::Buffer> {
|
||||
self.parent_create_output_buffer(element, num_frames)
|
||||
fn create_output_buffer(&self, num_frames: u32) -> Option<gst::Buffer> {
|
||||
self.parent_create_output_buffer(num_frames)
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn aggregate_one_buffer(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
pad: &AudioAggregatorPad,
|
||||
inbuf: &gst::BufferRef,
|
||||
in_offset: u32,
|
||||
|
@ -26,23 +25,16 @@ pub trait AudioAggregatorImpl: AudioAggregatorImplExt + AggregatorImpl {
|
|||
out_offset: u32,
|
||||
num_frames: u32,
|
||||
) -> bool {
|
||||
self.parent_aggregate_one_buffer(
|
||||
element, pad, inbuf, in_offset, outbuf, out_offset, num_frames,
|
||||
)
|
||||
self.parent_aggregate_one_buffer(pad, inbuf, in_offset, outbuf, out_offset, num_frames)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait AudioAggregatorImplExt: ObjectSubclass {
|
||||
fn parent_create_output_buffer(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
num_frames: u32,
|
||||
) -> Option<gst::Buffer>;
|
||||
fn parent_create_output_buffer(&self, num_frames: u32) -> Option<gst::Buffer>;
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn parent_aggregate_one_buffer(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
pad: &AudioAggregatorPad,
|
||||
inbuf: &gst::BufferRef,
|
||||
in_offset: u32,
|
||||
|
@ -53,11 +45,7 @@ pub trait AudioAggregatorImplExt: ObjectSubclass {
|
|||
}
|
||||
|
||||
impl<T: AudioAggregatorImpl> AudioAggregatorImplExt for T {
|
||||
fn parent_create_output_buffer(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
num_frames: u32,
|
||||
) -> Option<gst::Buffer> {
|
||||
fn parent_create_output_buffer(&self, num_frames: u32) -> Option<gst::Buffer> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioAggregatorClass;
|
||||
|
@ -66,7 +54,7 @@ impl<T: AudioAggregatorImpl> AudioAggregatorImplExt for T {
|
|||
.expect("Missing parent function `create_output_buffer`");
|
||||
|
||||
from_glib_full(f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioAggregator>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -77,7 +65,6 @@ impl<T: AudioAggregatorImpl> AudioAggregatorImplExt for T {
|
|||
|
||||
fn parent_aggregate_one_buffer(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
pad: &AudioAggregatorPad,
|
||||
inbuf: &gst::BufferRef,
|
||||
in_offset: u32,
|
||||
|
@ -93,7 +80,7 @@ impl<T: AudioAggregatorImpl> AudioAggregatorImplExt for T {
|
|||
.expect("Missing parent function `aggregate_one_buffer`");
|
||||
|
||||
from_glib(f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioAggregator>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -124,13 +111,10 @@ unsafe extern "C" fn audio_aggregator_create_output_buffer<T: AudioAggregatorImp
|
|||
) -> *mut gst::ffi::GstBuffer {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioAggregator> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), None, {
|
||||
imp.create_output_buffer(wrap.unsafe_cast_ref(), num_frames)
|
||||
})
|
||||
.map(|buffer| buffer.into_glib_ptr())
|
||||
.unwrap_or(ptr::null_mut())
|
||||
gst::panic_to_error!(imp, None, { imp.create_output_buffer(num_frames) })
|
||||
.map(|buffer| buffer.into_glib_ptr())
|
||||
.unwrap_or(ptr::null_mut())
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_aggregator_aggregate_one_buffer<T: AudioAggregatorImpl>(
|
||||
|
@ -144,11 +128,9 @@ unsafe extern "C" fn audio_aggregator_aggregate_one_buffer<T: AudioAggregatorImp
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioAggregator> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), true, {
|
||||
gst::panic_to_error!(imp, true, {
|
||||
imp.aggregate_one_buffer(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&from_glib_borrow(pad),
|
||||
gst::BufferRef::from_ptr(inbuf),
|
||||
in_offset,
|
||||
|
|
|
@ -12,27 +12,25 @@ use crate::AudioAggregatorPad;
|
|||
pub trait AudioAggregatorPadImpl: AudioAggregatorPadImplExt + AggregatorPadImpl {
|
||||
const HANDLE_CONVERSION: bool = false;
|
||||
|
||||
fn update_conversion_info(&self, pad: &Self::Type) {
|
||||
self.parent_update_conversion_info(pad)
|
||||
fn update_conversion_info(&self) {
|
||||
self.parent_update_conversion_info()
|
||||
}
|
||||
|
||||
fn convert_buffer(
|
||||
&self,
|
||||
pad: &Self::Type,
|
||||
in_info: &crate::AudioInfo,
|
||||
out_info: &crate::AudioInfo,
|
||||
buffer: &gst::Buffer,
|
||||
) -> Option<gst::Buffer> {
|
||||
self.parent_convert_buffer(pad, in_info, out_info, buffer)
|
||||
self.parent_convert_buffer(in_info, out_info, buffer)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait AudioAggregatorPadImplExt: ObjectSubclass {
|
||||
fn parent_update_conversion_info(&self, pad: &Self::Type);
|
||||
fn parent_update_conversion_info(&self);
|
||||
|
||||
fn parent_convert_buffer(
|
||||
&self,
|
||||
pad: &Self::Type,
|
||||
in_info: &crate::AudioInfo,
|
||||
out_info: &crate::AudioInfo,
|
||||
buffer: &gst::Buffer,
|
||||
|
@ -40,19 +38,22 @@ pub trait AudioAggregatorPadImplExt: ObjectSubclass {
|
|||
}
|
||||
|
||||
impl<T: AudioAggregatorPadImpl> AudioAggregatorPadImplExt for T {
|
||||
fn parent_update_conversion_info(&self, pad: &Self::Type) {
|
||||
fn parent_update_conversion_info(&self) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioAggregatorPadClass;
|
||||
if let Some(f) = (*parent_class).update_conversion_info {
|
||||
f(pad.unsafe_cast_ref::<AudioAggregatorPad>().to_glib_none().0);
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioAggregatorPad>()
|
||||
.to_glib_none()
|
||||
.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_convert_buffer(
|
||||
&self,
|
||||
pad: &Self::Type,
|
||||
in_info: &crate::AudioInfo,
|
||||
out_info: &crate::AudioInfo,
|
||||
buffer: &gst::Buffer,
|
||||
|
@ -64,7 +65,10 @@ impl<T: AudioAggregatorPadImpl> AudioAggregatorPadImplExt for T {
|
|||
.convert_buffer
|
||||
.expect("Missing parent function `convert_buffer`");
|
||||
from_glib_full(f(
|
||||
pad.unsafe_cast_ref::<AudioAggregatorPad>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioAggregatorPad>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
mut_override(in_info.to_glib_none().0),
|
||||
mut_override(out_info.to_glib_none().0),
|
||||
buffer.as_mut_ptr(),
|
||||
|
@ -90,9 +94,8 @@ unsafe extern "C" fn audio_aggregator_pad_update_conversion_info<T: AudioAggrega
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioAggregatorPad> = from_glib_borrow(ptr);
|
||||
|
||||
imp.update_conversion_info(wrap.unsafe_cast_ref());
|
||||
imp.update_conversion_info();
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_aggregator_pad_convert_buffer<T: AudioAggregatorPadImpl>(
|
||||
|
@ -103,10 +106,8 @@ unsafe extern "C" fn audio_aggregator_pad_convert_buffer<T: AudioAggregatorPadIm
|
|||
) -> *mut gst::ffi::GstBuffer {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioAggregatorPad> = from_glib_borrow(ptr);
|
||||
|
||||
imp.convert_buffer(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&from_glib_none(in_info),
|
||||
&from_glib_none(out_info),
|
||||
&from_glib_borrow(buffer),
|
||||
|
|
|
@ -12,164 +12,139 @@ use crate::prelude::*;
|
|||
use crate::AudioDecoder;
|
||||
|
||||
pub trait AudioDecoderImpl: AudioDecoderImplExt + ElementImpl {
|
||||
fn open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_open(element)
|
||||
fn open(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_open()
|
||||
}
|
||||
|
||||
fn close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_close(element)
|
||||
fn close(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_close()
|
||||
}
|
||||
|
||||
fn start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_start(element)
|
||||
fn start(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_start()
|
||||
}
|
||||
|
||||
fn stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_stop(element)
|
||||
fn stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_stop()
|
||||
}
|
||||
|
||||
fn set_format(&self, element: &Self::Type, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_format(element, caps)
|
||||
fn set_format(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_format(caps)
|
||||
}
|
||||
|
||||
fn parse(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
adapter: &gst_base::Adapter,
|
||||
) -> Result<(u32, u32), gst::FlowError> {
|
||||
self.parent_parse(element, adapter)
|
||||
fn parse(&self, adapter: &gst_base::Adapter) -> Result<(u32, u32), gst::FlowError> {
|
||||
self.parent_parse(adapter)
|
||||
}
|
||||
|
||||
fn handle_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: Option<&gst::Buffer>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_handle_frame(element, buffer)
|
||||
self.parent_handle_frame(buffer)
|
||||
}
|
||||
|
||||
fn pre_push(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: gst::Buffer,
|
||||
) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
||||
self.parent_pre_push(element, buffer)
|
||||
fn pre_push(&self, buffer: gst::Buffer) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
||||
self.parent_pre_push(buffer)
|
||||
}
|
||||
|
||||
fn flush(&self, element: &Self::Type, hard: bool) {
|
||||
self.parent_flush(element, hard)
|
||||
fn flush(&self, hard: bool) {
|
||||
self.parent_flush(hard)
|
||||
}
|
||||
|
||||
fn negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
self.parent_negotiate(element)
|
||||
fn negotiate(&self) -> Result<(), gst::LoggableError> {
|
||||
self.parent_negotiate()
|
||||
}
|
||||
|
||||
fn caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
self.parent_caps(element, filter)
|
||||
fn caps(&self, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
self.parent_caps(filter)
|
||||
}
|
||||
|
||||
fn sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
self.parent_sink_event(element, event)
|
||||
fn sink_event(&self, event: gst::Event) -> bool {
|
||||
self.parent_sink_event(event)
|
||||
}
|
||||
|
||||
fn sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
self.parent_sink_query(element, query)
|
||||
fn sink_query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
self.parent_sink_query(query)
|
||||
}
|
||||
|
||||
fn src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
self.parent_src_event(element, event)
|
||||
fn src_event(&self, event: gst::Event) -> bool {
|
||||
self.parent_src_event(event)
|
||||
}
|
||||
|
||||
fn src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
self.parent_src_query(element, query)
|
||||
fn src_query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
self.parent_src_query(query)
|
||||
}
|
||||
|
||||
fn propose_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_propose_allocation(element, query)
|
||||
self.parent_propose_allocation(query)
|
||||
}
|
||||
|
||||
fn decide_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_decide_allocation(element, query)
|
||||
self.parent_decide_allocation(query)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait AudioDecoderImplExt: ObjectSubclass {
|
||||
fn parent_open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_open(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_close(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_start(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_stop(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_set_format(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
fn parent_set_format(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_parse(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
adapter: &gst_base::Adapter,
|
||||
) -> Result<(u32, u32), gst::FlowError>;
|
||||
fn parent_parse(&self, adapter: &gst_base::Adapter) -> Result<(u32, u32), gst::FlowError>;
|
||||
|
||||
fn parent_handle_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: Option<&gst::Buffer>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_pre_push(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: gst::Buffer,
|
||||
) -> Result<Option<gst::Buffer>, gst::FlowError>;
|
||||
fn parent_pre_push(&self, buffer: gst::Buffer) -> Result<Option<gst::Buffer>, gst::FlowError>;
|
||||
|
||||
fn parent_flush(&self, element: &Self::Type, hard: bool);
|
||||
fn parent_flush(&self, hard: bool);
|
||||
|
||||
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError>;
|
||||
fn parent_negotiate(&self) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps;
|
||||
fn parent_caps(&self, filter: Option<&gst::Caps>) -> gst::Caps;
|
||||
|
||||
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||
fn parent_sink_event(&self, event: gst::Event) -> bool;
|
||||
|
||||
fn parent_sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool;
|
||||
fn parent_sink_query(&self, query: &mut gst::QueryRef) -> bool;
|
||||
|
||||
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||
fn parent_src_event(&self, event: gst::Event) -> bool;
|
||||
|
||||
fn parent_src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool;
|
||||
fn parent_src_query(&self, query: &mut gst::QueryRef) -> bool;
|
||||
|
||||
fn parent_propose_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_decide_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
}
|
||||
|
||||
impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
||||
fn parent_open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_open(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
(*parent_class)
|
||||
.open
|
||||
.map(|f| {
|
||||
if from_glib(f(element
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioDecoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -186,14 +161,15 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_close(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
(*parent_class)
|
||||
.close
|
||||
.map(|f| {
|
||||
if from_glib(f(element
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioDecoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -210,14 +186,15 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_start(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
(*parent_class)
|
||||
.start
|
||||
.map(|f| {
|
||||
if from_glib(f(element
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioDecoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -234,14 +211,15 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
(*parent_class)
|
||||
.stop
|
||||
.map(|f| {
|
||||
if from_glib(f(element
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioDecoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -258,11 +236,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_set_format(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
fn parent_set_format(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
|
@ -271,7 +245,10 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
caps.to_glib_none().0
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -282,11 +259,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_parse(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
adapter: &gst_base::Adapter,
|
||||
) -> Result<(u32, u32), gst::FlowError> {
|
||||
fn parent_parse(&self, adapter: &gst_base::Adapter) -> Result<(u32, u32), gst::FlowError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
|
@ -296,7 +269,10 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
let mut offset = mem::MaybeUninit::uninit();
|
||||
let mut len = mem::MaybeUninit::uninit();
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
adapter.to_glib_none().0,
|
||||
offset.as_mut_ptr(),
|
||||
len.as_mut_ptr(),
|
||||
|
@ -315,7 +291,6 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
|
||||
fn parent_handle_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: Option<&gst::Buffer>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
|
@ -325,7 +300,10 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
.handle_frame
|
||||
.map(|f| {
|
||||
try_from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.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()),
|
||||
|
@ -335,18 +313,17 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_pre_push(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: gst::Buffer,
|
||||
) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
||||
fn parent_pre_push(&self, buffer: gst::Buffer) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
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_glib_ptr();
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
&mut buffer,
|
||||
))
|
||||
.map(|_| from_glib_full(buffer))
|
||||
|
@ -356,7 +333,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_flush(&self, element: &Self::Type, hard: bool) {
|
||||
fn parent_flush(&self, hard: bool) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
|
@ -364,7 +341,10 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
.flush
|
||||
.map(|f| {
|
||||
f(
|
||||
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
hard.into_glib(),
|
||||
)
|
||||
})
|
||||
|
@ -372,7 +352,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
fn parent_negotiate(&self) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
|
@ -380,7 +360,11 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
.negotiate
|
||||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0),
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioDecoder>()
|
||||
.to_glib_none()
|
||||
.0),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `negotiate` failed"
|
||||
)
|
||||
|
@ -389,7 +373,7 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
fn parent_caps(&self, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
|
@ -397,19 +381,22 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
.getcaps
|
||||
.map(|f| {
|
||||
from_glib_full(f(
|
||||
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
filter.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioDecoder>()
|
||||
.proxy_getcaps(None, filter)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
fn parent_sink_event(&self, event: gst::Event) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
|
@ -417,13 +404,16 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
.sink_event
|
||||
.expect("Missing parent function `sink_event`");
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
event.into_glib_ptr(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
fn parent_sink_query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
|
@ -431,13 +421,16 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
.sink_query
|
||||
.expect("Missing parent function `sink_query`");
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
fn parent_src_event(&self, event: gst::Event) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
|
@ -445,13 +438,16 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
.src_event
|
||||
.expect("Missing parent function `src_event`");
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
event.into_glib_ptr(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
fn parent_src_query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioDecoderClass;
|
||||
|
@ -459,7 +455,10 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
.src_query
|
||||
.expect("Missing parent function `src_query`");
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
))
|
||||
}
|
||||
|
@ -467,7 +466,6 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
|
||||
fn parent_propose_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
|
@ -478,7 +476,10 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -491,7 +492,6 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
|
||||
fn parent_decide_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
|
@ -502,7 +502,10 @@ impl<T: AudioDecoderImpl> AudioDecoderImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<AudioDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -543,13 +546,12 @@ unsafe extern "C" fn audio_decoder_open<T: AudioDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.open(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.open() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -562,13 +564,12 @@ unsafe extern "C" fn audio_decoder_close<T: AudioDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.close(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.close() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -581,13 +582,12 @@ unsafe extern "C" fn audio_decoder_start<T: AudioDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.start(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.start() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -600,13 +600,12 @@ unsafe extern "C" fn audio_decoder_stop<T: AudioDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.stop(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.stop() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -620,13 +619,12 @@ unsafe extern "C" fn audio_decoder_set_format<T: AudioDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.set_format(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.set_format(&from_glib_borrow(caps)) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -642,10 +640,9 @@ unsafe extern "C" fn audio_decoder_parse<T: AudioDecoderImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
match imp.parse(wrap.unsafe_cast_ref(), &from_glib_borrow(adapter)) {
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
match imp.parse(&from_glib_borrow(adapter)) {
|
||||
Ok((new_offset, new_len)) => {
|
||||
assert!(new_offset <= std::i32::MAX as u32);
|
||||
assert!(new_len <= std::i32::MAX as u32);
|
||||
|
@ -668,14 +665,10 @@ unsafe extern "C" fn audio_decoder_handle_frame<T: AudioDecoderImpl>(
|
|||
let buffer = buffer as *mut gst::ffi::GstBuffer;
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
imp.handle_frame(
|
||||
wrap.unsafe_cast_ref(),
|
||||
Option::<gst::Buffer>::from_glib_none(buffer).as_ref(),
|
||||
)
|
||||
.into()
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
imp.handle_frame(Option::<gst::Buffer>::from_glib_none(buffer).as_ref())
|
||||
.into()
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -686,10 +679,9 @@ unsafe extern "C" fn audio_decoder_pre_push<T: AudioDecoderImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
match imp.pre_push(wrap.unsafe_cast_ref(), from_glib_full(*buffer)) {
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
match imp.pre_push(from_glib_full(*buffer)) {
|
||||
Ok(Some(new_buffer)) => {
|
||||
*buffer = new_buffer.into_glib_ptr();
|
||||
Ok(gst::FlowSuccess::Ok)
|
||||
|
@ -711,11 +703,8 @@ unsafe extern "C" fn audio_decoder_flush<T: AudioDecoderImpl>(
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), (), {
|
||||
AudioDecoderImpl::flush(imp, wrap.unsafe_cast_ref(), from_glib(hard))
|
||||
})
|
||||
gst::panic_to_error!(imp, (), { AudioDecoderImpl::flush(imp, from_glib(hard)) })
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_negotiate<T: AudioDecoderImpl>(
|
||||
|
@ -723,13 +712,12 @@ unsafe extern "C" fn audio_decoder_negotiate<T: AudioDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.negotiate(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.negotiate() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -743,12 +731,10 @@ unsafe extern "C" fn audio_decoder_getcaps<T: AudioDecoderImpl>(
|
|||
) -> *mut gst::ffi::GstCaps {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::Caps::new_empty(), {
|
||||
gst::panic_to_error!(imp, gst::Caps::new_empty(), {
|
||||
AudioDecoderImpl::caps(
|
||||
imp,
|
||||
wrap.unsafe_cast_ref(),
|
||||
Option::<gst::Caps>::from_glib_borrow(filter)
|
||||
.as_ref()
|
||||
.as_ref(),
|
||||
|
@ -763,12 +749,8 @@ unsafe extern "C" fn audio_decoder_sink_event<T: AudioDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.sink_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, false, { imp.sink_event(from_glib_full(event)) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_sink_query<T: AudioDecoderImpl>(
|
||||
|
@ -777,10 +759,9 @@ unsafe extern "C" fn audio_decoder_sink_query<T: AudioDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.sink_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||
gst::panic_to_error!(imp, false, {
|
||||
imp.sink_query(gst::QueryRef::from_mut_ptr(query))
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -791,12 +772,8 @@ unsafe extern "C" fn audio_decoder_src_event<T: AudioDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, false, { imp.src_event(from_glib_full(event)) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_decoder_src_query<T: AudioDecoderImpl>(
|
||||
|
@ -805,10 +782,9 @@ unsafe extern "C" fn audio_decoder_src_query<T: AudioDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.src_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||
gst::panic_to_error!(imp, false, {
|
||||
imp.src_query(gst::QueryRef::from_mut_ptr(query))
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -819,17 +795,16 @@ unsafe extern "C" fn audio_decoder_propose_allocation<T: AudioDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
|
||||
gst::QueryViewMut::Allocation(allocation) => allocation,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.propose_allocation(wrap.unsafe_cast_ref(), query) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.propose_allocation(query) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -843,17 +818,16 @@ unsafe extern "C" fn audio_decoder_decide_allocation<T: AudioDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioDecoder> = from_glib_borrow(ptr);
|
||||
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
|
||||
gst::QueryViewMut::Allocation(allocation) => allocation,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.decide_allocation(query) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,150 +12,133 @@ use crate::AudioEncoder;
|
|||
use crate::AudioInfo;
|
||||
|
||||
pub trait AudioEncoderImpl: AudioEncoderImplExt + ElementImpl {
|
||||
fn open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_open(element)
|
||||
fn open(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_open()
|
||||
}
|
||||
|
||||
fn close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_close(element)
|
||||
fn close(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_close()
|
||||
}
|
||||
|
||||
fn start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_start(element)
|
||||
fn start(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_start()
|
||||
}
|
||||
|
||||
fn stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_stop(element)
|
||||
fn stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_stop()
|
||||
}
|
||||
|
||||
fn set_format(&self, element: &Self::Type, info: &AudioInfo) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_format(element, info)
|
||||
fn set_format(&self, info: &AudioInfo) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_format(info)
|
||||
}
|
||||
|
||||
fn handle_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: Option<&gst::Buffer>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_handle_frame(element, buffer)
|
||||
self.parent_handle_frame(buffer)
|
||||
}
|
||||
|
||||
fn pre_push(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: gst::Buffer,
|
||||
) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
||||
self.parent_pre_push(element, buffer)
|
||||
fn pre_push(&self, buffer: gst::Buffer) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
||||
self.parent_pre_push(buffer)
|
||||
}
|
||||
|
||||
fn flush(&self, element: &Self::Type) {
|
||||
self.parent_flush(element)
|
||||
fn flush(&self) {
|
||||
self.parent_flush()
|
||||
}
|
||||
|
||||
fn negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
self.parent_negotiate(element)
|
||||
fn negotiate(&self) -> Result<(), gst::LoggableError> {
|
||||
self.parent_negotiate()
|
||||
}
|
||||
|
||||
fn caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
self.parent_caps(element, filter)
|
||||
fn caps(&self, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
self.parent_caps(filter)
|
||||
}
|
||||
|
||||
fn sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
self.parent_sink_event(element, event)
|
||||
fn sink_event(&self, event: gst::Event) -> bool {
|
||||
self.parent_sink_event(event)
|
||||
}
|
||||
|
||||
fn sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
self.parent_sink_query(element, query)
|
||||
fn sink_query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
self.parent_sink_query(query)
|
||||
}
|
||||
|
||||
fn src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
self.parent_src_event(element, event)
|
||||
fn src_event(&self, event: gst::Event) -> bool {
|
||||
self.parent_src_event(event)
|
||||
}
|
||||
|
||||
fn src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
self.parent_src_query(element, query)
|
||||
fn src_query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
self.parent_src_query(query)
|
||||
}
|
||||
|
||||
fn propose_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_propose_allocation(element, query)
|
||||
self.parent_propose_allocation(query)
|
||||
}
|
||||
|
||||
fn decide_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_decide_allocation(element, query)
|
||||
self.parent_decide_allocation(query)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait AudioEncoderImplExt: ObjectSubclass {
|
||||
fn parent_open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_open(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_close(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_start(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_stop(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_set_format(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
info: &AudioInfo,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
fn parent_set_format(&self, info: &AudioInfo) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_handle_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: Option<&gst::Buffer>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_pre_push(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: gst::Buffer,
|
||||
) -> Result<Option<gst::Buffer>, gst::FlowError>;
|
||||
fn parent_pre_push(&self, buffer: gst::Buffer) -> Result<Option<gst::Buffer>, gst::FlowError>;
|
||||
|
||||
fn parent_flush(&self, element: &Self::Type);
|
||||
fn parent_flush(&self);
|
||||
|
||||
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError>;
|
||||
fn parent_negotiate(&self) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps;
|
||||
fn parent_caps(&self, filter: Option<&gst::Caps>) -> gst::Caps;
|
||||
|
||||
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||
fn parent_sink_event(&self, event: gst::Event) -> bool;
|
||||
|
||||
fn parent_sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool;
|
||||
fn parent_sink_query(&self, query: &mut gst::QueryRef) -> bool;
|
||||
|
||||
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||
fn parent_src_event(&self, event: gst::Event) -> bool;
|
||||
|
||||
fn parent_src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool;
|
||||
fn parent_src_query(&self, query: &mut gst::QueryRef) -> bool;
|
||||
|
||||
fn parent_propose_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_decide_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
}
|
||||
|
||||
impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
||||
fn parent_open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_open(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
(*parent_class)
|
||||
.open
|
||||
.map(|f| {
|
||||
if from_glib(f(element
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioEncoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -172,14 +155,15 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_close(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
(*parent_class)
|
||||
.close
|
||||
.map(|f| {
|
||||
if from_glib(f(element
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioEncoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -196,14 +180,15 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_start(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
(*parent_class)
|
||||
.start
|
||||
.map(|f| {
|
||||
if from_glib(f(element
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioEncoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -220,14 +205,15 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
(*parent_class)
|
||||
.stop
|
||||
.map(|f| {
|
||||
if from_glib(f(element
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioEncoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -244,11 +230,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_set_format(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
info: &AudioInfo,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
fn parent_set_format(&self, info: &AudioInfo) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
|
@ -257,7 +239,10 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioEncoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
info.to_glib_none().0 as *mut _
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -270,7 +255,6 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
|
||||
fn parent_handle_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: Option<&gst::Buffer>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
|
@ -280,7 +264,10 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
.handle_frame
|
||||
.map(|f| {
|
||||
try_from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.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()),
|
||||
|
@ -290,18 +277,17 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_pre_push(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: gst::Buffer,
|
||||
) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
||||
fn parent_pre_push(&self, buffer: gst::Buffer) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
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_glib_ptr();
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioEncoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
&mut buffer,
|
||||
))
|
||||
.map(|_| from_glib_full(buffer))
|
||||
|
@ -311,18 +297,24 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_flush(&self, element: &Self::Type) {
|
||||
fn parent_flush(&self) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
(*parent_class)
|
||||
.flush
|
||||
.map(|f| f(element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0))
|
||||
.map(|f| {
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioEncoder>()
|
||||
.to_glib_none()
|
||||
.0)
|
||||
})
|
||||
.unwrap_or(())
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
fn parent_negotiate(&self) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
|
@ -330,7 +322,11 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
.negotiate
|
||||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0),
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioEncoder>()
|
||||
.to_glib_none()
|
||||
.0),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `negotiate` failed"
|
||||
)
|
||||
|
@ -339,7 +335,7 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
fn parent_caps(&self, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
|
@ -347,19 +343,22 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
.getcaps
|
||||
.map(|f| {
|
||||
from_glib_full(f(
|
||||
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioEncoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
filter.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioEncoder>()
|
||||
.proxy_getcaps(None, filter)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
fn parent_sink_event(&self, event: gst::Event) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
|
@ -367,13 +366,16 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
.sink_event
|
||||
.expect("Missing parent function `sink_event`");
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioEncoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
event.into_glib_ptr(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
fn parent_sink_query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
|
@ -381,13 +383,16 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
.sink_query
|
||||
.expect("Missing parent function `sink_query`");
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioEncoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
fn parent_src_event(&self, event: gst::Event) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
|
@ -395,13 +400,16 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
.src_event
|
||||
.expect("Missing parent function `src_event`");
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioEncoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
event.into_glib_ptr(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
fn parent_src_query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioEncoderClass;
|
||||
|
@ -409,7 +417,10 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
.src_query
|
||||
.expect("Missing parent function `src_query`");
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioEncoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
))
|
||||
}
|
||||
|
@ -417,7 +428,6 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
|
||||
fn parent_propose_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
|
@ -428,7 +438,10 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioEncoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -441,7 +454,6 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
|
||||
fn parent_decide_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
|
@ -452,7 +464,10 @@ impl<T: AudioEncoderImpl> AudioEncoderImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<AudioEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioEncoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -492,13 +507,12 @@ unsafe extern "C" fn audio_encoder_open<T: AudioEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.open(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.open() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -511,13 +525,12 @@ unsafe extern "C" fn audio_encoder_close<T: AudioEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.close(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.close() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -530,13 +543,12 @@ unsafe extern "C" fn audio_encoder_start<T: AudioEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.start(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.start() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -549,13 +561,12 @@ unsafe extern "C" fn audio_encoder_stop<T: AudioEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.stop(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.stop() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -569,13 +580,12 @@ unsafe extern "C" fn audio_encoder_set_format<T: AudioEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.set_format(wrap.unsafe_cast_ref(), &from_glib_none(info)) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.set_format(&from_glib_none(info)) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -591,14 +601,10 @@ unsafe extern "C" fn audio_encoder_handle_frame<T: AudioEncoderImpl>(
|
|||
let buffer = buffer as *mut gst::ffi::GstBuffer;
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
imp.handle_frame(
|
||||
wrap.unsafe_cast_ref(),
|
||||
Option::<gst::Buffer>::from_glib_none(buffer).as_ref(),
|
||||
)
|
||||
.into()
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
imp.handle_frame(Option::<gst::Buffer>::from_glib_none(buffer).as_ref())
|
||||
.into()
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -609,10 +615,9 @@ unsafe extern "C" fn audio_encoder_pre_push<T: AudioEncoderImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
match imp.pre_push(wrap.unsafe_cast_ref(), from_glib_full(*buffer)) {
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
match imp.pre_push(from_glib_full(*buffer)) {
|
||||
Ok(Some(new_buffer)) => {
|
||||
*buffer = new_buffer.into_glib_ptr();
|
||||
Ok(gst::FlowSuccess::Ok)
|
||||
|
@ -631,11 +636,8 @@ unsafe extern "C" fn audio_encoder_pre_push<T: AudioEncoderImpl>(
|
|||
unsafe extern "C" fn audio_encoder_flush<T: AudioEncoderImpl>(ptr: *mut ffi::GstAudioEncoder) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), (), {
|
||||
AudioEncoderImpl::flush(imp, wrap.unsafe_cast_ref())
|
||||
})
|
||||
gst::panic_to_error!(imp, (), { AudioEncoderImpl::flush(imp,) })
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_negotiate<T: AudioEncoderImpl>(
|
||||
|
@ -643,13 +645,12 @@ unsafe extern "C" fn audio_encoder_negotiate<T: AudioEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.negotiate(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.negotiate() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -663,12 +664,10 @@ unsafe extern "C" fn audio_encoder_getcaps<T: AudioEncoderImpl>(
|
|||
) -> *mut gst::ffi::GstCaps {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::Caps::new_empty(), {
|
||||
gst::panic_to_error!(imp, gst::Caps::new_empty(), {
|
||||
AudioEncoderImpl::caps(
|
||||
imp,
|
||||
wrap.unsafe_cast_ref(),
|
||||
Option::<gst::Caps>::from_glib_borrow(filter)
|
||||
.as_ref()
|
||||
.as_ref(),
|
||||
|
@ -683,12 +682,8 @@ unsafe extern "C" fn audio_encoder_sink_event<T: AudioEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.sink_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, false, { imp.sink_event(from_glib_full(event)) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_sink_query<T: AudioEncoderImpl>(
|
||||
|
@ -697,10 +692,9 @@ unsafe extern "C" fn audio_encoder_sink_query<T: AudioEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.sink_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||
gst::panic_to_error!(imp, false, {
|
||||
imp.sink_query(gst::QueryRef::from_mut_ptr(query))
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -711,12 +705,8 @@ unsafe extern "C" fn audio_encoder_src_event<T: AudioEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, false, { imp.src_event(from_glib_full(event)) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audio_encoder_src_query<T: AudioEncoderImpl>(
|
||||
|
@ -725,10 +715,9 @@ unsafe extern "C" fn audio_encoder_src_query<T: AudioEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.src_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||
gst::panic_to_error!(imp, false, {
|
||||
imp.src_query(gst::QueryRef::from_mut_ptr(query))
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -739,17 +728,16 @@ unsafe extern "C" fn audio_encoder_propose_allocation<T: AudioEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
|
||||
gst::QueryViewMut::Allocation(allocation) => allocation,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.propose_allocation(wrap.unsafe_cast_ref(), query) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.propose_allocation(query) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -763,17 +751,16 @@ unsafe extern "C" fn audio_encoder_decide_allocation<T: AudioEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioEncoder> = from_glib_borrow(ptr);
|
||||
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
|
||||
gst::QueryViewMut::Allocation(allocation) => allocation,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.decide_allocation(query) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,55 +11,47 @@ use crate::AudioRingBufferSpec;
|
|||
use crate::AudioSink;
|
||||
|
||||
pub trait AudioSinkImpl: AudioSinkImplExt + AudioBaseSinkImpl {
|
||||
fn close(&self, sink: &Self::Type) -> Result<(), LoggableError> {
|
||||
self.parent_close(sink)
|
||||
fn close(&self) -> Result<(), LoggableError> {
|
||||
self.parent_close()
|
||||
}
|
||||
|
||||
fn delay(&self, sink: &Self::Type) -> u32 {
|
||||
self.parent_delay(sink)
|
||||
fn delay(&self) -> u32 {
|
||||
self.parent_delay()
|
||||
}
|
||||
|
||||
fn open(&self, sink: &Self::Type) -> Result<(), LoggableError> {
|
||||
self.parent_open(sink)
|
||||
fn open(&self) -> Result<(), LoggableError> {
|
||||
self.parent_open()
|
||||
}
|
||||
|
||||
fn prepare(
|
||||
&self,
|
||||
sink: &Self::Type,
|
||||
spec: &mut AudioRingBufferSpec,
|
||||
) -> Result<(), LoggableError> {
|
||||
AudioSinkImplExt::parent_prepare(self, sink, spec)
|
||||
fn prepare(&self, spec: &mut AudioRingBufferSpec) -> Result<(), LoggableError> {
|
||||
AudioSinkImplExt::parent_prepare(self, spec)
|
||||
}
|
||||
|
||||
fn unprepare(&self, sink: &Self::Type) -> Result<(), LoggableError> {
|
||||
self.parent_unprepare(sink)
|
||||
fn unprepare(&self) -> Result<(), LoggableError> {
|
||||
self.parent_unprepare()
|
||||
}
|
||||
|
||||
fn write(&self, sink: &Self::Type, audio_data: &[u8]) -> Result<i32, LoggableError> {
|
||||
self.parent_write(sink, audio_data)
|
||||
fn write(&self, audio_data: &[u8]) -> Result<i32, LoggableError> {
|
||||
self.parent_write(audio_data)
|
||||
}
|
||||
|
||||
fn reset(&self, sink: &Self::Type) {
|
||||
self.parent_reset(sink)
|
||||
fn reset(&self) {
|
||||
self.parent_reset()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait AudioSinkImplExt: ObjectSubclass {
|
||||
fn parent_close(&self, sink: &Self::Type) -> Result<(), LoggableError>;
|
||||
fn parent_delay(&self, sink: &Self::Type) -> u32;
|
||||
fn parent_open(&self, sink: &Self::Type) -> Result<(), LoggableError>;
|
||||
fn parent_prepare(
|
||||
&self,
|
||||
sink: &Self::Type,
|
||||
spec: &mut AudioRingBufferSpec,
|
||||
) -> Result<(), LoggableError>;
|
||||
fn parent_unprepare(&self, sink: &Self::Type) -> Result<(), LoggableError>;
|
||||
fn parent_write(&self, sink: &Self::Type, audio_data: &[u8]) -> Result<i32, LoggableError>;
|
||||
fn parent_reset(&self, sink: &Self::Type);
|
||||
fn parent_close(&self) -> Result<(), LoggableError>;
|
||||
fn parent_delay(&self) -> u32;
|
||||
fn parent_open(&self) -> Result<(), LoggableError>;
|
||||
fn parent_prepare(&self, spec: &mut AudioRingBufferSpec) -> Result<(), LoggableError>;
|
||||
fn parent_unprepare(&self) -> Result<(), LoggableError>;
|
||||
fn parent_write(&self, audio_data: &[u8]) -> Result<i32, LoggableError>;
|
||||
fn parent_reset(&self);
|
||||
}
|
||||
|
||||
impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
||||
fn parent_close(&self, sink: &Self::Type) -> Result<(), LoggableError> {
|
||||
fn parent_close(&self) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioSinkClass;
|
||||
|
@ -68,14 +60,18 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
|||
Some(f) => f,
|
||||
};
|
||||
gst::result_from_gboolean!(
|
||||
f(sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0),
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioSink>()
|
||||
.to_glib_none()
|
||||
.0),
|
||||
gst::CAT_RUST,
|
||||
"Failed to close element using the parent function"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_delay(&self, sink: &Self::Type) -> u32 {
|
||||
fn parent_delay(&self) -> u32 {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioSinkClass;
|
||||
|
@ -83,11 +79,15 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
|||
Some(f) => f,
|
||||
None => return 0,
|
||||
};
|
||||
f(sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0)
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioSink>()
|
||||
.to_glib_none()
|
||||
.0)
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_open(&self, sink: &Self::Type) -> Result<(), LoggableError> {
|
||||
fn parent_open(&self) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioSinkClass;
|
||||
|
@ -96,18 +96,18 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
|||
None => return Ok(()),
|
||||
};
|
||||
gst::result_from_gboolean!(
|
||||
f(sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0),
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioSink>()
|
||||
.to_glib_none()
|
||||
.0),
|
||||
gst::CAT_RUST,
|
||||
"Failed to open element using the parent function"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_prepare(
|
||||
&self,
|
||||
sink: &Self::Type,
|
||||
spec: &mut AudioRingBufferSpec,
|
||||
) -> Result<(), LoggableError> {
|
||||
fn parent_prepare(&self, spec: &mut AudioRingBufferSpec) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioSinkClass;
|
||||
|
@ -117,7 +117,10 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
|||
};
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioSink>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
&mut spec.0
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -126,7 +129,7 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_unprepare(&self, sink: &Self::Type) -> Result<(), LoggableError> {
|
||||
fn parent_unprepare(&self) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioSinkClass;
|
||||
|
@ -140,14 +143,18 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
|||
}
|
||||
};
|
||||
gst::result_from_gboolean!(
|
||||
f(sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0),
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioSink>()
|
||||
.to_glib_none()
|
||||
.0),
|
||||
gst::CAT_RUST,
|
||||
"Failed to unprepare element using the parent function"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_write(&self, sink: &Self::Type, buffer: &[u8]) -> Result<i32, LoggableError> {
|
||||
fn parent_write(&self, buffer: &[u8]) -> Result<i32, LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioSinkClass;
|
||||
|
@ -157,7 +164,10 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
|||
};
|
||||
let buffer_ptr = buffer.as_ptr() as *const _ as *mut _;
|
||||
let ret = f(
|
||||
sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioSink>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
buffer_ptr,
|
||||
buffer.len() as u32,
|
||||
);
|
||||
|
@ -172,12 +182,16 @@ impl<T: AudioSinkImpl> AudioSinkImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_reset(&self, sink: &Self::Type) {
|
||||
fn parent_reset(&self) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioSinkClass;
|
||||
if let Some(f) = (*parent_class).reset {
|
||||
f(sink.unsafe_cast_ref::<AudioSink>().to_glib_none().0)
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioSink>()
|
||||
.to_glib_none()
|
||||
.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -202,13 +216,12 @@ unsafe extern "C" fn audiosink_close<T: AudioSinkImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.close(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.close() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -219,11 +232,8 @@ unsafe extern "C" fn audiosink_close<T: AudioSinkImpl>(
|
|||
unsafe extern "C" fn audiosink_delay<T: AudioSinkImpl>(ptr: *mut ffi::GstAudioSink) -> u32 {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), 0, {
|
||||
imp.delay(wrap.unsafe_cast_ref())
|
||||
})
|
||||
gst::panic_to_error!(imp, 0, { imp.delay() })
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audiosink_open<T: AudioSinkImpl>(
|
||||
|
@ -231,13 +241,12 @@ unsafe extern "C" fn audiosink_open<T: AudioSinkImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.open(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.open() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -251,15 +260,14 @@ unsafe extern "C" fn audiosink_prepare<T: AudioSinkImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
||||
|
||||
let spec = &mut *(spec as *mut AudioRingBufferSpec);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match AudioSinkImpl::prepare(imp, wrap.unsafe_cast_ref(), spec) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match AudioSinkImpl::prepare(imp, spec) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -272,13 +280,12 @@ unsafe extern "C" fn audiosink_unprepare<T: AudioSinkImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.unprepare(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.unprepare() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -293,24 +300,20 @@ unsafe extern "C" fn audiosink_write<T: AudioSinkImpl>(
|
|||
) -> i32 {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
||||
let data_slice = if length == 0 {
|
||||
&[]
|
||||
} else {
|
||||
std::slice::from_raw_parts(data as *const u8, length as usize)
|
||||
};
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), -1, {
|
||||
imp.write(wrap.unsafe_cast_ref(), data_slice).unwrap_or(-1)
|
||||
})
|
||||
gst::panic_to_error!(imp, -1, { imp.write(data_slice).unwrap_or(-1) })
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audiosink_reset<T: AudioSinkImpl>(ptr: *mut ffi::GstAudioSink) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioSink> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), (), {
|
||||
imp.reset(wrap.unsafe_cast_ref());
|
||||
gst::panic_to_error!(imp, (), {
|
||||
imp.reset();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,63 +13,50 @@ use crate::AudioRingBufferSpec;
|
|||
use crate::AudioSrc;
|
||||
|
||||
pub trait AudioSrcImpl: AudioSrcImplExt + AudioBaseSrcImpl {
|
||||
fn close(&self, src: &Self::Type) -> Result<(), LoggableError> {
|
||||
self.parent_close(src)
|
||||
fn close(&self) -> Result<(), LoggableError> {
|
||||
self.parent_close()
|
||||
}
|
||||
|
||||
fn delay(&self, src: &Self::Type) -> u32 {
|
||||
self.parent_delay(src)
|
||||
fn delay(&self) -> u32 {
|
||||
self.parent_delay()
|
||||
}
|
||||
|
||||
fn open(&self, src: &Self::Type) -> Result<(), LoggableError> {
|
||||
self.parent_open(src)
|
||||
fn open(&self) -> Result<(), LoggableError> {
|
||||
self.parent_open()
|
||||
}
|
||||
|
||||
fn prepare(
|
||||
&self,
|
||||
src: &Self::Type,
|
||||
spec: &mut AudioRingBufferSpec,
|
||||
) -> Result<(), LoggableError> {
|
||||
AudioSrcImplExt::parent_prepare(self, src, spec)
|
||||
fn prepare(&self, spec: &mut AudioRingBufferSpec) -> Result<(), LoggableError> {
|
||||
AudioSrcImplExt::parent_prepare(self, spec)
|
||||
}
|
||||
|
||||
fn unprepare(&self, src: &Self::Type) -> Result<(), LoggableError> {
|
||||
self.parent_unprepare(src)
|
||||
fn unprepare(&self) -> Result<(), LoggableError> {
|
||||
self.parent_unprepare()
|
||||
}
|
||||
|
||||
fn read(
|
||||
&self,
|
||||
src: &Self::Type,
|
||||
audio_data: &mut [u8],
|
||||
) -> Result<(u32, Option<gst::ClockTime>), LoggableError> {
|
||||
self.parent_read(src, audio_data)
|
||||
fn read(&self, audio_data: &mut [u8]) -> Result<(u32, Option<gst::ClockTime>), LoggableError> {
|
||||
self.parent_read(audio_data)
|
||||
}
|
||||
|
||||
fn reset(&self, src: &Self::Type) {
|
||||
self.parent_reset(src)
|
||||
fn reset(&self) {
|
||||
self.parent_reset()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait AudioSrcImplExt: ObjectSubclass {
|
||||
fn parent_close(&self, src: &Self::Type) -> Result<(), LoggableError>;
|
||||
fn parent_delay(&self, src: &Self::Type) -> u32;
|
||||
fn parent_open(&self, src: &Self::Type) -> Result<(), LoggableError>;
|
||||
fn parent_prepare(
|
||||
&self,
|
||||
src: &Self::Type,
|
||||
spec: &mut AudioRingBufferSpec,
|
||||
) -> Result<(), LoggableError>;
|
||||
fn parent_unprepare(&self, src: &Self::Type) -> Result<(), LoggableError>;
|
||||
fn parent_close(&self) -> Result<(), LoggableError>;
|
||||
fn parent_delay(&self) -> u32;
|
||||
fn parent_open(&self) -> Result<(), LoggableError>;
|
||||
fn parent_prepare(&self, spec: &mut AudioRingBufferSpec) -> Result<(), LoggableError>;
|
||||
fn parent_unprepare(&self) -> Result<(), LoggableError>;
|
||||
fn parent_read(
|
||||
&self,
|
||||
src: &Self::Type,
|
||||
audio_data: &mut [u8],
|
||||
) -> Result<(u32, Option<gst::ClockTime>), LoggableError>;
|
||||
fn parent_reset(&self, src: &Self::Type);
|
||||
fn parent_reset(&self);
|
||||
}
|
||||
|
||||
impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
||||
fn parent_close(&self, src: &Self::Type) -> Result<(), LoggableError> {
|
||||
fn parent_close(&self) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioSrcClass;
|
||||
|
@ -78,14 +65,18 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
|||
Some(f) => f,
|
||||
};
|
||||
gst::result_from_gboolean!(
|
||||
f(src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0),
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioSrc>()
|
||||
.to_glib_none()
|
||||
.0),
|
||||
gst::CAT_RUST,
|
||||
"Failed to close element using the parent function"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_delay(&self, src: &Self::Type) -> u32 {
|
||||
fn parent_delay(&self) -> u32 {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioSrcClass;
|
||||
|
@ -93,11 +84,15 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
|||
Some(f) => f,
|
||||
None => return 0,
|
||||
};
|
||||
f(src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0)
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioSrc>()
|
||||
.to_glib_none()
|
||||
.0)
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_open(&self, src: &Self::Type) -> Result<(), LoggableError> {
|
||||
fn parent_open(&self) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioSrcClass;
|
||||
|
@ -106,18 +101,18 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
|||
None => return Ok(()),
|
||||
};
|
||||
gst::result_from_gboolean!(
|
||||
f(src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0),
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioSrc>()
|
||||
.to_glib_none()
|
||||
.0),
|
||||
gst::CAT_RUST,
|
||||
"Failed to open element using the parent function"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_prepare(
|
||||
&self,
|
||||
src: &Self::Type,
|
||||
spec: &mut AudioRingBufferSpec,
|
||||
) -> Result<(), LoggableError> {
|
||||
fn parent_prepare(&self, spec: &mut AudioRingBufferSpec) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioSrcClass;
|
||||
|
@ -127,7 +122,10 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
|||
};
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioSrc>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
&mut spec.0
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -136,7 +134,7 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_unprepare(&self, src: &Self::Type) -> Result<(), LoggableError> {
|
||||
fn parent_unprepare(&self) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioSrcClass;
|
||||
|
@ -150,7 +148,11 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
|||
}
|
||||
};
|
||||
gst::result_from_gboolean!(
|
||||
f(src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0),
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioSrc>()
|
||||
.to_glib_none()
|
||||
.0),
|
||||
gst::CAT_RUST,
|
||||
"Failed to unprepare element using the parent function"
|
||||
)
|
||||
|
@ -159,7 +161,6 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
|||
|
||||
fn parent_read(
|
||||
&self,
|
||||
src: &Self::Type,
|
||||
buffer: &mut [u8],
|
||||
) -> Result<(u32, Option<gst::ClockTime>), LoggableError> {
|
||||
unsafe {
|
||||
|
@ -172,7 +173,10 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
|||
let buffer_ptr = buffer.as_mut_ptr() as *mut _;
|
||||
let mut timestamp = mem::MaybeUninit::uninit();
|
||||
let ret = f(
|
||||
src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioSrc>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
buffer_ptr,
|
||||
buffer.len() as u32,
|
||||
timestamp.as_mut_ptr(),
|
||||
|
@ -188,12 +192,16 @@ impl<T: AudioSrcImpl> AudioSrcImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_reset(&self, src: &Self::Type) {
|
||||
fn parent_reset(&self) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAudioSrcClass;
|
||||
if let Some(f) = (*parent_class).reset {
|
||||
f(src.unsafe_cast_ref::<AudioSrc>().to_glib_none().0)
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioSrc>()
|
||||
.to_glib_none()
|
||||
.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -218,13 +226,12 @@ unsafe extern "C" fn audiosrc_close<T: AudioSrcImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.close(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.close() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -235,11 +242,8 @@ unsafe extern "C" fn audiosrc_close<T: AudioSrcImpl>(
|
|||
unsafe extern "C" fn audiosrc_delay<T: AudioSrcImpl>(ptr: *mut ffi::GstAudioSrc) -> u32 {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), 0, {
|
||||
imp.delay(wrap.unsafe_cast_ref())
|
||||
})
|
||||
gst::panic_to_error!(imp, 0, { imp.delay() })
|
||||
}
|
||||
|
||||
unsafe extern "C" fn audiosrc_open<T: AudioSrcImpl>(
|
||||
|
@ -247,13 +251,12 @@ unsafe extern "C" fn audiosrc_open<T: AudioSrcImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.open(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.open() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -267,15 +270,14 @@ unsafe extern "C" fn audiosrc_prepare<T: AudioSrcImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
||||
|
||||
let spec = &mut *(spec as *mut AudioRingBufferSpec);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match AudioSrcImpl::prepare(imp, wrap.unsafe_cast_ref(), spec) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match AudioSrcImpl::prepare(imp, spec) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -288,13 +290,12 @@ unsafe extern "C" fn audiosrc_unprepare<T: AudioSrcImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.unprepare(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.unprepare() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -310,17 +311,14 @@ unsafe extern "C" fn audiosrc_read<T: AudioSrcImpl>(
|
|||
) -> u32 {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
||||
let data_slice = if length == 0 {
|
||||
&mut []
|
||||
} else {
|
||||
std::slice::from_raw_parts_mut(data as *mut u8, length as usize)
|
||||
};
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), 0, {
|
||||
let (res, timestamp_res) = imp
|
||||
.read(wrap.unsafe_cast_ref(), data_slice)
|
||||
.unwrap_or((0, gst::ClockTime::NONE));
|
||||
gst::panic_to_error!(imp, 0, {
|
||||
let (res, timestamp_res) = imp.read(data_slice).unwrap_or((0, gst::ClockTime::NONE));
|
||||
*timestamp = timestamp_res.into_glib();
|
||||
|
||||
res
|
||||
|
@ -330,9 +328,8 @@ unsafe extern "C" fn audiosrc_read<T: AudioSrcImpl>(
|
|||
unsafe extern "C" fn audiosrc_reset<T: AudioSrcImpl>(ptr: *mut ffi::GstAudioSrc) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), (), {
|
||||
imp.reset(wrap.unsafe_cast_ref());
|
||||
gst::panic_to_error!(imp, (), {
|
||||
imp.reset();
|
||||
});
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -9,45 +9,23 @@ use crate::Aggregator;
|
|||
use crate::AggregatorPad;
|
||||
|
||||
pub trait AggregatorPadImpl: AggregatorPadImplExt + PadImpl {
|
||||
fn flush(
|
||||
&self,
|
||||
aggregator_pad: &Self::Type,
|
||||
aggregator: &Aggregator,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_flush(aggregator_pad, aggregator)
|
||||
fn flush(&self, aggregator: &Aggregator) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_flush(aggregator)
|
||||
}
|
||||
|
||||
fn skip_buffer(
|
||||
&self,
|
||||
aggregator_pad: &Self::Type,
|
||||
aggregator: &Aggregator,
|
||||
buffer: &gst::Buffer,
|
||||
) -> bool {
|
||||
self.parent_skip_buffer(aggregator_pad, aggregator, buffer)
|
||||
fn skip_buffer(&self, aggregator: &Aggregator, buffer: &gst::Buffer) -> bool {
|
||||
self.parent_skip_buffer(aggregator, buffer)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait AggregatorPadImplExt: ObjectSubclass {
|
||||
fn parent_flush(
|
||||
&self,
|
||||
aggregator_pad: &Self::Type,
|
||||
aggregator: &Aggregator,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
fn parent_flush(&self, aggregator: &Aggregator) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_skip_buffer(
|
||||
&self,
|
||||
aggregator_pad: &Self::Type,
|
||||
aggregator: &Aggregator,
|
||||
buffer: &gst::Buffer,
|
||||
) -> bool;
|
||||
fn parent_skip_buffer(&self, aggregator: &Aggregator, buffer: &gst::Buffer) -> bool;
|
||||
}
|
||||
|
||||
impl<T: AggregatorPadImpl> AggregatorPadImplExt for T {
|
||||
fn parent_flush(
|
||||
&self,
|
||||
aggregator_pad: &Self::Type,
|
||||
aggregator: &Aggregator,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
fn parent_flush(&self, aggregator: &Aggregator) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorPadClass;
|
||||
|
@ -55,7 +33,7 @@ impl<T: AggregatorPadImpl> AggregatorPadImplExt for T {
|
|||
.flush
|
||||
.map(|f| {
|
||||
try_from_glib(f(
|
||||
aggregator_pad
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AggregatorPad>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -66,12 +44,7 @@ impl<T: AggregatorPadImpl> AggregatorPadImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_skip_buffer(
|
||||
&self,
|
||||
aggregator_pad: &Self::Type,
|
||||
aggregator: &Aggregator,
|
||||
buffer: &gst::Buffer,
|
||||
) -> bool {
|
||||
fn parent_skip_buffer(&self, aggregator: &Aggregator, buffer: &gst::Buffer) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstAggregatorPadClass;
|
||||
|
@ -79,7 +52,7 @@ impl<T: AggregatorPadImpl> AggregatorPadImplExt for T {
|
|||
.skip_buffer
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
aggregator_pad
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AggregatorPad>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -106,11 +79,8 @@ unsafe extern "C" fn aggregator_pad_flush<T: AggregatorPadImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AggregatorPad> = from_glib_borrow(ptr);
|
||||
|
||||
let res: gst::FlowReturn = imp
|
||||
.flush(wrap.unsafe_cast_ref(), &from_glib_borrow(aggregator))
|
||||
.into();
|
||||
let res: gst::FlowReturn = imp.flush(&from_glib_borrow(aggregator)).into();
|
||||
res.into_glib()
|
||||
}
|
||||
|
||||
|
@ -121,12 +91,7 @@ unsafe extern "C" fn aggregator_pad_skip_buffer<T: AggregatorPadImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AggregatorPad> = from_glib_borrow(ptr);
|
||||
|
||||
imp.skip_buffer(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&from_glib_borrow(aggregator),
|
||||
&from_glib_borrow(buffer),
|
||||
)
|
||||
.into_glib()
|
||||
imp.skip_buffer(&from_glib_borrow(aggregator), &from_glib_borrow(buffer))
|
||||
.into_glib()
|
||||
}
|
||||
|
|
|
@ -12,74 +12,67 @@ use crate::BaseParse;
|
|||
use crate::BaseParseFrame;
|
||||
|
||||
pub trait BaseParseImpl: BaseParseImplExt + ElementImpl {
|
||||
fn start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_start(element)
|
||||
fn start(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_start()
|
||||
}
|
||||
|
||||
fn stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_stop(element)
|
||||
fn stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_stop()
|
||||
}
|
||||
|
||||
fn set_sink_caps(
|
||||
fn set_sink_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_sink_caps(caps)
|
||||
}
|
||||
|
||||
fn handle_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_sink_caps(element, caps)
|
||||
}
|
||||
|
||||
fn handle_frame<'a>(
|
||||
&'a self,
|
||||
element: &Self::Type,
|
||||
frame: BaseParseFrame,
|
||||
) -> Result<(gst::FlowSuccess, u32), gst::FlowError> {
|
||||
self.parent_handle_frame(element, frame)
|
||||
self.parent_handle_frame(frame)
|
||||
}
|
||||
|
||||
fn convert(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
src_val: impl gst::FormattedValue,
|
||||
dest_format: gst::Format,
|
||||
) -> Option<gst::GenericFormattedValue> {
|
||||
self.parent_convert(element, src_val, dest_format)
|
||||
self.parent_convert(src_val, dest_format)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait BaseParseImplExt: ObjectSubclass {
|
||||
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_start(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_stop(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_set_sink_caps(
|
||||
fn parent_set_sink_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_handle_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_handle_frame<'a>(
|
||||
&'a self,
|
||||
element: &Self::Type,
|
||||
frame: BaseParseFrame,
|
||||
) -> Result<(gst::FlowSuccess, u32), gst::FlowError>;
|
||||
|
||||
fn parent_convert(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
src_val: impl gst::FormattedValue,
|
||||
dest_format: gst::Format,
|
||||
) -> Option<gst::GenericFormattedValue>;
|
||||
}
|
||||
|
||||
impl<T: BaseParseImpl> BaseParseImplExt for T {
|
||||
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_start(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseParseClass;
|
||||
(*parent_class)
|
||||
.start
|
||||
.map(|f| {
|
||||
if from_glib(f(element.unsafe_cast_ref::<BaseParse>().to_glib_none().0)) {
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<BaseParse>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst::error_msg!(
|
||||
|
@ -92,14 +85,19 @@ impl<T: BaseParseImpl> BaseParseImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseParseClass;
|
||||
(*parent_class)
|
||||
.stop
|
||||
.map(|f| {
|
||||
if from_glib(f(element.unsafe_cast_ref::<BaseParse>().to_glib_none().0)) {
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<BaseParse>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst::error_msg!(
|
||||
|
@ -112,11 +110,7 @@ impl<T: BaseParseImpl> BaseParseImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_set_sink_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
fn parent_set_sink_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseParseClass;
|
||||
|
@ -125,7 +119,10 @@ impl<T: BaseParseImpl> BaseParseImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<BaseParse>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseParse>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
caps.to_glib_none().0,
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -136,9 +133,8 @@ impl<T: BaseParseImpl> BaseParseImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_handle_frame<'a>(
|
||||
&'a self,
|
||||
element: &'a Self::Type,
|
||||
fn parent_handle_frame(
|
||||
&self,
|
||||
frame: BaseParseFrame,
|
||||
) -> Result<(gst::FlowSuccess, u32), gst::FlowError> {
|
||||
unsafe {
|
||||
|
@ -149,7 +145,10 @@ impl<T: BaseParseImpl> BaseParseImplExt for T {
|
|||
.handle_frame
|
||||
.map(|f| {
|
||||
let res = try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseParse>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseParse>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
frame.to_glib_none().0,
|
||||
&mut skipsize,
|
||||
));
|
||||
|
@ -161,7 +160,6 @@ impl<T: BaseParseImpl> BaseParseImplExt for T {
|
|||
|
||||
fn parent_convert(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
src_val: impl gst::FormattedValue,
|
||||
dest_format: gst::Format,
|
||||
) -> Option<gst::GenericFormattedValue> {
|
||||
|
@ -172,7 +170,10 @@ impl<T: BaseParseImpl> BaseParseImplExt for T {
|
|||
let mut dest_val = mem::MaybeUninit::uninit();
|
||||
|
||||
let res = from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseParse>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseParse>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
src_val.format().into_glib(),
|
||||
src_val.into_raw_value(),
|
||||
dest_format.into_glib(),
|
||||
|
@ -209,13 +210,12 @@ unsafe extern "C" fn base_parse_start<T: BaseParseImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseParse> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.start(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.start() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -228,13 +228,12 @@ unsafe extern "C" fn base_parse_stop<T: BaseParseImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseParse> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.stop(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.stop() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -248,14 +247,13 @@ unsafe extern "C" fn base_parse_set_sink_caps<T: BaseParseImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseParse> = from_glib_borrow(ptr);
|
||||
let caps: Borrowed<gst::Caps> = from_glib_borrow(caps);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.set_sink_caps(wrap.unsafe_cast_ref(), &caps) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.set_sink_caps(&caps) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -270,11 +268,12 @@ unsafe extern "C" fn base_parse_handle_frame<T: BaseParseImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseParse> = from_glib_borrow(ptr);
|
||||
let wrap_frame = BaseParseFrame::new(frame, &wrap);
|
||||
let instance = imp.instance();
|
||||
let instance = instance.unsafe_cast_ref::<BaseParse>();
|
||||
let wrap_frame = BaseParseFrame::new(frame, instance);
|
||||
|
||||
let res = gst::panic_to_error!(&wrap, imp.panicked(), Err(gst::FlowError::Error), {
|
||||
imp.handle_frame(wrap.unsafe_cast_ref(), wrap_frame)
|
||||
let res = gst::panic_to_error!(imp, Err(gst::FlowError::Error), {
|
||||
imp.handle_frame(wrap_frame)
|
||||
});
|
||||
|
||||
match res {
|
||||
|
@ -296,12 +295,9 @@ unsafe extern "C" fn base_parse_convert<T: BaseParseImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseParse> = from_glib_borrow(ptr);
|
||||
let source = gst::GenericFormattedValue::new(from_glib(source_format), source_value);
|
||||
|
||||
let res = gst::panic_to_error!(&wrap, imp.panicked(), None, {
|
||||
imp.convert(wrap.unsafe_cast_ref(), source, from_glib(dest_format))
|
||||
});
|
||||
let res = gst::panic_to_error!(imp, None, { imp.convert(source, from_glib(dest_format)) });
|
||||
|
||||
match res {
|
||||
Some(dest) => {
|
||||
|
|
|
@ -10,146 +10,119 @@ use std::ptr;
|
|||
use crate::BaseSink;
|
||||
|
||||
pub trait BaseSinkImpl: BaseSinkImplExt + ElementImpl {
|
||||
fn start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_start(element)
|
||||
fn start(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_start()
|
||||
}
|
||||
|
||||
fn stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_stop(element)
|
||||
fn stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_stop()
|
||||
}
|
||||
|
||||
fn render(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: &gst::Buffer,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_render(element, buffer)
|
||||
fn render(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_render(buffer)
|
||||
}
|
||||
|
||||
fn prepare(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: &gst::Buffer,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_prepare(element, buffer)
|
||||
fn prepare(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_prepare(buffer)
|
||||
}
|
||||
|
||||
fn render_list(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
list: &gst::BufferList,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_render_list(element, list)
|
||||
fn render_list(&self, list: &gst::BufferList) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_render_list(list)
|
||||
}
|
||||
|
||||
fn prepare_list(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
list: &gst::BufferList,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_prepare_list(element, list)
|
||||
fn prepare_list(&self, list: &gst::BufferList) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_prepare_list(list)
|
||||
}
|
||||
|
||||
fn query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
BaseSinkImplExt::parent_query(self, element, query)
|
||||
fn query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
BaseSinkImplExt::parent_query(self, query)
|
||||
}
|
||||
|
||||
fn event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
self.parent_event(element, event)
|
||||
fn event(&self, event: gst::Event) -> bool {
|
||||
self.parent_event(event)
|
||||
}
|
||||
|
||||
fn caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> Option<gst::Caps> {
|
||||
self.parent_caps(element, filter)
|
||||
fn caps(&self, filter: Option<&gst::Caps>) -> Option<gst::Caps> {
|
||||
self.parent_caps(filter)
|
||||
}
|
||||
|
||||
fn set_caps(&self, element: &Self::Type, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_caps(element, caps)
|
||||
fn set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_caps(caps)
|
||||
}
|
||||
|
||||
fn fixate(&self, element: &Self::Type, caps: gst::Caps) -> gst::Caps {
|
||||
self.parent_fixate(element, caps)
|
||||
fn fixate(&self, caps: gst::Caps) -> gst::Caps {
|
||||
self.parent_fixate(caps)
|
||||
}
|
||||
|
||||
fn unlock(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_unlock(element)
|
||||
fn unlock(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_unlock()
|
||||
}
|
||||
|
||||
fn unlock_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_unlock_stop(element)
|
||||
fn unlock_stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_unlock_stop()
|
||||
}
|
||||
|
||||
fn propose_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_propose_allocation(element, query)
|
||||
self.parent_propose_allocation(query)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait BaseSinkImplExt: ObjectSubclass {
|
||||
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_start(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_stop(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_render(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: &gst::Buffer,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
fn parent_render(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_prepare(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: &gst::Buffer,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
fn parent_prepare(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_render_list(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
list: &gst::BufferList,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_prepare_list(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
list: &gst::BufferList,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool;
|
||||
fn parent_query(&self, query: &mut gst::QueryRef) -> bool;
|
||||
|
||||
fn parent_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||
fn parent_event(&self, event: gst::Event) -> bool;
|
||||
|
||||
fn parent_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> Option<gst::Caps>;
|
||||
fn parent_caps(&self, filter: Option<&gst::Caps>) -> Option<gst::Caps>;
|
||||
|
||||
fn parent_set_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
fn parent_set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_fixate(&self, element: &Self::Type, caps: gst::Caps) -> gst::Caps;
|
||||
fn parent_fixate(&self, caps: gst::Caps) -> gst::Caps;
|
||||
|
||||
fn parent_unlock(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_unlock(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_unlock_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_unlock_stop(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_propose_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
}
|
||||
|
||||
impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
||||
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_start(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass;
|
||||
(*parent_class)
|
||||
.start
|
||||
.map(|f| {
|
||||
if from_glib(f(element.unsafe_cast_ref::<BaseSink>().to_glib_none().0)) {
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<BaseSink>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst::error_msg!(
|
||||
|
@ -162,14 +135,19 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass;
|
||||
(*parent_class)
|
||||
.stop
|
||||
.map(|f| {
|
||||
if from_glib(f(element.unsafe_cast_ref::<BaseSink>().to_glib_none().0)) {
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<BaseSink>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst::error_msg!(
|
||||
|
@ -182,11 +160,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_render(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: &gst::Buffer,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
fn parent_render(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass;
|
||||
|
@ -194,7 +168,10 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
.render
|
||||
.map(|f| {
|
||||
try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSink>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
buffer.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
|
@ -202,11 +179,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_prepare(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: &gst::Buffer,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
fn parent_prepare(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass;
|
||||
|
@ -214,7 +187,10 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
.prepare
|
||||
.map(|f| {
|
||||
try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSink>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
buffer.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
|
@ -224,7 +200,6 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
|
||||
fn parent_render_list(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
list: &gst::BufferList,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
|
@ -234,13 +209,16 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
.render_list
|
||||
.map(|f| {
|
||||
try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSink>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
list.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
for buffer in list.iter() {
|
||||
self.render(element, &from_glib_borrow(buffer.as_ptr()))?;
|
||||
self.render(&from_glib_borrow(buffer.as_ptr()))?;
|
||||
}
|
||||
Ok(gst::FlowSuccess::Ok)
|
||||
})
|
||||
|
@ -249,7 +227,6 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
|
||||
fn parent_prepare_list(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
list: &gst::BufferList,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
|
@ -259,20 +236,23 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
.prepare_list
|
||||
.map(|f| {
|
||||
try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSink>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
list.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
for buffer in list.iter() {
|
||||
self.prepare(element, &from_glib_borrow(buffer.as_ptr()))?;
|
||||
self.prepare(&from_glib_borrow(buffer.as_ptr()))?;
|
||||
}
|
||||
Ok(gst::FlowSuccess::Ok)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
fn parent_query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass;
|
||||
|
@ -280,7 +260,10 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
.query
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSink>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
))
|
||||
})
|
||||
|
@ -288,7 +271,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
fn parent_event(&self, event: gst::Event) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass;
|
||||
|
@ -296,7 +279,10 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
.event
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSink>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
event.into_glib_ptr(),
|
||||
))
|
||||
})
|
||||
|
@ -304,7 +290,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> Option<gst::Caps> {
|
||||
fn parent_caps(&self, filter: Option<&gst::Caps>) -> Option<gst::Caps> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass;
|
||||
|
@ -313,7 +299,10 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
.get_caps
|
||||
.map(|f| {
|
||||
from_glib_full(f(
|
||||
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSink>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
filter.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
|
@ -321,11 +310,7 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_set_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
fn parent_set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass;
|
||||
|
@ -334,7 +319,10 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSink>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
caps.to_glib_none().0
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -345,14 +333,17 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_fixate(&self, element: &Self::Type, caps: gst::Caps) -> gst::Caps {
|
||||
fn parent_fixate(&self, caps: gst::Caps) -> gst::Caps {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass;
|
||||
|
||||
match (*parent_class).fixate {
|
||||
Some(fixate) => from_glib_full(fixate(
|
||||
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSink>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
caps.into_glib_ptr(),
|
||||
)),
|
||||
None => caps,
|
||||
|
@ -360,14 +351,19 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_unlock(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_unlock(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass;
|
||||
(*parent_class)
|
||||
.unlock
|
||||
.map(|f| {
|
||||
if from_glib(f(element.unsafe_cast_ref::<BaseSink>().to_glib_none().0)) {
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<BaseSink>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst::error_msg!(
|
||||
|
@ -380,14 +376,19 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_unlock_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_unlock_stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSinkClass;
|
||||
(*parent_class)
|
||||
.unlock_stop
|
||||
.map(|f| {
|
||||
if from_glib(f(element.unsafe_cast_ref::<BaseSink>().to_glib_none().0)) {
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<BaseSink>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst::error_msg!(
|
||||
|
@ -402,7 +403,6 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
|
||||
fn parent_propose_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
|
@ -413,7 +413,10 @@ impl<T: BaseSinkImpl> BaseSinkImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<BaseSink>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSink>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -451,13 +454,12 @@ unsafe extern "C" fn base_sink_start<T: BaseSinkImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.start(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.start() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -470,13 +472,12 @@ unsafe extern "C" fn base_sink_stop<T: BaseSinkImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.stop(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.stop() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -490,13 +491,9 @@ unsafe extern "C" fn base_sink_render<T: BaseSinkImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
|
||||
let buffer = from_glib_borrow(buffer);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
imp.render(wrap.unsafe_cast_ref(), &buffer).into()
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, { imp.render(&buffer).into() }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_sink_prepare<T: BaseSinkImpl>(
|
||||
|
@ -505,13 +502,9 @@ unsafe extern "C" fn base_sink_prepare<T: BaseSinkImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
|
||||
let buffer = from_glib_borrow(buffer);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
imp.prepare(wrap.unsafe_cast_ref(), &buffer).into()
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, { imp.prepare(&buffer).into() }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_sink_render_list<T: BaseSinkImpl>(
|
||||
|
@ -520,11 +513,10 @@ unsafe extern "C" fn base_sink_render_list<T: BaseSinkImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
|
||||
let list = from_glib_borrow(list);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
imp.render_list(wrap.unsafe_cast_ref(), &list).into()
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
imp.render_list(&list).into()
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -535,11 +527,10 @@ unsafe extern "C" fn base_sink_prepare_list<T: BaseSinkImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
|
||||
let list = from_glib_borrow(list);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
imp.prepare_list(wrap.unsafe_cast_ref(), &list).into()
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
imp.prepare_list(&list).into()
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -550,13 +541,9 @@ unsafe extern "C" fn base_sink_query<T: BaseSinkImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
|
||||
let query = gst::QueryRef::from_mut_ptr(query_ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
BaseSinkImpl::query(imp, wrap.unsafe_cast_ref(), query)
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, false, { BaseSinkImpl::query(imp, query) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_sink_event<T: BaseSinkImpl>(
|
||||
|
@ -565,12 +552,8 @@ unsafe extern "C" fn base_sink_event<T: BaseSinkImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.event(wrap.unsafe_cast_ref(), from_glib_full(event_ptr))
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, false, { imp.event(from_glib_full(event_ptr)) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_sink_get_caps<T: BaseSinkImpl>(
|
||||
|
@ -579,14 +562,11 @@ unsafe extern "C" fn base_sink_get_caps<T: BaseSinkImpl>(
|
|||
) -> *mut gst::ffi::GstCaps {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
|
||||
let filter = Option::<gst::Caps>::from_glib_borrow(filter);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), None, {
|
||||
imp.caps(wrap.unsafe_cast_ref(), filter.as_ref().as_ref())
|
||||
})
|
||||
.map(|caps| caps.into_glib_ptr())
|
||||
.unwrap_or(ptr::null_mut())
|
||||
gst::panic_to_error!(imp, None, { imp.caps(filter.as_ref().as_ref()) })
|
||||
.map(|caps| caps.into_glib_ptr())
|
||||
.unwrap_or(ptr::null_mut())
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_sink_set_caps<T: BaseSinkImpl>(
|
||||
|
@ -595,14 +575,13 @@ unsafe extern "C" fn base_sink_set_caps<T: BaseSinkImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
|
||||
let caps = from_glib_borrow(caps);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.set_caps(wrap.unsafe_cast_ref(), &caps) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.set_caps(&caps) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -616,13 +595,9 @@ unsafe extern "C" fn base_sink_fixate<T: BaseSinkImpl>(
|
|||
) -> *mut gst::ffi::GstCaps {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
|
||||
let caps = from_glib_full(caps);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::Caps::new_empty(), {
|
||||
imp.fixate(wrap.unsafe_cast_ref(), caps)
|
||||
})
|
||||
.into_glib_ptr()
|
||||
gst::panic_to_error!(imp, gst::Caps::new_empty(), { imp.fixate(caps) }).into_glib_ptr()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_sink_unlock<T: BaseSinkImpl>(
|
||||
|
@ -630,13 +605,12 @@ unsafe extern "C" fn base_sink_unlock<T: BaseSinkImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.unlock(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.unlock() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -649,13 +623,12 @@ unsafe extern "C" fn base_sink_unlock_stop<T: BaseSinkImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.unlock_stop(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.unlock_stop() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -669,17 +642,16 @@ unsafe extern "C" fn base_sink_propose_allocation<T: BaseSinkImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSink> = from_glib_borrow(ptr);
|
||||
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
|
||||
gst::QueryViewMut::Allocation(allocation) => allocation,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.propose_allocation(wrap.unsafe_cast_ref(), query) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.propose_allocation(query) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,181 +27,161 @@ pub enum CreateSuccess {
|
|||
}
|
||||
|
||||
pub trait BaseSrcImpl: BaseSrcImplExt + ElementImpl {
|
||||
fn start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_start(element)
|
||||
fn start(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_start()
|
||||
}
|
||||
|
||||
fn stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_stop(element)
|
||||
fn stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_stop()
|
||||
}
|
||||
|
||||
fn is_seekable(&self, element: &Self::Type) -> bool {
|
||||
self.parent_is_seekable(element)
|
||||
fn is_seekable(&self) -> bool {
|
||||
self.parent_is_seekable()
|
||||
}
|
||||
|
||||
fn size(&self, element: &Self::Type) -> Option<u64> {
|
||||
self.parent_size(element)
|
||||
fn size(&self) -> Option<u64> {
|
||||
self.parent_size()
|
||||
}
|
||||
|
||||
#[doc(alias = "get_times")]
|
||||
fn times(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: &gst::BufferRef,
|
||||
) -> (Option<gst::ClockTime>, Option<gst::ClockTime>) {
|
||||
self.parent_times(element, buffer)
|
||||
fn times(&self, buffer: &gst::BufferRef) -> (Option<gst::ClockTime>, Option<gst::ClockTime>) {
|
||||
self.parent_times(buffer)
|
||||
}
|
||||
|
||||
fn fill(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
offset: u64,
|
||||
length: u32,
|
||||
buffer: &mut gst::BufferRef,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_fill(element, offset, length, buffer)
|
||||
self.parent_fill(offset, length, buffer)
|
||||
}
|
||||
|
||||
fn alloc(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
offset: u64,
|
||||
length: u32,
|
||||
) -> Result<gst::Buffer, gst::FlowError> {
|
||||
self.parent_alloc(element, offset, length)
|
||||
fn alloc(&self, offset: u64, length: u32) -> Result<gst::Buffer, gst::FlowError> {
|
||||
self.parent_alloc(offset, length)
|
||||
}
|
||||
|
||||
fn create(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
offset: u64,
|
||||
buffer: Option<&mut gst::BufferRef>,
|
||||
length: u32,
|
||||
) -> Result<CreateSuccess, gst::FlowError> {
|
||||
self.parent_create(element, offset, buffer, length)
|
||||
self.parent_create(offset, buffer, length)
|
||||
}
|
||||
|
||||
fn do_seek(&self, element: &Self::Type, segment: &mut gst::Segment) -> bool {
|
||||
self.parent_do_seek(element, segment)
|
||||
fn do_seek(&self, segment: &mut gst::Segment) -> bool {
|
||||
self.parent_do_seek(segment)
|
||||
}
|
||||
|
||||
fn query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
BaseSrcImplExt::parent_query(self, element, query)
|
||||
fn query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
BaseSrcImplExt::parent_query(self, query)
|
||||
}
|
||||
|
||||
fn event(&self, element: &Self::Type, event: &gst::Event) -> bool {
|
||||
self.parent_event(element, event)
|
||||
fn event(&self, event: &gst::Event) -> bool {
|
||||
self.parent_event(event)
|
||||
}
|
||||
|
||||
fn caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> Option<gst::Caps> {
|
||||
self.parent_caps(element, filter)
|
||||
fn caps(&self, filter: Option<&gst::Caps>) -> Option<gst::Caps> {
|
||||
self.parent_caps(filter)
|
||||
}
|
||||
|
||||
fn negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
self.parent_negotiate(element)
|
||||
fn negotiate(&self) -> Result<(), gst::LoggableError> {
|
||||
self.parent_negotiate()
|
||||
}
|
||||
|
||||
fn set_caps(&self, element: &Self::Type, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_caps(element, caps)
|
||||
fn set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_caps(caps)
|
||||
}
|
||||
|
||||
fn fixate(&self, element: &Self::Type, caps: gst::Caps) -> gst::Caps {
|
||||
self.parent_fixate(element, caps)
|
||||
fn fixate(&self, caps: gst::Caps) -> gst::Caps {
|
||||
self.parent_fixate(caps)
|
||||
}
|
||||
|
||||
fn unlock(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_unlock(element)
|
||||
fn unlock(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_unlock()
|
||||
}
|
||||
|
||||
fn unlock_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_unlock_stop(element)
|
||||
fn unlock_stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_unlock_stop()
|
||||
}
|
||||
|
||||
fn decide_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_decide_allocation(element, query)
|
||||
self.parent_decide_allocation(query)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait BaseSrcImplExt: ObjectSubclass {
|
||||
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_start(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_stop(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_is_seekable(&self, element: &Self::Type) -> bool;
|
||||
fn parent_is_seekable(&self) -> bool;
|
||||
|
||||
fn parent_size(&self, element: &Self::Type) -> Option<u64>;
|
||||
fn parent_size(&self) -> Option<u64>;
|
||||
|
||||
fn parent_times(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: &gst::BufferRef,
|
||||
) -> (Option<gst::ClockTime>, Option<gst::ClockTime>);
|
||||
|
||||
fn parent_fill(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
offset: u64,
|
||||
length: u32,
|
||||
buffer: &mut gst::BufferRef,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_alloc(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
offset: u64,
|
||||
length: u32,
|
||||
) -> Result<gst::Buffer, gst::FlowError>;
|
||||
fn parent_alloc(&self, offset: u64, length: u32) -> Result<gst::Buffer, gst::FlowError>;
|
||||
|
||||
fn parent_create(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
offset: u64,
|
||||
buffer: Option<&mut gst::BufferRef>,
|
||||
length: u32,
|
||||
) -> Result<CreateSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_do_seek(&self, element: &Self::Type, segment: &mut gst::Segment) -> bool;
|
||||
fn parent_do_seek(&self, segment: &mut gst::Segment) -> bool;
|
||||
|
||||
fn parent_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool;
|
||||
fn parent_query(&self, query: &mut gst::QueryRef) -> bool;
|
||||
|
||||
fn parent_event(&self, element: &Self::Type, event: &gst::Event) -> bool;
|
||||
fn parent_event(&self, event: &gst::Event) -> bool;
|
||||
|
||||
fn parent_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> Option<gst::Caps>;
|
||||
fn parent_caps(&self, filter: Option<&gst::Caps>) -> Option<gst::Caps>;
|
||||
|
||||
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError>;
|
||||
fn parent_negotiate(&self) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_set_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
fn parent_set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_fixate(&self, element: &Self::Type, caps: gst::Caps) -> gst::Caps;
|
||||
fn parent_fixate(&self, caps: gst::Caps) -> gst::Caps;
|
||||
|
||||
fn parent_unlock(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_unlock(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_unlock_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_unlock_stop(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_decide_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
}
|
||||
|
||||
impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
||||
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_start(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass;
|
||||
(*parent_class)
|
||||
.start
|
||||
.map(|f| {
|
||||
if from_glib(f(element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0)) {
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<BaseSrc>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst::error_msg!(
|
||||
|
@ -214,14 +194,19 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass;
|
||||
(*parent_class)
|
||||
.stop
|
||||
.map(|f| {
|
||||
if from_glib(f(element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0)) {
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<BaseSrc>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst::error_msg!(
|
||||
|
@ -234,18 +219,24 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_is_seekable(&self, element: &Self::Type) -> bool {
|
||||
fn parent_is_seekable(&self) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass;
|
||||
(*parent_class)
|
||||
.is_seekable
|
||||
.map(|f| from_glib(f(element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0)))
|
||||
.map(|f| {
|
||||
from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<BaseSrc>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
})
|
||||
.unwrap_or(false)
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_size(&self, element: &Self::Type) -> Option<u64> {
|
||||
fn parent_size(&self) -> Option<u64> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass;
|
||||
|
@ -254,7 +245,10 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
.map(|f| {
|
||||
let mut size = mem::MaybeUninit::uninit();
|
||||
if from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSrc>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
size.as_mut_ptr(),
|
||||
)) {
|
||||
Some(size.assume_init())
|
||||
|
@ -268,7 +262,6 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
|
||||
fn parent_times(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: &gst::BufferRef,
|
||||
) -> (Option<gst::ClockTime>, Option<gst::ClockTime>) {
|
||||
unsafe {
|
||||
|
@ -280,7 +273,10 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
let mut start = mem::MaybeUninit::uninit();
|
||||
let mut stop = mem::MaybeUninit::uninit();
|
||||
f(
|
||||
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSrc>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
buffer.as_mut_ptr(),
|
||||
start.as_mut_ptr(),
|
||||
stop.as_mut_ptr(),
|
||||
|
@ -296,7 +292,6 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
|
||||
fn parent_fill(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
offset: u64,
|
||||
length: u32,
|
||||
buffer: &mut gst::BufferRef,
|
||||
|
@ -308,7 +303,10 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
.fill
|
||||
.map(|f| {
|
||||
try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSrc>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
offset,
|
||||
length,
|
||||
buffer.as_mut_ptr(),
|
||||
|
@ -318,12 +316,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_alloc(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
offset: u64,
|
||||
length: u32,
|
||||
) -> Result<gst::Buffer, gst::FlowError> {
|
||||
fn parent_alloc(&self, offset: u64, length: u32) -> Result<gst::Buffer, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass;
|
||||
|
@ -337,7 +330,10 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
let buffer_ref = &mut buffer_ptr as *mut _ as *mut gst::ffi::GstBuffer;
|
||||
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSrc>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
offset,
|
||||
length,
|
||||
buffer_ref,
|
||||
|
@ -350,7 +346,6 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
|
||||
fn parent_create(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
offset: u64,
|
||||
mut buffer: Option<&mut gst::BufferRef>,
|
||||
length: u32,
|
||||
|
@ -361,6 +356,8 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
(*parent_class)
|
||||
.create
|
||||
.map(|f| {
|
||||
let instance = self.instance();
|
||||
let instance = instance.unsafe_cast_ref::<BaseSrc>();
|
||||
let orig_buffer_ptr = buffer
|
||||
.as_mut()
|
||||
.map(|b| b.as_mut_ptr())
|
||||
|
@ -375,7 +372,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
|
||||
if let Err(err) = gst::FlowSuccess::try_from_glib(
|
||||
f(
|
||||
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
|
||||
instance.to_glib_none().0,
|
||||
offset,
|
||||
length,
|
||||
buffer_ref,
|
||||
|
@ -387,14 +384,14 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
|
||||
let pending_buffer_list = instance_data.pending_buffer_list.borrow_mut().take();
|
||||
if pending_buffer_list.is_some() &&
|
||||
(buffer.is_some() || element.unsafe_cast_ref::<BaseSrc>().src_pad().mode() == gst::PadMode::Pull) {
|
||||
(buffer.is_some() || instance.src_pad().mode() == gst::PadMode::Pull) {
|
||||
panic!("Buffer lists can only be returned in push mode");
|
||||
}
|
||||
|
||||
if buffer_ptr.is_null() && pending_buffer_list.is_none() {
|
||||
gst::error!(
|
||||
gst::CAT_RUST,
|
||||
obj: element.unsafe_cast_ref::<BaseSrc>(),
|
||||
obj: instance,
|
||||
"No buffer and no buffer list returned"
|
||||
);
|
||||
return Err(gst::FlowError::Error);
|
||||
|
@ -403,7 +400,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
if !buffer_ptr.is_null() && pending_buffer_list.is_some() {
|
||||
gst::error!(
|
||||
gst::CAT_RUST,
|
||||
obj: element.unsafe_cast_ref::<BaseSrc>(),
|
||||
obj: instance,
|
||||
"Both buffer and buffer list returned"
|
||||
);
|
||||
return Err(gst::FlowError::Error);
|
||||
|
@ -415,7 +412,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
|
||||
gst::debug!(
|
||||
gst::CAT_PERFORMANCE,
|
||||
obj: element.unsafe_cast_ref::<BaseSrc>(),
|
||||
obj: instance,
|
||||
"Returned new buffer from parent create function, copying into passed buffer"
|
||||
);
|
||||
|
||||
|
@ -424,7 +421,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
Err(_) => {
|
||||
gst::error!(
|
||||
gst::CAT_RUST,
|
||||
obj: element.unsafe_cast_ref::<BaseSrc>(),
|
||||
obj: instance,
|
||||
"Failed to map passed buffer writable"
|
||||
);
|
||||
return Err(gst::FlowError::Error);
|
||||
|
@ -443,7 +440,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
Err(_) => {
|
||||
gst::error!(
|
||||
gst::CAT_RUST,
|
||||
obj: element.unsafe_cast_ref::<BaseSrc>(),
|
||||
obj: instance,
|
||||
"Failed to copy buffer metadata"
|
||||
);
|
||||
|
||||
|
@ -463,7 +460,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_do_seek(&self, element: &Self::Type, segment: &mut gst::Segment) -> bool {
|
||||
fn parent_do_seek(&self, segment: &mut gst::Segment) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass;
|
||||
|
@ -471,7 +468,10 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
.do_seek
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSrc>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
segment.to_glib_none_mut().0,
|
||||
))
|
||||
})
|
||||
|
@ -479,7 +479,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
fn parent_query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass;
|
||||
|
@ -487,7 +487,10 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
.query
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSrc>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
))
|
||||
})
|
||||
|
@ -495,7 +498,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_event(&self, element: &Self::Type, event: &gst::Event) -> bool {
|
||||
fn parent_event(&self, event: &gst::Event) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass;
|
||||
|
@ -503,7 +506,10 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
.event
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSrc>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
event.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
|
@ -511,7 +517,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> Option<gst::Caps> {
|
||||
fn parent_caps(&self, filter: Option<&gst::Caps>) -> Option<gst::Caps> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass;
|
||||
|
@ -520,7 +526,10 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
.get_caps
|
||||
.map(|f| {
|
||||
from_glib_full(f(
|
||||
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSrc>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
filter.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
|
@ -528,7 +537,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
fn parent_negotiate(&self) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass;
|
||||
|
@ -536,7 +545,11 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
.negotiate
|
||||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0),
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<BaseSrc>()
|
||||
.to_glib_none()
|
||||
.0),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `negotiate` failed"
|
||||
)
|
||||
|
@ -545,11 +558,7 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_set_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
fn parent_set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass;
|
||||
|
@ -558,7 +567,10 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSrc>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
caps.to_glib_none().0
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -569,14 +581,17 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_fixate(&self, element: &Self::Type, caps: gst::Caps) -> gst::Caps {
|
||||
fn parent_fixate(&self, caps: gst::Caps) -> gst::Caps {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass;
|
||||
|
||||
match (*parent_class).fixate {
|
||||
Some(fixate) => from_glib_full(fixate(
|
||||
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSrc>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
caps.into_glib_ptr(),
|
||||
)),
|
||||
None => caps,
|
||||
|
@ -584,14 +599,19 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_unlock(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_unlock(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass;
|
||||
(*parent_class)
|
||||
.unlock
|
||||
.map(|f| {
|
||||
if from_glib(f(element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0)) {
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<BaseSrc>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst::error_msg!(
|
||||
|
@ -604,14 +624,19 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_unlock_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_unlock_stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBaseSrcClass;
|
||||
(*parent_class)
|
||||
.unlock_stop
|
||||
.map(|f| {
|
||||
if from_glib(f(element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0)) {
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<BaseSrc>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
{
|
||||
Ok(())
|
||||
} else {
|
||||
Err(gst::error_msg!(
|
||||
|
@ -626,7 +651,6 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
|
||||
fn parent_decide_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
|
@ -637,7 +661,10 @@ impl<T: BaseSrcImpl> BaseSrcImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<BaseSrc>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<BaseSrc>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -685,13 +712,12 @@ unsafe extern "C" fn base_src_start<T: BaseSrcImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.start(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.start() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -704,13 +730,12 @@ unsafe extern "C" fn base_src_stop<T: BaseSrcImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.stop(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.stop() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -723,12 +748,8 @@ unsafe extern "C" fn base_src_is_seekable<T: BaseSrcImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.is_seekable(wrap.unsafe_cast_ref())
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, false, { imp.is_seekable() }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_src_get_size<T: BaseSrcImpl>(
|
||||
|
@ -737,10 +758,9 @@ unsafe extern "C" fn base_src_get_size<T: BaseSrcImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.size(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.size() {
|
||||
Some(s) => {
|
||||
*size = s;
|
||||
true
|
||||
|
@ -759,14 +779,13 @@ unsafe extern "C" fn base_src_get_times<T: BaseSrcImpl>(
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
|
||||
let buffer = gst::BufferRef::from_ptr(buffer);
|
||||
|
||||
*start = gst::ffi::GST_CLOCK_TIME_NONE;
|
||||
*stop = gst::ffi::GST_CLOCK_TIME_NONE;
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), (), {
|
||||
let (start_, stop_) = imp.times(wrap.unsafe_cast_ref(), buffer);
|
||||
gst::panic_to_error!(imp, (), {
|
||||
let (start_, stop_) = imp.times(buffer);
|
||||
*start = start_.into_glib();
|
||||
*stop = stop_.into_glib();
|
||||
});
|
||||
|
@ -780,12 +799,10 @@ unsafe extern "C" fn base_src_fill<T: BaseSrcImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
|
||||
let buffer = gst::BufferRef::from_mut_ptr(buffer);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
imp.fill(wrap.unsafe_cast_ref(), offset, length, buffer)
|
||||
.into()
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
imp.fill(offset, length, buffer).into()
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -798,13 +815,12 @@ unsafe extern "C" fn base_src_alloc<T: BaseSrcImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
|
||||
// FIXME: Wrong signature in -sys bindings
|
||||
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3
|
||||
let buffer_ptr = buffer_ptr as *mut *mut gst::ffi::GstBuffer;
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
match imp.alloc(wrap.unsafe_cast_ref(), offset, length) {
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
match imp.alloc(offset, length) {
|
||||
Ok(buffer) => {
|
||||
*buffer_ptr = buffer.into_glib_ptr();
|
||||
gst::FlowReturn::Ok
|
||||
|
@ -824,7 +840,8 @@ unsafe extern "C" fn base_src_create<T: BaseSrcImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
|
||||
let instance = imp.instance();
|
||||
let instance = instance.unsafe_cast_ref::<BaseSrc>();
|
||||
// FIXME: Wrong signature in -sys bindings
|
||||
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3
|
||||
let buffer_ptr = buffer_ptr as *mut *mut gst::ffi::GstBuffer;
|
||||
|
@ -840,23 +857,18 @@ unsafe extern "C" fn base_src_create<T: BaseSrcImpl>(
|
|||
.unwrap();
|
||||
|
||||
// If there is a pending buffer list at this point then unset it.
|
||||
if wrap.type_() == T::Type::static_type() {
|
||||
if instance.type_() == T::Type::static_type() {
|
||||
*instance_data.pending_buffer_list.borrow_mut() = None;
|
||||
}
|
||||
|
||||
let res = gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
match imp.create(
|
||||
wrap.unsafe_cast_ref(),
|
||||
offset,
|
||||
buffer.as_deref_mut(),
|
||||
length,
|
||||
) {
|
||||
let res = gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
match imp.create(offset, buffer.as_deref_mut(), length) {
|
||||
Ok(CreateSuccess::NewBuffer(new_buffer)) => {
|
||||
if let Some(passed_buffer) = buffer {
|
||||
if passed_buffer.as_ptr() != new_buffer.as_ptr() {
|
||||
gst::debug!(
|
||||
gst::CAT_PERFORMANCE,
|
||||
obj: &*wrap,
|
||||
obj: instance,
|
||||
"Returned new buffer from create function, copying into passed buffer"
|
||||
);
|
||||
|
||||
|
@ -865,7 +877,7 @@ unsafe extern "C" fn base_src_create<T: BaseSrcImpl>(
|
|||
Err(_) => {
|
||||
gst::error!(
|
||||
gst::CAT_RUST,
|
||||
obj: &*wrap,
|
||||
obj: instance,
|
||||
"Failed to map passed buffer writable"
|
||||
);
|
||||
return gst::FlowReturn::Error;
|
||||
|
@ -889,7 +901,7 @@ unsafe extern "C" fn base_src_create<T: BaseSrcImpl>(
|
|||
Err(_) => {
|
||||
gst::error!(
|
||||
gst::CAT_RUST,
|
||||
obj: &*wrap,
|
||||
obj: instance,
|
||||
"Failed to copy buffer metadata"
|
||||
);
|
||||
|
||||
|
@ -905,9 +917,7 @@ unsafe extern "C" fn base_src_create<T: BaseSrcImpl>(
|
|||
}
|
||||
}
|
||||
Ok(CreateSuccess::NewBufferList(new_buffer_list)) => {
|
||||
if buffer.is_some()
|
||||
|| wrap.unsafe_cast_ref::<BaseSrc>().src_pad().mode() == gst::PadMode::Pull
|
||||
{
|
||||
if buffer.is_some() || instance.src_pad().mode() == gst::PadMode::Pull {
|
||||
panic!("Buffer lists can only be returned in push mode");
|
||||
}
|
||||
|
||||
|
@ -916,9 +926,9 @@ unsafe extern "C" fn base_src_create<T: BaseSrcImpl>(
|
|||
// If this is the final type then submit the buffer list. This can only be done
|
||||
// once so can only really be done here.
|
||||
// FIXME: This won't work if a non-Rust subclass of a Rust subclass is created.
|
||||
if wrap.type_() == T::Type::static_type() {
|
||||
if instance.type_() == T::Type::static_type() {
|
||||
ffi::gst_base_src_submit_buffer_list(
|
||||
wrap.to_glib_none().0,
|
||||
instance.to_glib_none().0,
|
||||
new_buffer_list.into_glib_ptr(),
|
||||
);
|
||||
} else {
|
||||
|
@ -934,7 +944,7 @@ unsafe extern "C" fn base_src_create<T: BaseSrcImpl>(
|
|||
.into_glib();
|
||||
|
||||
// If there is a pending buffer list at this point then unset it.
|
||||
if wrap.type_() == T::Type::static_type() {
|
||||
if instance.type_() == T::Type::static_type() {
|
||||
*instance_data.pending_buffer_list.borrow_mut() = None;
|
||||
}
|
||||
|
||||
|
@ -947,11 +957,10 @@ unsafe extern "C" fn base_src_do_seek<T: BaseSrcImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
let mut s = from_glib_none(segment);
|
||||
let res = imp.do_seek(wrap.unsafe_cast_ref(), &mut s);
|
||||
let res = imp.do_seek(&mut s);
|
||||
ptr::write(segment, *(s.to_glib_none().0));
|
||||
|
||||
res
|
||||
|
@ -965,13 +974,9 @@ unsafe extern "C" fn base_src_query<T: BaseSrcImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
|
||||
let query = gst::QueryRef::from_mut_ptr(query_ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
BaseSrcImpl::query(imp, wrap.unsafe_cast_ref(), query)
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, false, { BaseSrcImpl::query(imp, query) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_src_event<T: BaseSrcImpl>(
|
||||
|
@ -980,12 +985,8 @@ unsafe extern "C" fn base_src_event<T: BaseSrcImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.event(wrap.unsafe_cast_ref(), &from_glib_borrow(event_ptr))
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, false, { imp.event(&from_glib_borrow(event_ptr)) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_src_get_caps<T: BaseSrcImpl>(
|
||||
|
@ -994,14 +995,11 @@ unsafe extern "C" fn base_src_get_caps<T: BaseSrcImpl>(
|
|||
) -> *mut gst::ffi::GstCaps {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
|
||||
let filter = Option::<gst::Caps>::from_glib_borrow(filter);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), None, {
|
||||
imp.caps(wrap.unsafe_cast_ref(), filter.as_ref().as_ref())
|
||||
})
|
||||
.map(|caps| caps.into_glib_ptr())
|
||||
.unwrap_or(ptr::null_mut())
|
||||
gst::panic_to_error!(imp, None, { imp.caps(filter.as_ref().as_ref()) })
|
||||
.map(|caps| caps.into_glib_ptr())
|
||||
.unwrap_or(ptr::null_mut())
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_src_negotiate<T: BaseSrcImpl>(
|
||||
|
@ -1009,13 +1007,12 @@ unsafe extern "C" fn base_src_negotiate<T: BaseSrcImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.negotiate(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.negotiate() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -1029,14 +1026,13 @@ unsafe extern "C" fn base_src_set_caps<T: BaseSrcImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
|
||||
let caps = from_glib_borrow(caps);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.set_caps(wrap.unsafe_cast_ref(), &caps) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.set_caps(&caps) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -1050,13 +1046,9 @@ unsafe extern "C" fn base_src_fixate<T: BaseSrcImpl>(
|
|||
) -> *mut gst::ffi::GstCaps {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
|
||||
let caps = from_glib_full(caps);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::Caps::new_empty(), {
|
||||
imp.fixate(wrap.unsafe_cast_ref(), caps)
|
||||
})
|
||||
.into_glib_ptr()
|
||||
gst::panic_to_error!(imp, gst::Caps::new_empty(), { imp.fixate(caps) }).into_glib_ptr()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn base_src_unlock<T: BaseSrcImpl>(
|
||||
|
@ -1064,13 +1056,12 @@ unsafe extern "C" fn base_src_unlock<T: BaseSrcImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.unlock(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.unlock() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -1083,13 +1074,12 @@ unsafe extern "C" fn base_src_unlock_stop<T: BaseSrcImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.unlock_stop(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.unlock_stop() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -1103,17 +1093,16 @@ unsafe extern "C" fn base_src_decide_allocation<T: BaseSrcImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BaseSrc> = from_glib_borrow(ptr);
|
||||
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
|
||||
gst::QueryViewMut::Allocation(allocation) => allocation,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.decide_allocation(query) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -12,49 +12,32 @@ use crate::prelude::BaseSrcExtManual;
|
|||
use crate::PushSrc;
|
||||
|
||||
pub trait PushSrcImpl: PushSrcImplExt + BaseSrcImpl {
|
||||
fn fill(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: &mut gst::BufferRef,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
PushSrcImplExt::parent_fill(self, element, buffer)
|
||||
fn fill(&self, buffer: &mut gst::BufferRef) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
PushSrcImplExt::parent_fill(self, buffer)
|
||||
}
|
||||
|
||||
fn alloc(&self, element: &Self::Type) -> Result<gst::Buffer, gst::FlowError> {
|
||||
PushSrcImplExt::parent_alloc(self, element)
|
||||
fn alloc(&self) -> Result<gst::Buffer, gst::FlowError> {
|
||||
PushSrcImplExt::parent_alloc(self)
|
||||
}
|
||||
|
||||
fn create(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: Option<&mut gst::BufferRef>,
|
||||
) -> Result<CreateSuccess, gst::FlowError> {
|
||||
PushSrcImplExt::parent_create(self, element, buffer)
|
||||
fn create(&self, buffer: Option<&mut gst::BufferRef>) -> Result<CreateSuccess, gst::FlowError> {
|
||||
PushSrcImplExt::parent_create(self, buffer)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait PushSrcImplExt: ObjectSubclass {
|
||||
fn parent_fill(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: &mut gst::BufferRef,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
fn parent_fill(&self, buffer: &mut gst::BufferRef) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_alloc(&self, element: &Self::Type) -> Result<gst::Buffer, gst::FlowError>;
|
||||
fn parent_alloc(&self) -> Result<gst::Buffer, gst::FlowError>;
|
||||
|
||||
fn parent_create(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: Option<&mut gst::BufferRef>,
|
||||
) -> Result<CreateSuccess, gst::FlowError>;
|
||||
}
|
||||
|
||||
impl<T: PushSrcImpl> PushSrcImplExt for T {
|
||||
fn parent_fill(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: &mut gst::BufferRef,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
fn parent_fill(&self, buffer: &mut gst::BufferRef) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstPushSrcClass;
|
||||
|
@ -62,7 +45,10 @@ impl<T: PushSrcImpl> PushSrcImplExt for T {
|
|||
.fill
|
||||
.map(|f| {
|
||||
try_from_glib(f(
|
||||
element.unsafe_cast_ref::<PushSrc>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<PushSrc>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
buffer.as_mut_ptr(),
|
||||
))
|
||||
})
|
||||
|
@ -70,7 +56,7 @@ impl<T: PushSrcImpl> PushSrcImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_alloc(&self, element: &Self::Type) -> Result<gst::Buffer, gst::FlowError> {
|
||||
fn parent_alloc(&self) -> Result<gst::Buffer, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstPushSrcClass;
|
||||
|
@ -84,7 +70,10 @@ impl<T: PushSrcImpl> PushSrcImplExt for T {
|
|||
let buffer_ref = &mut buffer_ptr as *mut _ as *mut gst::ffi::GstBuffer;
|
||||
|
||||
gst::FlowSuccess::try_from_glib(f(
|
||||
element.unsafe_cast_ref::<PushSrc>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<PushSrc>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
buffer_ref,
|
||||
))
|
||||
.map(|_| from_glib_full(buffer_ref))
|
||||
|
@ -95,7 +84,6 @@ impl<T: PushSrcImpl> PushSrcImplExt for T {
|
|||
|
||||
fn parent_create(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
mut buffer: Option<&mut gst::BufferRef>,
|
||||
) -> Result<CreateSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
|
@ -104,6 +92,8 @@ impl<T: PushSrcImpl> PushSrcImplExt for T {
|
|||
(*parent_class)
|
||||
.create
|
||||
.map(|f| {
|
||||
let instance = self.instance();
|
||||
let instance = instance.unsafe_cast_ref::<PushSrc>();
|
||||
let orig_buffer_ptr = buffer
|
||||
.as_mut()
|
||||
.map(|b| b.as_mut_ptr())
|
||||
|
@ -117,7 +107,7 @@ impl<T: PushSrcImpl> PushSrcImplExt for T {
|
|||
|
||||
if let Err(err) = gst::FlowSuccess::try_from_glib(
|
||||
f(
|
||||
element.unsafe_cast_ref::<PushSrc>().to_glib_none().0,
|
||||
instance.to_glib_none().0,
|
||||
buffer_ref,
|
||||
)
|
||||
) {
|
||||
|
@ -127,7 +117,7 @@ impl<T: PushSrcImpl> PushSrcImplExt for T {
|
|||
|
||||
let pending_buffer_list = instance_data.pending_buffer_list.borrow_mut().take();
|
||||
if pending_buffer_list.is_some() &&
|
||||
(buffer.is_some() || element.unsafe_cast_ref::<PushSrc>().src_pad().mode() == gst::PadMode::Pull) {
|
||||
(buffer.is_some() || instance.src_pad().mode() == gst::PadMode::Pull) {
|
||||
panic!("Buffer lists can only be returned in push mode");
|
||||
}
|
||||
|
||||
|
@ -135,7 +125,7 @@ impl<T: PushSrcImpl> PushSrcImplExt for T {
|
|||
if buffer_ptr.is_null() && pending_buffer_list.is_none() {
|
||||
gst::error!(
|
||||
gst::CAT_RUST,
|
||||
obj: element.unsafe_cast_ref::<PushSrc>(),
|
||||
obj: instance,
|
||||
"No buffer and no buffer list returned"
|
||||
);
|
||||
return Err(gst::FlowError::Error);
|
||||
|
@ -144,7 +134,7 @@ impl<T: PushSrcImpl> PushSrcImplExt for T {
|
|||
if !buffer_ptr.is_null() && pending_buffer_list.is_some() {
|
||||
gst::error!(
|
||||
gst::CAT_RUST,
|
||||
obj: element.unsafe_cast_ref::<PushSrc>(),
|
||||
obj: instance,
|
||||
"Both buffer and buffer list returned"
|
||||
);
|
||||
return Err(gst::FlowError::Error);
|
||||
|
@ -156,7 +146,7 @@ impl<T: PushSrcImpl> PushSrcImplExt for T {
|
|||
|
||||
gst::debug!(
|
||||
gst::CAT_PERFORMANCE,
|
||||
obj: element.unsafe_cast_ref::<PushSrc>(),
|
||||
obj: instance,
|
||||
"Returned new buffer from parent create function, copying into passed buffer"
|
||||
);
|
||||
|
||||
|
@ -165,7 +155,7 @@ impl<T: PushSrcImpl> PushSrcImplExt for T {
|
|||
Err(_) => {
|
||||
gst::error!(
|
||||
gst::CAT_RUST,
|
||||
obj: element.unsafe_cast_ref::<PushSrc>(),
|
||||
obj: instance,
|
||||
"Failed to map passed buffer writable"
|
||||
);
|
||||
return Err(gst::FlowError::Error);
|
||||
|
@ -184,7 +174,7 @@ impl<T: PushSrcImpl> PushSrcImplExt for T {
|
|||
Err(_) => {
|
||||
gst::error!(
|
||||
gst::CAT_RUST,
|
||||
obj: element.unsafe_cast_ref::<PushSrc>(),
|
||||
obj: instance,
|
||||
"Failed to copy buffer metadata"
|
||||
);
|
||||
|
||||
|
@ -221,11 +211,10 @@ unsafe extern "C" fn push_src_fill<T: PushSrcImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<PushSrc> = from_glib_borrow(ptr);
|
||||
let buffer = gst::BufferRef::from_mut_ptr(buffer);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
PushSrcImpl::fill(imp, wrap.unsafe_cast_ref(), buffer).into()
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
PushSrcImpl::fill(imp, buffer).into()
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -236,13 +225,12 @@ unsafe extern "C" fn push_src_alloc<T: PushSrcImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<PushSrc> = from_glib_borrow(ptr);
|
||||
// FIXME: Wrong signature in -sys bindings
|
||||
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3
|
||||
let buffer_ptr = buffer_ptr as *mut *mut gst::ffi::GstBuffer;
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
match PushSrcImpl::alloc(imp, wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
match PushSrcImpl::alloc(imp) {
|
||||
Ok(buffer) => {
|
||||
*buffer_ptr = buffer.into_glib_ptr();
|
||||
gst::FlowReturn::Ok
|
||||
|
@ -260,7 +248,6 @@ unsafe extern "C" fn push_src_create<T: PushSrcImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<PushSrc> = from_glib_borrow(ptr);
|
||||
// FIXME: Wrong signature in -sys bindings
|
||||
// https://gitlab.freedesktop.org/gstreamer/gstreamer-rs-sys/issues/3
|
||||
let buffer_ptr = buffer_ptr as *mut *mut gst::ffi::GstBuffer;
|
||||
|
@ -275,8 +262,8 @@ unsafe extern "C" fn push_src_create<T: PushSrcImpl>(
|
|||
.instance_data::<super::base_src::InstanceData>(crate::BaseSrc::static_type())
|
||||
.unwrap();
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
match PushSrcImpl::create(imp, wrap.unsafe_cast_ref(), buffer.as_deref_mut()) {
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
match PushSrcImpl::create(imp, buffer.as_deref_mut()) {
|
||||
Ok(CreateSuccess::NewBuffer(new_buffer)) => {
|
||||
// Clear any pending buffer list
|
||||
*instance_data.pending_buffer_list.borrow_mut() = None;
|
||||
|
@ -285,7 +272,7 @@ unsafe extern "C" fn push_src_create<T: PushSrcImpl>(
|
|||
if passed_buffer.as_ptr() != new_buffer.as_ptr() {
|
||||
gst::debug!(
|
||||
gst::CAT_PERFORMANCE,
|
||||
obj: &*wrap,
|
||||
imp: imp,
|
||||
"Returned new buffer from create function, copying into passed buffer"
|
||||
);
|
||||
|
||||
|
@ -294,7 +281,7 @@ unsafe extern "C" fn push_src_create<T: PushSrcImpl>(
|
|||
Err(_) => {
|
||||
gst::error!(
|
||||
gst::CAT_RUST,
|
||||
obj: &*wrap,
|
||||
imp: imp,
|
||||
"Failed to map passed buffer writable"
|
||||
);
|
||||
return gst::FlowReturn::Error;
|
||||
|
@ -318,7 +305,7 @@ unsafe extern "C" fn push_src_create<T: PushSrcImpl>(
|
|||
Err(_) => {
|
||||
gst::error!(
|
||||
gst::CAT_RUST,
|
||||
obj: &*wrap,
|
||||
imp: imp,
|
||||
"Failed to copy buffer metadata"
|
||||
);
|
||||
|
||||
|
@ -335,7 +322,8 @@ unsafe extern "C" fn push_src_create<T: PushSrcImpl>(
|
|||
}
|
||||
Ok(CreateSuccess::NewBufferList(new_buffer_list)) => {
|
||||
if buffer.is_some()
|
||||
|| wrap.unsafe_cast_ref::<PushSrc>().src_pad().mode() == gst::PadMode::Pull
|
||||
|| imp.instance().unsafe_cast_ref::<PushSrc>().src_pad().mode()
|
||||
== gst::PadMode::Pull
|
||||
{
|
||||
panic!("Buffer lists can only be returned in push mode");
|
||||
}
|
||||
|
|
|
@ -11,44 +11,29 @@ use gst_base::subclass::prelude::*;
|
|||
use crate::GLBaseFilter;
|
||||
|
||||
pub trait GLBaseFilterImpl: GLBaseFilterImplExt + BaseTransformImpl {
|
||||
fn gl_set_caps(
|
||||
&self,
|
||||
filter: &Self::Type,
|
||||
incaps: &Caps,
|
||||
outcaps: &Caps,
|
||||
) -> Result<(), LoggableError> {
|
||||
self.parent_gl_set_caps(filter, incaps, outcaps)
|
||||
fn gl_set_caps(&self, incaps: &Caps, outcaps: &Caps) -> Result<(), LoggableError> {
|
||||
self.parent_gl_set_caps(incaps, outcaps)
|
||||
}
|
||||
|
||||
fn gl_start(&self, filter: &Self::Type) -> Result<(), LoggableError> {
|
||||
self.parent_gl_start(filter)
|
||||
fn gl_start(&self) -> Result<(), LoggableError> {
|
||||
self.parent_gl_start()
|
||||
}
|
||||
|
||||
fn gl_stop(&self, filter: &Self::Type) {
|
||||
self.parent_gl_stop(filter)
|
||||
fn gl_stop(&self) {
|
||||
self.parent_gl_stop()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait GLBaseFilterImplExt: ObjectSubclass {
|
||||
fn parent_gl_set_caps(
|
||||
&self,
|
||||
filter: &Self::Type,
|
||||
incaps: &Caps,
|
||||
outcaps: &Caps,
|
||||
) -> Result<(), LoggableError>;
|
||||
fn parent_gl_set_caps(&self, incaps: &Caps, outcaps: &Caps) -> Result<(), LoggableError>;
|
||||
|
||||
fn parent_gl_start(&self, filter: &Self::Type) -> Result<(), LoggableError>;
|
||||
fn parent_gl_start(&self) -> Result<(), LoggableError>;
|
||||
|
||||
fn parent_gl_stop(&self, filter: &Self::Type);
|
||||
fn parent_gl_stop(&self);
|
||||
}
|
||||
|
||||
impl<T: GLBaseFilterImpl> GLBaseFilterImplExt for T {
|
||||
fn parent_gl_set_caps(
|
||||
&self,
|
||||
filter: &Self::Type,
|
||||
incaps: &Caps,
|
||||
outcaps: &Caps,
|
||||
) -> Result<(), LoggableError> {
|
||||
fn parent_gl_set_caps(&self, incaps: &Caps, outcaps: &Caps) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstGLBaseFilterClass;
|
||||
|
@ -58,7 +43,10 @@ impl<T: GLBaseFilterImpl> GLBaseFilterImplExt for T {
|
|||
.map(|f| {
|
||||
result_from_gboolean!(
|
||||
f(
|
||||
filter.unsafe_cast_ref::<GLBaseFilter>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<GLBaseFilter>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
incaps.to_glib_none().0,
|
||||
outcaps.to_glib_none().0,
|
||||
),
|
||||
|
@ -70,7 +58,7 @@ impl<T: GLBaseFilterImpl> GLBaseFilterImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_gl_start(&self, filter: &Self::Type) -> Result<(), LoggableError> {
|
||||
fn parent_gl_start(&self) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstGLBaseFilterClass;
|
||||
|
@ -79,7 +67,11 @@ impl<T: GLBaseFilterImpl> GLBaseFilterImplExt for T {
|
|||
.gl_start
|
||||
.map(|f| {
|
||||
result_from_gboolean!(
|
||||
f(filter.unsafe_cast_ref::<GLBaseFilter>().to_glib_none().0),
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<GLBaseFilter>()
|
||||
.to_glib_none()
|
||||
.0),
|
||||
CAT_RUST,
|
||||
"Parent function `gl_start` failed",
|
||||
)
|
||||
|
@ -88,13 +80,17 @@ impl<T: GLBaseFilterImpl> GLBaseFilterImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_gl_stop(&self, filter: &Self::Type) {
|
||||
fn parent_gl_stop(&self) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstGLBaseFilterClass;
|
||||
|
||||
if let Some(f) = (*parent_class).gl_stop {
|
||||
f(filter.unsafe_cast_ref::<GLBaseFilter>().to_glib_none().0)
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<GLBaseFilter>()
|
||||
.to_glib_none()
|
||||
.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,17 +113,12 @@ unsafe extern "C" fn gl_set_caps<T: GLBaseFilterImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<GLBaseFilter> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.gl_set_caps(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&from_glib_borrow(incaps),
|
||||
&from_glib_borrow(outcaps),
|
||||
) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.gl_set_caps(&from_glib_borrow(incaps), &from_glib_borrow(outcaps)) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -140,13 +131,12 @@ unsafe extern "C" fn gl_start<T: GLBaseFilterImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<GLBaseFilter> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.gl_start(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.gl_start() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -157,9 +147,6 @@ unsafe extern "C" fn gl_start<T: GLBaseFilterImpl>(
|
|||
unsafe extern "C" fn gl_stop<T: GLBaseFilterImpl>(ptr: *mut GstGLBaseFilter) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<GLBaseFilter> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), (), {
|
||||
imp.gl_stop(wrap.unsafe_cast_ref())
|
||||
})
|
||||
gst::panic_to_error!(imp, (), { imp.gl_stop() })
|
||||
}
|
||||
|
|
|
@ -12,33 +12,29 @@ use crate::{GLBaseSrc, GLMemory, GLAPI};
|
|||
pub trait GLBaseSrcImpl: GLBaseSrcImplExt + PushSrcImpl {
|
||||
const SUPPORTED_GL_API: GLAPI;
|
||||
|
||||
fn gl_start(&self, element: &Self::Type) -> Result<(), LoggableError> {
|
||||
self.parent_gl_start(element)
|
||||
fn gl_start(&self) -> Result<(), LoggableError> {
|
||||
self.parent_gl_start()
|
||||
}
|
||||
|
||||
fn gl_stop(&self, element: &Self::Type) {
|
||||
self.parent_gl_stop(element)
|
||||
fn gl_stop(&self) {
|
||||
self.parent_gl_stop()
|
||||
}
|
||||
|
||||
fn fill_gl_memory(&self, element: &Self::Type, memory: &GLMemory) -> Result<(), LoggableError> {
|
||||
self.parent_fill_gl_memory(element, memory)
|
||||
fn fill_gl_memory(&self, memory: &GLMemory) -> Result<(), LoggableError> {
|
||||
self.parent_fill_gl_memory(memory)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait GLBaseSrcImplExt: ObjectSubclass {
|
||||
fn parent_gl_start(&self, element: &Self::Type) -> Result<(), LoggableError>;
|
||||
fn parent_gl_start(&self) -> Result<(), LoggableError>;
|
||||
|
||||
fn parent_gl_stop(&self, element: &Self::Type);
|
||||
fn parent_gl_stop(&self);
|
||||
|
||||
fn parent_fill_gl_memory(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
memory: &GLMemory,
|
||||
) -> Result<(), LoggableError>;
|
||||
fn parent_fill_gl_memory(&self, memory: &GLMemory) -> Result<(), LoggableError>;
|
||||
}
|
||||
|
||||
impl<T: GLBaseSrcImpl> GLBaseSrcImplExt for T {
|
||||
fn parent_gl_start(&self, element: &Self::Type) -> Result<(), LoggableError> {
|
||||
fn parent_gl_start(&self) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstGLBaseSrcClass;
|
||||
|
@ -47,7 +43,11 @@ impl<T: GLBaseSrcImpl> GLBaseSrcImplExt for T {
|
|||
.gl_start
|
||||
.map(|f| {
|
||||
result_from_gboolean!(
|
||||
f(element.unsafe_cast_ref::<GLBaseSrc>().to_glib_none().0),
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<GLBaseSrc>()
|
||||
.to_glib_none()
|
||||
.0),
|
||||
CAT_RUST,
|
||||
"Parent function `gl_start` failed",
|
||||
)
|
||||
|
@ -56,22 +56,22 @@ impl<T: GLBaseSrcImpl> GLBaseSrcImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_gl_stop(&self, element: &Self::Type) {
|
||||
fn parent_gl_stop(&self) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstGLBaseSrcClass;
|
||||
|
||||
if let Some(f) = (*parent_class).gl_stop {
|
||||
f(element.unsafe_cast_ref::<GLBaseSrc>().to_glib_none().0)
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<GLBaseSrc>()
|
||||
.to_glib_none()
|
||||
.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_fill_gl_memory(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
memory: &GLMemory,
|
||||
) -> Result<(), LoggableError> {
|
||||
fn parent_fill_gl_memory(&self, memory: &GLMemory) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstGLBaseSrcClass;
|
||||
|
@ -81,7 +81,10 @@ impl<T: GLBaseSrcImpl> GLBaseSrcImplExt for T {
|
|||
.map(|f| {
|
||||
result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<GLBaseSrc>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<GLBaseSrc>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
mut_override(memory.to_glib_none().0),
|
||||
),
|
||||
CAT_RUST,
|
||||
|
@ -107,13 +110,12 @@ unsafe impl<T: GLBaseSrcImpl> IsSubclassable<T> for GLBaseSrc {
|
|||
unsafe extern "C" fn gl_start<T: GLBaseSrcImpl>(ptr: *mut GstGLBaseSrc) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<GLBaseSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.gl_start(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.gl_start() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -124,11 +126,8 @@ unsafe extern "C" fn gl_start<T: GLBaseSrcImpl>(ptr: *mut GstGLBaseSrc) -> glib:
|
|||
unsafe extern "C" fn gl_stop<T: GLBaseSrcImpl>(ptr: *mut GstGLBaseSrc) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<GLBaseSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), (), {
|
||||
imp.gl_stop(wrap.unsafe_cast_ref())
|
||||
})
|
||||
gst::panic_to_error!(imp, (), { imp.gl_stop() })
|
||||
}
|
||||
|
||||
unsafe extern "C" fn fill_gl_memory<T: GLBaseSrcImpl>(
|
||||
|
@ -137,13 +136,12 @@ unsafe extern "C" fn fill_gl_memory<T: GLBaseSrcImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<GLBaseSrc> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.fill_gl_memory(wrap.unsafe_cast_ref(), &from_glib_borrow(memory)) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.fill_gl_memory(&from_glib_borrow(memory)) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,75 +24,47 @@ pub trait GLFilterImpl: GLFilterImplExt + GLBaseFilterImpl {
|
|||
/// in [`GLFilter::class_init`] if [`true`].
|
||||
const ADD_RGBA_PAD_TEMPLATES: bool = true;
|
||||
|
||||
fn set_caps(
|
||||
&self,
|
||||
filter: &Self::Type,
|
||||
incaps: &Caps,
|
||||
outcaps: &Caps,
|
||||
) -> Result<(), LoggableError> {
|
||||
GLFilterImplExt::parent_set_caps(self, filter, incaps, outcaps)
|
||||
fn set_caps(&self, incaps: &Caps, outcaps: &Caps) -> Result<(), LoggableError> {
|
||||
GLFilterImplExt::parent_set_caps(self, incaps, outcaps)
|
||||
}
|
||||
|
||||
fn filter(
|
||||
&self,
|
||||
filter: &Self::Type,
|
||||
input: &Buffer,
|
||||
output: &Buffer,
|
||||
) -> Result<(), LoggableError> {
|
||||
self.parent_filter(filter, input, output)
|
||||
fn filter(&self, input: &Buffer, output: &Buffer) -> Result<(), LoggableError> {
|
||||
self.parent_filter(input, output)
|
||||
}
|
||||
|
||||
fn filter_texture(
|
||||
&self,
|
||||
filter: &Self::Type,
|
||||
input: &GLMemory,
|
||||
output: &GLMemory,
|
||||
) -> Result<(), LoggableError> {
|
||||
self.parent_filter_texture(filter, input, output)
|
||||
fn filter_texture(&self, input: &GLMemory, output: &GLMemory) -> Result<(), LoggableError> {
|
||||
self.parent_filter_texture(input, output)
|
||||
}
|
||||
|
||||
fn init_fbo(&self, filter: &Self::Type) -> Result<(), LoggableError> {
|
||||
self.parent_init_fbo(filter)
|
||||
fn init_fbo(&self) -> Result<(), LoggableError> {
|
||||
self.parent_init_fbo()
|
||||
}
|
||||
|
||||
fn transform_internal_caps(
|
||||
&self,
|
||||
filter: &Self::Type,
|
||||
direction: PadDirection,
|
||||
caps: &Caps,
|
||||
filter_caps: Option<&Caps>,
|
||||
) -> Option<Caps> {
|
||||
self.parent_transform_internal_caps(filter, direction, caps, filter_caps)
|
||||
self.parent_transform_internal_caps(direction, caps, filter_caps)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait GLFilterImplExt: ObjectSubclass {
|
||||
fn parent_set_caps(
|
||||
&self,
|
||||
filter: &Self::Type,
|
||||
incaps: &Caps,
|
||||
outcaps: &Caps,
|
||||
) -> Result<(), LoggableError>;
|
||||
fn parent_set_caps(&self, incaps: &Caps, outcaps: &Caps) -> Result<(), LoggableError>;
|
||||
|
||||
fn parent_filter(
|
||||
&self,
|
||||
filter: &Self::Type,
|
||||
input: &Buffer,
|
||||
output: &Buffer,
|
||||
) -> Result<(), LoggableError>;
|
||||
fn parent_filter(&self, input: &Buffer, output: &Buffer) -> Result<(), LoggableError>;
|
||||
|
||||
fn parent_filter_texture(
|
||||
&self,
|
||||
filter: &Self::Type,
|
||||
input: &GLMemory,
|
||||
output: &GLMemory,
|
||||
) -> Result<(), LoggableError>;
|
||||
|
||||
fn parent_init_fbo(&self, filter: &Self::Type) -> Result<(), LoggableError>;
|
||||
fn parent_init_fbo(&self) -> Result<(), LoggableError>;
|
||||
|
||||
fn parent_transform_internal_caps(
|
||||
&self,
|
||||
filter: &Self::Type,
|
||||
direction: PadDirection,
|
||||
caps: &Caps,
|
||||
filter_caps: Option<&Caps>,
|
||||
|
@ -100,12 +72,7 @@ pub trait GLFilterImplExt: ObjectSubclass {
|
|||
}
|
||||
|
||||
impl<T: GLFilterImpl> GLFilterImplExt for T {
|
||||
fn parent_set_caps(
|
||||
&self,
|
||||
filter: &Self::Type,
|
||||
incaps: &Caps,
|
||||
outcaps: &Caps,
|
||||
) -> Result<(), LoggableError> {
|
||||
fn parent_set_caps(&self, incaps: &Caps, outcaps: &Caps) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut GstGLFilterClass;
|
||||
|
@ -115,7 +82,10 @@ impl<T: GLFilterImpl> GLFilterImplExt for T {
|
|||
.map(|f| {
|
||||
result_from_gboolean!(
|
||||
f(
|
||||
filter.unsafe_cast_ref::<GLFilter>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<GLFilter>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
incaps.to_glib_none().0,
|
||||
outcaps.to_glib_none().0,
|
||||
),
|
||||
|
@ -127,12 +97,7 @@ impl<T: GLFilterImpl> GLFilterImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_filter(
|
||||
&self,
|
||||
filter: &Self::Type,
|
||||
input: &Buffer,
|
||||
output: &Buffer,
|
||||
) -> Result<(), LoggableError> {
|
||||
fn parent_filter(&self, input: &Buffer, output: &Buffer) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut GstGLFilterClass;
|
||||
|
@ -142,7 +107,10 @@ impl<T: GLFilterImpl> GLFilterImplExt for T {
|
|||
.map(|f| {
|
||||
result_from_gboolean!(
|
||||
f(
|
||||
filter.unsafe_cast_ref::<GLFilter>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<GLFilter>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
input.to_glib_none().0,
|
||||
output.to_glib_none().0,
|
||||
),
|
||||
|
@ -156,7 +124,6 @@ impl<T: GLFilterImpl> GLFilterImplExt for T {
|
|||
|
||||
fn parent_filter_texture(
|
||||
&self,
|
||||
filter: &Self::Type,
|
||||
input: &GLMemory,
|
||||
output: &GLMemory,
|
||||
) -> Result<(), LoggableError> {
|
||||
|
@ -169,7 +136,10 @@ impl<T: GLFilterImpl> GLFilterImplExt for T {
|
|||
.map(|f| {
|
||||
result_from_gboolean!(
|
||||
f(
|
||||
filter.unsafe_cast_ref::<GLFilter>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<GLFilter>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
input.to_glib_none().0,
|
||||
output.to_glib_none().0,
|
||||
),
|
||||
|
@ -181,7 +151,7 @@ impl<T: GLFilterImpl> GLFilterImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_init_fbo(&self, filter: &Self::Type) -> Result<(), LoggableError> {
|
||||
fn parent_init_fbo(&self) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut GstGLFilterClass;
|
||||
|
@ -190,7 +160,11 @@ impl<T: GLFilterImpl> GLFilterImplExt for T {
|
|||
.init_fbo
|
||||
.map(|f| {
|
||||
result_from_gboolean!(
|
||||
f(filter.unsafe_cast_ref::<GLFilter>().to_glib_none().0),
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<GLFilter>()
|
||||
.to_glib_none()
|
||||
.0),
|
||||
CAT_RUST,
|
||||
"Parent function `init_fbo` failed"
|
||||
)
|
||||
|
@ -200,7 +174,6 @@ impl<T: GLFilterImpl> GLFilterImplExt for T {
|
|||
}
|
||||
fn parent_transform_internal_caps(
|
||||
&self,
|
||||
filter: &Self::Type,
|
||||
direction: PadDirection,
|
||||
caps: &Caps,
|
||||
filter_caps: Option<&Caps>,
|
||||
|
@ -214,7 +187,10 @@ impl<T: GLFilterImpl> GLFilterImplExt for T {
|
|||
.expect("Missing parent function `transform_internal_caps`");
|
||||
|
||||
from_glib_full(f(
|
||||
filter.unsafe_cast_ref::<GLFilter>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<GLFilter>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
direction.into_glib(),
|
||||
caps.to_glib_none().0,
|
||||
filter_caps.to_glib_none().0,
|
||||
|
@ -255,17 +231,12 @@ unsafe extern "C" fn filter<T: GLFilterImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<GLFilter> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.filter(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&from_glib_borrow(input),
|
||||
&from_glib_borrow(output),
|
||||
) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.filter(&from_glib_borrow(input), &from_glib_borrow(output)) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -280,17 +251,12 @@ unsafe extern "C" fn filter_texture<T: GLFilterImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<GLFilter> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.filter_texture(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&from_glib_borrow(input),
|
||||
&from_glib_borrow(output),
|
||||
) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.filter_texture(&from_glib_borrow(input), &from_glib_borrow(output)) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -301,13 +267,12 @@ unsafe extern "C" fn filter_texture<T: GLFilterImpl>(
|
|||
unsafe extern "C" fn init_fbo<T: GLFilterImpl>(ptr: *mut GstGLFilter) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<GLFilter> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.init_fbo(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.init_fbo() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -322,18 +287,12 @@ unsafe extern "C" fn set_caps<T: GLFilterImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<GLFilter> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match GLFilterImpl::set_caps(
|
||||
imp,
|
||||
wrap.unsafe_cast_ref(),
|
||||
&from_glib_borrow(incaps),
|
||||
&from_glib_borrow(outcaps),
|
||||
) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match GLFilterImpl::set_caps(imp, &from_glib_borrow(incaps), &from_glib_borrow(outcaps)) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -349,13 +308,11 @@ unsafe extern "C" fn transform_internal_caps<T: GLFilterImpl>(
|
|||
) -> *mut gst::ffi::GstCaps {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<GLFilter> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), None, {
|
||||
gst::panic_to_error!(imp, None, {
|
||||
let filter_caps: Borrowed<Option<Caps>> = from_glib_borrow(filter_caps);
|
||||
|
||||
imp.transform_internal_caps(
|
||||
wrap.unsafe_cast_ref(),
|
||||
from_glib(direction),
|
||||
&from_glib_borrow(caps),
|
||||
filter_caps.as_ref().as_ref(),
|
||||
|
|
|
@ -10,61 +10,45 @@ use crate::AudioVisualizer;
|
|||
pub struct AudioVisualizerSetupToken<'a>(pub(crate) &'a AudioVisualizer);
|
||||
|
||||
pub trait AudioVisualizerImpl: AudioVisualizerImplExt + ElementImpl {
|
||||
fn setup(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
token: &AudioVisualizerSetupToken,
|
||||
) -> Result<(), LoggableError> {
|
||||
self.parent_setup(element, token)
|
||||
fn setup(&self, token: &AudioVisualizerSetupToken) -> Result<(), LoggableError> {
|
||||
self.parent_setup(token)
|
||||
}
|
||||
|
||||
fn render(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
audio_buffer: &gst::BufferRef,
|
||||
video_frame: &mut gst_video::VideoFrameRef<&mut gst::BufferRef>,
|
||||
) -> Result<(), LoggableError> {
|
||||
self.parent_render(element, audio_buffer, video_frame)
|
||||
self.parent_render(audio_buffer, video_frame)
|
||||
}
|
||||
|
||||
fn decide_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_decide_allocation(element, query)
|
||||
self.parent_decide_allocation(query)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait AudioVisualizerImplExt: ObjectSubclass {
|
||||
fn parent_setup(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
token: &AudioVisualizerSetupToken,
|
||||
) -> Result<(), LoggableError>;
|
||||
fn parent_setup(&self, token: &AudioVisualizerSetupToken) -> Result<(), LoggableError>;
|
||||
|
||||
fn parent_render(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
audio_buffer: &gst::BufferRef,
|
||||
video_frame: &mut gst_video::VideoFrameRef<&mut gst::BufferRef>,
|
||||
) -> Result<(), LoggableError>;
|
||||
|
||||
fn parent_decide_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
}
|
||||
|
||||
impl<T: AudioVisualizerImpl> AudioVisualizerImplExt for T {
|
||||
fn parent_setup(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
token: &AudioVisualizerSetupToken,
|
||||
) -> Result<(), LoggableError> {
|
||||
fn parent_setup(&self, token: &AudioVisualizerSetupToken) -> Result<(), LoggableError> {
|
||||
assert_eq!(
|
||||
element.as_ptr() as *mut ffi::GstAudioVisualizer,
|
||||
self.instance().as_ptr() as *mut ffi::GstAudioVisualizer,
|
||||
token.0.as_ptr() as *mut ffi::GstAudioVisualizer
|
||||
);
|
||||
|
||||
|
@ -75,7 +59,8 @@ impl<T: AudioVisualizerImpl> AudioVisualizerImplExt for T {
|
|||
.setup
|
||||
.map(|f| {
|
||||
result_from_gboolean!(
|
||||
f(element
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<AudioVisualizer>()
|
||||
.to_glib_none()
|
||||
.0,),
|
||||
|
@ -89,7 +74,6 @@ impl<T: AudioVisualizerImpl> AudioVisualizerImplExt for T {
|
|||
|
||||
fn parent_render(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
audio_buffer: &gst::BufferRef,
|
||||
video_frame: &mut gst_video::VideoFrameRef<&mut gst::BufferRef>,
|
||||
) -> Result<(), LoggableError> {
|
||||
|
@ -101,7 +85,7 @@ impl<T: AudioVisualizerImpl> AudioVisualizerImplExt for T {
|
|||
.map(|f| {
|
||||
result_from_gboolean!(
|
||||
f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioVisualizer>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -118,7 +102,6 @@ impl<T: AudioVisualizerImpl> AudioVisualizerImplExt for T {
|
|||
|
||||
fn parent_decide_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
|
@ -129,7 +112,7 @@ impl<T: AudioVisualizerImpl> AudioVisualizerImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<AudioVisualizer>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -159,15 +142,16 @@ unsafe extern "C" fn audio_visualizer_setup<T: AudioVisualizerImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioVisualizer> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
let token = AudioVisualizerSetupToken(&*wrap);
|
||||
gst::panic_to_error!(imp, false, {
|
||||
let instance = imp.instance();
|
||||
let instance = instance.unsafe_cast_ref::<AudioVisualizer>();
|
||||
let token = AudioVisualizerSetupToken(instance);
|
||||
|
||||
match imp.setup(wrap.unsafe_cast_ref(), &token) {
|
||||
match imp.setup(&token) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -182,18 +166,16 @@ unsafe extern "C" fn audio_visualizer_render<T: AudioVisualizerImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioVisualizer> = from_glib_borrow(ptr);
|
||||
let buffer = gst::BufferRef::from_ptr(audio_buffer);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.render(
|
||||
wrap.unsafe_cast_ref(),
|
||||
buffer,
|
||||
&mut gst_video::VideoFrameRef::from_glib_borrow_mut(video_frame),
|
||||
) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -207,17 +189,16 @@ unsafe extern "C" fn audio_visualizer_decide_allocation<T: AudioVisualizerImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<AudioVisualizer> = from_glib_borrow(ptr);
|
||||
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
|
||||
gst::QueryViewMut::Allocation(allocation) => allocation,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.decide_allocation(query) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use glib::subclass::prelude::*;
|
|||
use glib::translate::*;
|
||||
|
||||
pub trait PlayVideoRendererImpl: ObjectImpl {
|
||||
fn create_video_sink(&self, video_renderer: &Self::Type, play: &Play) -> gst::Element;
|
||||
fn create_video_sink(&self, play: &Play) -> gst::Element;
|
||||
}
|
||||
|
||||
unsafe impl<T: PlayVideoRendererImpl> IsImplementable<T> for PlayVideoRenderer {
|
||||
|
@ -19,11 +19,11 @@ unsafe impl<T: PlayVideoRendererImpl> IsImplementable<T> for PlayVideoRenderer {
|
|||
}
|
||||
|
||||
pub trait PlayVideoRendererImplExt: ObjectSubclass {
|
||||
fn parent_create_video_sink(&self, video_renderer: &Self::Type, play: &Play) -> gst::Element;
|
||||
fn parent_create_video_sink(&self, play: &Play) -> gst::Element;
|
||||
}
|
||||
|
||||
impl<T: PlayVideoRendererImpl> PlayVideoRendererImplExt for T {
|
||||
fn parent_create_video_sink(&self, video_renderer: &Self::Type, play: &Play) -> gst::Element {
|
||||
fn parent_create_video_sink(&self, play: &Play) -> gst::Element {
|
||||
unsafe {
|
||||
let type_data = Self::type_data();
|
||||
let parent_iface = type_data.as_ref().parent_interface::<PlayVideoRenderer>()
|
||||
|
@ -33,7 +33,7 @@ impl<T: PlayVideoRendererImpl> PlayVideoRendererImplExt for T {
|
|||
.create_video_sink
|
||||
.expect("no parent \"create_video_sink\" implementation");
|
||||
let ret = func(
|
||||
video_renderer
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<PlayVideoRenderer>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -55,10 +55,7 @@ unsafe extern "C" fn video_renderer_create_video_sink<T: PlayVideoRendererImpl>(
|
|||
let instance = &*(video_renderer as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
|
||||
let sink = imp.create_video_sink(
|
||||
from_glib_borrow::<_, PlayVideoRenderer>(video_renderer).unsafe_cast_ref(),
|
||||
&Play::from_glib_borrow(play),
|
||||
);
|
||||
let sink = imp.create_video_sink(&Play::from_glib_borrow(play));
|
||||
|
||||
let sink_ptr: *mut gst::ffi::GstElement = sink.to_glib_none().0;
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ use glib::subclass::prelude::*;
|
|||
use glib::translate::*;
|
||||
|
||||
pub trait PlayerVideoRendererImpl: ObjectImpl {
|
||||
fn create_video_sink(&self, video_renderer: &Self::Type, player: &Player) -> gst::Element;
|
||||
fn create_video_sink(&self, player: &Player) -> gst::Element;
|
||||
}
|
||||
|
||||
unsafe impl<T: PlayerVideoRendererImpl> IsImplementable<T> for PlayerVideoRenderer {
|
||||
|
@ -19,19 +19,11 @@ unsafe impl<T: PlayerVideoRendererImpl> IsImplementable<T> for PlayerVideoRender
|
|||
}
|
||||
|
||||
pub trait PlayerVideoRendererImplExt: ObjectSubclass {
|
||||
fn parent_create_video_sink(
|
||||
&self,
|
||||
video_renderer: &Self::Type,
|
||||
player: &Player,
|
||||
) -> gst::Element;
|
||||
fn parent_create_video_sink(&self, player: &Player) -> gst::Element;
|
||||
}
|
||||
|
||||
impl<T: PlayerVideoRendererImpl> PlayerVideoRendererImplExt for T {
|
||||
fn parent_create_video_sink(
|
||||
&self,
|
||||
video_renderer: &Self::Type,
|
||||
player: &Player,
|
||||
) -> gst::Element {
|
||||
fn parent_create_video_sink(&self, player: &Player) -> gst::Element {
|
||||
unsafe {
|
||||
let type_data = Self::type_data();
|
||||
let parent_iface = type_data.as_ref().parent_interface::<PlayerVideoRenderer>()
|
||||
|
@ -41,7 +33,7 @@ impl<T: PlayerVideoRendererImpl> PlayerVideoRendererImplExt for T {
|
|||
.create_video_sink
|
||||
.expect("no parent \"create_video_sink\" implementation");
|
||||
let ret = func(
|
||||
video_renderer
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<PlayerVideoRenderer>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -63,10 +55,7 @@ unsafe extern "C" fn video_renderer_create_video_sink<T: PlayerVideoRendererImpl
|
|||
let instance = &*(video_renderer as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
|
||||
let sink = imp.create_video_sink(
|
||||
from_glib_borrow::<_, PlayerVideoRenderer>(video_renderer).unsafe_cast_ref(),
|
||||
&Player::from_glib_borrow(player),
|
||||
);
|
||||
let sink = imp.create_video_sink(&from_glib_borrow::<_, Player>(player));
|
||||
|
||||
let sink_ptr: *mut gst::ffi::GstElement = sink.to_glib_none().0;
|
||||
|
||||
|
|
|
@ -9,51 +9,41 @@ use crate::RTPBaseDepayload;
|
|||
use std::ptr;
|
||||
|
||||
pub trait RTPBaseDepayloadImpl: RTPBaseDepayloadImplExt + ElementImpl {
|
||||
fn set_caps(&self, element: &Self::Type, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_caps(element, caps)
|
||||
fn set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_caps(caps)
|
||||
}
|
||||
|
||||
fn handle_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
self.parent_handle_event(element, event)
|
||||
fn handle_event(&self, event: gst::Event) -> bool {
|
||||
self.parent_handle_event(event)
|
||||
}
|
||||
|
||||
fn packet_lost(&self, element: &Self::Type, event: &gst::EventRef) -> bool {
|
||||
self.parent_packet_lost(element, event)
|
||||
fn packet_lost(&self, event: &gst::EventRef) -> bool {
|
||||
self.parent_packet_lost(event)
|
||||
}
|
||||
|
||||
fn process_rtp_packet(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
rtp_buffer: &crate::RTPBuffer<crate::rtp_buffer::Readable>,
|
||||
) -> Option<gst::Buffer> {
|
||||
self.parent_process_rtp_packet(element, rtp_buffer)
|
||||
self.parent_process_rtp_packet(rtp_buffer)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RTPBaseDepayloadImplExt: ObjectSubclass {
|
||||
fn parent_set_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
fn parent_set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_handle_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||
fn parent_handle_event(&self, event: gst::Event) -> bool;
|
||||
|
||||
fn parent_packet_lost(&self, element: &Self::Type, event: &gst::EventRef) -> bool;
|
||||
fn parent_packet_lost(&self, event: &gst::EventRef) -> bool;
|
||||
|
||||
fn parent_process_rtp_packet(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
rtp_buffer: &crate::RTPBuffer<crate::rtp_buffer::Readable>,
|
||||
) -> Option<gst::Buffer>;
|
||||
}
|
||||
|
||||
impl<T: RTPBaseDepayloadImpl> RTPBaseDepayloadImplExt for T {
|
||||
fn parent_set_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
fn parent_set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTPBaseDepayloadClass;
|
||||
|
@ -62,7 +52,7 @@ impl<T: RTPBaseDepayloadImpl> RTPBaseDepayloadImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTPBaseDepayload>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -76,7 +66,7 @@ impl<T: RTPBaseDepayloadImpl> RTPBaseDepayloadImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_handle_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
fn parent_handle_event(&self, event: gst::Event) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTPBaseDepayloadClass;
|
||||
|
@ -84,7 +74,7 @@ impl<T: RTPBaseDepayloadImpl> RTPBaseDepayloadImplExt for T {
|
|||
.handle_event
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTPBaseDepayload>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -95,7 +85,7 @@ impl<T: RTPBaseDepayloadImpl> RTPBaseDepayloadImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_packet_lost(&self, element: &Self::Type, event: &gst::EventRef) -> bool {
|
||||
fn parent_packet_lost(&self, event: &gst::EventRef) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTPBaseDepayloadClass;
|
||||
|
@ -103,7 +93,7 @@ impl<T: RTPBaseDepayloadImpl> RTPBaseDepayloadImplExt for T {
|
|||
.packet_lost
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTPBaseDepayload>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -116,7 +106,6 @@ impl<T: RTPBaseDepayloadImpl> RTPBaseDepayloadImplExt for T {
|
|||
|
||||
fn parent_process_rtp_packet(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
rtp_buffer: &crate::RTPBuffer<crate::rtp_buffer::Readable>,
|
||||
) -> Option<gst::Buffer> {
|
||||
unsafe {
|
||||
|
@ -128,7 +117,7 @@ impl<T: RTPBaseDepayloadImpl> RTPBaseDepayloadImplExt for T {
|
|||
.expect("no parent \"process\" implementation");
|
||||
|
||||
from_glib_full(f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<crate::RTPBaseDepayload>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -157,14 +146,13 @@ unsafe extern "C" fn rtp_base_depayload_set_caps<T: RTPBaseDepayloadImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTPBaseDepayload> = from_glib_borrow(ptr);
|
||||
let caps = from_glib_borrow(caps);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.set_caps(wrap.unsafe_cast_ref(), &caps) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.set_caps(&caps) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -178,12 +166,8 @@ unsafe extern "C" fn rtp_base_depayload_handle_event<T: RTPBaseDepayloadImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTPBaseDepayload> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.handle_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, false, { imp.handle_event(from_glib_full(event)) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn rtp_base_depayload_packet_lost<T: RTPBaseDepayloadImpl>(
|
||||
|
@ -192,10 +176,9 @@ unsafe extern "C" fn rtp_base_depayload_packet_lost<T: RTPBaseDepayloadImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTPBaseDepayload> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.packet_lost(wrap.unsafe_cast_ref(), gst::EventRef::from_ptr(event))
|
||||
gst::panic_to_error!(imp, false, {
|
||||
imp.packet_lost(gst::EventRef::from_ptr(event))
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -206,12 +189,11 @@ unsafe extern "C" fn rtp_base_depayload_process_rtp_packet<T: RTPBaseDepayloadIm
|
|||
) -> *mut gst::ffi::GstBuffer {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<crate::RTPBaseDepayload> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), ptr::null_mut(), {
|
||||
gst::panic_to_error!(imp, ptr::null_mut(), {
|
||||
let bufwrap = crate::RTPBuffer::<crate::rtp_buffer::Readable>::from_glib_borrow(rtp_packet);
|
||||
|
||||
imp.process_rtp_packet(wrap.unsafe_cast_ref(), &bufwrap)
|
||||
imp.process_rtp_packet(&bufwrap)
|
||||
.map(|buffer| buffer.into_glib_ptr())
|
||||
.unwrap_or(ptr::null_mut())
|
||||
})
|
||||
|
|
|
@ -8,70 +8,48 @@ use crate::prelude::*;
|
|||
use crate::RTPBasePayload;
|
||||
|
||||
pub trait RTPBasePayloadImpl: RTPBasePayloadImplExt + ElementImpl {
|
||||
fn caps(&self, element: &Self::Type, pad: &gst::Pad, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
self.parent_caps(element, pad, filter)
|
||||
fn caps(&self, pad: &gst::Pad, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
self.parent_caps(pad, filter)
|
||||
}
|
||||
|
||||
fn set_caps(&self, element: &Self::Type, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_caps(element, caps)
|
||||
fn set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_caps(caps)
|
||||
}
|
||||
|
||||
fn handle_buffer(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: gst::Buffer,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_handle_buffer(element, buffer)
|
||||
fn handle_buffer(&self, buffer: gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_handle_buffer(buffer)
|
||||
}
|
||||
|
||||
fn query(&self, element: &Self::Type, pad: &gst::Pad, query: &mut gst::QueryRef) -> bool {
|
||||
RTPBasePayloadImplExt::parent_query(self, element, pad, query)
|
||||
fn query(&self, pad: &gst::Pad, query: &mut gst::QueryRef) -> bool {
|
||||
RTPBasePayloadImplExt::parent_query(self, pad, query)
|
||||
}
|
||||
|
||||
fn sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
self.parent_sink_event(element, event)
|
||||
fn sink_event(&self, event: gst::Event) -> bool {
|
||||
self.parent_sink_event(event)
|
||||
}
|
||||
|
||||
fn src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
self.parent_src_event(element, event)
|
||||
fn src_event(&self, event: gst::Event) -> bool {
|
||||
self.parent_src_event(event)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RTPBasePayloadImplExt: ObjectSubclass {
|
||||
fn parent_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
pad: &gst::Pad,
|
||||
filter: Option<&gst::Caps>,
|
||||
) -> gst::Caps;
|
||||
fn parent_caps(&self, pad: &gst::Pad, filter: Option<&gst::Caps>) -> gst::Caps;
|
||||
|
||||
fn parent_set_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
fn parent_set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_handle_buffer(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: gst::Buffer,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
fn parent_handle_buffer(&self, buffer: gst::Buffer)
|
||||
-> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_query(&self, element: &Self::Type, pad: &gst::Pad, query: &mut gst::QueryRef)
|
||||
-> bool;
|
||||
fn parent_query(&self, pad: &gst::Pad, query: &mut gst::QueryRef) -> bool;
|
||||
|
||||
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||
fn parent_sink_event(&self, event: gst::Event) -> bool;
|
||||
|
||||
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||
fn parent_src_event(&self, event: gst::Event) -> bool;
|
||||
}
|
||||
|
||||
impl<T: RTPBasePayloadImpl> RTPBasePayloadImplExt for T {
|
||||
fn parent_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
pad: &gst::Pad,
|
||||
filter: Option<&gst::Caps>,
|
||||
) -> gst::Caps {
|
||||
fn parent_caps(&self, pad: &gst::Pad, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTPBasePayloadClass;
|
||||
|
@ -79,18 +57,17 @@ impl<T: RTPBasePayloadImpl> RTPBasePayloadImplExt for T {
|
|||
.get_caps
|
||||
.expect("Missing parent function `get_caps`");
|
||||
from_glib_full(f(
|
||||
element.unsafe_cast_ref::<RTPBasePayload>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTPBasePayload>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
pad.to_glib_none().0,
|
||||
filter.to_glib_none().0,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_set_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
fn parent_set_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTPBasePayloadClass;
|
||||
|
@ -99,7 +76,10 @@ impl<T: RTPBasePayloadImpl> RTPBasePayloadImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<RTPBasePayload>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTPBasePayload>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
caps.to_glib_none().0
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -108,7 +88,7 @@ impl<T: RTPBasePayloadImpl> RTPBasePayloadImplExt for T {
|
|||
})
|
||||
.unwrap_or_else(|| {
|
||||
// Trigger negotiation as the base class does
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTPBasePayload>()
|
||||
.set_outcaps(None)
|
||||
.map_err(|_| gst::loggable_error!(gst::CAT_RUST, "Failed to negotiate"))
|
||||
|
@ -118,7 +98,6 @@ impl<T: RTPBasePayloadImpl> RTPBasePayloadImplExt for T {
|
|||
|
||||
fn parent_handle_buffer(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: gst::Buffer,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
|
@ -128,7 +107,10 @@ impl<T: RTPBasePayloadImpl> RTPBasePayloadImplExt for T {
|
|||
.handle_buffer
|
||||
.map(|f| {
|
||||
try_from_glib(f(
|
||||
element.unsafe_cast_ref::<RTPBasePayload>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTPBasePayload>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
buffer.into_glib_ptr(),
|
||||
))
|
||||
})
|
||||
|
@ -136,12 +118,7 @@ impl<T: RTPBasePayloadImpl> RTPBasePayloadImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_query(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
pad: &gst::Pad,
|
||||
query: &mut gst::QueryRef,
|
||||
) -> bool {
|
||||
fn parent_query(&self, pad: &gst::Pad, query: &mut gst::QueryRef) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTPBasePayloadClass;
|
||||
|
@ -149,7 +126,10 @@ impl<T: RTPBasePayloadImpl> RTPBasePayloadImplExt for T {
|
|||
.query
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<RTPBasePayload>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTPBasePayload>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
pad.to_glib_none().0,
|
||||
query.as_mut_ptr(),
|
||||
))
|
||||
|
@ -158,7 +138,7 @@ impl<T: RTPBasePayloadImpl> RTPBasePayloadImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
fn parent_sink_event(&self, event: gst::Event) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTPBasePayloadClass;
|
||||
|
@ -166,7 +146,10 @@ impl<T: RTPBasePayloadImpl> RTPBasePayloadImplExt for T {
|
|||
.sink_event
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<RTPBasePayload>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTPBasePayload>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
event.into_glib_ptr(),
|
||||
))
|
||||
})
|
||||
|
@ -174,7 +157,7 @@ impl<T: RTPBasePayloadImpl> RTPBasePayloadImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
fn parent_src_event(&self, event: gst::Event) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTPBasePayloadClass;
|
||||
|
@ -182,7 +165,10 @@ impl<T: RTPBasePayloadImpl> RTPBasePayloadImplExt for T {
|
|||
.src_event
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<RTPBasePayload>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTPBasePayload>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
event.into_glib_ptr(),
|
||||
))
|
||||
})
|
||||
|
@ -211,12 +197,10 @@ unsafe extern "C" fn rtp_base_payload_get_caps<T: RTPBasePayloadImpl>(
|
|||
) -> *mut gst::ffi::GstCaps {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTPBasePayload> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::Caps::new_empty(), {
|
||||
gst::panic_to_error!(imp, gst::Caps::new_empty(), {
|
||||
RTPBasePayloadImpl::caps(
|
||||
imp,
|
||||
wrap.unsafe_cast_ref(),
|
||||
&from_glib_borrow(pad),
|
||||
Option::<gst::Caps>::from_glib_borrow(filter)
|
||||
.as_ref()
|
||||
|
@ -232,14 +216,13 @@ unsafe extern "C" fn rtp_base_payload_set_caps<T: RTPBasePayloadImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTPBasePayload> = from_glib_borrow(ptr);
|
||||
let caps = from_glib_borrow(caps);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.set_caps(wrap.unsafe_cast_ref(), &caps) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.set_caps(&caps) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -253,11 +236,9 @@ unsafe extern "C" fn rtp_base_payload_handle_buffer<T: RTPBasePayloadImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTPBasePayload> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
imp.handle_buffer(wrap.unsafe_cast_ref(), from_glib_full(buffer))
|
||||
.into()
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
imp.handle_buffer(from_glib_full(buffer)).into()
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -269,12 +250,10 @@ unsafe extern "C" fn rtp_base_payload_query<T: RTPBasePayloadImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTPBasePayload> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
RTPBasePayloadImpl::query(
|
||||
imp,
|
||||
wrap.unsafe_cast_ref(),
|
||||
&from_glib_borrow(pad),
|
||||
gst::QueryRef::from_mut_ptr(query),
|
||||
)
|
||||
|
@ -288,12 +267,8 @@ unsafe extern "C" fn rtp_base_payload_sink_event<T: RTPBasePayloadImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTPBasePayload> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.sink_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, false, { imp.sink_event(from_glib_full(event)) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn rtp_base_payload_src_event<T: RTPBasePayloadImpl>(
|
||||
|
@ -302,10 +277,6 @@ unsafe extern "C" fn rtp_base_payload_src_event<T: RTPBasePayloadImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTPBasePayload> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, false, { imp.src_event(from_glib_full(event)) }).into_glib()
|
||||
}
|
||||
|
|
|
@ -8,75 +8,59 @@ use glib::translate::*;
|
|||
pub trait RTPHeaderExtensionImpl: RTPHeaderExtensionImplExt + ElementImpl {
|
||||
const URI: &'static str;
|
||||
|
||||
fn supported_flags(&self, element: &Self::Type) -> crate::RTPHeaderExtensionFlags {
|
||||
self.parent_supported_flags(element)
|
||||
fn supported_flags(&self) -> crate::RTPHeaderExtensionFlags {
|
||||
self.parent_supported_flags()
|
||||
}
|
||||
|
||||
fn max_size(&self, element: &Self::Type, input: &gst::BufferRef) -> usize {
|
||||
self.parent_max_size(element, input)
|
||||
fn max_size(&self, input: &gst::BufferRef) -> usize {
|
||||
self.parent_max_size(input)
|
||||
}
|
||||
|
||||
fn write(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
input: &gst::BufferRef,
|
||||
write_flags: crate::RTPHeaderExtensionFlags,
|
||||
output: &mut gst::BufferRef,
|
||||
output_data: &mut [u8],
|
||||
) -> Result<usize, gst::LoggableError> {
|
||||
self.parent_write(element, input, write_flags, output, output_data)
|
||||
self.parent_write(input, write_flags, output, output_data)
|
||||
}
|
||||
|
||||
fn read(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
read_flags: crate::RTPHeaderExtensionFlags,
|
||||
input_data: &[u8],
|
||||
output: &mut gst::BufferRef,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_read(element, read_flags, input_data, output)
|
||||
self.parent_read(read_flags, input_data, output)
|
||||
}
|
||||
|
||||
fn set_non_rtp_sink_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_non_rtp_sink_caps(element, caps)
|
||||
fn set_non_rtp_sink_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_non_rtp_sink_caps(caps)
|
||||
}
|
||||
|
||||
fn update_non_rtp_src_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &mut gst::CapsRef,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_update_non_rtp_src_caps(element, caps)
|
||||
fn update_non_rtp_src_caps(&self, caps: &mut gst::CapsRef) -> Result<(), gst::LoggableError> {
|
||||
self.parent_update_non_rtp_src_caps(caps)
|
||||
}
|
||||
|
||||
fn set_attributes(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
direction: crate::RTPHeaderExtensionDirection,
|
||||
attributes: &str,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_attributes(element, direction, attributes)
|
||||
self.parent_set_attributes(direction, attributes)
|
||||
}
|
||||
|
||||
fn set_caps_from_attributes(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &mut gst::CapsRef,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_caps_from_attributes(element, caps)
|
||||
fn set_caps_from_attributes(&self, caps: &mut gst::CapsRef) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_caps_from_attributes(caps)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RTPHeaderExtensionImplExt: ObjectSubclass {
|
||||
fn parent_supported_flags(&self, element: &Self::Type) -> crate::RTPHeaderExtensionFlags;
|
||||
fn parent_max_size(&self, element: &Self::Type, input: &gst::BufferRef) -> usize;
|
||||
fn parent_supported_flags(&self) -> crate::RTPHeaderExtensionFlags;
|
||||
fn parent_max_size(&self, input: &gst::BufferRef) -> usize;
|
||||
fn parent_write(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
input: &gst::BufferRef,
|
||||
write_flags: crate::RTPHeaderExtensionFlags,
|
||||
output: &mut gst::BufferRef,
|
||||
|
@ -84,50 +68,43 @@ pub trait RTPHeaderExtensionImplExt: ObjectSubclass {
|
|||
) -> Result<usize, gst::LoggableError>;
|
||||
fn parent_read(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
read_flags: crate::RTPHeaderExtensionFlags,
|
||||
input_data: &[u8],
|
||||
output: &mut gst::BufferRef,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
fn parent_set_non_rtp_sink_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
fn parent_set_non_rtp_sink_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError>;
|
||||
fn parent_update_non_rtp_src_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &mut gst::CapsRef,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
fn parent_set_attributes(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
direction: crate::RTPHeaderExtensionDirection,
|
||||
attributes: &str,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
fn parent_set_caps_from_attributes(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &mut gst::CapsRef,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
}
|
||||
|
||||
impl<T: RTPHeaderExtensionImpl> RTPHeaderExtensionImplExt for T {
|
||||
fn parent_supported_flags(&self, element: &Self::Type) -> crate::RTPHeaderExtensionFlags {
|
||||
fn parent_supported_flags(&self) -> crate::RTPHeaderExtensionFlags {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTPHeaderExtensionClass;
|
||||
let f = (*parent_class)
|
||||
.get_supported_flags
|
||||
.expect("no parent \"get_supported_flags\" implementation");
|
||||
from_glib(f(element
|
||||
from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<crate::RTPHeaderExtension>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_max_size(&self, element: &Self::Type, input: &gst::BufferRef) -> usize {
|
||||
fn parent_max_size(&self, input: &gst::BufferRef) -> usize {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTPHeaderExtensionClass;
|
||||
|
@ -135,7 +112,7 @@ impl<T: RTPHeaderExtensionImpl> RTPHeaderExtensionImplExt for T {
|
|||
.get_max_size
|
||||
.expect("no parent \"get_max_size\" implementation");
|
||||
f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<crate::RTPHeaderExtension>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -146,7 +123,6 @@ impl<T: RTPHeaderExtensionImpl> RTPHeaderExtensionImplExt for T {
|
|||
|
||||
fn parent_write(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
input: &gst::BufferRef,
|
||||
write_flags: crate::RTPHeaderExtensionFlags,
|
||||
output: &mut gst::BufferRef,
|
||||
|
@ -160,7 +136,7 @@ impl<T: RTPHeaderExtensionImpl> RTPHeaderExtensionImplExt for T {
|
|||
.expect("no parent \"write\" implementation");
|
||||
|
||||
let res = f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<crate::RTPHeaderExtension>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -184,7 +160,6 @@ impl<T: RTPHeaderExtensionImpl> RTPHeaderExtensionImplExt for T {
|
|||
|
||||
fn parent_read(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
read_flags: crate::RTPHeaderExtensionFlags,
|
||||
input_data: &[u8],
|
||||
output: &mut gst::BufferRef,
|
||||
|
@ -198,7 +173,7 @@ impl<T: RTPHeaderExtensionImpl> RTPHeaderExtensionImplExt for T {
|
|||
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<crate::RTPHeaderExtension>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -213,18 +188,14 @@ impl<T: RTPHeaderExtensionImpl> RTPHeaderExtensionImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_set_non_rtp_sink_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
fn parent_set_non_rtp_sink_caps(&self, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTPHeaderExtensionClass;
|
||||
if let Some(f) = (*parent_class).set_non_rtp_sink_caps {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<crate::RTPHeaderExtension>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -241,7 +212,6 @@ impl<T: RTPHeaderExtensionImpl> RTPHeaderExtensionImplExt for T {
|
|||
|
||||
fn parent_update_non_rtp_src_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &mut gst::CapsRef,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
|
@ -250,7 +220,7 @@ impl<T: RTPHeaderExtensionImpl> RTPHeaderExtensionImplExt for T {
|
|||
if let Some(f) = (*parent_class).update_non_rtp_src_caps {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<crate::RTPHeaderExtension>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -267,7 +237,6 @@ impl<T: RTPHeaderExtensionImpl> RTPHeaderExtensionImplExt for T {
|
|||
|
||||
fn parent_set_attributes(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
direction: crate::RTPHeaderExtensionDirection,
|
||||
attributes: &str,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
|
@ -277,7 +246,7 @@ impl<T: RTPHeaderExtensionImpl> RTPHeaderExtensionImplExt for T {
|
|||
if let Some(f) = (*parent_class).set_attributes {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<crate::RTPHeaderExtension>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -295,7 +264,6 @@ impl<T: RTPHeaderExtensionImpl> RTPHeaderExtensionImplExt for T {
|
|||
|
||||
fn parent_set_caps_from_attributes(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &mut gst::CapsRef,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
|
@ -307,7 +275,7 @@ impl<T: RTPHeaderExtensionImpl> RTPHeaderExtensionImplExt for T {
|
|||
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<crate::RTPHeaderExtension>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -344,14 +312,10 @@ unsafe extern "C" fn get_supported_flags<T: RTPHeaderExtensionImpl>(
|
|||
) -> ffi::GstRTPHeaderExtensionFlags {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<crate::RTPHeaderExtension> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(
|
||||
&wrap,
|
||||
imp.panicked(),
|
||||
crate::RTPHeaderExtensionFlags::empty(),
|
||||
{ imp.supported_flags(wrap.unsafe_cast_ref()) }
|
||||
)
|
||||
gst::panic_to_error!(imp, crate::RTPHeaderExtensionFlags::empty(), {
|
||||
imp.supported_flags()
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
||||
|
@ -361,11 +325,8 @@ unsafe extern "C" fn get_max_size<T: RTPHeaderExtensionImpl>(
|
|||
) -> usize {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<crate::RTPHeaderExtension> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), 0, {
|
||||
imp.max_size(wrap.unsafe_cast_ref(), gst::BufferRef::from_ptr(input))
|
||||
})
|
||||
gst::panic_to_error!(imp, 0, { imp.max_size(gst::BufferRef::from_ptr(input)) })
|
||||
}
|
||||
|
||||
unsafe extern "C" fn write<T: RTPHeaderExtensionImpl>(
|
||||
|
@ -378,11 +339,9 @@ unsafe extern "C" fn write<T: RTPHeaderExtensionImpl>(
|
|||
) -> isize {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<crate::RTPHeaderExtension> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), -1, {
|
||||
gst::panic_to_error!(imp, -1, {
|
||||
match imp.write(
|
||||
wrap.unsafe_cast_ref(),
|
||||
gst::BufferRef::from_ptr(input),
|
||||
from_glib(write_flags),
|
||||
gst::BufferRef::from_mut_ptr(output),
|
||||
|
@ -394,7 +353,7 @@ unsafe extern "C" fn write<T: RTPHeaderExtensionImpl>(
|
|||
) {
|
||||
Ok(len) => len as isize,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
-1
|
||||
}
|
||||
}
|
||||
|
@ -410,11 +369,9 @@ unsafe extern "C" fn read<T: RTPHeaderExtensionImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<crate::RTPHeaderExtension> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.read(
|
||||
wrap.unsafe_cast_ref(),
|
||||
from_glib(read_flags),
|
||||
if input_data_len == 0 {
|
||||
&[]
|
||||
|
@ -425,7 +382,7 @@ unsafe extern "C" fn read<T: RTPHeaderExtensionImpl>(
|
|||
) {
|
||||
Ok(_) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -439,13 +396,12 @@ unsafe extern "C" fn set_non_rtp_sink_caps<T: RTPHeaderExtensionImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<crate::RTPHeaderExtension> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.set_non_rtp_sink_caps(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.set_non_rtp_sink_caps(&from_glib_borrow(caps)) {
|
||||
Ok(_) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -459,14 +415,12 @@ unsafe extern "C" fn update_non_rtp_src_caps<T: RTPHeaderExtensionImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<crate::RTPHeaderExtension> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.update_non_rtp_src_caps(wrap.unsafe_cast_ref(), gst::CapsRef::from_mut_ptr(caps))
|
||||
{
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.update_non_rtp_src_caps(gst::CapsRef::from_mut_ptr(caps)) {
|
||||
Ok(_) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -481,17 +435,15 @@ unsafe extern "C" fn set_attributes<T: RTPHeaderExtensionImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<crate::RTPHeaderExtension> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.set_attributes(
|
||||
wrap.unsafe_cast_ref(),
|
||||
from_glib(direction),
|
||||
&glib::GString::from_glib_borrow(attributes),
|
||||
) {
|
||||
Ok(_) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -505,14 +457,12 @@ unsafe extern "C" fn set_caps_from_attributes<T: RTPHeaderExtensionImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<crate::RTPHeaderExtension> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.set_caps_from_attributes(wrap.unsafe_cast_ref(), gst::CapsRef::from_mut_ptr(caps))
|
||||
{
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.set_caps_from_attributes(gst::CapsRef::from_mut_ptr(caps)) {
|
||||
Ok(_) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -26,137 +26,118 @@ impl SDPInfo {
|
|||
}
|
||||
|
||||
pub trait RTSPMediaImpl: RTSPMediaImplExt + ObjectImpl + Send + Sync {
|
||||
fn handle_message(&self, media: &Self::Type, message: &gst::MessageRef) -> bool {
|
||||
self.parent_handle_message(media, message)
|
||||
fn handle_message(&self, message: &gst::MessageRef) -> bool {
|
||||
self.parent_handle_message(message)
|
||||
}
|
||||
|
||||
fn prepare(&self, media: &Self::Type, thread: &RTSPThread) -> Result<(), gst::LoggableError> {
|
||||
self.parent_prepare(media, thread)
|
||||
fn prepare(&self, thread: &RTSPThread) -> Result<(), gst::LoggableError> {
|
||||
self.parent_prepare(thread)
|
||||
}
|
||||
|
||||
fn unprepare(&self, media: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
self.parent_unprepare(media)
|
||||
fn unprepare(&self) -> Result<(), gst::LoggableError> {
|
||||
self.parent_unprepare()
|
||||
}
|
||||
|
||||
fn suspend(&self, media: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
self.parent_suspend(media)
|
||||
fn suspend(&self) -> Result<(), gst::LoggableError> {
|
||||
self.parent_suspend()
|
||||
}
|
||||
|
||||
fn unsuspend(&self, media: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
self.parent_unsuspend(media)
|
||||
fn unsuspend(&self) -> Result<(), gst::LoggableError> {
|
||||
self.parent_unsuspend()
|
||||
}
|
||||
|
||||
// TODO missing: convert_range
|
||||
|
||||
fn query_position(&self, media: &Self::Type) -> Option<gst::ClockTime> {
|
||||
self.parent_query_position(media)
|
||||
fn query_position(&self) -> Option<gst::ClockTime> {
|
||||
self.parent_query_position()
|
||||
}
|
||||
|
||||
fn query_stop(&self, media: &Self::Type) -> Option<gst::ClockTime> {
|
||||
self.parent_query_stop(media)
|
||||
fn query_stop(&self) -> Option<gst::ClockTime> {
|
||||
self.parent_query_stop()
|
||||
}
|
||||
|
||||
fn create_rtpbin(&self, media: &Self::Type) -> Option<gst::Element> {
|
||||
self.parent_create_rtpbin(media)
|
||||
fn create_rtpbin(&self) -> Option<gst::Element> {
|
||||
self.parent_create_rtpbin()
|
||||
}
|
||||
|
||||
fn setup_rtpbin(
|
||||
&self,
|
||||
media: &Self::Type,
|
||||
rtpbin: &gst::Element,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_setup_rtpbin(media, rtpbin)
|
||||
fn setup_rtpbin(&self, rtpbin: &gst::Element) -> Result<(), gst::LoggableError> {
|
||||
self.parent_setup_rtpbin(rtpbin)
|
||||
}
|
||||
|
||||
fn setup_sdp(
|
||||
&self,
|
||||
media: &Self::Type,
|
||||
sdp: &mut gst_sdp::SDPMessageRef,
|
||||
info: &SDPInfo,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_setup_sdp(media, sdp, info)
|
||||
self.parent_setup_sdp(sdp, info)
|
||||
}
|
||||
|
||||
fn new_stream(&self, media: &Self::Type, stream: &crate::RTSPStream) {
|
||||
self.parent_new_stream(media, stream);
|
||||
fn new_stream(&self, stream: &crate::RTSPStream) {
|
||||
self.parent_new_stream(stream);
|
||||
}
|
||||
|
||||
fn removed_stream(&self, media: &Self::Type, stream: &crate::RTSPStream) {
|
||||
self.parent_removed_stream(media, stream);
|
||||
fn removed_stream(&self, stream: &crate::RTSPStream) {
|
||||
self.parent_removed_stream(stream);
|
||||
}
|
||||
|
||||
fn prepared(&self, media: &Self::Type) {
|
||||
self.parent_prepared(media);
|
||||
fn prepared(&self) {
|
||||
self.parent_prepared();
|
||||
}
|
||||
|
||||
fn unprepared(&self, media: &Self::Type) {
|
||||
self.parent_unprepared(media);
|
||||
fn unprepared(&self) {
|
||||
self.parent_unprepared();
|
||||
}
|
||||
|
||||
fn target_state(&self, media: &Self::Type, state: gst::State) {
|
||||
self.parent_target_state(media, state);
|
||||
fn target_state(&self, state: gst::State) {
|
||||
self.parent_target_state(state);
|
||||
}
|
||||
|
||||
fn new_state(&self, media: &Self::Type, state: gst::State) {
|
||||
self.parent_new_state(media, state);
|
||||
fn new_state(&self, state: gst::State) {
|
||||
self.parent_new_state(state);
|
||||
}
|
||||
|
||||
fn handle_sdp(
|
||||
&self,
|
||||
media: &Self::Type,
|
||||
sdp: &gst_sdp::SDPMessageRef,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_handle_sdp(media, sdp)
|
||||
fn handle_sdp(&self, sdp: &gst_sdp::SDPMessageRef) -> Result<(), gst::LoggableError> {
|
||||
self.parent_handle_sdp(sdp)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RTSPMediaImplExt: ObjectSubclass {
|
||||
fn parent_handle_message(&self, media: &Self::Type, message: &gst::MessageRef) -> bool;
|
||||
fn parent_prepare(
|
||||
&self,
|
||||
media: &Self::Type,
|
||||
thread: &RTSPThread,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
fn parent_unprepare(&self, media: &Self::Type) -> Result<(), gst::LoggableError>;
|
||||
fn parent_suspend(&self, media: &Self::Type) -> Result<(), gst::LoggableError>;
|
||||
fn parent_unsuspend(&self, media: &Self::Type) -> Result<(), gst::LoggableError>;
|
||||
fn parent_handle_message(&self, message: &gst::MessageRef) -> bool;
|
||||
fn parent_prepare(&self, thread: &RTSPThread) -> Result<(), gst::LoggableError>;
|
||||
fn parent_unprepare(&self) -> Result<(), gst::LoggableError>;
|
||||
fn parent_suspend(&self) -> Result<(), gst::LoggableError>;
|
||||
fn parent_unsuspend(&self) -> Result<(), gst::LoggableError>;
|
||||
// TODO missing: convert_range
|
||||
|
||||
fn parent_query_position(&self, media: &Self::Type) -> Option<gst::ClockTime>;
|
||||
fn parent_query_stop(&self, media: &Self::Type) -> Option<gst::ClockTime>;
|
||||
fn parent_create_rtpbin(&self, media: &Self::Type) -> Option<gst::Element>;
|
||||
fn parent_setup_rtpbin(
|
||||
&self,
|
||||
media: &Self::Type,
|
||||
rtpbin: &gst::Element,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
fn parent_query_position(&self) -> Option<gst::ClockTime>;
|
||||
fn parent_query_stop(&self) -> Option<gst::ClockTime>;
|
||||
fn parent_create_rtpbin(&self) -> Option<gst::Element>;
|
||||
fn parent_setup_rtpbin(&self, rtpbin: &gst::Element) -> Result<(), gst::LoggableError>;
|
||||
fn parent_setup_sdp(
|
||||
&self,
|
||||
media: &Self::Type,
|
||||
sdp: &mut gst_sdp::SDPMessageRef,
|
||||
info: &SDPInfo,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
fn parent_new_stream(&self, media: &Self::Type, stream: &crate::RTSPStream);
|
||||
fn parent_removed_stream(&self, media: &Self::Type, stream: &crate::RTSPStream);
|
||||
fn parent_prepared(&self, media: &Self::Type);
|
||||
fn parent_unprepared(&self, media: &Self::Type);
|
||||
fn parent_target_state(&self, media: &Self::Type, state: gst::State);
|
||||
fn parent_new_state(&self, media: &Self::Type, state: gst::State);
|
||||
fn parent_handle_sdp(
|
||||
&self,
|
||||
media: &Self::Type,
|
||||
sdp: &gst_sdp::SDPMessageRef,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
fn parent_new_stream(&self, stream: &crate::RTSPStream);
|
||||
fn parent_removed_stream(&self, stream: &crate::RTSPStream);
|
||||
fn parent_prepared(&self);
|
||||
fn parent_unprepared(&self);
|
||||
fn parent_target_state(&self, state: gst::State);
|
||||
fn parent_new_state(&self, state: gst::State);
|
||||
fn parent_handle_sdp(&self, sdp: &gst_sdp::SDPMessageRef) -> Result<(), gst::LoggableError>;
|
||||
}
|
||||
|
||||
impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
||||
fn parent_handle_message(&self, media: &Self::Type, message: &gst::MessageRef) -> bool {
|
||||
fn parent_handle_message(&self, message: &gst::MessageRef) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).handle_message {
|
||||
from_glib(f(
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMedia>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
message.as_ptr() as *mut _,
|
||||
))
|
||||
} else {
|
||||
|
@ -165,18 +146,17 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_prepare(
|
||||
&self,
|
||||
media: &Self::Type,
|
||||
thread: &RTSPThread,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
fn parent_prepare(&self, thread: &RTSPThread) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).prepare {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMedia>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
thread.to_glib_none().0
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -188,13 +168,17 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_unprepare(&self, media: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
fn parent_unprepare(&self) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).unprepare {
|
||||
gst::result_from_gboolean!(
|
||||
f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0),
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<RTSPMedia>()
|
||||
.to_glib_none()
|
||||
.0),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `unprepare` failed"
|
||||
)
|
||||
|
@ -204,13 +188,17 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_suspend(&self, media: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
fn parent_suspend(&self) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).suspend {
|
||||
gst::result_from_gboolean!(
|
||||
f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0),
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<RTSPMedia>()
|
||||
.to_glib_none()
|
||||
.0),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `suspend` failed"
|
||||
)
|
||||
|
@ -220,13 +208,17 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_unsuspend(&self, media: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
fn parent_unsuspend(&self) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).unsuspend {
|
||||
gst::result_from_gboolean!(
|
||||
f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0),
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<RTSPMedia>()
|
||||
.to_glib_none()
|
||||
.0),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `unsuspend` failed"
|
||||
)
|
||||
|
@ -238,7 +230,7 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
|
||||
// TODO missing: convert_range
|
||||
|
||||
fn parent_query_position(&self, media: &Self::Type) -> Option<gst::ClockTime> {
|
||||
fn parent_query_position(&self) -> Option<gst::ClockTime> {
|
||||
unsafe {
|
||||
use std::mem;
|
||||
|
||||
|
@ -247,7 +239,10 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
if let Some(f) = (*parent_class).query_position {
|
||||
let mut position = mem::MaybeUninit::uninit();
|
||||
if f(
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMedia>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
position.as_mut_ptr(),
|
||||
) == glib::ffi::GFALSE
|
||||
{
|
||||
|
@ -261,7 +256,7 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_query_stop(&self, media: &Self::Type) -> Option<gst::ClockTime> {
|
||||
fn parent_query_stop(&self) -> Option<gst::ClockTime> {
|
||||
unsafe {
|
||||
use std::mem;
|
||||
|
||||
|
@ -270,7 +265,10 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
if let Some(f) = (*parent_class).query_stop {
|
||||
let mut stop = mem::MaybeUninit::uninit();
|
||||
if f(
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMedia>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
stop.as_mut_ptr(),
|
||||
) == glib::ffi::GFALSE
|
||||
{
|
||||
|
@ -284,7 +282,7 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_create_rtpbin(&self, media: &Self::Type) -> Option<gst::Element> {
|
||||
fn parent_create_rtpbin(&self) -> Option<gst::Element> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
||||
|
@ -292,15 +290,15 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
.create_rtpbin
|
||||
.expect("No `create_rtpbin` virtual method implementation in parent class");
|
||||
|
||||
from_glib_none(f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0))
|
||||
from_glib_none(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<RTSPMedia>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_setup_rtpbin(
|
||||
&self,
|
||||
media: &Self::Type,
|
||||
rtpbin: &gst::Element,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
fn parent_setup_rtpbin(&self, rtpbin: &gst::Element) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
||||
|
@ -311,7 +309,13 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
glib::gobject_ffi::g_object_force_floating(ptr as *mut _);
|
||||
|
||||
let res = gst::result_from_gboolean!(
|
||||
f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0, ptr),
|
||||
f(
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMedia>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
ptr
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `setup_sdp` failed"
|
||||
);
|
||||
|
@ -332,7 +336,6 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
|
||||
fn parent_setup_sdp(
|
||||
&self,
|
||||
media: &Self::Type,
|
||||
sdp: &mut gst_sdp::SDPMessageRef,
|
||||
info: &SDPInfo,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
|
@ -345,7 +348,10 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMedia>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
sdp as *mut _ as *mut gst_sdp::ffi::GstSDPMessage,
|
||||
info.0.as_ptr()
|
||||
),
|
||||
|
@ -355,83 +361,99 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_new_stream(&self, media: &Self::Type, stream: &crate::RTSPStream) {
|
||||
fn parent_new_stream(&self, stream: &crate::RTSPStream) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).new_stream {
|
||||
f(
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMedia>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
stream.to_glib_none().0,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_removed_stream(&self, media: &Self::Type, stream: &crate::RTSPStream) {
|
||||
fn parent_removed_stream(&self, stream: &crate::RTSPStream) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).removed_stream {
|
||||
f(
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMedia>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
stream.to_glib_none().0,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_prepared(&self, media: &Self::Type) {
|
||||
fn parent_prepared(&self) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).prepared {
|
||||
f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0);
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<RTSPMedia>()
|
||||
.to_glib_none()
|
||||
.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_unprepared(&self, media: &Self::Type) {
|
||||
fn parent_unprepared(&self) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).unprepared {
|
||||
f(media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0);
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<RTSPMedia>()
|
||||
.to_glib_none()
|
||||
.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_target_state(&self, media: &Self::Type, state: gst::State) {
|
||||
fn parent_target_state(&self, state: gst::State) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).target_state {
|
||||
f(
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMedia>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
state.into_glib(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_new_state(&self, media: &Self::Type, state: gst::State) {
|
||||
fn parent_new_state(&self, state: gst::State) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
||||
if let Some(f) = (*parent_class).new_state {
|
||||
f(
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMedia>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
state.into_glib(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_handle_sdp(
|
||||
&self,
|
||||
media: &Self::Type,
|
||||
sdp: &gst_sdp::SDPMessageRef,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
fn parent_handle_sdp(&self, sdp: &gst_sdp::SDPMessageRef) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaClass;
|
||||
|
@ -441,7 +463,10 @@ impl<T: RTSPMediaImpl> RTSPMediaImplExt for T {
|
|||
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
media.unsafe_cast_ref::<RTSPMedia>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMedia>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
sdp as *const _ as *mut gst_sdp::ffi::GstSDPMessage
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -480,9 +505,8 @@ unsafe extern "C" fn media_handle_message<T: RTSPMediaImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
imp.handle_message(wrap.unsafe_cast_ref(), gst::MessageRef::from_ptr(message))
|
||||
imp.handle_message(gst::MessageRef::from_ptr(message))
|
||||
.into_glib()
|
||||
}
|
||||
|
||||
|
@ -492,12 +516,11 @@ unsafe extern "C" fn media_prepare<T: RTSPMediaImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.prepare(wrap.unsafe_cast_ref(), &from_glib_borrow(thread)) {
|
||||
match imp.prepare(&from_glib_borrow(thread)) {
|
||||
Ok(()) => glib::ffi::GTRUE,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
glib::ffi::GFALSE
|
||||
}
|
||||
}
|
||||
|
@ -508,12 +531,11 @@ unsafe extern "C" fn media_unprepare<T: RTSPMediaImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.unprepare(wrap.unsafe_cast_ref()) {
|
||||
match imp.unprepare() {
|
||||
Ok(()) => glib::ffi::GTRUE,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
glib::ffi::GFALSE
|
||||
}
|
||||
}
|
||||
|
@ -524,12 +546,11 @@ unsafe extern "C" fn media_suspend<T: RTSPMediaImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.suspend(wrap.unsafe_cast_ref()) {
|
||||
match imp.suspend() {
|
||||
Ok(()) => glib::ffi::GTRUE,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
glib::ffi::GFALSE
|
||||
}
|
||||
}
|
||||
|
@ -540,12 +561,11 @@ unsafe extern "C" fn media_unsuspend<T: RTSPMediaImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.unsuspend(wrap.unsafe_cast_ref()) {
|
||||
match imp.unsuspend() {
|
||||
Ok(()) => glib::ffi::GTRUE,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
glib::ffi::GFALSE
|
||||
}
|
||||
}
|
||||
|
@ -557,9 +577,8 @@ unsafe extern "C" fn media_query_position<T: RTSPMediaImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.query_position(wrap.unsafe_cast_ref()) {
|
||||
match imp.query_position() {
|
||||
Some(pos) => {
|
||||
*position = pos.into_glib() as i64;
|
||||
glib::ffi::GTRUE
|
||||
|
@ -574,9 +593,8 @@ unsafe extern "C" fn media_query_stop<T: RTSPMediaImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.query_stop(wrap.unsafe_cast_ref()) {
|
||||
match imp.query_stop() {
|
||||
Some(s) => {
|
||||
*stop = s.into_glib() as i64;
|
||||
glib::ffi::GTRUE
|
||||
|
@ -590,9 +608,8 @@ unsafe extern "C" fn media_create_rtpbin<T: RTSPMediaImpl>(
|
|||
) -> *mut gst::ffi::GstElement {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
let res: *mut gst::ffi::GstElement = imp.create_rtpbin(wrap.unsafe_cast_ref()).to_glib_full();
|
||||
let res: *mut gst::ffi::GstElement = imp.create_rtpbin().to_glib_full();
|
||||
|
||||
if !res.is_null() {
|
||||
glib::gobject_ffi::g_object_force_floating(res as *mut _);
|
||||
|
@ -607,7 +624,6 @@ unsafe extern "C" fn media_setup_rtpbin<T: RTSPMediaImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
// If the rtpbin was floating before make sure it is not anymore for now so
|
||||
// we don't accidentally take ownership of it somewhere along the line
|
||||
|
@ -615,10 +631,10 @@ unsafe extern "C" fn media_setup_rtpbin<T: RTSPMediaImpl>(
|
|||
glib::gobject_ffi::g_object_ref_sink(rtpbin as *mut _);
|
||||
}
|
||||
|
||||
let res = match imp.setup_rtpbin(wrap.unsafe_cast_ref(), &from_glib_borrow(rtpbin)) {
|
||||
let res = match imp.setup_rtpbin(&from_glib_borrow(rtpbin)) {
|
||||
Ok(()) => glib::ffi::GTRUE,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
glib::ffi::GFALSE
|
||||
}
|
||||
};
|
||||
|
@ -636,16 +652,14 @@ unsafe extern "C" fn media_setup_sdp<T: RTSPMediaImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.setup_sdp(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&mut *(sdp as *mut gst_sdp::SDPMessageRef),
|
||||
&SDPInfo(ptr::NonNull::new(info).expect("NULL SDPInfo")),
|
||||
) {
|
||||
Ok(()) => glib::ffi::GTRUE,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
glib::ffi::GFALSE
|
||||
}
|
||||
}
|
||||
|
@ -657,9 +671,8 @@ unsafe extern "C" fn media_new_stream<T: RTSPMediaImpl>(
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
imp.new_stream(wrap.unsafe_cast_ref(), &from_glib_borrow(stream));
|
||||
imp.new_stream(&from_glib_borrow(stream));
|
||||
}
|
||||
|
||||
unsafe extern "C" fn media_removed_stream<T: RTSPMediaImpl>(
|
||||
|
@ -668,25 +681,22 @@ unsafe extern "C" fn media_removed_stream<T: RTSPMediaImpl>(
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
imp.removed_stream(wrap.unsafe_cast_ref(), &from_glib_borrow(stream));
|
||||
imp.removed_stream(&from_glib_borrow(stream));
|
||||
}
|
||||
|
||||
unsafe extern "C" fn media_prepared<T: RTSPMediaImpl>(ptr: *mut ffi::GstRTSPMedia) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
imp.prepared(wrap.unsafe_cast_ref());
|
||||
imp.prepared();
|
||||
}
|
||||
|
||||
unsafe extern "C" fn media_unprepared<T: RTSPMediaImpl>(ptr: *mut ffi::GstRTSPMedia) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
imp.unprepared(wrap.unsafe_cast_ref());
|
||||
imp.unprepared();
|
||||
}
|
||||
|
||||
unsafe extern "C" fn media_target_state<T: RTSPMediaImpl>(
|
||||
|
@ -695,9 +705,8 @@ unsafe extern "C" fn media_target_state<T: RTSPMediaImpl>(
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
imp.target_state(wrap.unsafe_cast_ref(), from_glib(state));
|
||||
imp.target_state(from_glib(state));
|
||||
}
|
||||
|
||||
unsafe extern "C" fn media_new_state<T: RTSPMediaImpl>(
|
||||
|
@ -706,9 +715,8 @@ unsafe extern "C" fn media_new_state<T: RTSPMediaImpl>(
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
imp.new_state(wrap.unsafe_cast_ref(), from_glib(state));
|
||||
imp.new_state(from_glib(state));
|
||||
}
|
||||
|
||||
unsafe extern "C" fn media_handle_sdp<T: RTSPMediaImpl>(
|
||||
|
@ -717,15 +725,11 @@ unsafe extern "C" fn media_handle_sdp<T: RTSPMediaImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMedia> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.handle_sdp(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&*(sdp as *const gst_sdp::SDPMessageRef),
|
||||
) {
|
||||
match imp.handle_sdp(&*(sdp as *const gst_sdp::SDPMessageRef)) {
|
||||
Ok(()) => glib::ffi::GTRUE,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
glib::ffi::GFALSE
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,80 +9,52 @@ use crate::RTSPMediaFactory;
|
|||
use std::mem::transmute;
|
||||
|
||||
pub trait RTSPMediaFactoryImpl: RTSPMediaFactoryImplExt + ObjectImpl + Send + Sync {
|
||||
fn gen_key(&self, factory: &Self::Type, url: &gst_rtsp::RTSPUrl) -> Option<glib::GString> {
|
||||
self.parent_gen_key(factory, url)
|
||||
fn gen_key(&self, url: &gst_rtsp::RTSPUrl) -> Option<glib::GString> {
|
||||
self.parent_gen_key(url)
|
||||
}
|
||||
|
||||
fn create_element(
|
||||
&self,
|
||||
factory: &Self::Type,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<gst::Element> {
|
||||
self.parent_create_element(factory, url)
|
||||
fn create_element(&self, url: &gst_rtsp::RTSPUrl) -> Option<gst::Element> {
|
||||
self.parent_create_element(url)
|
||||
}
|
||||
|
||||
fn construct(&self, factory: &Self::Type, url: &gst_rtsp::RTSPUrl) -> Option<crate::RTSPMedia> {
|
||||
self.parent_construct(factory, url)
|
||||
fn construct(&self, url: &gst_rtsp::RTSPUrl) -> Option<crate::RTSPMedia> {
|
||||
self.parent_construct(url)
|
||||
}
|
||||
|
||||
fn create_pipeline(
|
||||
&self,
|
||||
factory: &Self::Type,
|
||||
media: &crate::RTSPMedia,
|
||||
) -> Option<gst::Pipeline> {
|
||||
self.parent_create_pipeline(factory, media)
|
||||
fn create_pipeline(&self, media: &crate::RTSPMedia) -> Option<gst::Pipeline> {
|
||||
self.parent_create_pipeline(media)
|
||||
}
|
||||
|
||||
fn configure(&self, factory: &Self::Type, media: &crate::RTSPMedia) {
|
||||
self.parent_configure(factory, media)
|
||||
fn configure(&self, media: &crate::RTSPMedia) {
|
||||
self.parent_configure(media)
|
||||
}
|
||||
|
||||
fn media_constructed(&self, factory: &Self::Type, media: &crate::RTSPMedia) {
|
||||
self.parent_media_constructed(factory, media)
|
||||
fn media_constructed(&self, media: &crate::RTSPMedia) {
|
||||
self.parent_media_constructed(media)
|
||||
}
|
||||
|
||||
fn media_configure(&self, factory: &Self::Type, media: &crate::RTSPMedia) {
|
||||
self.parent_media_configure(factory, media)
|
||||
fn media_configure(&self, media: &crate::RTSPMedia) {
|
||||
self.parent_media_configure(media)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RTSPMediaFactoryImplExt: ObjectSubclass {
|
||||
fn parent_gen_key(
|
||||
&self,
|
||||
factory: &Self::Type,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<glib::GString>;
|
||||
fn parent_gen_key(&self, url: &gst_rtsp::RTSPUrl) -> Option<glib::GString>;
|
||||
|
||||
fn parent_create_element(
|
||||
&self,
|
||||
factory: &Self::Type,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<gst::Element>;
|
||||
fn parent_create_element(&self, url: &gst_rtsp::RTSPUrl) -> Option<gst::Element>;
|
||||
|
||||
fn parent_construct(
|
||||
&self,
|
||||
factory: &Self::Type,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<crate::RTSPMedia>;
|
||||
fn parent_construct(&self, url: &gst_rtsp::RTSPUrl) -> Option<crate::RTSPMedia>;
|
||||
|
||||
fn parent_create_pipeline(
|
||||
&self,
|
||||
factory: &Self::Type,
|
||||
media: &crate::RTSPMedia,
|
||||
) -> Option<gst::Pipeline>;
|
||||
fn parent_create_pipeline(&self, media: &crate::RTSPMedia) -> Option<gst::Pipeline>;
|
||||
|
||||
fn parent_configure(&self, factory: &Self::Type, media: &crate::RTSPMedia);
|
||||
fn parent_configure(&self, media: &crate::RTSPMedia);
|
||||
|
||||
fn parent_media_constructed(&self, factory: &Self::Type, media: &crate::RTSPMedia);
|
||||
fn parent_media_configure(&self, factory: &Self::Type, media: &crate::RTSPMedia);
|
||||
fn parent_media_constructed(&self, media: &crate::RTSPMedia);
|
||||
fn parent_media_configure(&self, media: &crate::RTSPMedia);
|
||||
}
|
||||
|
||||
impl<T: RTSPMediaFactoryImpl> RTSPMediaFactoryImplExt for T {
|
||||
fn parent_gen_key(
|
||||
&self,
|
||||
factory: &Self::Type,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<glib::GString> {
|
||||
fn parent_gen_key(&self, url: &gst_rtsp::RTSPUrl) -> Option<glib::GString> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaFactoryClass;
|
||||
|
@ -90,7 +62,7 @@ impl<T: RTSPMediaFactoryImpl> RTSPMediaFactoryImplExt for T {
|
|||
.gen_key
|
||||
.map(|f| {
|
||||
from_glib_full(f(
|
||||
factory
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMediaFactory>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -101,11 +73,7 @@ impl<T: RTSPMediaFactoryImpl> RTSPMediaFactoryImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_create_element(
|
||||
&self,
|
||||
factory: &Self::Type,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<gst::Element> {
|
||||
fn parent_create_element(&self, url: &gst_rtsp::RTSPUrl) -> Option<gst::Element> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaFactoryClass;
|
||||
|
@ -113,7 +81,7 @@ impl<T: RTSPMediaFactoryImpl> RTSPMediaFactoryImplExt for T {
|
|||
.create_element
|
||||
.map(|f| {
|
||||
from_glib_none(f(
|
||||
factory
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMediaFactory>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -124,11 +92,7 @@ impl<T: RTSPMediaFactoryImpl> RTSPMediaFactoryImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_construct(
|
||||
&self,
|
||||
factory: &Self::Type,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<crate::RTSPMedia> {
|
||||
fn parent_construct(&self, url: &gst_rtsp::RTSPUrl) -> Option<crate::RTSPMedia> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaFactoryClass;
|
||||
|
@ -136,7 +100,7 @@ impl<T: RTSPMediaFactoryImpl> RTSPMediaFactoryImplExt for T {
|
|||
.construct
|
||||
.map(|f| {
|
||||
from_glib_full(f(
|
||||
factory
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMediaFactory>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -147,11 +111,7 @@ impl<T: RTSPMediaFactoryImpl> RTSPMediaFactoryImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_create_pipeline(
|
||||
&self,
|
||||
factory: &Self::Type,
|
||||
media: &crate::RTSPMedia,
|
||||
) -> Option<gst::Pipeline> {
|
||||
fn parent_create_pipeline(&self, media: &crate::RTSPMedia) -> Option<gst::Pipeline> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaFactoryClass;
|
||||
|
@ -159,7 +119,7 @@ impl<T: RTSPMediaFactoryImpl> RTSPMediaFactoryImplExt for T {
|
|||
.create_pipeline
|
||||
.map(|f| {
|
||||
let ptr = f(
|
||||
factory
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMediaFactory>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -176,13 +136,13 @@ impl<T: RTSPMediaFactoryImpl> RTSPMediaFactoryImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_configure(&self, factory: &Self::Type, media: &crate::RTSPMedia) {
|
||||
fn parent_configure(&self, media: &crate::RTSPMedia) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaFactoryClass;
|
||||
if let Some(f) = (*parent_class).configure {
|
||||
f(
|
||||
factory
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMediaFactory>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -192,13 +152,13 @@ impl<T: RTSPMediaFactoryImpl> RTSPMediaFactoryImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_media_constructed(&self, factory: &Self::Type, media: &crate::RTSPMedia) {
|
||||
fn parent_media_constructed(&self, media: &crate::RTSPMedia) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaFactoryClass;
|
||||
if let Some(f) = (*parent_class).media_constructed {
|
||||
f(
|
||||
factory
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMediaFactory>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -208,13 +168,13 @@ impl<T: RTSPMediaFactoryImpl> RTSPMediaFactoryImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_media_configure(&self, factory: &Self::Type, media: &crate::RTSPMedia) {
|
||||
fn parent_media_configure(&self, media: &crate::RTSPMedia) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMediaFactoryClass;
|
||||
if let Some(f) = (*parent_class).media_configure {
|
||||
f(
|
||||
factory
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMediaFactory>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -244,10 +204,8 @@ unsafe extern "C" fn factory_gen_key<T: RTSPMediaFactoryImpl>(
|
|||
) -> *mut std::os::raw::c_char {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMediaFactory> = from_glib_borrow(ptr);
|
||||
|
||||
imp.gen_key(wrap.unsafe_cast_ref(), &from_glib_borrow(url))
|
||||
.to_glib_full()
|
||||
imp.gen_key(&from_glib_borrow(url)).to_glib_full()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn factory_create_element<T: RTSPMediaFactoryImpl>(
|
||||
|
@ -256,11 +214,8 @@ unsafe extern "C" fn factory_create_element<T: RTSPMediaFactoryImpl>(
|
|||
) -> *mut gst::ffi::GstElement {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMediaFactory> = from_glib_borrow(ptr);
|
||||
|
||||
let element = imp
|
||||
.create_element(wrap.unsafe_cast_ref(), &from_glib_borrow(url))
|
||||
.to_glib_full();
|
||||
let element = imp.create_element(&from_glib_borrow(url)).to_glib_full();
|
||||
glib::gobject_ffi::g_object_force_floating(element as *mut _);
|
||||
element
|
||||
}
|
||||
|
@ -271,10 +226,8 @@ unsafe extern "C" fn factory_construct<T: RTSPMediaFactoryImpl>(
|
|||
) -> *mut ffi::GstRTSPMedia {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMediaFactory> = from_glib_borrow(ptr);
|
||||
|
||||
imp.construct(wrap.unsafe_cast_ref(), &from_glib_borrow(url))
|
||||
.to_glib_full()
|
||||
imp.construct(&from_glib_borrow(url)).to_glib_full()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn factory_create_pipeline<T: RTSPMediaFactoryImpl>(
|
||||
|
@ -288,11 +241,9 @@ unsafe extern "C" fn factory_create_pipeline<T: RTSPMediaFactoryImpl>(
|
|||
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMediaFactory> = from_glib_borrow(ptr);
|
||||
|
||||
let pipeline: *mut gst::ffi::GstPipeline = imp
|
||||
.create_pipeline(wrap.unsafe_cast_ref(), &from_glib_borrow(media))
|
||||
.to_glib_full();
|
||||
let pipeline: *mut gst::ffi::GstPipeline =
|
||||
imp.create_pipeline(&from_glib_borrow(media)).to_glib_full();
|
||||
|
||||
// FIXME We somehow need to ensure the pipeline actually stays alive...
|
||||
glib::gobject_ffi::g_object_set_qdata_full(
|
||||
|
@ -313,9 +264,8 @@ unsafe extern "C" fn factory_configure<T: RTSPMediaFactoryImpl>(
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMediaFactory> = from_glib_borrow(ptr);
|
||||
|
||||
imp.configure(wrap.unsafe_cast_ref(), &from_glib_borrow(media));
|
||||
imp.configure(&from_glib_borrow(media));
|
||||
}
|
||||
|
||||
unsafe extern "C" fn factory_media_constructed<T: RTSPMediaFactoryImpl>(
|
||||
|
@ -324,9 +274,8 @@ unsafe extern "C" fn factory_media_constructed<T: RTSPMediaFactoryImpl>(
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMediaFactory> = from_glib_borrow(ptr);
|
||||
|
||||
imp.media_constructed(wrap.unsafe_cast_ref(), &from_glib_borrow(media));
|
||||
imp.media_constructed(&from_glib_borrow(media));
|
||||
}
|
||||
|
||||
unsafe extern "C" fn factory_media_configure<T: RTSPMediaFactoryImpl>(
|
||||
|
@ -335,7 +284,6 @@ unsafe extern "C" fn factory_media_configure<T: RTSPMediaFactoryImpl>(
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMediaFactory> = from_glib_borrow(ptr);
|
||||
|
||||
imp.media_configure(wrap.unsafe_cast_ref(), &from_glib_borrow(media));
|
||||
imp.media_configure(&from_glib_borrow(media));
|
||||
}
|
||||
|
|
|
@ -8,29 +8,17 @@ use gst_rtsp::ffi::GstRTSPUrl;
|
|||
use crate::RTSPMountPoints;
|
||||
|
||||
pub trait RTSPMountPointsImpl: RTSPMountPointsImplExt + ObjectImpl + Send + Sync {
|
||||
fn make_path(
|
||||
&self,
|
||||
mount_points: &Self::Type,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<glib::GString> {
|
||||
self.parent_make_path(mount_points, url)
|
||||
fn make_path(&self, url: &gst_rtsp::RTSPUrl) -> Option<glib::GString> {
|
||||
self.parent_make_path(url)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RTSPMountPointsImplExt: ObjectSubclass {
|
||||
fn parent_make_path(
|
||||
&self,
|
||||
mount_points: &Self::Type,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<glib::GString>;
|
||||
fn parent_make_path(&self, url: &gst_rtsp::RTSPUrl) -> Option<glib::GString>;
|
||||
}
|
||||
|
||||
impl<T: RTSPMountPointsImpl> RTSPMountPointsImplExt for T {
|
||||
fn parent_make_path(
|
||||
&self,
|
||||
mount_points: &Self::Type,
|
||||
url: &gst_rtsp::RTSPUrl,
|
||||
) -> Option<glib::GString> {
|
||||
fn parent_make_path(&self, url: &gst_rtsp::RTSPUrl) -> Option<glib::GString> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPMountPointsClass;
|
||||
|
@ -38,7 +26,7 @@ impl<T: RTSPMountPointsImpl> RTSPMountPointsImplExt for T {
|
|||
.make_path
|
||||
.expect("No `make_path` virtual method implementation in parent class");
|
||||
from_glib_full(f(
|
||||
mount_points
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPMountPoints>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -62,8 +50,6 @@ unsafe extern "C" fn mount_points_make_path<T: RTSPMountPointsImpl>(
|
|||
) -> *mut std::os::raw::c_char {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPMountPoints> = from_glib_borrow(ptr);
|
||||
|
||||
imp.make_path(wrap.unsafe_cast_ref(), &from_glib_borrow(url))
|
||||
.to_glib_full()
|
||||
imp.make_path(&from_glib_borrow(url)).to_glib_full()
|
||||
}
|
||||
|
|
|
@ -10,17 +10,17 @@ use crate::RTSPOnvifMediaFactory;
|
|||
pub trait RTSPOnvifMediaFactoryImpl:
|
||||
RTSPMediaFactoryImplExt + RTSPMediaFactoryImpl + Send + Sync
|
||||
{
|
||||
fn has_backchannel_support(&self, factory: &Self::Type) -> bool {
|
||||
self.parent_has_backchannel_support(factory)
|
||||
fn has_backchannel_support(&self) -> bool {
|
||||
self.parent_has_backchannel_support()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RTSPOnvifMediaFactoryImplExt: ObjectSubclass {
|
||||
fn parent_has_backchannel_support(&self, factory: &Self::Type) -> bool;
|
||||
fn parent_has_backchannel_support(&self) -> bool;
|
||||
}
|
||||
|
||||
impl<T: RTSPOnvifMediaFactoryImpl> RTSPOnvifMediaFactoryImplExt for T {
|
||||
fn parent_has_backchannel_support(&self, factory: &Self::Type) -> bool {
|
||||
fn parent_has_backchannel_support(&self) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class =
|
||||
|
@ -28,7 +28,8 @@ impl<T: RTSPOnvifMediaFactoryImpl> RTSPOnvifMediaFactoryImplExt for T {
|
|||
(*parent_class)
|
||||
.has_backchannel_support
|
||||
.map(|f| {
|
||||
from_glib(f(factory
|
||||
from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<RTSPOnvifMediaFactory>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -51,8 +52,6 @@ unsafe extern "C" fn factory_has_backchannel_support<T: RTSPOnvifMediaFactoryImp
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPOnvifMediaFactory> = from_glib_borrow(ptr);
|
||||
|
||||
imp.has_backchannel_support(wrap.unsafe_cast_ref())
|
||||
.into_glib()
|
||||
imp.has_backchannel_support().into_glib()
|
||||
}
|
||||
|
|
|
@ -7,40 +7,47 @@ use glib::translate::*;
|
|||
use crate::RTSPServer;
|
||||
|
||||
pub trait RTSPServerImpl: RTSPServerImplExt + ObjectImpl + Send + Sync {
|
||||
fn create_client(&self, server: &Self::Type) -> Option<crate::RTSPClient> {
|
||||
self.parent_create_client(server)
|
||||
fn create_client(&self) -> Option<crate::RTSPClient> {
|
||||
self.parent_create_client()
|
||||
}
|
||||
|
||||
fn client_connected(&self, server: &Self::Type, client: &crate::RTSPClient) {
|
||||
self.parent_client_connected(server, client);
|
||||
fn client_connected(&self, client: &crate::RTSPClient) {
|
||||
self.parent_client_connected(client);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait RTSPServerImplExt: ObjectSubclass {
|
||||
fn parent_create_client(&self, server: &Self::Type) -> Option<crate::RTSPClient>;
|
||||
fn parent_create_client(&self) -> Option<crate::RTSPClient>;
|
||||
|
||||
fn parent_client_connected(&self, server: &Self::Type, client: &crate::RTSPClient);
|
||||
fn parent_client_connected(&self, client: &crate::RTSPClient);
|
||||
}
|
||||
|
||||
impl<T: RTSPServerImpl> RTSPServerImplExt for T {
|
||||
fn parent_create_client(&self, server: &Self::Type) -> Option<crate::RTSPClient> {
|
||||
fn parent_create_client(&self) -> Option<crate::RTSPClient> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPServerClass;
|
||||
let f = (*parent_class)
|
||||
.create_client
|
||||
.expect("No `create_client` virtual method implementation in parent class");
|
||||
from_glib_full(f(server.unsafe_cast_ref::<RTSPServer>().to_glib_none().0))
|
||||
from_glib_full(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<RTSPServer>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_client_connected(&self, server: &Self::Type, client: &crate::RTSPClient) {
|
||||
fn parent_client_connected(&self, client: &crate::RTSPClient) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstRTSPServerClass;
|
||||
if let Some(f) = (*parent_class).client_connected {
|
||||
f(
|
||||
server.unsafe_cast_ref::<RTSPServer>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<RTSPServer>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
client.to_glib_none().0,
|
||||
)
|
||||
}
|
||||
|
@ -61,9 +68,8 @@ unsafe extern "C" fn server_create_client<T: RTSPServerImpl>(
|
|||
) -> *mut ffi::GstRTSPClient {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPServer> = from_glib_borrow(ptr);
|
||||
|
||||
imp.create_client(wrap.unsafe_cast_ref()).to_glib_full()
|
||||
imp.create_client().to_glib_full()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn server_client_connected<T: RTSPServerImpl>(
|
||||
|
@ -72,7 +78,6 @@ unsafe extern "C" fn server_client_connected<T: RTSPServerImpl>(
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<RTSPServer> = from_glib_borrow(ptr);
|
||||
|
||||
imp.client_connected(wrap.unsafe_cast_ref(), &from_glib_borrow(client));
|
||||
imp.client_connected(&from_glib_borrow(client));
|
||||
}
|
||||
|
|
|
@ -8,31 +8,31 @@ use glib::subclass::prelude::*;
|
|||
use crate::Navigation;
|
||||
|
||||
pub trait NavigationImpl: ObjectImpl {
|
||||
fn send_event(&self, nav: &Self::Type, structure: gst::Structure);
|
||||
fn send_event(&self, structure: gst::Structure);
|
||||
|
||||
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
|
||||
fn send_event_simple(&self, nav: &Self::Type, event: gst::Event) {
|
||||
fn send_event_simple(&self, event: gst::Event) {
|
||||
if let Some(structure) = event.structure() {
|
||||
self.send_event(nav, structure.to_owned());
|
||||
self.send_event(structure.to_owned());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait NavigationImplExt: ObjectSubclass {
|
||||
fn parent_send_event(&self, nav: &Self::Type, structure: gst::Structure);
|
||||
fn parent_send_event(&self, structure: gst::Structure);
|
||||
|
||||
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
|
||||
fn parent_send_event_simple(&self, nav: &Self::Type, event: gst::Event) {
|
||||
fn parent_send_event_simple(&self, event: gst::Event) {
|
||||
if let Some(structure) = event.structure() {
|
||||
self.parent_send_event(nav, structure.to_owned());
|
||||
self.parent_send_event(structure.to_owned());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: NavigationImpl> NavigationImplExt for T {
|
||||
fn parent_send_event(&self, nav: &Self::Type, structure: gst::Structure) {
|
||||
fn parent_send_event(&self, structure: gst::Structure) {
|
||||
unsafe {
|
||||
let type_data = Self::type_data();
|
||||
let parent_iface = type_data.as_ref().parent_interface::<Navigation>()
|
||||
|
@ -44,7 +44,10 @@ impl<T: NavigationImpl> NavigationImplExt for T {
|
|||
};
|
||||
|
||||
func(
|
||||
nav.unsafe_cast_ref::<Navigation>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<Navigation>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
structure.into_glib_ptr(),
|
||||
);
|
||||
}
|
||||
|
@ -52,7 +55,7 @@ impl<T: NavigationImpl> NavigationImplExt for T {
|
|||
|
||||
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_22")))]
|
||||
fn parent_send_event_simple(&self, nav: &Self::Type, event: gst::Event) {
|
||||
fn parent_send_event_simple(&self, event: gst::Event) {
|
||||
unsafe {
|
||||
let type_data = Self::type_data();
|
||||
let parent_iface = type_data.as_ref().parent_interface::<Navigation>()
|
||||
|
@ -64,7 +67,10 @@ impl<T: NavigationImpl> NavigationImplExt for T {
|
|||
};
|
||||
|
||||
func(
|
||||
nav.unsafe_cast_ref::<Navigation>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<Navigation>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
event.into_glib_ptr(),
|
||||
);
|
||||
}
|
||||
|
@ -96,10 +102,7 @@ unsafe extern "C" fn navigation_send_event<T: NavigationImpl>(
|
|||
let instance = &*(nav as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
|
||||
imp.send_event(
|
||||
from_glib_borrow::<_, Navigation>(nav).unsafe_cast_ref(),
|
||||
from_glib_full(structure),
|
||||
);
|
||||
imp.send_event(from_glib_full(structure));
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_22", feature = "dox"))]
|
||||
|
@ -111,8 +114,5 @@ unsafe extern "C" fn navigation_send_event_simple<T: NavigationImpl>(
|
|||
let instance = &*(nav as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
|
||||
imp.send_event_simple(
|
||||
from_glib_borrow::<_, Navigation>(nav).unsafe_cast_ref(),
|
||||
from_glib_full(event),
|
||||
);
|
||||
imp.send_event_simple(from_glib_full(event));
|
||||
}
|
||||
|
|
|
@ -13,71 +13,46 @@ use crate::VideoAggregator;
|
|||
pub struct AggregateFramesToken<'a>(pub(crate) &'a VideoAggregator);
|
||||
|
||||
pub trait VideoAggregatorImpl: VideoAggregatorImplExt + AggregatorImpl {
|
||||
fn update_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<gst::Caps, gst::LoggableError> {
|
||||
self.parent_update_caps(element, caps)
|
||||
fn update_caps(&self, caps: &gst::Caps) -> Result<gst::Caps, gst::LoggableError> {
|
||||
self.parent_update_caps(caps)
|
||||
}
|
||||
|
||||
fn aggregate_frames(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
token: &AggregateFramesToken,
|
||||
outbuf: &mut gst::BufferRef,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_aggregate_frames(element, token, outbuf)
|
||||
self.parent_aggregate_frames(token, outbuf)
|
||||
}
|
||||
|
||||
fn create_output_buffer(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
||||
self.parent_create_output_buffer(element)
|
||||
fn create_output_buffer(&self) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
||||
self.parent_create_output_buffer()
|
||||
}
|
||||
|
||||
fn find_best_format(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
downstream_caps: &gst::Caps,
|
||||
) -> Option<(crate::VideoInfo, bool)> {
|
||||
self.parent_find_best_format(element, downstream_caps)
|
||||
fn find_best_format(&self, downstream_caps: &gst::Caps) -> Option<(crate::VideoInfo, bool)> {
|
||||
self.parent_find_best_format(downstream_caps)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait VideoAggregatorImplExt: ObjectSubclass {
|
||||
fn parent_update_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<gst::Caps, gst::LoggableError>;
|
||||
fn parent_update_caps(&self, caps: &gst::Caps) -> Result<gst::Caps, gst::LoggableError>;
|
||||
|
||||
fn parent_aggregate_frames(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
token: &AggregateFramesToken,
|
||||
outbuf: &mut gst::BufferRef,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_create_output_buffer(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
) -> Result<Option<gst::Buffer>, gst::FlowError>;
|
||||
fn parent_create_output_buffer(&self) -> Result<Option<gst::Buffer>, gst::FlowError>;
|
||||
|
||||
fn parent_find_best_format(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
downstream_caps: &gst::Caps,
|
||||
) -> Option<(crate::VideoInfo, bool)>;
|
||||
}
|
||||
|
||||
impl<T: VideoAggregatorImpl> VideoAggregatorImplExt for T {
|
||||
fn parent_update_caps(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
caps: &gst::Caps,
|
||||
) -> Result<gst::Caps, gst::LoggableError> {
|
||||
fn parent_update_caps(&self, caps: &gst::Caps) -> Result<gst::Caps, gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoAggregatorClass;
|
||||
|
@ -86,7 +61,7 @@ impl<T: VideoAggregatorImpl> VideoAggregatorImplExt for T {
|
|||
.expect("Missing parent function `update_caps`");
|
||||
|
||||
Option::<_>::from_glib_full(f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoAggregator>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -100,12 +75,11 @@ impl<T: VideoAggregatorImpl> VideoAggregatorImplExt for T {
|
|||
|
||||
fn parent_aggregate_frames(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
token: &AggregateFramesToken,
|
||||
outbuf: &mut gst::BufferRef,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
assert_eq!(
|
||||
element.as_ptr() as *mut ffi::GstVideoAggregator,
|
||||
self.instance().as_ptr() as *mut ffi::GstVideoAggregator,
|
||||
token.0.as_ptr() as *mut ffi::GstVideoAggregator
|
||||
);
|
||||
|
||||
|
@ -117,7 +91,7 @@ impl<T: VideoAggregatorImpl> VideoAggregatorImplExt for T {
|
|||
.expect("Missing parent function `aggregate_frames`");
|
||||
|
||||
try_from_glib(f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoAggregator>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -127,10 +101,7 @@ impl<T: VideoAggregatorImpl> VideoAggregatorImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_create_output_buffer(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
||||
fn parent_create_output_buffer(&self) -> Result<Option<gst::Buffer>, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoAggregatorClass;
|
||||
|
@ -140,7 +111,7 @@ impl<T: VideoAggregatorImpl> VideoAggregatorImplExt for T {
|
|||
|
||||
let mut buffer = ptr::null_mut();
|
||||
try_from_glib(f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoAggregator>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -152,7 +123,6 @@ impl<T: VideoAggregatorImpl> VideoAggregatorImplExt for T {
|
|||
|
||||
fn parent_find_best_format(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
downstream_caps: &gst::Caps,
|
||||
) -> Option<(crate::VideoInfo, bool)> {
|
||||
unsafe {
|
||||
|
@ -166,7 +136,7 @@ impl<T: VideoAggregatorImpl> VideoAggregatorImplExt for T {
|
|||
let mut at_least_one_alpha = glib::ffi::GFALSE;
|
||||
|
||||
f(
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoAggregator>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -206,13 +176,12 @@ unsafe extern "C" fn video_aggregator_update_caps<T: VideoAggregatorImpl>(
|
|||
) -> *mut gst::ffi::GstCaps {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoAggregator> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), ptr::null_mut(), {
|
||||
match imp.update_caps(wrap.unsafe_cast_ref(), &from_glib_borrow(caps)) {
|
||||
gst::panic_to_error!(imp, ptr::null_mut(), {
|
||||
match imp.update_caps(&from_glib_borrow(caps)) {
|
||||
Ok(caps) => caps.into_glib_ptr(),
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
ptr::null_mut()
|
||||
}
|
||||
}
|
||||
|
@ -225,13 +194,13 @@ unsafe extern "C" fn video_aggregator_aggregate_frames<T: VideoAggregatorImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoAggregator> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
let token = AggregateFramesToken(&*wrap);
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
let instance = imp.instance();
|
||||
let instance = instance.unsafe_cast_ref::<VideoAggregator>();
|
||||
let token = AggregateFramesToken(instance);
|
||||
|
||||
imp.aggregate_frames(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&token,
|
||||
gst::BufferRef::from_mut_ptr(
|
||||
// Wrong pointer type
|
||||
|
@ -249,10 +218,9 @@ unsafe extern "C" fn video_aggregator_create_output_buffer<T: VideoAggregatorImp
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoAggregator> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
match imp.create_output_buffer(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
match imp.create_output_buffer() {
|
||||
Ok(buffer) => {
|
||||
*outbuf = buffer.map(|b| b.into_glib_ptr()).unwrap_or(ptr::null_mut());
|
||||
Ok(gst::FlowSuccess::Ok)
|
||||
|
@ -275,10 +243,9 @@ unsafe extern "C" fn video_aggregator_find_best_format<T: VideoAggregatorImpl>(
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoAggregator> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), (), {
|
||||
match imp.find_best_format(wrap.unsafe_cast_ref(), &from_glib_borrow(downstream_caps)) {
|
||||
gst::panic_to_error!(imp, (), {
|
||||
match imp.find_best_format(&from_glib_borrow(downstream_caps)) {
|
||||
None => (),
|
||||
Some((info, alpha)) => {
|
||||
*best_info = *info.to_glib_none().0;
|
||||
|
|
|
@ -13,37 +13,34 @@ use crate::VideoAggregator;
|
|||
use crate::VideoAggregatorPad;
|
||||
|
||||
pub trait VideoAggregatorPadImpl: VideoAggregatorPadImplExt + AggregatorPadImpl {
|
||||
fn update_conversion_info(&self, pad: &Self::Type) {
|
||||
self.parent_update_conversion_info(pad)
|
||||
fn update_conversion_info(&self) {
|
||||
self.parent_update_conversion_info()
|
||||
}
|
||||
|
||||
fn prepare_frame(
|
||||
&self,
|
||||
pad: &Self::Type,
|
||||
aggregator: &crate::VideoAggregator,
|
||||
token: &AggregateFramesToken,
|
||||
buffer: &gst::Buffer,
|
||||
) -> Option<crate::VideoFrame<crate::video_frame::Readable>> {
|
||||
self.parent_prepare_frame(pad, aggregator, token, buffer)
|
||||
self.parent_prepare_frame(aggregator, token, buffer)
|
||||
}
|
||||
|
||||
fn clean_frame(
|
||||
&self,
|
||||
pad: &Self::Type,
|
||||
aggregator: &crate::VideoAggregator,
|
||||
token: &AggregateFramesToken,
|
||||
frame: Option<crate::VideoFrame<crate::video_frame::Readable>>,
|
||||
) {
|
||||
self.parent_clean_frame(pad, aggregator, token, frame)
|
||||
self.parent_clean_frame(aggregator, token, frame)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait VideoAggregatorPadImplExt: ObjectSubclass {
|
||||
fn parent_update_conversion_info(&self, pad: &Self::Type);
|
||||
fn parent_update_conversion_info(&self);
|
||||
|
||||
fn parent_prepare_frame(
|
||||
&self,
|
||||
pad: &Self::Type,
|
||||
aggregator: &crate::VideoAggregator,
|
||||
token: &AggregateFramesToken,
|
||||
buffer: &gst::Buffer,
|
||||
|
@ -51,7 +48,6 @@ pub trait VideoAggregatorPadImplExt: ObjectSubclass {
|
|||
|
||||
fn parent_clean_frame(
|
||||
&self,
|
||||
pad: &Self::Type,
|
||||
aggregator: &crate::VideoAggregator,
|
||||
token: &AggregateFramesToken,
|
||||
frame: Option<crate::VideoFrame<crate::video_frame::Readable>>,
|
||||
|
@ -59,19 +55,22 @@ pub trait VideoAggregatorPadImplExt: ObjectSubclass {
|
|||
}
|
||||
|
||||
impl<T: VideoAggregatorPadImpl> VideoAggregatorPadImplExt for T {
|
||||
fn parent_update_conversion_info(&self, pad: &Self::Type) {
|
||||
fn parent_update_conversion_info(&self) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoAggregatorPadClass;
|
||||
if let Some(f) = (*parent_class).update_conversion_info {
|
||||
f(pad.unsafe_cast_ref::<VideoAggregatorPad>().to_glib_none().0);
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<VideoAggregatorPad>()
|
||||
.to_glib_none()
|
||||
.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_prepare_frame(
|
||||
&self,
|
||||
pad: &Self::Type,
|
||||
aggregator: &crate::VideoAggregator,
|
||||
token: &AggregateFramesToken,
|
||||
buffer: &gst::Buffer,
|
||||
|
@ -88,7 +87,10 @@ impl<T: VideoAggregatorPadImpl> VideoAggregatorPadImplExt for T {
|
|||
let mut prepared_frame = mem::MaybeUninit::zeroed();
|
||||
|
||||
f(
|
||||
pad.unsafe_cast_ref::<VideoAggregatorPad>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoAggregatorPad>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
aggregator.to_glib_none().0,
|
||||
buffer.as_mut_ptr(),
|
||||
prepared_frame.as_mut_ptr(),
|
||||
|
@ -108,7 +110,6 @@ impl<T: VideoAggregatorPadImpl> VideoAggregatorPadImplExt for T {
|
|||
|
||||
fn parent_clean_frame(
|
||||
&self,
|
||||
pad: &Self::Type,
|
||||
aggregator: &crate::VideoAggregator,
|
||||
token: &AggregateFramesToken,
|
||||
frame: Option<crate::VideoFrame<crate::video_frame::Readable>>,
|
||||
|
@ -129,7 +130,10 @@ impl<T: VideoAggregatorPadImpl> VideoAggregatorPadImplExt for T {
|
|||
};
|
||||
|
||||
f(
|
||||
pad.unsafe_cast_ref::<VideoAggregatorPad>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoAggregatorPad>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
aggregator.to_glib_none().0,
|
||||
&mut prepared_frame,
|
||||
);
|
||||
|
@ -154,9 +158,8 @@ unsafe extern "C" fn video_aggregator_pad_update_conversion_info<T: VideoAggrega
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoAggregatorPad> = from_glib_borrow(ptr);
|
||||
|
||||
imp.update_conversion_info(wrap.unsafe_cast_ref());
|
||||
imp.update_conversion_info();
|
||||
}
|
||||
|
||||
unsafe extern "C" fn video_aggregator_pad_prepare_frame<T: VideoAggregatorPadImpl>(
|
||||
|
@ -167,17 +170,11 @@ unsafe extern "C" fn video_aggregator_pad_prepare_frame<T: VideoAggregatorPadImp
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoAggregatorPad> = from_glib_borrow(ptr);
|
||||
let aggregator: Borrowed<VideoAggregator> = from_glib_borrow(aggregator);
|
||||
|
||||
let token = AggregateFramesToken(&*aggregator);
|
||||
|
||||
match imp.prepare_frame(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&aggregator,
|
||||
&token,
|
||||
&from_glib_borrow(buffer),
|
||||
) {
|
||||
match imp.prepare_frame(&aggregator, &token, &from_glib_borrow(buffer)) {
|
||||
Some(frame) => {
|
||||
*prepared_frame = frame.into_raw();
|
||||
}
|
||||
|
@ -196,7 +193,6 @@ unsafe extern "C" fn video_aggregator_pad_clean_frame<T: VideoAggregatorPadImpl>
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoAggregatorPad> = from_glib_borrow(ptr);
|
||||
let aggregator: Borrowed<VideoAggregator> = from_glib_borrow(aggregator);
|
||||
|
||||
let token = AggregateFramesToken(&*aggregator);
|
||||
|
@ -209,5 +205,5 @@ unsafe extern "C" fn video_aggregator_pad_clean_frame<T: VideoAggregatorPadImpl>
|
|||
Some(frame)
|
||||
};
|
||||
|
||||
imp.clean_frame(wrap.unsafe_cast_ref(), &aggregator, &token, frame);
|
||||
imp.clean_frame(&aggregator, &token, frame);
|
||||
}
|
||||
|
|
|
@ -10,134 +10,123 @@ use crate::VideoCodecFrame;
|
|||
use crate::VideoDecoder;
|
||||
|
||||
pub trait VideoDecoderImpl: VideoDecoderImplExt + ElementImpl {
|
||||
fn open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_open(element)
|
||||
fn open(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_open()
|
||||
}
|
||||
|
||||
fn close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_close(element)
|
||||
fn close(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_close()
|
||||
}
|
||||
|
||||
fn start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_start(element)
|
||||
fn start(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_start()
|
||||
}
|
||||
|
||||
fn stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_stop(element)
|
||||
fn stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_stop()
|
||||
}
|
||||
|
||||
fn finish(&self, element: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_finish(element)
|
||||
fn finish(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_finish()
|
||||
}
|
||||
|
||||
fn drain(&self, element: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_drain(element)
|
||||
fn drain(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_drain()
|
||||
}
|
||||
|
||||
fn set_format(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
state: &VideoCodecState<'static, Readable>,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_format(element, state)
|
||||
self.parent_set_format(state)
|
||||
}
|
||||
|
||||
fn parse(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
frame: &VideoCodecFrame,
|
||||
adapter: &gst_base::Adapter,
|
||||
at_eos: bool,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_parse(element, frame, adapter, at_eos)
|
||||
self.parent_parse(frame, adapter, at_eos)
|
||||
}
|
||||
|
||||
fn handle_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
frame: VideoCodecFrame,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_handle_frame(element, frame)
|
||||
fn handle_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_handle_frame(frame)
|
||||
}
|
||||
|
||||
fn flush(&self, element: &Self::Type) -> bool {
|
||||
self.parent_flush(element)
|
||||
fn flush(&self) -> bool {
|
||||
self.parent_flush()
|
||||
}
|
||||
|
||||
fn negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
self.parent_negotiate(element)
|
||||
fn negotiate(&self) -> Result<(), gst::LoggableError> {
|
||||
self.parent_negotiate()
|
||||
}
|
||||
|
||||
fn caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
self.parent_caps(element, filter)
|
||||
fn caps(&self, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
self.parent_caps(filter)
|
||||
}
|
||||
|
||||
fn sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
self.parent_sink_event(element, event)
|
||||
fn sink_event(&self, event: gst::Event) -> bool {
|
||||
self.parent_sink_event(event)
|
||||
}
|
||||
|
||||
fn sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
self.parent_sink_query(element, query)
|
||||
fn sink_query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
self.parent_sink_query(query)
|
||||
}
|
||||
|
||||
fn src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
self.parent_src_event(element, event)
|
||||
fn src_event(&self, event: gst::Event) -> bool {
|
||||
self.parent_src_event(event)
|
||||
}
|
||||
|
||||
fn src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
self.parent_src_query(element, query)
|
||||
fn src_query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
self.parent_src_query(query)
|
||||
}
|
||||
|
||||
fn propose_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_propose_allocation(element, query)
|
||||
self.parent_propose_allocation(query)
|
||||
}
|
||||
|
||||
fn decide_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_decide_allocation(element, query)
|
||||
self.parent_decide_allocation(query)
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_20", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
|
||||
fn handle_missing_data(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
timestamp: gst::ClockTime,
|
||||
duration: Option<gst::ClockTime>,
|
||||
) -> bool {
|
||||
self.parent_handle_missing_data(element, timestamp, duration)
|
||||
self.parent_handle_missing_data(timestamp, duration)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait VideoDecoderImplExt: ObjectSubclass {
|
||||
fn parent_open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_open(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_close(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_start(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_stop(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_finish(&self, element: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
fn parent_finish(&self) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_drain(&self, element: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
fn parent_drain(&self) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_set_format(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
state: &VideoCodecState<'static, Readable>,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_parse(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
frame: &VideoCodecFrame,
|
||||
adapter: &gst_base::Adapter,
|
||||
at_eos: bool,
|
||||
|
@ -145,33 +134,30 @@ pub trait VideoDecoderImplExt: ObjectSubclass {
|
|||
|
||||
fn parent_handle_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
frame: VideoCodecFrame,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_flush(&self, element: &Self::Type) -> bool;
|
||||
fn parent_flush(&self) -> bool;
|
||||
|
||||
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError>;
|
||||
fn parent_negotiate(&self) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps;
|
||||
fn parent_caps(&self, filter: Option<&gst::Caps>) -> gst::Caps;
|
||||
|
||||
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||
fn parent_sink_event(&self, event: gst::Event) -> bool;
|
||||
|
||||
fn parent_sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool;
|
||||
fn parent_sink_query(&self, query: &mut gst::QueryRef) -> bool;
|
||||
|
||||
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||
fn parent_src_event(&self, event: gst::Event) -> bool;
|
||||
|
||||
fn parent_src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool;
|
||||
fn parent_src_query(&self, query: &mut gst::QueryRef) -> bool;
|
||||
|
||||
fn parent_propose_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_decide_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
|
||||
|
@ -179,21 +165,21 @@ pub trait VideoDecoderImplExt: ObjectSubclass {
|
|||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
|
||||
fn parent_handle_missing_data(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
timestamp: gst::ClockTime,
|
||||
duration: Option<gst::ClockTime>,
|
||||
) -> bool;
|
||||
}
|
||||
|
||||
impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
||||
fn parent_open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_open(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoDecoderClass;
|
||||
(*parent_class)
|
||||
.open
|
||||
.map(|f| {
|
||||
if from_glib(f(element
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -210,14 +196,15 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_close(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoDecoderClass;
|
||||
(*parent_class)
|
||||
.close
|
||||
.map(|f| {
|
||||
if from_glib(f(element
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -234,14 +221,15 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_start(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoDecoderClass;
|
||||
(*parent_class)
|
||||
.start
|
||||
.map(|f| {
|
||||
if from_glib(f(element
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -258,14 +246,15 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoDecoderClass;
|
||||
(*parent_class)
|
||||
.stop
|
||||
.map(|f| {
|
||||
if from_glib(f(element
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -282,14 +271,15 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_finish(&self, element: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
fn parent_finish(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoDecoderClass;
|
||||
(*parent_class)
|
||||
.finish
|
||||
.map(|f| {
|
||||
try_from_glib(f(element
|
||||
try_from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -298,14 +288,15 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_drain(&self, element: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
fn parent_drain(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoDecoderClass;
|
||||
(*parent_class)
|
||||
.drain
|
||||
.map(|f| {
|
||||
try_from_glib(f(element
|
||||
try_from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -316,7 +307,6 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
|
||||
fn parent_set_format(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
state: &VideoCodecState<'static, Readable>,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
|
@ -327,7 +317,10 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
state.as_mut_ptr()
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -340,7 +333,6 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
|
||||
fn parent_parse(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
frame: &VideoCodecFrame,
|
||||
adapter: &gst_base::Adapter,
|
||||
at_eos: bool,
|
||||
|
@ -352,7 +344,10 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
.parse
|
||||
.map(|f| {
|
||||
try_from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
frame.to_glib_none().0,
|
||||
adapter.to_glib_none().0,
|
||||
at_eos.into_glib(),
|
||||
|
@ -364,7 +359,6 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
|
||||
fn parent_handle_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
frame: VideoCodecFrame,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
|
@ -374,7 +368,10 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
.handle_frame
|
||||
.map(|f| {
|
||||
try_from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
frame.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
|
@ -382,14 +379,15 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_flush(&self, element: &Self::Type) -> bool {
|
||||
fn parent_flush(&self) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoDecoderClass;
|
||||
(*parent_class)
|
||||
.flush
|
||||
.map(|f| {
|
||||
from_glib(f(element
|
||||
from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -398,7 +396,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
fn parent_negotiate(&self) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoDecoderClass;
|
||||
|
@ -406,7 +404,11 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
.negotiate
|
||||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0),
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `negotiate` failed"
|
||||
)
|
||||
|
@ -415,7 +417,7 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
fn parent_caps(&self, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoDecoderClass;
|
||||
|
@ -423,19 +425,22 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
.getcaps
|
||||
.map(|f| {
|
||||
from_glib_full(f(
|
||||
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
filter.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.proxy_getcaps(None, filter)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
fn parent_sink_event(&self, event: gst::Event) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoDecoderClass;
|
||||
|
@ -443,13 +448,16 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
.sink_event
|
||||
.expect("Missing parent function `sink_event`");
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
event.into_glib_ptr(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
fn parent_sink_query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoDecoderClass;
|
||||
|
@ -457,13 +465,16 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
.sink_query
|
||||
.expect("Missing parent function `sink_query`");
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
fn parent_src_event(&self, event: gst::Event) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoDecoderClass;
|
||||
|
@ -471,13 +482,16 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
.src_event
|
||||
.expect("Missing parent function `src_event`");
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
event.into_glib_ptr(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
fn parent_src_query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoDecoderClass;
|
||||
|
@ -485,7 +499,10 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
.src_query
|
||||
.expect("Missing parent function `src_query`");
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
))
|
||||
}
|
||||
|
@ -493,7 +510,6 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
|
||||
fn parent_propose_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
|
@ -504,7 +520,10 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -517,7 +536,6 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
|
||||
fn parent_decide_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
|
@ -528,7 +546,10 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -543,7 +564,6 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_20")))]
|
||||
fn parent_handle_missing_data(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
timestamp: gst::ClockTime,
|
||||
duration: Option<gst::ClockTime>,
|
||||
) -> bool {
|
||||
|
@ -554,7 +574,10 @@ impl<T: VideoDecoderImpl> VideoDecoderImplExt for T {
|
|||
.handle_missing_data
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoDecoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoDecoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
timestamp.into_glib(),
|
||||
duration.into_glib(),
|
||||
))
|
||||
|
@ -598,13 +621,12 @@ unsafe extern "C" fn video_decoder_open<T: VideoDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.open(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.open() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -617,13 +639,12 @@ unsafe extern "C" fn video_decoder_close<T: VideoDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.close(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.close() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -636,13 +657,12 @@ unsafe extern "C" fn video_decoder_start<T: VideoDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.start(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.start() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -655,13 +675,12 @@ unsafe extern "C" fn video_decoder_stop<T: VideoDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.stop(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.stop() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -674,12 +693,8 @@ unsafe extern "C" fn video_decoder_finish<T: VideoDecoderImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
imp.finish(wrap.unsafe_cast_ref()).into()
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, { imp.finish().into() }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn video_decoder_drain<T: VideoDecoderImpl>(
|
||||
|
@ -687,12 +702,8 @@ unsafe extern "C" fn video_decoder_drain<T: VideoDecoderImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
imp.drain(wrap.unsafe_cast_ref()).into()
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, { imp.drain().into() }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn video_decoder_set_format<T: VideoDecoderImpl>(
|
||||
|
@ -701,15 +712,14 @@ unsafe extern "C" fn video_decoder_set_format<T: VideoDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
ffi::gst_video_codec_state_ref(state);
|
||||
let wrap_state = VideoCodecState::<Readable>::new(state);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.set_format(wrap.unsafe_cast_ref(), &wrap_state) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.set_format(&wrap_state) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -725,15 +735,15 @@ unsafe extern "C" fn video_decoder_parse<T: VideoDecoderImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
ffi::gst_video_codec_frame_ref(frame);
|
||||
let wrap_frame = VideoCodecFrame::new(frame, &*wrap);
|
||||
let instance = imp.instance();
|
||||
let instance = instance.unsafe_cast_ref::<VideoDecoder>();
|
||||
let wrap_frame = VideoCodecFrame::new(frame, instance);
|
||||
let wrap_adapter: Borrowed<gst_base::Adapter> = from_glib_borrow(adapter);
|
||||
let at_eos: bool = from_glib(at_eos);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
imp.parse(wrap.unsafe_cast_ref(), &wrap_frame, &wrap_adapter, at_eos)
|
||||
.into()
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
imp.parse(&wrap_frame, &wrap_adapter, at_eos).into()
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -744,11 +754,12 @@ unsafe extern "C" fn video_decoder_handle_frame<T: VideoDecoderImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
let wrap_frame = VideoCodecFrame::new(frame, &*wrap);
|
||||
let instance = imp.instance();
|
||||
let instance = instance.unsafe_cast_ref::<VideoDecoder>();
|
||||
let wrap_frame = VideoCodecFrame::new(frame, instance);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
imp.handle_frame(wrap.unsafe_cast_ref(), wrap_frame).into()
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
imp.handle_frame(wrap_frame).into()
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -758,12 +769,8 @@ unsafe extern "C" fn video_decoder_flush<T: VideoDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
VideoDecoderImpl::flush(imp, wrap.unsafe_cast_ref())
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, false, { VideoDecoderImpl::flush(imp) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn video_decoder_negotiate<T: VideoDecoderImpl>(
|
||||
|
@ -771,13 +778,12 @@ unsafe extern "C" fn video_decoder_negotiate<T: VideoDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.negotiate(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.negotiate() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -791,12 +797,10 @@ unsafe extern "C" fn video_decoder_getcaps<T: VideoDecoderImpl>(
|
|||
) -> *mut gst::ffi::GstCaps {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::Caps::new_empty(), {
|
||||
gst::panic_to_error!(imp, gst::Caps::new_empty(), {
|
||||
VideoDecoderImpl::caps(
|
||||
imp,
|
||||
wrap.unsafe_cast_ref(),
|
||||
Option::<gst::Caps>::from_glib_borrow(filter)
|
||||
.as_ref()
|
||||
.as_ref(),
|
||||
|
@ -811,12 +815,8 @@ unsafe extern "C" fn video_decoder_sink_event<T: VideoDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.sink_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, false, { imp.sink_event(from_glib_full(event)) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn video_decoder_sink_query<T: VideoDecoderImpl>(
|
||||
|
@ -825,10 +825,9 @@ unsafe extern "C" fn video_decoder_sink_query<T: VideoDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.sink_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||
gst::panic_to_error!(imp, false, {
|
||||
imp.sink_query(gst::QueryRef::from_mut_ptr(query))
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -839,12 +838,8 @@ unsafe extern "C" fn video_decoder_src_event<T: VideoDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, false, { imp.src_event(from_glib_full(event)) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn video_decoder_src_query<T: VideoDecoderImpl>(
|
||||
|
@ -853,10 +848,9 @@ unsafe extern "C" fn video_decoder_src_query<T: VideoDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.src_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||
gst::panic_to_error!(imp, false, {
|
||||
imp.src_query(gst::QueryRef::from_mut_ptr(query))
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -867,17 +861,16 @@ unsafe extern "C" fn video_decoder_propose_allocation<T: VideoDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
|
||||
gst::QueryViewMut::Allocation(allocation) => allocation,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.propose_allocation(wrap.unsafe_cast_ref(), query) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.propose_allocation(query) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -891,17 +884,16 @@ unsafe extern "C" fn video_decoder_decide_allocation<T: VideoDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
|
||||
gst::QueryViewMut::Allocation(allocation) => allocation,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.decide_allocation(query) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -917,11 +909,9 @@ unsafe extern "C" fn video_decoder_handle_missing_data<T: VideoDecoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoDecoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), true, {
|
||||
gst::panic_to_error!(imp, true, {
|
||||
imp.handle_missing_data(
|
||||
wrap.unsafe_cast_ref(),
|
||||
Option::<gst::ClockTime>::from_glib(timestamp).unwrap(),
|
||||
from_glib(duration),
|
||||
)
|
||||
|
|
|
@ -10,146 +10,136 @@ use crate::VideoCodecFrame;
|
|||
use crate::VideoEncoder;
|
||||
|
||||
pub trait VideoEncoderImpl: VideoEncoderImplExt + ElementImpl {
|
||||
fn open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_open(element)
|
||||
fn open(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_open()
|
||||
}
|
||||
|
||||
fn close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_close(element)
|
||||
fn close(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_close()
|
||||
}
|
||||
|
||||
fn start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_start(element)
|
||||
fn start(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_start()
|
||||
}
|
||||
|
||||
fn stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_stop(element)
|
||||
fn stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
self.parent_stop()
|
||||
}
|
||||
|
||||
fn finish(&self, element: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_finish(element)
|
||||
fn finish(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_finish()
|
||||
}
|
||||
|
||||
fn set_format(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
state: &VideoCodecState<'static, Readable>,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_format(element, state)
|
||||
self.parent_set_format(state)
|
||||
}
|
||||
|
||||
fn handle_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
frame: VideoCodecFrame,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_handle_frame(element, frame)
|
||||
fn handle_frame(&self, frame: VideoCodecFrame) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_handle_frame(frame)
|
||||
}
|
||||
|
||||
fn flush(&self, element: &Self::Type) -> bool {
|
||||
self.parent_flush(element)
|
||||
fn flush(&self) -> bool {
|
||||
self.parent_flush()
|
||||
}
|
||||
|
||||
fn negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
self.parent_negotiate(element)
|
||||
fn negotiate(&self) -> Result<(), gst::LoggableError> {
|
||||
self.parent_negotiate()
|
||||
}
|
||||
|
||||
fn caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
self.parent_caps(element, filter)
|
||||
fn caps(&self, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
self.parent_caps(filter)
|
||||
}
|
||||
|
||||
fn sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
self.parent_sink_event(element, event)
|
||||
fn sink_event(&self, event: gst::Event) -> bool {
|
||||
self.parent_sink_event(event)
|
||||
}
|
||||
|
||||
fn sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
self.parent_sink_query(element, query)
|
||||
fn sink_query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
self.parent_sink_query(query)
|
||||
}
|
||||
|
||||
fn src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
self.parent_src_event(element, event)
|
||||
fn src_event(&self, event: gst::Event) -> bool {
|
||||
self.parent_src_event(event)
|
||||
}
|
||||
|
||||
fn src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
self.parent_src_query(element, query)
|
||||
fn src_query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
self.parent_src_query(query)
|
||||
}
|
||||
|
||||
fn propose_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_propose_allocation(element, query)
|
||||
self.parent_propose_allocation(query)
|
||||
}
|
||||
|
||||
fn decide_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_decide_allocation(element, query)
|
||||
self.parent_decide_allocation(query)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait VideoEncoderImplExt: ObjectSubclass {
|
||||
fn parent_open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_open(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_close(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_start(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage>;
|
||||
fn parent_stop(&self) -> Result<(), gst::ErrorMessage>;
|
||||
|
||||
fn parent_finish(&self, element: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
fn parent_finish(&self) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_set_format(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
state: &VideoCodecState<'static, Readable>,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_handle_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
frame: VideoCodecFrame,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_flush(&self, element: &Self::Type) -> bool;
|
||||
fn parent_flush(&self) -> bool;
|
||||
|
||||
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError>;
|
||||
fn parent_negotiate(&self) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps;
|
||||
fn parent_caps(&self, filter: Option<&gst::Caps>) -> gst::Caps;
|
||||
|
||||
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||
fn parent_sink_event(&self, event: gst::Event) -> bool;
|
||||
|
||||
fn parent_sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool;
|
||||
fn parent_sink_query(&self, query: &mut gst::QueryRef) -> bool;
|
||||
|
||||
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool;
|
||||
fn parent_src_event(&self, event: gst::Event) -> bool;
|
||||
|
||||
fn parent_src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool;
|
||||
fn parent_src_query(&self, query: &mut gst::QueryRef) -> bool;
|
||||
|
||||
fn parent_propose_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
|
||||
fn parent_decide_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError>;
|
||||
}
|
||||
|
||||
impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
||||
fn parent_open(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_open(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoEncoderClass;
|
||||
(*parent_class)
|
||||
.open
|
||||
.map(|f| {
|
||||
if from_glib(f(element
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<VideoEncoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -166,14 +156,15 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_close(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_close(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoEncoderClass;
|
||||
(*parent_class)
|
||||
.close
|
||||
.map(|f| {
|
||||
if from_glib(f(element
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<VideoEncoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -190,14 +181,15 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_start(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_start(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoEncoderClass;
|
||||
(*parent_class)
|
||||
.start
|
||||
.map(|f| {
|
||||
if from_glib(f(element
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<VideoEncoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -214,14 +206,15 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_stop(&self, element: &Self::Type) -> Result<(), gst::ErrorMessage> {
|
||||
fn parent_stop(&self) -> Result<(), gst::ErrorMessage> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoEncoderClass;
|
||||
(*parent_class)
|
||||
.stop
|
||||
.map(|f| {
|
||||
if from_glib(f(element
|
||||
if from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<VideoEncoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -238,14 +231,15 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_finish(&self, element: &Self::Type) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
fn parent_finish(&self) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoEncoderClass;
|
||||
(*parent_class)
|
||||
.finish
|
||||
.map(|f| {
|
||||
try_from_glib(f(element
|
||||
try_from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<VideoEncoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -256,7 +250,6 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
|
||||
fn parent_set_format(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
state: &VideoCodecState<'static, Readable>,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
|
@ -267,7 +260,10 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoEncoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
state.as_mut_ptr()
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -280,7 +276,6 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
|
||||
fn parent_handle_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
frame: VideoCodecFrame,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
|
@ -290,7 +285,10 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
.handle_frame
|
||||
.map(|f| {
|
||||
try_from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoEncoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
frame.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
|
@ -298,14 +296,15 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_flush(&self, element: &Self::Type) -> bool {
|
||||
fn parent_flush(&self) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoEncoderClass;
|
||||
(*parent_class)
|
||||
.flush
|
||||
.map(|f| {
|
||||
from_glib(f(element
|
||||
from_glib(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<VideoEncoder>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -314,7 +313,7 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_negotiate(&self, element: &Self::Type) -> Result<(), gst::LoggableError> {
|
||||
fn parent_negotiate(&self) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoEncoderClass;
|
||||
|
@ -322,7 +321,11 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
.negotiate
|
||||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0),
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<VideoEncoder>()
|
||||
.to_glib_none()
|
||||
.0),
|
||||
gst::CAT_RUST,
|
||||
"Parent function `negotiate` failed"
|
||||
)
|
||||
|
@ -331,7 +334,7 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_caps(&self, element: &Self::Type, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
fn parent_caps(&self, filter: Option<&gst::Caps>) -> gst::Caps {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoEncoderClass;
|
||||
|
@ -339,19 +342,22 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
.getcaps
|
||||
.map(|f| {
|
||||
from_glib_full(f(
|
||||
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoEncoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
filter.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
element
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoEncoder>()
|
||||
.proxy_getcaps(None, filter)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_sink_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
fn parent_sink_event(&self, event: gst::Event) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoEncoderClass;
|
||||
|
@ -359,13 +365,16 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
.sink_event
|
||||
.expect("Missing parent function `sink_event`");
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoEncoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
event.into_glib_ptr(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_sink_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
fn parent_sink_query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoEncoderClass;
|
||||
|
@ -373,13 +382,16 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
.sink_query
|
||||
.expect("Missing parent function `sink_query`");
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoEncoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_src_event(&self, element: &Self::Type, event: gst::Event) -> bool {
|
||||
fn parent_src_event(&self, event: gst::Event) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoEncoderClass;
|
||||
|
@ -387,13 +399,16 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
.src_event
|
||||
.expect("Missing parent function `src_event`");
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoEncoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
event.into_glib_ptr(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_src_query(&self, element: &Self::Type, query: &mut gst::QueryRef) -> bool {
|
||||
fn parent_src_query(&self, query: &mut gst::QueryRef) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoEncoderClass;
|
||||
|
@ -401,7 +416,10 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
.src_query
|
||||
.expect("Missing parent function `src_query`");
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoEncoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
))
|
||||
}
|
||||
|
@ -409,7 +427,6 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
|
||||
fn parent_propose_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
|
@ -420,7 +437,10 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoEncoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -433,7 +453,6 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
|
||||
fn parent_decide_allocation(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
query: &mut gst::query::Allocation,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
unsafe {
|
||||
|
@ -444,7 +463,10 @@ impl<T: VideoEncoderImpl> VideoEncoderImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<VideoEncoder>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoEncoder>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
),
|
||||
gst::CAT_RUST,
|
||||
|
@ -484,13 +506,12 @@ unsafe extern "C" fn video_encoder_open<T: VideoEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.open(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.open() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -503,13 +524,12 @@ unsafe extern "C" fn video_encoder_close<T: VideoEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.close(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.close() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -522,13 +542,12 @@ unsafe extern "C" fn video_encoder_start<T: VideoEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.start(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.start() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -541,13 +560,12 @@ unsafe extern "C" fn video_encoder_stop<T: VideoEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.stop(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.stop() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
wrap.post_error_message(err);
|
||||
imp.post_error_message(err);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -560,12 +578,8 @@ unsafe extern "C" fn video_encoder_finish<T: VideoEncoderImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
imp.finish(wrap.unsafe_cast_ref()).into()
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, { imp.finish().into() }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn video_encoder_set_format<T: VideoEncoderImpl>(
|
||||
|
@ -574,15 +588,14 @@ unsafe extern "C" fn video_encoder_set_format<T: VideoEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||
ffi::gst_video_codec_state_ref(state);
|
||||
let wrap_state = VideoCodecState::<Readable>::new(state);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.set_format(wrap.unsafe_cast_ref(), &wrap_state) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.set_format(&wrap_state) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -596,11 +609,12 @@ unsafe extern "C" fn video_encoder_handle_frame<T: VideoEncoderImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||
let wrap_frame = VideoCodecFrame::new(frame, &*wrap);
|
||||
let instance = imp.instance();
|
||||
let instance = instance.unsafe_cast_ref::<VideoEncoder>();
|
||||
let wrap_frame = VideoCodecFrame::new(frame, instance);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
imp.handle_frame(wrap.unsafe_cast_ref(), wrap_frame).into()
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
imp.handle_frame(wrap_frame).into()
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -610,12 +624,8 @@ unsafe extern "C" fn video_encoder_flush<T: VideoEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
VideoEncoderImpl::flush(imp, wrap.unsafe_cast_ref())
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, false, { VideoEncoderImpl::flush(imp) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn video_encoder_negotiate<T: VideoEncoderImpl>(
|
||||
|
@ -623,13 +633,12 @@ unsafe extern "C" fn video_encoder_negotiate<T: VideoEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.negotiate(wrap.unsafe_cast_ref()) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.negotiate() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -643,12 +652,10 @@ unsafe extern "C" fn video_encoder_getcaps<T: VideoEncoderImpl>(
|
|||
) -> *mut gst::ffi::GstCaps {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::Caps::new_empty(), {
|
||||
gst::panic_to_error!(imp, gst::Caps::new_empty(), {
|
||||
VideoEncoderImpl::caps(
|
||||
imp,
|
||||
wrap.unsafe_cast_ref(),
|
||||
Option::<gst::Caps>::from_glib_borrow(filter)
|
||||
.as_ref()
|
||||
.as_ref(),
|
||||
|
@ -663,12 +670,8 @@ unsafe extern "C" fn video_encoder_sink_event<T: VideoEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.sink_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, false, { imp.sink_event(from_glib_full(event)) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn video_encoder_sink_query<T: VideoEncoderImpl>(
|
||||
|
@ -677,10 +680,9 @@ unsafe extern "C" fn video_encoder_sink_query<T: VideoEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.sink_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||
gst::panic_to_error!(imp, false, {
|
||||
imp.sink_query(gst::QueryRef::from_mut_ptr(query))
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -691,12 +693,8 @@ unsafe extern "C" fn video_encoder_src_event<T: VideoEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.src_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||
})
|
||||
.into_glib()
|
||||
gst::panic_to_error!(imp, false, { imp.src_event(from_glib_full(event)) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn video_encoder_src_query<T: VideoEncoderImpl>(
|
||||
|
@ -705,10 +703,9 @@ unsafe extern "C" fn video_encoder_src_query<T: VideoEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.src_query(wrap.unsafe_cast_ref(), gst::QueryRef::from_mut_ptr(query))
|
||||
gst::panic_to_error!(imp, false, {
|
||||
imp.src_query(gst::QueryRef::from_mut_ptr(query))
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
@ -719,17 +716,16 @@ unsafe extern "C" fn video_encoder_propose_allocation<T: VideoEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
|
||||
gst::QueryViewMut::Allocation(allocation) => allocation,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.propose_allocation(wrap.unsafe_cast_ref(), query) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.propose_allocation(query) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -743,17 +739,16 @@ unsafe extern "C" fn video_encoder_decide_allocation<T: VideoEncoderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoEncoder> = from_glib_borrow(ptr);
|
||||
let query = match gst::QueryRef::from_mut_ptr(query).view_mut() {
|
||||
gst::QueryViewMut::Allocation(allocation) => allocation,
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.decide_allocation(wrap.unsafe_cast_ref(), query) {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.decide_allocation(query) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,45 +12,40 @@ use crate::VideoInfo;
|
|||
pub trait VideoFilterImpl: VideoFilterImplExt + BaseTransformImpl {
|
||||
fn set_info(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
incaps: &gst::Caps,
|
||||
in_info: &VideoInfo,
|
||||
outcaps: &gst::Caps,
|
||||
out_info: &VideoInfo,
|
||||
) -> Result<(), gst::LoggableError> {
|
||||
self.parent_set_info(element, incaps, in_info, outcaps, out_info)
|
||||
self.parent_set_info(incaps, in_info, outcaps, out_info)
|
||||
}
|
||||
|
||||
fn transform_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
inframe: &VideoFrameRef<&gst::BufferRef>,
|
||||
outframe: &mut VideoFrameRef<&mut gst::BufferRef>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_transform_frame(element, inframe, outframe)
|
||||
self.parent_transform_frame(inframe, outframe)
|
||||
}
|
||||
|
||||
fn transform_frame_ip(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
frame: &mut VideoFrameRef<&mut gst::BufferRef>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_transform_frame_ip(element, frame)
|
||||
self.parent_transform_frame_ip(frame)
|
||||
}
|
||||
|
||||
fn transform_frame_ip_passthrough(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
frame: &VideoFrameRef<&gst::BufferRef>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_transform_frame_ip_passthrough(element, frame)
|
||||
self.parent_transform_frame_ip_passthrough(frame)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait VideoFilterImplExt: ObjectSubclass {
|
||||
fn parent_set_info(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
incaps: &gst::Caps,
|
||||
in_info: &VideoInfo,
|
||||
outcaps: &gst::Caps,
|
||||
|
@ -59,20 +54,17 @@ pub trait VideoFilterImplExt: ObjectSubclass {
|
|||
|
||||
fn parent_transform_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
inframe: &VideoFrameRef<&gst::BufferRef>,
|
||||
outframe: &mut VideoFrameRef<&mut gst::BufferRef>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_transform_frame_ip(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
frame: &mut VideoFrameRef<&mut gst::BufferRef>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
|
||||
fn parent_transform_frame_ip_passthrough(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
frame: &VideoFrameRef<&gst::BufferRef>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
}
|
||||
|
@ -80,7 +72,6 @@ pub trait VideoFilterImplExt: ObjectSubclass {
|
|||
impl<T: VideoFilterImpl> VideoFilterImplExt for T {
|
||||
fn parent_set_info(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
incaps: &gst::Caps,
|
||||
in_info: &VideoInfo,
|
||||
outcaps: &gst::Caps,
|
||||
|
@ -94,7 +85,10 @@ impl<T: VideoFilterImpl> VideoFilterImplExt for T {
|
|||
.map(|f| {
|
||||
gst::result_from_gboolean!(
|
||||
f(
|
||||
element.unsafe_cast_ref::<VideoFilter>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoFilter>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
incaps.to_glib_none().0,
|
||||
mut_override(in_info.to_glib_none().0),
|
||||
outcaps.to_glib_none().0,
|
||||
|
@ -110,7 +104,6 @@ impl<T: VideoFilterImpl> VideoFilterImplExt for T {
|
|||
|
||||
fn parent_transform_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
inframe: &VideoFrameRef<&gst::BufferRef>,
|
||||
outframe: &mut VideoFrameRef<&mut gst::BufferRef>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
|
@ -121,21 +114,24 @@ impl<T: VideoFilterImpl> VideoFilterImplExt for T {
|
|||
.transform_frame
|
||||
.map(|f| {
|
||||
try_from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoFilter>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoFilter>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
mut_override(inframe.as_ptr()),
|
||||
outframe.as_mut_ptr(),
|
||||
))
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
if !element
|
||||
if !self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<gst_base::BaseTransform>()
|
||||
.is_in_place()
|
||||
{
|
||||
Err(gst::FlowError::NotSupported)
|
||||
} else {
|
||||
unreachable!(concat!(
|
||||
"parent `transform_frame` called ",
|
||||
"while transform element operates in-place"
|
||||
"parent `transform_frame` called while transform operates in-place"
|
||||
));
|
||||
}
|
||||
})
|
||||
|
@ -144,31 +140,33 @@ impl<T: VideoFilterImpl> VideoFilterImplExt for T {
|
|||
|
||||
fn parent_transform_frame_ip(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
frame: &mut VideoFrameRef<&mut gst::BufferRef>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoFilterClass;
|
||||
let f = (*parent_class).transform_frame_ip.unwrap_or_else(|| {
|
||||
if element
|
||||
if self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<gst_base::BaseTransform>()
|
||||
.is_in_place()
|
||||
{
|
||||
panic!(concat!(
|
||||
"Missing parent function `transform_frame_ip`. Required because ",
|
||||
"transform element operates in-place"
|
||||
"transform operates in-place"
|
||||
));
|
||||
} else {
|
||||
unreachable!(concat!(
|
||||
"parent `transform_frame` called ",
|
||||
"while transform element doesn't operate in-place"
|
||||
"parent `transform_frame` called while transform doesn't operate in-place"
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
try_from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoFilter>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoFilter>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
frame.as_mut_ptr(),
|
||||
))
|
||||
}
|
||||
|
@ -176,31 +174,34 @@ impl<T: VideoFilterImpl> VideoFilterImplExt for T {
|
|||
|
||||
fn parent_transform_frame_ip_passthrough(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
frame: &VideoFrameRef<&gst::BufferRef>,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoFilterClass;
|
||||
let f = (*parent_class).transform_frame_ip.unwrap_or_else(|| {
|
||||
if element
|
||||
if self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<gst_base::BaseTransform>()
|
||||
.is_in_place()
|
||||
{
|
||||
panic!(concat!(
|
||||
"Missing parent function `transform_frame_ip`. Required because ",
|
||||
"transform element operates in-place (passthrough mode)"
|
||||
"transform operates in-place (passthrough mode)"
|
||||
));
|
||||
} else {
|
||||
unreachable!(concat!(
|
||||
"parent `transform_frame_ip` called ",
|
||||
"while transform element doesn't operate in-place (passthrough mode)"
|
||||
"while transform doesn't operate in-place (passthrough mode)"
|
||||
));
|
||||
}
|
||||
});
|
||||
|
||||
try_from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoFilter>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoFilter>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
mut_override(frame.as_ptr()),
|
||||
))
|
||||
}
|
||||
|
@ -242,11 +243,9 @@ unsafe extern "C" fn video_filter_set_info<T: VideoFilterImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoFilter> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
gst::panic_to_error!(imp, false, {
|
||||
match imp.set_info(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&from_glib_borrow(incaps),
|
||||
&from_glib_none(in_info),
|
||||
&from_glib_borrow(outcaps),
|
||||
|
@ -254,7 +253,7 @@ unsafe extern "C" fn video_filter_set_info<T: VideoFilterImpl>(
|
|||
) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -269,11 +268,9 @@ unsafe extern "C" fn video_filter_transform_frame<T: VideoFilterImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoFilter> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
imp.transform_frame(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&VideoFrameRef::from_glib_borrow(inframe),
|
||||
&mut VideoFrameRef::from_glib_borrow_mut(outframe),
|
||||
)
|
||||
|
@ -288,23 +285,16 @@ unsafe extern "C" fn video_filter_transform_frame_ip<T: VideoFilterImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoFilter> = from_glib_borrow(ptr);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
if from_glib(gst_base::ffi::gst_base_transform_is_passthrough(
|
||||
ptr as *mut gst_base::ffi::GstBaseTransform,
|
||||
)) {
|
||||
imp.transform_frame_ip_passthrough(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&VideoFrameRef::from_glib_borrow(frame),
|
||||
)
|
||||
.into()
|
||||
imp.transform_frame_ip_passthrough(&VideoFrameRef::from_glib_borrow(frame))
|
||||
.into()
|
||||
} else {
|
||||
imp.transform_frame_ip(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&mut VideoFrameRef::from_glib_borrow_mut(frame),
|
||||
)
|
||||
.into()
|
||||
imp.transform_frame_ip(&mut VideoFrameRef::from_glib_borrow_mut(frame))
|
||||
.into()
|
||||
}
|
||||
})
|
||||
.into_glib()
|
||||
|
|
|
@ -8,29 +8,17 @@ use gst_base::subclass::prelude::*;
|
|||
use crate::VideoSink;
|
||||
|
||||
pub trait VideoSinkImpl: VideoSinkImplExt + BaseSinkImpl + ElementImpl {
|
||||
fn show_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: &gst::Buffer,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_show_frame(element, buffer)
|
||||
fn show_frame(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
self.parent_show_frame(buffer)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait VideoSinkImplExt: ObjectSubclass {
|
||||
fn parent_show_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: &gst::Buffer,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
fn parent_show_frame(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||
}
|
||||
|
||||
impl<T: VideoSinkImpl> VideoSinkImplExt for T {
|
||||
fn parent_show_frame(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
buffer: &gst::Buffer,
|
||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
fn parent_show_frame(&self, buffer: &gst::Buffer) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstVideoSinkClass;
|
||||
|
@ -38,7 +26,10 @@ impl<T: VideoSinkImpl> VideoSinkImplExt for T {
|
|||
.show_frame
|
||||
.map(|f| {
|
||||
try_from_glib(f(
|
||||
element.unsafe_cast_ref::<VideoSink>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<VideoSink>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
buffer.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
|
@ -61,11 +52,10 @@ unsafe extern "C" fn video_sink_show_frame<T: VideoSinkImpl>(
|
|||
) -> gst::ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<VideoSink> = from_glib_borrow(ptr);
|
||||
let buffer = from_glib_borrow(buffer);
|
||||
|
||||
gst::panic_to_error!(&wrap, imp.panicked(), gst::FlowReturn::Error, {
|
||||
imp.show_frame(wrap.unsafe_cast_ref(), &buffer).into()
|
||||
gst::panic_to_error!(imp, gst::FlowReturn::Error, {
|
||||
imp.show_frame(&buffer).into()
|
||||
})
|
||||
.into_glib()
|
||||
}
|
||||
|
|
|
@ -491,7 +491,7 @@ macro_rules! log_with_level(
|
|||
// Check the log level before using `format_args!` otherwise
|
||||
// formatted arguments are evaluated even if we end up not logging.
|
||||
if $level <= $cat.threshold() {
|
||||
$crate::DebugCategory::log_unfiltered($cat.clone(), Some($obj),
|
||||
$crate::DebugCategory::log_unfiltered($cat.clone(), Some(&*$obj),
|
||||
$level, file!(), module_path!(), line!(), format_args!($($args)*))
|
||||
}
|
||||
}};
|
||||
|
|
|
@ -12,39 +12,35 @@ use crate::LoggableError;
|
|||
use crate::Message;
|
||||
|
||||
pub trait BinImpl: BinImplExt + ElementImpl {
|
||||
fn add_element(&self, bin: &Self::Type, element: &Element) -> Result<(), LoggableError> {
|
||||
self.parent_add_element(bin, element)
|
||||
fn add_element(&self, element: &Element) -> Result<(), LoggableError> {
|
||||
self.parent_add_element(element)
|
||||
}
|
||||
|
||||
fn remove_element(&self, bin: &Self::Type, element: &Element) -> Result<(), LoggableError> {
|
||||
self.parent_remove_element(bin, element)
|
||||
fn remove_element(&self, element: &Element) -> Result<(), LoggableError> {
|
||||
self.parent_remove_element(element)
|
||||
}
|
||||
|
||||
fn do_latency(&self, bin: &Self::Type) -> Result<(), LoggableError> {
|
||||
self.parent_do_latency(bin)
|
||||
fn do_latency(&self) -> Result<(), LoggableError> {
|
||||
self.parent_do_latency()
|
||||
}
|
||||
|
||||
fn handle_message(&self, bin: &Self::Type, message: Message) {
|
||||
self.parent_handle_message(bin, message)
|
||||
fn handle_message(&self, message: Message) {
|
||||
self.parent_handle_message(message)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait BinImplExt: ObjectSubclass {
|
||||
fn parent_add_element(&self, bin: &Self::Type, element: &Element) -> Result<(), LoggableError>;
|
||||
fn parent_add_element(&self, element: &Element) -> Result<(), LoggableError>;
|
||||
|
||||
fn parent_remove_element(
|
||||
&self,
|
||||
bin: &Self::Type,
|
||||
element: &Element,
|
||||
) -> Result<(), LoggableError>;
|
||||
fn parent_remove_element(&self, element: &Element) -> Result<(), LoggableError>;
|
||||
|
||||
fn parent_do_latency(&self, bin: &Self::Type) -> Result<(), LoggableError>;
|
||||
fn parent_do_latency(&self) -> Result<(), LoggableError>;
|
||||
|
||||
fn parent_handle_message(&self, bin: &Self::Type, message: Message);
|
||||
fn parent_handle_message(&self, message: Message);
|
||||
}
|
||||
|
||||
impl<T: BinImpl> BinImplExt for T {
|
||||
fn parent_add_element(&self, bin: &Self::Type, element: &Element) -> Result<(), LoggableError> {
|
||||
fn parent_add_element(&self, element: &Element) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBinClass;
|
||||
|
@ -56,7 +52,10 @@ impl<T: BinImpl> BinImplExt for T {
|
|||
})?;
|
||||
result_from_gboolean!(
|
||||
f(
|
||||
bin.unsafe_cast_ref::<crate::Bin>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<crate::Bin>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
element.to_glib_none().0
|
||||
),
|
||||
crate::CAT_RUST,
|
||||
|
@ -65,11 +64,7 @@ impl<T: BinImpl> BinImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_remove_element(
|
||||
&self,
|
||||
bin: &Self::Type,
|
||||
element: &Element,
|
||||
) -> Result<(), LoggableError> {
|
||||
fn parent_remove_element(&self, element: &Element) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBinClass;
|
||||
|
@ -81,7 +76,10 @@ impl<T: BinImpl> BinImplExt for T {
|
|||
})?;
|
||||
result_from_gboolean!(
|
||||
f(
|
||||
bin.unsafe_cast_ref::<crate::Bin>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<crate::Bin>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
element.to_glib_none().0
|
||||
),
|
||||
crate::CAT_RUST,
|
||||
|
@ -90,7 +88,7 @@ impl<T: BinImpl> BinImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_do_latency(&self, bin: &Self::Type) -> Result<(), LoggableError> {
|
||||
fn parent_do_latency(&self) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBinClass;
|
||||
|
@ -101,20 +99,27 @@ impl<T: BinImpl> BinImplExt for T {
|
|||
)
|
||||
})?;
|
||||
result_from_gboolean!(
|
||||
f(bin.unsafe_cast_ref::<crate::Bin>().to_glib_none().0,),
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<crate::Bin>()
|
||||
.to_glib_none()
|
||||
.0,),
|
||||
crate::CAT_RUST,
|
||||
"Failed to update latency using the parent function"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_handle_message(&self, bin: &Self::Type, message: Message) {
|
||||
fn parent_handle_message(&self, message: Message) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBinClass;
|
||||
if let Some(ref f) = (*parent_class).handle_message {
|
||||
f(
|
||||
bin.unsafe_cast_ref::<crate::Bin>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<crate::Bin>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
message.into_glib_ptr(),
|
||||
);
|
||||
}
|
||||
|
@ -139,13 +144,12 @@ unsafe extern "C" fn bin_add_element<T: BinImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Bin> = from_glib_borrow(ptr);
|
||||
|
||||
panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.add_element(wrap.unsafe_cast_ref(), &from_glib_none(element)) {
|
||||
panic_to_error!(imp, false, {
|
||||
match imp.add_element(&from_glib_none(element)) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +163,6 @@ unsafe extern "C" fn bin_remove_element<T: BinImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Bin> = from_glib_borrow(ptr);
|
||||
|
||||
// If we get a floating reference passed simply return FALSE here. It can't be
|
||||
// stored inside this bin, and if we continued to use it we would take ownership
|
||||
|
@ -170,11 +173,11 @@ unsafe extern "C" fn bin_remove_element<T: BinImpl>(
|
|||
return glib::ffi::GFALSE;
|
||||
}
|
||||
|
||||
panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.remove_element(wrap.unsafe_cast_ref(), &from_glib_none(element)) {
|
||||
panic_to_error!(imp, false, {
|
||||
match imp.remove_element(&from_glib_none(element)) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -185,13 +188,12 @@ unsafe extern "C" fn bin_remove_element<T: BinImpl>(
|
|||
unsafe extern "C" fn bin_do_latency<T: BinImpl>(ptr: *mut ffi::GstBin) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Bin> = from_glib_borrow(ptr);
|
||||
|
||||
panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
match imp.do_latency(wrap.unsafe_cast_ref()) {
|
||||
panic_to_error!(imp, false, {
|
||||
match imp.do_latency() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -205,9 +207,6 @@ unsafe extern "C" fn bin_handle_message<T: BinImpl>(
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Bin> = from_glib_borrow(ptr);
|
||||
|
||||
panic_to_error!(&wrap, imp.panicked(), (), {
|
||||
imp.handle_message(wrap.unsafe_cast_ref(), from_glib_full(message))
|
||||
});
|
||||
panic_to_error!(imp, (), { imp.handle_message(from_glib_full(message)) });
|
||||
}
|
||||
|
|
|
@ -13,92 +13,86 @@ use crate::{BufferPool, BufferPoolAcquireParams, BufferPoolConfigRef};
|
|||
pub trait BufferPoolImpl: BufferPoolImplExt + GstObjectImpl + Send + Sync {
|
||||
fn acquire_buffer(
|
||||
&self,
|
||||
buffer_pool: &Self::Type,
|
||||
params: Option<&BufferPoolAcquireParams>,
|
||||
) -> Result<crate::Buffer, crate::FlowError> {
|
||||
self.parent_acquire_buffer(buffer_pool, params)
|
||||
self.parent_acquire_buffer(params)
|
||||
}
|
||||
|
||||
fn alloc_buffer(
|
||||
&self,
|
||||
buffer_pool: &Self::Type,
|
||||
params: Option<&BufferPoolAcquireParams>,
|
||||
) -> Result<crate::Buffer, crate::FlowError> {
|
||||
self.parent_alloc_buffer(buffer_pool, params)
|
||||
self.parent_alloc_buffer(params)
|
||||
}
|
||||
|
||||
fn flush_start(&self, buffer_pool: &Self::Type) {
|
||||
self.parent_flush_start(buffer_pool)
|
||||
fn flush_start(&self) {
|
||||
self.parent_flush_start()
|
||||
}
|
||||
|
||||
fn flush_stop(&self, buffer_pool: &Self::Type) {
|
||||
self.parent_flush_stop(buffer_pool)
|
||||
fn flush_stop(&self) {
|
||||
self.parent_flush_stop()
|
||||
}
|
||||
|
||||
fn free_buffer(&self, buffer_pool: &Self::Type, buffer: crate::Buffer) {
|
||||
self.parent_free_buffer(buffer_pool, buffer)
|
||||
fn free_buffer(&self, buffer: crate::Buffer) {
|
||||
self.parent_free_buffer(buffer)
|
||||
}
|
||||
|
||||
fn release_buffer(&self, buffer_pool: &Self::Type, buffer: crate::Buffer) {
|
||||
self.parent_release_buffer(buffer_pool, buffer)
|
||||
fn release_buffer(&self, buffer: crate::Buffer) {
|
||||
self.parent_release_buffer(buffer)
|
||||
}
|
||||
|
||||
fn reset_buffer(&self, buffer_pool: &Self::Type, buffer: &mut crate::BufferRef) {
|
||||
self.parent_reset_buffer(buffer_pool, buffer)
|
||||
fn reset_buffer(&self, buffer: &mut crate::BufferRef) {
|
||||
self.parent_reset_buffer(buffer)
|
||||
}
|
||||
|
||||
fn start(&self, buffer_pool: &Self::Type) -> bool {
|
||||
self.parent_start(buffer_pool)
|
||||
fn start(&self) -> bool {
|
||||
self.parent_start()
|
||||
}
|
||||
|
||||
fn stop(&self, buffer_pool: &Self::Type) -> bool {
|
||||
self.parent_stop(buffer_pool)
|
||||
fn stop(&self) -> bool {
|
||||
self.parent_stop()
|
||||
}
|
||||
|
||||
fn options() -> &'static [&'static str] {
|
||||
&[]
|
||||
}
|
||||
|
||||
fn set_config(&self, buffer_pool: &Self::Type, config: &mut BufferPoolConfigRef) -> bool {
|
||||
self.parent_set_config(buffer_pool, config)
|
||||
fn set_config(&self, config: &mut BufferPoolConfigRef) -> bool {
|
||||
self.parent_set_config(config)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait BufferPoolImplExt: ObjectSubclass {
|
||||
fn parent_acquire_buffer(
|
||||
&self,
|
||||
buffer_pool: &Self::Type,
|
||||
params: Option<&BufferPoolAcquireParams>,
|
||||
) -> Result<crate::Buffer, crate::FlowError>;
|
||||
|
||||
fn parent_alloc_buffer(
|
||||
&self,
|
||||
buffer_pool: &Self::Type,
|
||||
params: Option<&BufferPoolAcquireParams>,
|
||||
) -> Result<crate::Buffer, crate::FlowError>;
|
||||
|
||||
fn parent_free_buffer(&self, buffer_pool: &Self::Type, buffer: crate::Buffer);
|
||||
fn parent_free_buffer(&self, buffer: crate::Buffer);
|
||||
|
||||
fn parent_release_buffer(&self, buffer_pool: &Self::Type, buffer: crate::Buffer);
|
||||
fn parent_release_buffer(&self, buffer: crate::Buffer);
|
||||
|
||||
fn parent_reset_buffer(&self, buffer_pool: &Self::Type, buffer: &mut crate::BufferRef);
|
||||
fn parent_reset_buffer(&self, buffer: &mut crate::BufferRef);
|
||||
|
||||
fn parent_start(&self, buffer_pool: &Self::Type) -> bool;
|
||||
fn parent_start(&self) -> bool;
|
||||
|
||||
fn parent_stop(&self, buffer_pool: &Self::Type) -> bool;
|
||||
fn parent_stop(&self) -> bool;
|
||||
|
||||
fn parent_set_config(&self, buffer_pool: &Self::Type, config: &mut BufferPoolConfigRef)
|
||||
-> bool;
|
||||
fn parent_set_config(&self, config: &mut BufferPoolConfigRef) -> bool;
|
||||
|
||||
fn parent_flush_start(&self, _buffer_pool: &Self::Type);
|
||||
fn parent_flush_start(&self);
|
||||
|
||||
fn parent_flush_stop(&self, _buffer_pool: &Self::Type);
|
||||
fn parent_flush_stop(&self);
|
||||
}
|
||||
|
||||
impl<T: BufferPoolImpl> BufferPoolImplExt for T {
|
||||
fn parent_acquire_buffer(
|
||||
&self,
|
||||
buffer_pool: &Self::Type,
|
||||
params: Option<&BufferPoolAcquireParams>,
|
||||
) -> Result<crate::Buffer, crate::FlowError> {
|
||||
unsafe {
|
||||
|
@ -109,7 +103,7 @@ impl<T: BufferPoolImpl> BufferPoolImplExt for T {
|
|||
let mut buffer = std::ptr::null_mut();
|
||||
|
||||
let result = f(
|
||||
buffer_pool
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<crate::BufferPool>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -126,7 +120,6 @@ impl<T: BufferPoolImpl> BufferPoolImplExt for T {
|
|||
|
||||
fn parent_alloc_buffer(
|
||||
&self,
|
||||
buffer_pool: &Self::Type,
|
||||
params: Option<&BufferPoolAcquireParams>,
|
||||
) -> Result<crate::Buffer, crate::FlowError> {
|
||||
unsafe {
|
||||
|
@ -137,7 +130,7 @@ impl<T: BufferPoolImpl> BufferPoolImplExt for T {
|
|||
let mut buffer = std::ptr::null_mut();
|
||||
|
||||
let result = f(
|
||||
buffer_pool
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<crate::BufferPool>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -152,13 +145,13 @@ impl<T: BufferPoolImpl> BufferPoolImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_free_buffer(&self, buffer_pool: &Self::Type, buffer: crate::Buffer) {
|
||||
fn parent_free_buffer(&self, buffer: crate::Buffer) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBufferPoolClass;
|
||||
if let Some(f) = (*parent_class).free_buffer {
|
||||
f(
|
||||
buffer_pool
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<crate::BufferPool>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -168,13 +161,13 @@ impl<T: BufferPoolImpl> BufferPoolImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_release_buffer(&self, buffer_pool: &Self::Type, buffer: crate::Buffer) {
|
||||
fn parent_release_buffer(&self, buffer: crate::Buffer) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBufferPoolClass;
|
||||
if let Some(f) = (*parent_class).release_buffer {
|
||||
f(
|
||||
buffer_pool
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<crate::BufferPool>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -184,13 +177,13 @@ impl<T: BufferPoolImpl> BufferPoolImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_reset_buffer(&self, buffer_pool: &Self::Type, buffer: &mut crate::BufferRef) {
|
||||
fn parent_reset_buffer(&self, buffer: &mut crate::BufferRef) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBufferPoolClass;
|
||||
if let Some(f) = (*parent_class).reset_buffer {
|
||||
f(
|
||||
buffer_pool
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<crate::BufferPool>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -200,12 +193,13 @@ impl<T: BufferPoolImpl> BufferPoolImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_start(&self, buffer_pool: &Self::Type) -> bool {
|
||||
fn parent_start(&self) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBufferPoolClass;
|
||||
if let Some(f) = (*parent_class).start {
|
||||
let result = f(buffer_pool
|
||||
let result = f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<crate::BufferPool>()
|
||||
.to_glib_none()
|
||||
.0);
|
||||
|
@ -217,12 +211,13 @@ impl<T: BufferPoolImpl> BufferPoolImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_stop(&self, buffer_pool: &Self::Type) -> bool {
|
||||
fn parent_stop(&self) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBufferPoolClass;
|
||||
if let Some(f) = (*parent_class).stop {
|
||||
let result = f(buffer_pool
|
||||
let result = f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<crate::BufferPool>()
|
||||
.to_glib_none()
|
||||
.0);
|
||||
|
@ -234,17 +229,13 @@ impl<T: BufferPoolImpl> BufferPoolImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_set_config(
|
||||
&self,
|
||||
buffer_pool: &Self::Type,
|
||||
config: &mut BufferPoolConfigRef,
|
||||
) -> bool {
|
||||
fn parent_set_config(&self, config: &mut BufferPoolConfigRef) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBufferPoolClass;
|
||||
if let Some(f) = (*parent_class).set_config {
|
||||
let result = f(
|
||||
buffer_pool
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<crate::BufferPool>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
|
@ -258,12 +249,13 @@ impl<T: BufferPoolImpl> BufferPoolImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_flush_start(&self, buffer_pool: &Self::Type) {
|
||||
fn parent_flush_start(&self) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBufferPoolClass;
|
||||
if let Some(f) = (*parent_class).flush_start {
|
||||
f(buffer_pool
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<crate::BufferPool>()
|
||||
.to_glib_none()
|
||||
.0)
|
||||
|
@ -271,12 +263,13 @@ impl<T: BufferPoolImpl> BufferPoolImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_flush_stop(&self, buffer_pool: &Self::Type) {
|
||||
fn parent_flush_stop(&self) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstBufferPoolClass;
|
||||
if let Some(f) = (*parent_class).flush_stop {
|
||||
f(buffer_pool
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<crate::BufferPool>()
|
||||
.to_glib_none()
|
||||
.0)
|
||||
|
@ -331,10 +324,9 @@ unsafe extern "C" fn buffer_pool_acquire_buffer<T: BufferPoolImpl>(
|
|||
) -> ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BufferPool> = from_glib_borrow(ptr);
|
||||
let params: Option<BufferPoolAcquireParams> = from_glib_none(params);
|
||||
|
||||
match imp.acquire_buffer(wrap.unsafe_cast_ref(), params.as_ref()) {
|
||||
match imp.acquire_buffer(params.as_ref()) {
|
||||
Ok(b) => {
|
||||
*buffer = b.into_glib_ptr();
|
||||
ffi::GST_FLOW_OK
|
||||
|
@ -350,10 +342,9 @@ unsafe extern "C" fn buffer_pool_alloc_buffer<T: BufferPoolImpl>(
|
|||
) -> ffi::GstFlowReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BufferPool> = from_glib_borrow(ptr);
|
||||
let params: Option<BufferPoolAcquireParams> = from_glib_none(params);
|
||||
|
||||
match imp.alloc_buffer(wrap.unsafe_cast_ref(), params.as_ref()) {
|
||||
match imp.alloc_buffer(params.as_ref()) {
|
||||
Ok(b) => {
|
||||
*buffer = b.into_glib_ptr();
|
||||
ffi::GST_FLOW_OK
|
||||
|
@ -374,8 +365,7 @@ unsafe extern "C" fn buffer_pool_flush_start<T: BufferPoolImpl>(ptr: *mut ffi::G
|
|||
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BufferPool> = from_glib_borrow(ptr);
|
||||
imp.flush_start(wrap.unsafe_cast_ref());
|
||||
imp.flush_start();
|
||||
}
|
||||
|
||||
unsafe extern "C" fn buffer_pool_flush_stop<T: BufferPoolImpl>(ptr: *mut ffi::GstBufferPool) {
|
||||
|
@ -390,8 +380,7 @@ unsafe extern "C" fn buffer_pool_flush_stop<T: BufferPoolImpl>(ptr: *mut ffi::Gs
|
|||
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BufferPool> = from_glib_borrow(ptr);
|
||||
imp.flush_stop(wrap.unsafe_cast_ref());
|
||||
imp.flush_stop();
|
||||
}
|
||||
|
||||
unsafe extern "C" fn buffer_pool_free_buffer<T: BufferPoolImpl>(
|
||||
|
@ -417,8 +406,7 @@ unsafe extern "C" fn buffer_pool_free_buffer<T: BufferPoolImpl>(
|
|||
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BufferPool> = from_glib_borrow(ptr);
|
||||
imp.free_buffer(wrap.unsafe_cast_ref(), from_glib_full(buffer));
|
||||
imp.free_buffer(from_glib_full(buffer));
|
||||
}
|
||||
|
||||
unsafe extern "C" fn buffer_pool_release_buffer<T: BufferPoolImpl>(
|
||||
|
@ -427,8 +415,7 @@ unsafe extern "C" fn buffer_pool_release_buffer<T: BufferPoolImpl>(
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BufferPool> = from_glib_borrow(ptr);
|
||||
imp.release_buffer(wrap.unsafe_cast_ref(), from_glib_full(buffer));
|
||||
imp.release_buffer(from_glib_full(buffer));
|
||||
}
|
||||
|
||||
unsafe extern "C" fn buffer_pool_reset_buffer<T: BufferPoolImpl>(
|
||||
|
@ -437,11 +424,7 @@ unsafe extern "C" fn buffer_pool_reset_buffer<T: BufferPoolImpl>(
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BufferPool> = from_glib_borrow(ptr);
|
||||
imp.reset_buffer(
|
||||
wrap.unsafe_cast_ref(),
|
||||
crate::BufferRef::from_mut_ptr(buffer),
|
||||
);
|
||||
imp.reset_buffer(crate::BufferRef::from_mut_ptr(buffer));
|
||||
}
|
||||
|
||||
unsafe extern "C" fn buffer_pool_start<T: BufferPoolImpl>(
|
||||
|
@ -449,8 +432,7 @@ unsafe extern "C" fn buffer_pool_start<T: BufferPoolImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BufferPool> = from_glib_borrow(ptr);
|
||||
imp.start(wrap.unsafe_cast_ref()).into_glib()
|
||||
imp.start().into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn buffer_pool_stop<T: BufferPoolImpl>(
|
||||
|
@ -478,8 +460,7 @@ unsafe extern "C" fn buffer_pool_stop<T: BufferPoolImpl>(
|
|||
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BufferPool> = from_glib_borrow(ptr);
|
||||
imp.stop(wrap.unsafe_cast_ref()).into_glib()
|
||||
imp.stop().into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn buffer_pool_get_options<T: BufferPoolImpl>(
|
||||
|
@ -498,12 +479,8 @@ unsafe extern "C" fn buffer_pool_set_config<T: BufferPoolImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<BufferPool> = from_glib_borrow(ptr);
|
||||
imp.set_config(
|
||||
wrap.unsafe_cast_ref(),
|
||||
BufferPoolConfigRef::from_glib_borrow_mut(config),
|
||||
)
|
||||
.into_glib()
|
||||
imp.set_config(BufferPoolConfigRef::from_glib_borrow_mut(config))
|
||||
.into_glib()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -529,14 +506,10 @@ mod tests {
|
|||
&["TEST_OPTION"]
|
||||
}
|
||||
|
||||
fn set_config(
|
||||
&self,
|
||||
buffer_pool: &Self::Type,
|
||||
config: &mut BufferPoolConfigRef,
|
||||
) -> bool {
|
||||
fn set_config(&self, config: &mut BufferPoolConfigRef) -> bool {
|
||||
let (caps, size, min_buffers, max_buffers) = config.params().unwrap();
|
||||
config.set_params(caps.as_ref(), size * 2, min_buffers, max_buffers);
|
||||
self.parent_set_config(buffer_pool, config)
|
||||
self.parent_set_config(config)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,33 +8,33 @@ use glib::translate::*;
|
|||
use crate::ChildProxy;
|
||||
|
||||
pub trait ChildProxyImpl: GstObjectImpl + Send + Sync {
|
||||
fn child_by_name(&self, object: &Self::Type, name: &str) -> Option<glib::Object> {
|
||||
self.parent_child_by_name(object, name)
|
||||
fn child_by_name(&self, name: &str) -> Option<glib::Object> {
|
||||
self.parent_child_by_name(name)
|
||||
}
|
||||
|
||||
fn child_by_index(&self, object: &Self::Type, index: u32) -> Option<glib::Object>;
|
||||
fn children_count(&self, object: &Self::Type) -> u32;
|
||||
fn child_by_index(&self, index: u32) -> Option<glib::Object>;
|
||||
fn children_count(&self) -> u32;
|
||||
|
||||
fn child_added(&self, object: &Self::Type, child: &glib::Object, name: &str) {
|
||||
self.parent_child_added(object, child, name);
|
||||
fn child_added(&self, child: &glib::Object, name: &str) {
|
||||
self.parent_child_added(child, name);
|
||||
}
|
||||
fn child_removed(&self, object: &Self::Type, child: &glib::Object, name: &str) {
|
||||
self.parent_child_removed(object, child, name);
|
||||
fn child_removed(&self, child: &glib::Object, name: &str) {
|
||||
self.parent_child_removed(child, name);
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ChildProxyImplExt: ObjectSubclass {
|
||||
fn parent_child_by_name(&self, object: &Self::Type, name: &str) -> Option<glib::Object>;
|
||||
fn parent_child_by_name(&self, name: &str) -> Option<glib::Object>;
|
||||
|
||||
fn parent_child_by_index(&self, object: &Self::Type, index: u32) -> Option<glib::Object>;
|
||||
fn parent_children_count(&self, object: &Self::Type) -> u32;
|
||||
fn parent_child_by_index(&self, index: u32) -> Option<glib::Object>;
|
||||
fn parent_children_count(&self) -> u32;
|
||||
|
||||
fn parent_child_added(&self, _object: &Self::Type, _child: &glib::Object, _name: &str);
|
||||
fn parent_child_removed(&self, _object: &Self::Type, _child: &glib::Object, _name: &str);
|
||||
fn parent_child_added(&self, _child: &glib::Object, _name: &str);
|
||||
fn parent_child_removed(&self, _child: &glib::Object, _name: &str);
|
||||
}
|
||||
|
||||
impl<T: ChildProxyImpl> ChildProxyImplExt for T {
|
||||
fn parent_child_by_name(&self, object: &Self::Type, name: &str) -> Option<glib::Object> {
|
||||
fn parent_child_by_name(&self, name: &str) -> Option<glib::Object> {
|
||||
unsafe {
|
||||
let type_data = Self::type_data();
|
||||
let parent_iface = type_data.as_ref().parent_interface::<ChildProxy>()
|
||||
|
@ -44,14 +44,17 @@ impl<T: ChildProxyImpl> ChildProxyImplExt for T {
|
|||
.get_child_by_name
|
||||
.expect("no parent \"child_by_name\" implementation");
|
||||
let ret = func(
|
||||
object.unsafe_cast_ref::<ChildProxy>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<ChildProxy>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
name.to_glib_none().0,
|
||||
);
|
||||
from_glib_full(ret)
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_child_by_index(&self, object: &Self::Type, index: u32) -> Option<glib::Object> {
|
||||
fn parent_child_by_index(&self, index: u32) -> Option<glib::Object> {
|
||||
unsafe {
|
||||
let type_data = Self::type_data();
|
||||
let parent_iface = type_data.as_ref().parent_interface::<ChildProxy>()
|
||||
|
@ -61,14 +64,17 @@ impl<T: ChildProxyImpl> ChildProxyImplExt for T {
|
|||
.get_child_by_index
|
||||
.expect("no parent \"child_by_index\" implementation");
|
||||
let ret = func(
|
||||
object.unsafe_cast_ref::<ChildProxy>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<ChildProxy>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
index,
|
||||
);
|
||||
from_glib_full(ret)
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_children_count(&self, object: &Self::Type) -> u32 {
|
||||
fn parent_children_count(&self) -> u32 {
|
||||
unsafe {
|
||||
let type_data = Self::type_data();
|
||||
let parent_iface = type_data.as_ref().parent_interface::<ChildProxy>()
|
||||
|
@ -77,11 +83,16 @@ impl<T: ChildProxyImpl> ChildProxyImplExt for T {
|
|||
let func = (*parent_iface)
|
||||
.get_children_count
|
||||
.expect("no parent \"children_count\" implementation");
|
||||
func(object.unsafe_cast_ref::<ChildProxy>().to_glib_none().0)
|
||||
func(
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<ChildProxy>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_child_added(&self, object: &Self::Type, child: &glib::Object, name: &str) {
|
||||
fn parent_child_added(&self, child: &glib::Object, name: &str) {
|
||||
unsafe {
|
||||
let type_data = Self::type_data();
|
||||
let parent_iface = type_data.as_ref().parent_interface::<ChildProxy>()
|
||||
|
@ -89,7 +100,10 @@ impl<T: ChildProxyImpl> ChildProxyImplExt for T {
|
|||
|
||||
if let Some(func) = (*parent_iface).child_added {
|
||||
func(
|
||||
object.unsafe_cast_ref::<ChildProxy>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<ChildProxy>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
child.to_glib_none().0,
|
||||
name.to_glib_none().0,
|
||||
);
|
||||
|
@ -97,7 +111,7 @@ impl<T: ChildProxyImpl> ChildProxyImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_child_removed(&self, object: &Self::Type, child: &glib::Object, name: &str) {
|
||||
fn parent_child_removed(&self, child: &glib::Object, name: &str) {
|
||||
unsafe {
|
||||
let type_data = Self::type_data();
|
||||
let parent_iface = type_data.as_ref().parent_interface::<ChildProxy>()
|
||||
|
@ -105,7 +119,10 @@ impl<T: ChildProxyImpl> ChildProxyImplExt for T {
|
|||
|
||||
if let Some(func) = (*parent_iface).child_removed {
|
||||
func(
|
||||
object.unsafe_cast_ref::<ChildProxy>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<ChildProxy>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
child.to_glib_none().0,
|
||||
name.to_glib_none().0,
|
||||
);
|
||||
|
@ -133,11 +150,8 @@ unsafe extern "C" fn child_proxy_get_child_by_name<T: ChildProxyImpl>(
|
|||
let instance = &*(child_proxy as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
|
||||
imp.child_by_name(
|
||||
from_glib_borrow::<_, ChildProxy>(child_proxy).unsafe_cast_ref(),
|
||||
&glib::GString::from_glib_borrow(name),
|
||||
)
|
||||
.to_glib_full()
|
||||
imp.child_by_name(&glib::GString::from_glib_borrow(name))
|
||||
.to_glib_full()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn child_proxy_get_child_by_index<T: ChildProxyImpl>(
|
||||
|
@ -147,11 +161,7 @@ unsafe extern "C" fn child_proxy_get_child_by_index<T: ChildProxyImpl>(
|
|||
let instance = &*(child_proxy as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
|
||||
imp.child_by_index(
|
||||
from_glib_borrow::<_, ChildProxy>(child_proxy).unsafe_cast_ref(),
|
||||
index,
|
||||
)
|
||||
.to_glib_full()
|
||||
imp.child_by_index(index).to_glib_full()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn child_proxy_get_children_count<T: ChildProxyImpl>(
|
||||
|
@ -160,7 +170,7 @@ unsafe extern "C" fn child_proxy_get_children_count<T: ChildProxyImpl>(
|
|||
let instance = &*(child_proxy as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
|
||||
imp.children_count(from_glib_borrow::<_, ChildProxy>(child_proxy).unsafe_cast_ref())
|
||||
imp.children_count()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn child_proxy_child_added<T: ChildProxyImpl>(
|
||||
|
@ -172,7 +182,6 @@ unsafe extern "C" fn child_proxy_child_added<T: ChildProxyImpl>(
|
|||
let imp = instance.imp();
|
||||
|
||||
imp.child_added(
|
||||
from_glib_borrow::<_, ChildProxy>(child_proxy).unsafe_cast_ref(),
|
||||
&from_glib_borrow(child),
|
||||
&glib::GString::from_glib_borrow(name),
|
||||
)
|
||||
|
@ -187,7 +196,6 @@ unsafe extern "C" fn child_proxy_child_removed<T: ChildProxyImpl>(
|
|||
let imp = instance.imp();
|
||||
|
||||
imp.child_removed(
|
||||
from_glib_borrow::<_, ChildProxy>(child_proxy).unsafe_cast_ref(),
|
||||
&from_glib_borrow(child),
|
||||
&glib::GString::from_glib_borrow(name),
|
||||
)
|
||||
|
|
|
@ -14,65 +14,47 @@ use crate::ClockTime;
|
|||
use crate::ClockTimeDiff;
|
||||
|
||||
pub trait ClockImpl: ClockImplExt + GstObjectImpl + Send + Sync {
|
||||
fn change_resolution(
|
||||
&self,
|
||||
clock: &Self::Type,
|
||||
old_resolution: ClockTime,
|
||||
new_resolution: ClockTime,
|
||||
) -> ClockTime {
|
||||
self.parent_change_resolution(clock, old_resolution, new_resolution)
|
||||
fn change_resolution(&self, old_resolution: ClockTime, new_resolution: ClockTime) -> ClockTime {
|
||||
self.parent_change_resolution(old_resolution, new_resolution)
|
||||
}
|
||||
|
||||
fn resolution(&self, clock: &Self::Type) -> ClockTime {
|
||||
self.parent_resolution(clock)
|
||||
fn resolution(&self) -> ClockTime {
|
||||
self.parent_resolution()
|
||||
}
|
||||
|
||||
fn internal_time(&self, clock: &Self::Type) -> ClockTime {
|
||||
self.parent_internal_time(clock)
|
||||
fn internal_time(&self) -> ClockTime {
|
||||
self.parent_internal_time()
|
||||
}
|
||||
|
||||
fn wait(
|
||||
&self,
|
||||
clock: &Self::Type,
|
||||
id: &ClockId,
|
||||
) -> (Result<ClockSuccess, ClockError>, ClockTimeDiff) {
|
||||
self.parent_wait(clock, id)
|
||||
fn wait(&self, id: &ClockId) -> (Result<ClockSuccess, ClockError>, ClockTimeDiff) {
|
||||
self.parent_wait(id)
|
||||
}
|
||||
|
||||
fn wait_async(&self, clock: &Self::Type, id: &ClockId) -> Result<ClockSuccess, ClockError> {
|
||||
self.parent_wait_async(clock, id)
|
||||
fn wait_async(&self, id: &ClockId) -> Result<ClockSuccess, ClockError> {
|
||||
self.parent_wait_async(id)
|
||||
}
|
||||
|
||||
fn unschedule(&self, clock: &Self::Type, id: &ClockId) {
|
||||
self.parent_unschedule(clock, id)
|
||||
fn unschedule(&self, id: &ClockId) {
|
||||
self.parent_unschedule(id)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ClockImplExt: ObjectSubclass {
|
||||
fn parent_change_resolution(
|
||||
&self,
|
||||
clock: &Self::Type,
|
||||
old_resolution: ClockTime,
|
||||
new_resolution: ClockTime,
|
||||
) -> ClockTime;
|
||||
|
||||
fn parent_resolution(&self, clock: &Self::Type) -> ClockTime;
|
||||
fn parent_resolution(&self) -> ClockTime;
|
||||
|
||||
fn parent_internal_time(&self, clock: &Self::Type) -> ClockTime;
|
||||
fn parent_internal_time(&self) -> ClockTime;
|
||||
|
||||
fn parent_wait(
|
||||
&self,
|
||||
clock: &Self::Type,
|
||||
id: &ClockId,
|
||||
) -> (Result<ClockSuccess, ClockError>, ClockTimeDiff);
|
||||
fn parent_wait(&self, id: &ClockId) -> (Result<ClockSuccess, ClockError>, ClockTimeDiff);
|
||||
|
||||
fn parent_wait_async(
|
||||
&self,
|
||||
clock: &Self::Type,
|
||||
id: &ClockId,
|
||||
) -> Result<ClockSuccess, ClockError>;
|
||||
fn parent_wait_async(&self, id: &ClockId) -> Result<ClockSuccess, ClockError>;
|
||||
|
||||
fn parent_unschedule(&self, clock: &Self::Type, id: &ClockId);
|
||||
fn parent_unschedule(&self, id: &ClockId);
|
||||
|
||||
fn wake_id(&self, id: &ClockId)
|
||||
where
|
||||
|
@ -83,7 +65,6 @@ pub trait ClockImplExt: ObjectSubclass {
|
|||
impl<T: ClockImpl> ClockImplExt for T {
|
||||
fn parent_change_resolution(
|
||||
&self,
|
||||
clock: &Self::Type,
|
||||
old_resolution: ClockTime,
|
||||
new_resolution: ClockTime,
|
||||
) -> ClockTime {
|
||||
|
@ -93,18 +74,18 @@ impl<T: ClockImpl> ClockImplExt for T {
|
|||
|
||||
if let Some(func) = (*parent_class).change_resolution {
|
||||
try_from_glib(func(
|
||||
clock.unsafe_cast_ref::<Clock>().to_glib_none().0,
|
||||
self.instance().unsafe_cast_ref::<Clock>().to_glib_none().0,
|
||||
old_resolution.into_glib(),
|
||||
new_resolution.into_glib(),
|
||||
))
|
||||
.expect("undefined resolution")
|
||||
} else {
|
||||
self.resolution(clock)
|
||||
self.resolution()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_resolution(&self, clock: &Self::Type) -> ClockTime {
|
||||
fn parent_resolution(&self) -> ClockTime {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstClockClass;
|
||||
|
@ -112,14 +93,14 @@ impl<T: ClockImpl> ClockImplExt for T {
|
|||
try_from_glib(
|
||||
(*parent_class)
|
||||
.get_resolution
|
||||
.map(|f| f(clock.unsafe_cast_ref::<Clock>().to_glib_none().0))
|
||||
.map(|f| f(self.instance().unsafe_cast_ref::<Clock>().to_glib_none().0))
|
||||
.unwrap_or(1),
|
||||
)
|
||||
.expect("undefined resolution")
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_internal_time(&self, clock: &Self::Type) -> ClockTime {
|
||||
fn parent_internal_time(&self) -> ClockTime {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstClockClass;
|
||||
|
@ -127,18 +108,14 @@ impl<T: ClockImpl> ClockImplExt for T {
|
|||
try_from_glib(
|
||||
(*parent_class)
|
||||
.get_internal_time
|
||||
.map(|f| f(clock.unsafe_cast_ref::<Clock>().to_glib_none().0))
|
||||
.map(|f| f(self.instance().unsafe_cast_ref::<Clock>().to_glib_none().0))
|
||||
.unwrap_or(0),
|
||||
)
|
||||
.expect("undefined internal_time")
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_wait(
|
||||
&self,
|
||||
clock: &Self::Type,
|
||||
id: &ClockId,
|
||||
) -> (Result<ClockSuccess, ClockError>, ClockTimeDiff) {
|
||||
fn parent_wait(&self, id: &ClockId) -> (Result<ClockSuccess, ClockError>, ClockTimeDiff) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstClockClass;
|
||||
|
@ -150,7 +127,7 @@ impl<T: ClockImpl> ClockImplExt for T {
|
|||
.wait
|
||||
.map(|f| {
|
||||
f(
|
||||
clock.unsafe_cast_ref::<Clock>().to_glib_none().0,
|
||||
self.instance().unsafe_cast_ref::<Clock>().to_glib_none().0,
|
||||
id.as_ptr() as *mut ffi::GstClockEntry,
|
||||
&mut jitter,
|
||||
)
|
||||
|
@ -162,11 +139,7 @@ impl<T: ClockImpl> ClockImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_wait_async(
|
||||
&self,
|
||||
clock: &Self::Type,
|
||||
id: &ClockId,
|
||||
) -> Result<ClockSuccess, ClockError> {
|
||||
fn parent_wait_async(&self, id: &ClockId) -> Result<ClockSuccess, ClockError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstClockClass;
|
||||
|
@ -175,7 +148,7 @@ impl<T: ClockImpl> ClockImplExt for T {
|
|||
.wait_async
|
||||
.map(|f| {
|
||||
f(
|
||||
clock.unsafe_cast_ref::<Clock>().to_glib_none().0,
|
||||
self.instance().unsafe_cast_ref::<Clock>().to_glib_none().0,
|
||||
id.as_ptr() as *mut ffi::GstClockEntry,
|
||||
)
|
||||
})
|
||||
|
@ -184,13 +157,13 @@ impl<T: ClockImpl> ClockImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_unschedule(&self, clock: &Self::Type, id: &ClockId) {
|
||||
fn parent_unschedule(&self, id: &ClockId) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstClockClass;
|
||||
if let Some(func) = (*parent_class).unschedule {
|
||||
func(
|
||||
clock.unsafe_cast_ref::<Clock>().to_glib_none().0,
|
||||
self.instance().unsafe_cast_ref::<Clock>().to_glib_none().0,
|
||||
id.as_ptr() as *mut ffi::GstClockEntry,
|
||||
);
|
||||
}
|
||||
|
@ -203,14 +176,15 @@ impl<T: ClockImpl> ClockImplExt for T {
|
|||
<Self as ObjectSubclass>::Type: IsA<Clock>,
|
||||
{
|
||||
let clock = self.instance();
|
||||
let clock = unsafe { clock.unsafe_cast_ref::<Clock>() };
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "v1_16")] {
|
||||
assert!(id.uses_clock(&clock));
|
||||
assert!(id.uses_clock(clock));
|
||||
} else {
|
||||
unsafe {
|
||||
let ptr = id.as_ptr() as *mut ffi::GstClockEntry;
|
||||
assert_eq!((*ptr).clock, clock.as_ref().to_glib_none().0);
|
||||
assert_eq!((*ptr).clock, clock.to_glib_none().0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -219,7 +193,7 @@ impl<T: ClockImpl> ClockImplExt for T {
|
|||
let ptr = id.as_ptr() as *mut ffi::GstClockEntry;
|
||||
if let Some(func) = (*ptr).func {
|
||||
func(
|
||||
clock.as_ref().to_glib_none().0,
|
||||
clock.to_glib_none().0,
|
||||
(*ptr).time,
|
||||
ptr as ffi::GstClockID,
|
||||
(*ptr).user_data,
|
||||
|
@ -252,7 +226,6 @@ unsafe extern "C" fn clock_change_resolution<T: ClockImpl>(
|
|||
) -> ffi::GstClockTime {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Clock> = from_glib_borrow(ptr);
|
||||
|
||||
let old_resolution = match from_glib(old_resolution) {
|
||||
Some(old_resolution) => old_resolution,
|
||||
|
@ -263,7 +236,7 @@ unsafe extern "C" fn clock_change_resolution<T: ClockImpl>(
|
|||
None => return ffi::GST_CLOCK_TIME_NONE,
|
||||
};
|
||||
|
||||
imp.change_resolution(wrap.unsafe_cast_ref(), old_resolution, new_resolution)
|
||||
imp.change_resolution(old_resolution, new_resolution)
|
||||
.into_glib()
|
||||
}
|
||||
|
||||
|
@ -272,9 +245,8 @@ unsafe extern "C" fn clock_get_resolution<T: ClockImpl>(
|
|||
) -> ffi::GstClockTime {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Clock> = from_glib_borrow(ptr);
|
||||
|
||||
imp.resolution(wrap.unsafe_cast_ref()).into_glib()
|
||||
imp.resolution().into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn clock_get_internal_time<T: ClockImpl>(
|
||||
|
@ -282,9 +254,8 @@ unsafe extern "C" fn clock_get_internal_time<T: ClockImpl>(
|
|||
) -> ffi::GstClockTime {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Clock> = from_glib_borrow(ptr);
|
||||
|
||||
imp.internal_time(wrap.unsafe_cast_ref()).into_glib()
|
||||
imp.internal_time().into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn clock_wait<T: ClockImpl>(
|
||||
|
@ -294,12 +265,8 @@ unsafe extern "C" fn clock_wait<T: ClockImpl>(
|
|||
) -> ffi::GstClockReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Clock> = from_glib_borrow(ptr);
|
||||
|
||||
let (res, j) = imp.wait(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&from_glib_borrow(id as ffi::GstClockID),
|
||||
);
|
||||
let (res, j) = imp.wait(&from_glib_borrow(id as ffi::GstClockID));
|
||||
if !jitter.is_null() {
|
||||
*jitter = j;
|
||||
}
|
||||
|
@ -313,13 +280,8 @@ unsafe extern "C" fn clock_wait_async<T: ClockImpl>(
|
|||
) -> ffi::GstClockReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Clock> = from_glib_borrow(ptr);
|
||||
|
||||
ClockReturn::from(imp.wait_async(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&from_glib_borrow(id as ffi::GstClockID),
|
||||
))
|
||||
.into_glib()
|
||||
ClockReturn::from(imp.wait_async(&from_glib_borrow(id as ffi::GstClockID))).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn clock_unschedule<T: ClockImpl>(
|
||||
|
@ -328,10 +290,6 @@ unsafe extern "C" fn clock_unschedule<T: ClockImpl>(
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Clock> = from_glib_borrow(ptr);
|
||||
|
||||
imp.unschedule(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&from_glib_borrow(id as ffi::GstClockID),
|
||||
);
|
||||
imp.unschedule(&from_glib_borrow(id as ffi::GstClockID));
|
||||
}
|
||||
|
|
|
@ -12,49 +12,29 @@ use crate::LoggableError;
|
|||
use std::ptr;
|
||||
|
||||
pub trait DeviceImpl: DeviceImplExt + GstObjectImpl + Send + Sync {
|
||||
fn create_element(
|
||||
&self,
|
||||
device: &Self::Type,
|
||||
name: Option<&str>,
|
||||
) -> Result<Element, LoggableError> {
|
||||
self.parent_create_element(device, name)
|
||||
fn create_element(&self, name: Option<&str>) -> Result<Element, LoggableError> {
|
||||
self.parent_create_element(name)
|
||||
}
|
||||
|
||||
fn reconfigure_element(
|
||||
&self,
|
||||
device: &Self::Type,
|
||||
element: &Element,
|
||||
) -> Result<(), LoggableError> {
|
||||
self.parent_reconfigure_element(device, element)
|
||||
fn reconfigure_element(&self, element: &Element) -> Result<(), LoggableError> {
|
||||
self.parent_reconfigure_element(element)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait DeviceImplExt: ObjectSubclass {
|
||||
fn parent_create_element(
|
||||
&self,
|
||||
device: &Self::Type,
|
||||
name: Option<&str>,
|
||||
) -> Result<Element, LoggableError>;
|
||||
fn parent_create_element(&self, name: Option<&str>) -> Result<Element, LoggableError>;
|
||||
|
||||
fn parent_reconfigure_element(
|
||||
&self,
|
||||
device: &Self::Type,
|
||||
element: &Element,
|
||||
) -> Result<(), LoggableError>;
|
||||
fn parent_reconfigure_element(&self, element: &Element) -> Result<(), LoggableError>;
|
||||
}
|
||||
|
||||
impl<T: DeviceImpl> DeviceImplExt for T {
|
||||
fn parent_create_element(
|
||||
&self,
|
||||
device: &Self::Type,
|
||||
name: Option<&str>,
|
||||
) -> Result<Element, LoggableError> {
|
||||
fn parent_create_element(&self, name: Option<&str>) -> Result<Element, LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstDeviceClass;
|
||||
if let Some(f) = (*parent_class).create_element {
|
||||
let ptr = f(
|
||||
device.unsafe_cast_ref::<Device>().to_glib_none().0,
|
||||
self.instance().unsafe_cast_ref::<Device>().to_glib_none().0,
|
||||
name.to_glib_none().0,
|
||||
);
|
||||
|
||||
|
@ -74,11 +54,7 @@ impl<T: DeviceImpl> DeviceImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_reconfigure_element(
|
||||
&self,
|
||||
device: &Self::Type,
|
||||
element: &Element,
|
||||
) -> Result<(), LoggableError> {
|
||||
fn parent_reconfigure_element(&self, element: &Element) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstDeviceClass;
|
||||
|
@ -90,7 +66,7 @@ impl<T: DeviceImpl> DeviceImplExt for T {
|
|||
})?;
|
||||
result_from_gboolean!(
|
||||
f(
|
||||
device.unsafe_cast_ref::<Device>().to_glib_none().0,
|
||||
self.instance().unsafe_cast_ref::<Device>().to_glib_none().0,
|
||||
element.to_glib_none().0
|
||||
),
|
||||
crate::CAT_RUST,
|
||||
|
@ -115,10 +91,8 @@ unsafe extern "C" fn device_create_element<T: DeviceImpl>(
|
|||
) -> *mut ffi::GstElement {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Device> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.create_element(
|
||||
wrap.unsafe_cast_ref(),
|
||||
Option::<glib::GString>::from_glib_borrow(name)
|
||||
.as_ref()
|
||||
.as_ref()
|
||||
|
@ -136,7 +110,7 @@ unsafe extern "C" fn device_create_element<T: DeviceImpl>(
|
|||
element_ptr
|
||||
}
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
ptr::null_mut()
|
||||
}
|
||||
}
|
||||
|
@ -148,12 +122,11 @@ unsafe extern "C" fn device_reconfigure_element<T: DeviceImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Device> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.reconfigure_element(wrap.unsafe_cast_ref(), &from_glib_borrow(element)) {
|
||||
match imp.reconfigure_element(&from_glib_borrow(element)) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,34 +73,35 @@ pub trait DeviceProviderImpl: DeviceProviderImplExt + GstObjectImpl + Send + Syn
|
|||
None
|
||||
}
|
||||
|
||||
fn probe(&self, device_provider: &Self::Type) -> Vec<Device> {
|
||||
self.parent_probe(device_provider)
|
||||
fn probe(&self) -> Vec<Device> {
|
||||
self.parent_probe()
|
||||
}
|
||||
|
||||
fn start(&self, device_provider: &Self::Type) -> Result<(), LoggableError> {
|
||||
self.parent_start(device_provider)
|
||||
fn start(&self) -> Result<(), LoggableError> {
|
||||
self.parent_start()
|
||||
}
|
||||
|
||||
fn stop(&self, device_provider: &Self::Type) {
|
||||
self.parent_stop(device_provider)
|
||||
fn stop(&self) {
|
||||
self.parent_stop()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait DeviceProviderImplExt: ObjectSubclass {
|
||||
fn parent_probe(&self, device_provider: &Self::Type) -> Vec<Device>;
|
||||
fn parent_probe(&self) -> Vec<Device>;
|
||||
|
||||
fn parent_start(&self, device_provider: &Self::Type) -> Result<(), LoggableError>;
|
||||
fn parent_start(&self) -> Result<(), LoggableError>;
|
||||
|
||||
fn parent_stop(&self, device_provider: &Self::Type);
|
||||
fn parent_stop(&self);
|
||||
}
|
||||
|
||||
impl<T: DeviceProviderImpl> DeviceProviderImplExt for T {
|
||||
fn parent_probe(&self, device_provider: &Self::Type) -> Vec<Device> {
|
||||
fn parent_probe(&self) -> Vec<Device> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstDeviceProviderClass;
|
||||
if let Some(f) = (*parent_class).probe {
|
||||
FromGlibPtrContainer::from_glib_full(f(device_provider
|
||||
FromGlibPtrContainer::from_glib_full(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<DeviceProvider>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
|
@ -110,7 +111,7 @@ impl<T: DeviceProviderImpl> DeviceProviderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_start(&self, device_provider: &Self::Type) -> Result<(), LoggableError> {
|
||||
fn parent_start(&self) -> Result<(), LoggableError> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstDeviceProviderClass;
|
||||
|
@ -118,7 +119,8 @@ impl<T: DeviceProviderImpl> DeviceProviderImplExt for T {
|
|||
loggable_error!(crate::CAT_RUST, "Parent function `start` is not defined")
|
||||
})?;
|
||||
result_from_gboolean!(
|
||||
f(device_provider
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<DeviceProvider>()
|
||||
.to_glib_none()
|
||||
.0),
|
||||
|
@ -128,12 +130,13 @@ impl<T: DeviceProviderImpl> DeviceProviderImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_stop(&self, device_provider: &Self::Type) {
|
||||
fn parent_stop(&self) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstDeviceProviderClass;
|
||||
if let Some(f) = (*parent_class).stop {
|
||||
f(device_provider
|
||||
f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<DeviceProvider>()
|
||||
.to_glib_none()
|
||||
.0);
|
||||
|
@ -177,9 +180,8 @@ unsafe extern "C" fn device_provider_probe<T: DeviceProviderImpl>(
|
|||
) -> *mut glib::ffi::GList {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<DeviceProvider> = from_glib_borrow(ptr);
|
||||
|
||||
imp.probe(wrap.unsafe_cast_ref()).to_glib_full()
|
||||
imp.probe().to_glib_full()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn device_provider_start<T: DeviceProviderImpl>(
|
||||
|
@ -187,12 +189,11 @@ unsafe extern "C" fn device_provider_start<T: DeviceProviderImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<DeviceProvider> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.start(wrap.unsafe_cast_ref()) {
|
||||
match imp.start() {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
err.log_with_object(&*wrap);
|
||||
err.log_with_imp(imp);
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@ -202,7 +203,6 @@ unsafe extern "C" fn device_provider_start<T: DeviceProviderImpl>(
|
|||
unsafe extern "C" fn device_provider_stop<T: DeviceProviderImpl>(ptr: *mut ffi::GstDeviceProvider) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<DeviceProvider> = from_glib_borrow(ptr);
|
||||
|
||||
imp.stop(wrap.unsafe_cast_ref());
|
||||
imp.stop();
|
||||
}
|
||||
|
|
|
@ -85,79 +85,75 @@ pub trait ElementImpl: ElementImplExt + GstObjectImpl + Send + Sync {
|
|||
|
||||
fn change_state(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
transition: StateChange,
|
||||
) -> Result<StateChangeSuccess, StateChangeError> {
|
||||
self.parent_change_state(element, transition)
|
||||
self.parent_change_state(transition)
|
||||
}
|
||||
|
||||
fn request_new_pad(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
templ: &crate::PadTemplate,
|
||||
name: Option<String>,
|
||||
caps: Option<&crate::Caps>,
|
||||
) -> Option<crate::Pad> {
|
||||
self.parent_request_new_pad(element, templ, name, caps)
|
||||
self.parent_request_new_pad(templ, name, caps)
|
||||
}
|
||||
|
||||
fn release_pad(&self, element: &Self::Type, pad: &crate::Pad) {
|
||||
self.parent_release_pad(element, pad)
|
||||
fn release_pad(&self, pad: &crate::Pad) {
|
||||
self.parent_release_pad(pad)
|
||||
}
|
||||
|
||||
fn send_event(&self, element: &Self::Type, event: Event) -> bool {
|
||||
self.parent_send_event(element, event)
|
||||
fn send_event(&self, event: Event) -> bool {
|
||||
self.parent_send_event(event)
|
||||
}
|
||||
|
||||
fn query(&self, element: &Self::Type, query: &mut QueryRef) -> bool {
|
||||
self.parent_query(element, query)
|
||||
fn query(&self, query: &mut QueryRef) -> bool {
|
||||
self.parent_query(query)
|
||||
}
|
||||
|
||||
fn set_context(&self, element: &Self::Type, context: &crate::Context) {
|
||||
self.parent_set_context(element, context)
|
||||
fn set_context(&self, context: &crate::Context) {
|
||||
self.parent_set_context(context)
|
||||
}
|
||||
|
||||
fn set_clock(&self, element: &Self::Type, clock: Option<&crate::Clock>) -> bool {
|
||||
self.parent_set_clock(element, clock)
|
||||
fn set_clock(&self, clock: Option<&crate::Clock>) -> bool {
|
||||
self.parent_set_clock(clock)
|
||||
}
|
||||
|
||||
fn provide_clock(&self, element: &Self::Type) -> Option<crate::Clock> {
|
||||
self.parent_provide_clock(element)
|
||||
fn provide_clock(&self) -> Option<crate::Clock> {
|
||||
self.parent_provide_clock()
|
||||
}
|
||||
|
||||
fn post_message(&self, element: &Self::Type, msg: crate::Message) -> bool {
|
||||
self.parent_post_message(element, msg)
|
||||
fn post_message(&self, msg: crate::Message) -> bool {
|
||||
self.parent_post_message(msg)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ElementImplExt: ObjectSubclass {
|
||||
fn parent_change_state(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
transition: StateChange,
|
||||
) -> Result<StateChangeSuccess, StateChangeError>;
|
||||
|
||||
fn parent_request_new_pad(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
templ: &crate::PadTemplate,
|
||||
name: Option<String>,
|
||||
caps: Option<&crate::Caps>,
|
||||
) -> Option<crate::Pad>;
|
||||
|
||||
fn parent_release_pad(&self, element: &Self::Type, pad: &crate::Pad);
|
||||
fn parent_release_pad(&self, pad: &crate::Pad);
|
||||
|
||||
fn parent_send_event(&self, element: &Self::Type, event: Event) -> bool;
|
||||
fn parent_send_event(&self, event: Event) -> bool;
|
||||
|
||||
fn parent_query(&self, element: &Self::Type, query: &mut QueryRef) -> bool;
|
||||
fn parent_query(&self, query: &mut QueryRef) -> bool;
|
||||
|
||||
fn parent_set_context(&self, element: &Self::Type, context: &crate::Context);
|
||||
fn parent_set_context(&self, context: &crate::Context);
|
||||
|
||||
fn parent_set_clock(&self, element: &Self::Type, clock: Option<&crate::Clock>) -> bool;
|
||||
fn parent_set_clock(&self, clock: Option<&crate::Clock>) -> bool;
|
||||
|
||||
fn parent_provide_clock(&self, element: &Self::Type) -> Option<crate::Clock>;
|
||||
fn parent_provide_clock(&self) -> Option<crate::Clock>;
|
||||
|
||||
fn parent_post_message(&self, element: &Self::Type, msg: crate::Message) -> bool;
|
||||
fn parent_post_message(&self, msg: crate::Message) -> bool;
|
||||
|
||||
fn panicked(&self) -> &atomic::AtomicBool;
|
||||
|
||||
|
@ -168,7 +164,7 @@ pub trait ElementImplExt: ObjectSubclass {
|
|||
f: F,
|
||||
) -> R;
|
||||
|
||||
fn catch_panic_pad_function<R, F: FnOnce(&Self, &Self::Type) -> R, G: FnOnce() -> R>(
|
||||
fn catch_panic_pad_function<R, F: FnOnce(&Self) -> R, G: FnOnce() -> R>(
|
||||
parent: Option<&crate::Object>,
|
||||
fallback: G,
|
||||
f: F,
|
||||
|
@ -180,7 +176,6 @@ pub trait ElementImplExt: ObjectSubclass {
|
|||
impl<T: ElementImpl> ElementImplExt for T {
|
||||
fn parent_change_state(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
transition: StateChange,
|
||||
) -> Result<StateChangeSuccess, StateChangeError> {
|
||||
unsafe {
|
||||
|
@ -191,7 +186,10 @@ impl<T: ElementImpl> ElementImplExt for T {
|
|||
.change_state
|
||||
.expect("Missing parent function `change_state`");
|
||||
try_from_glib(f(
|
||||
element.unsafe_cast_ref::<Element>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<Element>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
transition.into_glib(),
|
||||
))
|
||||
}
|
||||
|
@ -199,7 +197,6 @@ impl<T: ElementImpl> ElementImplExt for T {
|
|||
|
||||
fn parent_request_new_pad(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
templ: &crate::PadTemplate,
|
||||
name: Option<String>,
|
||||
caps: Option<&crate::Caps>,
|
||||
|
@ -212,7 +209,10 @@ impl<T: ElementImpl> ElementImplExt for T {
|
|||
.request_new_pad
|
||||
.map(|f| {
|
||||
from_glib_none(f(
|
||||
element.unsafe_cast_ref::<Element>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<Element>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
templ.to_glib_none().0,
|
||||
name.to_glib_full(),
|
||||
caps.to_glib_none().0,
|
||||
|
@ -222,7 +222,7 @@ impl<T: ElementImpl> ElementImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_release_pad(&self, element: &Self::Type, pad: &crate::Pad) {
|
||||
fn parent_release_pad(&self, pad: &crate::Pad) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstElementClass;
|
||||
|
@ -231,7 +231,10 @@ impl<T: ElementImpl> ElementImplExt for T {
|
|||
.release_pad
|
||||
.map(|f| {
|
||||
f(
|
||||
element.unsafe_cast_ref::<Element>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<Element>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
pad.to_glib_none().0,
|
||||
)
|
||||
})
|
||||
|
@ -239,7 +242,7 @@ impl<T: ElementImpl> ElementImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_send_event(&self, element: &Self::Type, event: Event) -> bool {
|
||||
fn parent_send_event(&self, event: Event) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstElementClass;
|
||||
|
@ -248,7 +251,10 @@ impl<T: ElementImpl> ElementImplExt for T {
|
|||
.send_event
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<Element>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<Element>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
event.into_glib_ptr(),
|
||||
))
|
||||
})
|
||||
|
@ -256,7 +262,7 @@ impl<T: ElementImpl> ElementImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_query(&self, element: &Self::Type, query: &mut QueryRef) -> bool {
|
||||
fn parent_query(&self, query: &mut QueryRef) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstElementClass;
|
||||
|
@ -265,7 +271,10 @@ impl<T: ElementImpl> ElementImplExt for T {
|
|||
.query
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<Element>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<Element>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
query.as_mut_ptr(),
|
||||
))
|
||||
})
|
||||
|
@ -273,7 +282,7 @@ impl<T: ElementImpl> ElementImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_set_context(&self, element: &Self::Type, context: &crate::Context) {
|
||||
fn parent_set_context(&self, context: &crate::Context) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstElementClass;
|
||||
|
@ -282,7 +291,10 @@ impl<T: ElementImpl> ElementImplExt for T {
|
|||
.set_context
|
||||
.map(|f| {
|
||||
f(
|
||||
element.unsafe_cast_ref::<Element>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<Element>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
context.to_glib_none().0,
|
||||
)
|
||||
})
|
||||
|
@ -290,7 +302,7 @@ impl<T: ElementImpl> ElementImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_set_clock(&self, element: &Self::Type, clock: Option<&crate::Clock>) -> bool {
|
||||
fn parent_set_clock(&self, clock: Option<&crate::Clock>) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstElementClass;
|
||||
|
@ -299,7 +311,10 @@ impl<T: ElementImpl> ElementImplExt for T {
|
|||
.set_clock
|
||||
.map(|f| {
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<Element>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<Element>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
clock.to_glib_none().0,
|
||||
))
|
||||
})
|
||||
|
@ -307,26 +322,35 @@ impl<T: ElementImpl> ElementImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_provide_clock(&self, element: &Self::Type) -> Option<crate::Clock> {
|
||||
fn parent_provide_clock(&self) -> Option<crate::Clock> {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstElementClass;
|
||||
|
||||
(*parent_class)
|
||||
.provide_clock
|
||||
.map(|f| from_glib_none(f(element.unsafe_cast_ref::<Element>().to_glib_none().0)))
|
||||
.map(|f| {
|
||||
from_glib_none(f(self
|
||||
.instance()
|
||||
.unsafe_cast_ref::<Element>()
|
||||
.to_glib_none()
|
||||
.0))
|
||||
})
|
||||
.unwrap_or(None)
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_post_message(&self, element: &Self::Type, msg: crate::Message) -> bool {
|
||||
fn parent_post_message(&self, msg: crate::Message) -> bool {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstElementClass;
|
||||
|
||||
if let Some(f) = (*parent_class).post_message {
|
||||
from_glib(f(
|
||||
element.unsafe_cast_ref::<Element>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<Element>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
msg.into_glib_ptr(),
|
||||
))
|
||||
} else {
|
||||
|
@ -352,11 +376,11 @@ impl<T: ElementImpl> ElementImplExt for T {
|
|||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
|
||||
panic_to_error!(element, imp.panicked(), fallback(), { f(imp) })
|
||||
panic_to_error!(imp, fallback(), { f(imp) })
|
||||
}
|
||||
}
|
||||
|
||||
fn catch_panic_pad_function<R, F: FnOnce(&Self, &Self::Type) -> R, G: FnOnce() -> R>(
|
||||
fn catch_panic_pad_function<R, F: FnOnce(&Self) -> R, G: FnOnce() -> R>(
|
||||
parent: Option<&crate::Object>,
|
||||
fallback: G,
|
||||
f: F,
|
||||
|
@ -368,9 +392,7 @@ impl<T: ElementImpl> ElementImplExt for T {
|
|||
let instance = &*(ptr as *mut Self::Instance);
|
||||
let imp = instance.imp();
|
||||
|
||||
panic_to_error!(wrap, imp.panicked(), fallback(), {
|
||||
f(imp, wrap.unsafe_cast_ref())
|
||||
})
|
||||
panic_to_error!(imp, fallback(), { f(imp) })
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -435,7 +457,6 @@ unsafe extern "C" fn element_change_state<T: ElementImpl>(
|
|||
) -> ffi::GstStateChangeReturn {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Element> = from_glib_borrow(ptr);
|
||||
|
||||
// *Never* fail downwards state changes, this causes bugs in GStreamer
|
||||
// and leads to crashes and deadlocks.
|
||||
|
@ -447,10 +468,7 @@ unsafe extern "C" fn element_change_state<T: ElementImpl>(
|
|||
_ => StateChangeReturn::Failure,
|
||||
};
|
||||
|
||||
panic_to_error!(&wrap, imp.panicked(), fallback, {
|
||||
imp.change_state(wrap.unsafe_cast_ref(), transition).into()
|
||||
})
|
||||
.into_glib()
|
||||
panic_to_error!(imp, fallback, { imp.change_state(transition).into() }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn element_request_new_pad<T: ElementImpl>(
|
||||
|
@ -461,15 +479,13 @@ unsafe extern "C" fn element_request_new_pad<T: ElementImpl>(
|
|||
) -> *mut ffi::GstPad {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Element> = from_glib_borrow(ptr);
|
||||
|
||||
let caps = Option::<crate::Caps>::from_glib_borrow(caps);
|
||||
|
||||
// XXX: This is effectively unsafe but the best we can do
|
||||
// See https://bugzilla.gnome.org/show_bug.cgi?id=791193
|
||||
let pad = panic_to_error!(&wrap, imp.panicked(), None, {
|
||||
let pad = panic_to_error!(imp, None, {
|
||||
imp.request_new_pad(
|
||||
wrap.unsafe_cast_ref(),
|
||||
&from_glib_borrow(templ),
|
||||
from_glib_none(name),
|
||||
caps.as_ref().as_ref(),
|
||||
|
@ -495,7 +511,6 @@ unsafe extern "C" fn element_release_pad<T: ElementImpl>(
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Element> = from_glib_borrow(ptr);
|
||||
|
||||
// If we get a floating reference passed simply return here. It can't be stored inside this
|
||||
// element, and if we continued to use it we would take ownership of this floating reference.
|
||||
|
@ -505,9 +520,7 @@ unsafe extern "C" fn element_release_pad<T: ElementImpl>(
|
|||
return;
|
||||
}
|
||||
|
||||
panic_to_error!(&wrap, imp.panicked(), (), {
|
||||
imp.release_pad(wrap.unsafe_cast_ref(), &from_glib_none(pad))
|
||||
})
|
||||
panic_to_error!(imp, (), { imp.release_pad(&from_glib_none(pad)) })
|
||||
}
|
||||
|
||||
unsafe extern "C" fn element_send_event<T: ElementImpl>(
|
||||
|
@ -516,12 +529,8 @@ unsafe extern "C" fn element_send_event<T: ElementImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Element> = from_glib_borrow(ptr);
|
||||
|
||||
panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.send_event(wrap.unsafe_cast_ref(), from_glib_full(event))
|
||||
})
|
||||
.into_glib()
|
||||
panic_to_error!(imp, false, { imp.send_event(from_glib_full(event)) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn element_query<T: ElementImpl>(
|
||||
|
@ -530,13 +539,9 @@ unsafe extern "C" fn element_query<T: ElementImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Element> = from_glib_borrow(ptr);
|
||||
let query = QueryRef::from_mut_ptr(query);
|
||||
|
||||
panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.query(wrap.unsafe_cast_ref(), query)
|
||||
})
|
||||
.into_glib()
|
||||
panic_to_error!(imp, false, { imp.query(query) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn element_set_context<T: ElementImpl>(
|
||||
|
@ -545,11 +550,8 @@ unsafe extern "C" fn element_set_context<T: ElementImpl>(
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Element> = from_glib_borrow(ptr);
|
||||
|
||||
panic_to_error!(&wrap, imp.panicked(), (), {
|
||||
imp.set_context(wrap.unsafe_cast_ref(), &from_glib_borrow(context))
|
||||
})
|
||||
panic_to_error!(imp, (), { imp.set_context(&from_glib_borrow(context)) })
|
||||
}
|
||||
|
||||
unsafe extern "C" fn element_set_clock<T: ElementImpl>(
|
||||
|
@ -558,14 +560,10 @@ unsafe extern "C" fn element_set_clock<T: ElementImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Element> = from_glib_borrow(ptr);
|
||||
|
||||
let clock = Option::<crate::Clock>::from_glib_borrow(clock);
|
||||
|
||||
panic_to_error!(&wrap, imp.panicked(), false, {
|
||||
imp.set_clock(wrap.unsafe_cast_ref(), clock.as_ref().as_ref())
|
||||
})
|
||||
.into_glib()
|
||||
panic_to_error!(imp, false, { imp.set_clock(clock.as_ref().as_ref()) }).into_glib()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn element_provide_clock<T: ElementImpl>(
|
||||
|
@ -573,12 +571,8 @@ unsafe extern "C" fn element_provide_clock<T: ElementImpl>(
|
|||
) -> *mut ffi::GstClock {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Element> = from_glib_borrow(ptr);
|
||||
|
||||
panic_to_error!(&wrap, imp.panicked(), None, {
|
||||
imp.provide_clock(wrap.unsafe_cast_ref())
|
||||
})
|
||||
.to_glib_full()
|
||||
panic_to_error!(imp, None, { imp.provide_clock() }).to_glib_full()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn element_post_message<T: ElementImpl>(
|
||||
|
@ -587,12 +581,10 @@ unsafe extern "C" fn element_post_message<T: ElementImpl>(
|
|||
) -> glib::ffi::gboolean {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Element> = from_glib_borrow(ptr);
|
||||
|
||||
// Can't catch panics here as posting the error message would cause
|
||||
// this code to be called again recursively forever.
|
||||
imp.post_message(wrap.unsafe_cast_ref(), from_glib_full(msg))
|
||||
.into_glib()
|
||||
imp.post_message(from_glib_full(msg)).into_glib()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -616,46 +608,25 @@ mod tests {
|
|||
fn sink_chain(
|
||||
&self,
|
||||
_pad: &crate::Pad,
|
||||
_element: &super::TestElement,
|
||||
buffer: crate::Buffer,
|
||||
) -> Result<crate::FlowSuccess, crate::FlowError> {
|
||||
self.n_buffers.fetch_add(1, atomic::Ordering::SeqCst);
|
||||
self.srcpad.push(buffer)
|
||||
}
|
||||
|
||||
fn sink_event(
|
||||
&self,
|
||||
_pad: &crate::Pad,
|
||||
_element: &super::TestElement,
|
||||
event: crate::Event,
|
||||
) -> bool {
|
||||
fn sink_event(&self, _pad: &crate::Pad, event: crate::Event) -> bool {
|
||||
self.srcpad.push_event(event)
|
||||
}
|
||||
|
||||
fn sink_query(
|
||||
&self,
|
||||
_pad: &crate::Pad,
|
||||
_element: &super::TestElement,
|
||||
query: &mut crate::QueryRef,
|
||||
) -> bool {
|
||||
fn sink_query(&self, _pad: &crate::Pad, query: &mut crate::QueryRef) -> bool {
|
||||
self.srcpad.peer_query(query)
|
||||
}
|
||||
|
||||
fn src_event(
|
||||
&self,
|
||||
_pad: &crate::Pad,
|
||||
_element: &super::TestElement,
|
||||
event: crate::Event,
|
||||
) -> bool {
|
||||
fn src_event(&self, _pad: &crate::Pad, event: crate::Event) -> bool {
|
||||
self.sinkpad.push_event(event)
|
||||
}
|
||||
|
||||
fn src_query(
|
||||
&self,
|
||||
_pad: &crate::Pad,
|
||||
_element: &super::TestElement,
|
||||
query: &mut crate::QueryRef,
|
||||
) -> bool {
|
||||
fn src_query(&self, _pad: &crate::Pad, query: &mut crate::QueryRef) -> bool {
|
||||
self.sinkpad.peer_query(query)
|
||||
}
|
||||
}
|
||||
|
@ -673,21 +644,21 @@ mod tests {
|
|||
TestElement::catch_panic_pad_function(
|
||||
parent,
|
||||
|| Err(crate::FlowError::Error),
|
||||
|identity, element| identity.sink_chain(pad, element, buffer),
|
||||
|identity| identity.sink_chain(pad, buffer),
|
||||
)
|
||||
})
|
||||
.event_function(|pad, parent, event| {
|
||||
TestElement::catch_panic_pad_function(
|
||||
parent,
|
||||
|| false,
|
||||
|identity, element| identity.sink_event(pad, element, event),
|
||||
|identity| identity.sink_event(pad, event),
|
||||
)
|
||||
})
|
||||
.query_function(|pad, parent, query| {
|
||||
TestElement::catch_panic_pad_function(
|
||||
parent,
|
||||
|| false,
|
||||
|identity, element| identity.sink_query(pad, element, query),
|
||||
|identity| identity.sink_query(pad, query),
|
||||
)
|
||||
})
|
||||
.build();
|
||||
|
@ -698,14 +669,14 @@ mod tests {
|
|||
TestElement::catch_panic_pad_function(
|
||||
parent,
|
||||
|| false,
|
||||
|identity, element| identity.src_event(pad, element, event),
|
||||
|identity| identity.src_event(pad, event),
|
||||
)
|
||||
})
|
||||
.query_function(|pad, parent, query| {
|
||||
TestElement::catch_panic_pad_function(
|
||||
parent,
|
||||
|| false,
|
||||
|identity, element| identity.src_query(pad, element, query),
|
||||
|identity| identity.src_query(pad, query),
|
||||
)
|
||||
})
|
||||
.build();
|
||||
|
@ -720,9 +691,10 @@ mod tests {
|
|||
}
|
||||
|
||||
impl ObjectImpl for TestElement {
|
||||
fn constructed(&self, element: &Self::Type) {
|
||||
self.parent_constructed(element);
|
||||
fn constructed(&self) {
|
||||
self.parent_constructed();
|
||||
|
||||
let element = self.instance();
|
||||
element.add_pad(&self.sinkpad).unwrap();
|
||||
element.add_pad(&self.srcpad).unwrap();
|
||||
}
|
||||
|
@ -772,10 +744,9 @@ mod tests {
|
|||
|
||||
fn change_state(
|
||||
&self,
|
||||
element: &Self::Type,
|
||||
transition: crate::StateChange,
|
||||
) -> Result<crate::StateChangeSuccess, crate::StateChangeError> {
|
||||
let res = self.parent_change_state(element, transition)?;
|
||||
let res = self.parent_change_state(transition)?;
|
||||
|
||||
if transition == crate::StateChange::PausedToPlaying {
|
||||
self.reached_playing.store(true, atomic::Ordering::SeqCst);
|
||||
|
|
|
@ -7,15 +7,14 @@ use crate::FlowReturn;
|
|||
|
||||
#[macro_export]
|
||||
macro_rules! panic_to_error(
|
||||
($element:expr, $panicked:expr, $ret:expr, $code:block) => {{
|
||||
($imp:expr, $ret:expr, $code:block) => {{
|
||||
use std::panic::{self, AssertUnwindSafe};
|
||||
use std::sync::atomic::Ordering;
|
||||
use $crate::prelude::ElementExtManual;
|
||||
|
||||
#[allow(clippy::unused_unit)]
|
||||
{
|
||||
if $panicked.load(Ordering::Relaxed) {
|
||||
$element.post_error_message($crate::error_msg!($crate::LibraryError::Failed, ["Panicked"]));
|
||||
if $imp.panicked().load(Ordering::Relaxed) {
|
||||
$imp.post_error_message($crate::error_msg!($crate::LibraryError::Failed, ["Panicked"]));
|
||||
$ret
|
||||
} else {
|
||||
let result = panic::catch_unwind(AssertUnwindSafe(|| $code));
|
||||
|
@ -23,13 +22,13 @@ macro_rules! panic_to_error(
|
|||
match result {
|
||||
Ok(result) => result,
|
||||
Err(err) => {
|
||||
$panicked.store(true, Ordering::Relaxed);
|
||||
$imp.panicked().store(true, Ordering::Relaxed);
|
||||
if let Some(cause) = err.downcast_ref::<&str>() {
|
||||
$element.post_error_message($crate::error_msg!($crate::LibraryError::Failed, ["Panicked: {}", cause]));
|
||||
$imp.post_error_message($crate::error_msg!($crate::LibraryError::Failed, ["Panicked: {}", cause]));
|
||||
} else if let Some(cause) = err.downcast_ref::<String>() {
|
||||
$element.post_error_message($crate::error_msg!($crate::LibraryError::Failed, ["Panicked: {}", cause]));
|
||||
$imp.post_error_message($crate::error_msg!($crate::LibraryError::Failed, ["Panicked: {}", cause]));
|
||||
} else {
|
||||
$element.post_error_message($crate::error_msg!($crate::LibraryError::Failed, ["Panicked"]));
|
||||
$imp.post_error_message($crate::error_msg!($crate::LibraryError::Failed, ["Panicked"]));
|
||||
}
|
||||
$ret
|
||||
}
|
||||
|
|
|
@ -8,23 +8,23 @@ use glib::translate::*;
|
|||
use crate::Pad;
|
||||
|
||||
pub trait PadImpl: PadImplExt + GstObjectImpl + Send + Sync {
|
||||
fn linked(&self, pad: &Self::Type, peer: &Pad) {
|
||||
self.parent_linked(pad, peer)
|
||||
fn linked(&self, peer: &Pad) {
|
||||
self.parent_linked(peer)
|
||||
}
|
||||
|
||||
fn unlinked(&self, pad: &Self::Type, peer: &Pad) {
|
||||
self.parent_unlinked(pad, peer)
|
||||
fn unlinked(&self, peer: &Pad) {
|
||||
self.parent_unlinked(peer)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait PadImplExt: ObjectSubclass {
|
||||
fn parent_linked(&self, pad: &Self::Type, peer: &Pad);
|
||||
fn parent_linked(&self, peer: &Pad);
|
||||
|
||||
fn parent_unlinked(&self, pad: &Self::Type, peer: &Pad);
|
||||
fn parent_unlinked(&self, peer: &Pad);
|
||||
}
|
||||
|
||||
impl<T: PadImpl> PadImplExt for T {
|
||||
fn parent_linked(&self, pad: &Self::Type, peer: &Pad) {
|
||||
fn parent_linked(&self, peer: &Pad) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstPadClass;
|
||||
|
@ -33,7 +33,7 @@ impl<T: PadImpl> PadImplExt for T {
|
|||
.linked
|
||||
.map(|f| {
|
||||
f(
|
||||
pad.unsafe_cast_ref::<Pad>().to_glib_none().0,
|
||||
self.instance().unsafe_cast_ref::<Pad>().to_glib_none().0,
|
||||
peer.to_glib_none().0,
|
||||
)
|
||||
})
|
||||
|
@ -41,7 +41,7 @@ impl<T: PadImpl> PadImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_unlinked(&self, pad: &Self::Type, peer: &Pad) {
|
||||
fn parent_unlinked(&self, peer: &Pad) {
|
||||
unsafe {
|
||||
let data = Self::type_data();
|
||||
let parent_class = data.as_ref().parent_class() as *mut ffi::GstPadClass;
|
||||
|
@ -50,7 +50,7 @@ impl<T: PadImpl> PadImplExt for T {
|
|||
.unlinked
|
||||
.map(|f| {
|
||||
f(
|
||||
pad.unsafe_cast_ref::<Pad>().to_glib_none().0,
|
||||
self.instance().unsafe_cast_ref::<Pad>().to_glib_none().0,
|
||||
peer.to_glib_none().0,
|
||||
)
|
||||
})
|
||||
|
@ -71,17 +71,15 @@ unsafe impl<T: PadImpl> IsSubclassable<T> for Pad {
|
|||
unsafe extern "C" fn pad_linked<T: PadImpl>(ptr: *mut ffi::GstPad, peer: *mut ffi::GstPad) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Pad> = from_glib_borrow(ptr);
|
||||
|
||||
imp.linked(wrap.unsafe_cast_ref(), &from_glib_borrow(peer))
|
||||
imp.linked(&from_glib_borrow(peer))
|
||||
}
|
||||
|
||||
unsafe extern "C" fn pad_unlinked<T: PadImpl>(ptr: *mut ffi::GstPad, peer: *mut ffi::GstPad) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<Pad> = from_glib_borrow(ptr);
|
||||
|
||||
imp.unlinked(wrap.unsafe_cast_ref(), &from_glib_borrow(peer))
|
||||
imp.unlinked(&from_glib_borrow(peer))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -113,14 +111,14 @@ mod tests {
|
|||
impl GstObjectImpl for TestPad {}
|
||||
|
||||
impl PadImpl for TestPad {
|
||||
fn linked(&self, pad: &Self::Type, peer: &Pad) {
|
||||
fn linked(&self, peer: &Pad) {
|
||||
self.linked.store(true, atomic::Ordering::SeqCst);
|
||||
self.parent_linked(pad, peer)
|
||||
self.parent_linked(peer)
|
||||
}
|
||||
|
||||
fn unlinked(&self, pad: &Self::Type, peer: &Pad) {
|
||||
fn unlinked(&self, peer: &Pad) {
|
||||
self.unlinked.store(true, atomic::Ordering::SeqCst);
|
||||
self.parent_unlinked(pad, peer)
|
||||
self.parent_unlinked(peer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ use std::ptr;
|
|||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use glib::ffi::gpointer;
|
||||
use glib::prelude::*;
|
||||
use glib::subclass::prelude::*;
|
||||
use glib::translate::*;
|
||||
|
||||
|
@ -25,7 +24,7 @@ pub trait TaskPoolImpl: GstObjectImpl + Send + Sync {
|
|||
/// Prepare the task pool to accept tasks.
|
||||
///
|
||||
/// This defaults to doing nothing.
|
||||
fn prepare(&self, _task_pool: &Self::Type) -> Result<(), glib::Error> {
|
||||
fn prepare(&self) -> Result<(), glib::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -34,7 +33,7 @@ pub trait TaskPoolImpl: GstObjectImpl + Send + Sync {
|
|||
///
|
||||
/// This is mainly used internally to ensure proper cleanup of internal data structures in test
|
||||
/// suites.
|
||||
fn cleanup(&self, _task_pool: &Self::Type) {}
|
||||
fn cleanup(&self) {}
|
||||
|
||||
// rustdoc-stripper-ignore-next
|
||||
/// Deliver a task to the pool.
|
||||
|
@ -42,11 +41,7 @@ pub trait TaskPoolImpl: GstObjectImpl + Send + Sync {
|
|||
/// If returning `Ok`, you need to call the `func` eventually.
|
||||
///
|
||||
/// If returning `Err`, the `func` must be dropped without calling it.
|
||||
fn push(
|
||||
&self,
|
||||
task_pool: &Self::Type,
|
||||
func: TaskPoolFunction,
|
||||
) -> Result<Option<Self::Handle>, glib::Error>;
|
||||
fn push(&self, func: TaskPoolFunction) -> Result<Option<Self::Handle>, glib::Error>;
|
||||
}
|
||||
|
||||
unsafe impl<T: TaskPoolImpl> IsSubclassable<T> for TaskPool {
|
||||
|
@ -71,9 +66,8 @@ unsafe extern "C" fn task_pool_prepare<T: TaskPoolImpl>(
|
|||
) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<TaskPool> = from_glib_borrow(ptr);
|
||||
|
||||
match imp.prepare(wrap.unsafe_cast_ref()) {
|
||||
match imp.prepare() {
|
||||
Ok(()) => {}
|
||||
Err(err) => {
|
||||
if !error.is_null() {
|
||||
|
@ -86,9 +80,8 @@ unsafe extern "C" fn task_pool_prepare<T: TaskPoolImpl>(
|
|||
unsafe extern "C" fn task_pool_cleanup<T: TaskPoolImpl>(ptr: *mut ffi::GstTaskPool) {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<TaskPool> = from_glib_borrow(ptr);
|
||||
|
||||
imp.cleanup(wrap.unsafe_cast_ref());
|
||||
imp.cleanup();
|
||||
}
|
||||
|
||||
unsafe extern "C" fn task_pool_push<T: TaskPoolImpl>(
|
||||
|
@ -99,11 +92,10 @@ unsafe extern "C" fn task_pool_push<T: TaskPoolImpl>(
|
|||
) -> gpointer {
|
||||
let instance = &*(ptr as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
let wrap: Borrowed<TaskPool> = from_glib_borrow(ptr);
|
||||
|
||||
let func = TaskPoolFunction::new(func.expect("Tried to push null func"), user_data);
|
||||
|
||||
match imp.push(wrap.unsafe_cast_ref(), func.clone()) {
|
||||
match imp.push(func.clone()) {
|
||||
Ok(None) => ptr::null_mut(),
|
||||
Ok(Some(handle)) => Box::into_raw(Box::new(handle)) as gpointer,
|
||||
Err(err) => {
|
||||
|
@ -117,9 +109,8 @@ unsafe extern "C" fn task_pool_push<T: TaskPoolImpl>(
|
|||
}
|
||||
|
||||
unsafe extern "C" fn task_pool_join<T: TaskPoolImpl>(ptr: *mut ffi::GstTaskPool, id: gpointer) {
|
||||
let wrap: Borrowed<TaskPool> = from_glib_borrow(ptr);
|
||||
|
||||
if id.is_null() {
|
||||
let wrap: Borrowed<TaskPool> = from_glib_borrow(ptr);
|
||||
crate::warning!(crate::CAT_RUST, obj: wrap.as_ref(), "Tried to join null handle");
|
||||
return;
|
||||
}
|
||||
|
@ -134,9 +125,8 @@ unsafe extern "C" fn task_pool_dispose_handle<T: TaskPoolImpl>(
|
|||
ptr: *mut ffi::GstTaskPool,
|
||||
id: gpointer,
|
||||
) {
|
||||
let wrap: Borrowed<TaskPool> = from_glib_borrow(ptr);
|
||||
|
||||
if id.is_null() {
|
||||
let wrap: Borrowed<TaskPool> = from_glib_borrow(ptr);
|
||||
crate::warning!(crate::CAT_RUST, obj: wrap.as_ref(), "Tried to dispose null handle");
|
||||
return;
|
||||
}
|
||||
|
@ -270,20 +260,16 @@ mod tests {
|
|||
impl TaskPoolImpl for TestPool {
|
||||
type Handle = TestHandle;
|
||||
|
||||
fn prepare(&self, _task_pool: &Self::Type) -> Result<(), glib::Error> {
|
||||
fn prepare(&self) -> Result<(), glib::Error> {
|
||||
self.prepared.store(true, atomic::Ordering::SeqCst);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn cleanup(&self, _task_pool: &Self::Type) {
|
||||
fn cleanup(&self) {
|
||||
self.cleaned_up.store(true, atomic::Ordering::SeqCst);
|
||||
}
|
||||
|
||||
fn push(
|
||||
&self,
|
||||
_task_pool: &Self::Type,
|
||||
func: TaskPoolFunction,
|
||||
) -> Result<Option<Self::Handle>, glib::Error> {
|
||||
fn push(&self, func: TaskPoolFunction) -> Result<Option<Self::Handle>, glib::Error> {
|
||||
let handle = thread::spawn(move || func.call());
|
||||
Ok(Some(TestHandle(handle)))
|
||||
}
|
||||
|
|
|
@ -13,14 +13,14 @@ use std::ptr;
|
|||
pub trait URIHandlerImpl: super::element::ElementImpl {
|
||||
const URI_TYPE: URIType;
|
||||
fn protocols() -> &'static [&'static str];
|
||||
fn uri(&self, element: &Self::Type) -> Option<String>;
|
||||
fn set_uri(&self, element: &Self::Type, uri: &str) -> Result<(), glib::Error>;
|
||||
fn uri(&self) -> Option<String>;
|
||||
fn set_uri(&self, uri: &str) -> Result<(), glib::Error>;
|
||||
}
|
||||
|
||||
pub trait URIHandlerImplExt: ObjectSubclass {
|
||||
fn parent_protocols() -> Vec<String>;
|
||||
fn parent_uri(&self, element: &Self::Type) -> Option<String>;
|
||||
fn parent_set_uri(&self, element: &Self::Type, uri: &str) -> Result<(), glib::Error>;
|
||||
fn parent_uri(&self) -> Option<String>;
|
||||
fn parent_set_uri(&self, uri: &str) -> Result<(), glib::Error>;
|
||||
}
|
||||
|
||||
impl<T: URIHandlerImpl> URIHandlerImplExt for T {
|
||||
|
@ -38,7 +38,7 @@ impl<T: URIHandlerImpl> URIHandlerImplExt for T {
|
|||
}
|
||||
}
|
||||
|
||||
fn parent_uri(&self, element: &Self::Type) -> Option<String> {
|
||||
fn parent_uri(&self) -> Option<String> {
|
||||
unsafe {
|
||||
let type_data = Self::type_data();
|
||||
let parent_iface = type_data.as_ref().parent_interface::<URIHandler>()
|
||||
|
@ -47,12 +47,17 @@ impl<T: URIHandlerImpl> URIHandlerImplExt for T {
|
|||
let func = (*parent_iface)
|
||||
.get_uri
|
||||
.expect("no parent \"uri\" implementation");
|
||||
let ret = func(element.unsafe_cast_ref::<URIHandler>().to_glib_none().0);
|
||||
let ret = func(
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<URIHandler>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
);
|
||||
from_glib_full(ret)
|
||||
}
|
||||
}
|
||||
|
||||
fn parent_set_uri(&self, element: &Self::Type, uri: &str) -> Result<(), glib::Error> {
|
||||
fn parent_set_uri(&self, uri: &str) -> Result<(), glib::Error> {
|
||||
unsafe {
|
||||
let type_data = Self::type_data();
|
||||
let parent_iface = type_data.as_ref().parent_interface::<URIHandler>()
|
||||
|
@ -64,7 +69,10 @@ impl<T: URIHandlerImpl> URIHandlerImplExt for T {
|
|||
|
||||
let mut err = ptr::null_mut();
|
||||
func(
|
||||
element.unsafe_cast_ref::<URIHandler>().to_glib_none().0,
|
||||
self.instance()
|
||||
.unsafe_cast_ref::<URIHandler>()
|
||||
.to_glib_none()
|
||||
.0,
|
||||
uri.to_glib_none().0,
|
||||
&mut err,
|
||||
);
|
||||
|
@ -126,8 +134,7 @@ unsafe extern "C" fn uri_handler_get_uri<T: URIHandlerImpl>(
|
|||
let instance = &*(uri_handler as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
|
||||
imp.uri(from_glib_borrow::<_, URIHandler>(uri_handler).unsafe_cast_ref())
|
||||
.to_glib_full()
|
||||
imp.uri().to_glib_full()
|
||||
}
|
||||
|
||||
unsafe extern "C" fn uri_handler_set_uri<T: URIHandlerImpl>(
|
||||
|
@ -138,10 +145,7 @@ unsafe extern "C" fn uri_handler_set_uri<T: URIHandlerImpl>(
|
|||
let instance = &*(uri_handler as *mut T::Instance);
|
||||
let imp = instance.imp();
|
||||
|
||||
match imp.set_uri(
|
||||
from_glib_borrow::<_, URIHandler>(uri_handler).unsafe_cast_ref(),
|
||||
glib::GString::from_glib_borrow(uri).as_str(),
|
||||
) {
|
||||
match imp.set_uri(glib::GString::from_glib_borrow(uri).as_str()) {
|
||||
Ok(()) => true.into_glib(),
|
||||
Err(error) => {
|
||||
if !err.is_null() {
|
||||
|
|
Loading…
Reference in a new issue