mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-01-11 01:35:26 +00:00
Change various mini object references to references to the refcounted object
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/204
This commit is contained in:
parent
e6f65a5032
commit
6cef32a4dd
15 changed files with 264 additions and 227 deletions
|
@ -641,7 +641,7 @@ fn main_loop(mut app: App) -> Result<glutin::WindowedContext<glutin::PossiblyCur
|
||||||
|
|
||||||
// get the last frame in channel
|
// get the last frame in channel
|
||||||
if let Some(sample) = receiver.try_iter().last() {
|
if let Some(sample) = receiver.try_iter().last() {
|
||||||
let buffer = sample.get_buffer().unwrap();
|
let buffer = sample.get_buffer_owned().unwrap();
|
||||||
let info = sample
|
let info = sample
|
||||||
.get_caps()
|
.get_caps()
|
||||||
.and_then(|caps| gst_video::VideoInfo::from_caps(caps))
|
.and_then(|caps| gst_video::VideoInfo::from_caps(caps))
|
||||||
|
@ -660,9 +660,7 @@ fn main_loop(mut app: App) -> Result<glutin::WindowedContext<glutin::PossiblyCur
|
||||||
sync_meta.set_sync_point(gst_gl_context.as_ref().unwrap());
|
sync_meta.set_sync_point(gst_gl_context.as_ref().unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(frame) =
|
if let Ok(frame) = gst_video::VideoFrame::from_buffer_readable_gl(buffer, &info) {
|
||||||
gst_video::VideoFrame::from_buffer_readable_gl(buffer.to_owned(), &info)
|
|
||||||
{
|
|
||||||
curr_frame = Some(frame);
|
curr_frame = Some(frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl + Send + Sync + 'stati
|
||||||
aggregator: &Aggregator,
|
aggregator: &Aggregator,
|
||||||
templ: &gst::PadTemplate,
|
templ: &gst::PadTemplate,
|
||||||
req_name: Option<&str>,
|
req_name: Option<&str>,
|
||||||
caps: Option<&gst::CapsRef>,
|
caps: Option<&gst::Caps>,
|
||||||
) -> Option<AggregatorPad> {
|
) -> Option<AggregatorPad> {
|
||||||
self.parent_create_new_pad(aggregator, templ, req_name, caps)
|
self.parent_create_new_pad(aggregator, templ, req_name, caps)
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl + Send + Sync + 'stati
|
||||||
fn update_src_caps(
|
fn update_src_caps(
|
||||||
&self,
|
&self,
|
||||||
aggregator: &Aggregator,
|
aggregator: &Aggregator,
|
||||||
caps: &gst::CapsRef,
|
caps: &gst::Caps,
|
||||||
) -> Result<gst::Caps, gst::FlowError> {
|
) -> Result<gst::Caps, gst::FlowError> {
|
||||||
self.parent_update_src_caps(aggregator, caps)
|
self.parent_update_src_caps(aggregator, caps)
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ pub trait AggregatorImpl: AggregatorImplExt + ElementImpl + Send + Sync + 'stati
|
||||||
fn negotiated_src_caps(
|
fn negotiated_src_caps(
|
||||||
&self,
|
&self,
|
||||||
aggregator: &Aggregator,
|
aggregator: &Aggregator,
|
||||||
caps: &gst::CapsRef,
|
caps: &gst::Caps,
|
||||||
) -> Result<(), gst::LoggableError> {
|
) -> Result<(), gst::LoggableError> {
|
||||||
self.parent_negotiated_src_caps(aggregator, caps)
|
self.parent_negotiated_src_caps(aggregator, caps)
|
||||||
}
|
}
|
||||||
|
@ -189,13 +189,13 @@ pub trait AggregatorImplExt {
|
||||||
aggregator: &Aggregator,
|
aggregator: &Aggregator,
|
||||||
templ: &gst::PadTemplate,
|
templ: &gst::PadTemplate,
|
||||||
req_name: Option<&str>,
|
req_name: Option<&str>,
|
||||||
caps: Option<&gst::CapsRef>,
|
caps: Option<&gst::Caps>,
|
||||||
) -> Option<AggregatorPad>;
|
) -> Option<AggregatorPad>;
|
||||||
|
|
||||||
fn parent_update_src_caps(
|
fn parent_update_src_caps(
|
||||||
&self,
|
&self,
|
||||||
aggregator: &Aggregator,
|
aggregator: &Aggregator,
|
||||||
caps: &gst::CapsRef,
|
caps: &gst::Caps,
|
||||||
) -> Result<gst::Caps, gst::FlowError>;
|
) -> Result<gst::Caps, gst::FlowError>;
|
||||||
|
|
||||||
fn parent_fixate_src_caps(&self, aggregator: &Aggregator, caps: gst::Caps) -> gst::Caps;
|
fn parent_fixate_src_caps(&self, aggregator: &Aggregator, caps: gst::Caps) -> gst::Caps;
|
||||||
|
@ -203,7 +203,7 @@ pub trait AggregatorImplExt {
|
||||||
fn parent_negotiated_src_caps(
|
fn parent_negotiated_src_caps(
|
||||||
&self,
|
&self,
|
||||||
aggregator: &Aggregator,
|
aggregator: &Aggregator,
|
||||||
caps: &gst::CapsRef,
|
caps: &gst::Caps,
|
||||||
) -> Result<(), gst::LoggableError>;
|
) -> Result<(), gst::LoggableError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -426,7 +426,7 @@ impl<T: AggregatorImpl + ObjectImpl> AggregatorImplExt for T {
|
||||||
aggregator: &Aggregator,
|
aggregator: &Aggregator,
|
||||||
templ: &gst::PadTemplate,
|
templ: &gst::PadTemplate,
|
||||||
req_name: Option<&str>,
|
req_name: Option<&str>,
|
||||||
caps: Option<&gst::CapsRef>,
|
caps: Option<&gst::Caps>,
|
||||||
) -> Option<AggregatorPad> {
|
) -> Option<AggregatorPad> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = self.get_type_data();
|
let data = self.get_type_data();
|
||||||
|
@ -439,7 +439,7 @@ impl<T: AggregatorImpl + ObjectImpl> AggregatorImplExt for T {
|
||||||
aggregator.to_glib_none().0,
|
aggregator.to_glib_none().0,
|
||||||
templ.to_glib_none().0,
|
templ.to_glib_none().0,
|
||||||
req_name.to_glib_none().0,
|
req_name.to_glib_none().0,
|
||||||
caps.map(|c| c.as_ptr()).unwrap_or(ptr::null()),
|
caps.to_glib_none().0,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -447,7 +447,7 @@ impl<T: AggregatorImpl + ObjectImpl> AggregatorImplExt for T {
|
||||||
fn parent_update_src_caps(
|
fn parent_update_src_caps(
|
||||||
&self,
|
&self,
|
||||||
aggregator: &Aggregator,
|
aggregator: &Aggregator,
|
||||||
caps: &gst::CapsRef,
|
caps: &gst::Caps,
|
||||||
) -> Result<gst::Caps, gst::FlowError> {
|
) -> Result<gst::Caps, gst::FlowError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = self.get_type_data();
|
let data = self.get_type_data();
|
||||||
|
@ -483,7 +483,7 @@ impl<T: AggregatorImpl + ObjectImpl> AggregatorImplExt for T {
|
||||||
fn parent_negotiated_src_caps(
|
fn parent_negotiated_src_caps(
|
||||||
&self,
|
&self,
|
||||||
aggregator: &Aggregator,
|
aggregator: &Aggregator,
|
||||||
caps: &gst::CapsRef,
|
caps: &gst::Caps,
|
||||||
) -> Result<(), gst::LoggableError> {
|
) -> Result<(), gst::LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = self.get_type_data();
|
let data = self.get_type_data();
|
||||||
|
@ -493,7 +493,7 @@ impl<T: AggregatorImpl + ObjectImpl> AggregatorImplExt for T {
|
||||||
.negotiated_src_caps
|
.negotiated_src_caps
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(aggregator.to_glib_none().0, caps.as_mut_ptr()),
|
f(aggregator.to_glib_none().0, caps.to_glib_none().0),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"Parent function `negotiated_src_caps` failed"
|
"Parent function `negotiated_src_caps` failed"
|
||||||
)
|
)
|
||||||
|
@ -822,11 +822,7 @@ where
|
||||||
&wrap,
|
&wrap,
|
||||||
&from_glib_borrow(templ),
|
&from_glib_borrow(templ),
|
||||||
req_name,
|
req_name,
|
||||||
if caps.is_null() {
|
Option::<gst::Caps>::from_glib_borrow(caps).as_ref(),
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(gst::CapsRef::from_ptr(caps))
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.to_glib_full()
|
.to_glib_full()
|
||||||
|
@ -849,7 +845,7 @@ where
|
||||||
*res = ptr::null_mut();
|
*res = ptr::null_mut();
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||||
match imp.update_src_caps(&wrap, gst::CapsRef::from_ptr(caps)) {
|
match imp.update_src_caps(&wrap, &from_glib_borrow(caps)) {
|
||||||
Ok(res_caps) => {
|
Ok(res_caps) => {
|
||||||
*res = res_caps.into_ptr();
|
*res = res_caps.into_ptr();
|
||||||
gst::FlowReturn::Ok
|
gst::FlowReturn::Ok
|
||||||
|
@ -893,7 +889,7 @@ where
|
||||||
let wrap: Aggregator = from_glib_borrow(ptr);
|
let wrap: Aggregator = from_glib_borrow(ptr);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.negotiated_src_caps(&wrap, gst::CapsRef::from_ptr(caps)) {
|
match imp.negotiated_src_caps(&wrap, &from_glib_borrow(caps)) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&wrap);
|
err.log_with_object(&wrap);
|
||||||
|
|
|
@ -34,7 +34,7 @@ pub trait AggregatorPadImpl: AggregatorPadImplExt + PadImpl + Send + Sync + 'sta
|
||||||
&self,
|
&self,
|
||||||
aggregator_pad: &AggregatorPad,
|
aggregator_pad: &AggregatorPad,
|
||||||
aggregator: &Aggregator,
|
aggregator: &Aggregator,
|
||||||
buffer: &gst::BufferRef,
|
buffer: &gst::Buffer,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
self.parent_skip_buffer(aggregator_pad, aggregator, buffer)
|
self.parent_skip_buffer(aggregator_pad, aggregator, buffer)
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ pub trait AggregatorPadImplExt {
|
||||||
&self,
|
&self,
|
||||||
aggregator_pad: &AggregatorPad,
|
aggregator_pad: &AggregatorPad,
|
||||||
aggregator: &Aggregator,
|
aggregator: &Aggregator,
|
||||||
buffer: &gst::BufferRef,
|
buffer: &gst::Buffer,
|
||||||
) -> bool;
|
) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ impl<T: AggregatorPadImpl + ObjectImpl> AggregatorPadImplExt for T {
|
||||||
&self,
|
&self,
|
||||||
aggregator_pad: &AggregatorPad,
|
aggregator_pad: &AggregatorPad,
|
||||||
aggregator: &Aggregator,
|
aggregator: &Aggregator,
|
||||||
buffer: &gst::BufferRef,
|
buffer: &gst::Buffer,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = self.get_type_data();
|
let data = self.get_type_data();
|
||||||
|
@ -94,7 +94,7 @@ impl<T: AggregatorPadImpl + ObjectImpl> AggregatorPadImplExt for T {
|
||||||
from_glib(f(
|
from_glib(f(
|
||||||
aggregator_pad.to_glib_none().0,
|
aggregator_pad.to_glib_none().0,
|
||||||
aggregator.to_glib_none().0,
|
aggregator.to_glib_none().0,
|
||||||
buffer.as_mut_ptr(),
|
buffer.to_glib_none().0,
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
|
@ -144,7 +144,7 @@ where
|
||||||
imp.skip_buffer(
|
imp.skip_buffer(
|
||||||
&wrap,
|
&wrap,
|
||||||
&from_glib_borrow(aggregator),
|
&from_glib_borrow(aggregator),
|
||||||
gst::BufferRef::from_ptr(buffer),
|
&from_glib_borrow(buffer),
|
||||||
)
|
)
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,13 +34,13 @@ pub trait BaseSinkImpl: BaseSinkImplExt + ElementImpl + Send + Sync + 'static {
|
||||||
fn render(
|
fn render(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseSink,
|
element: &BaseSink,
|
||||||
buffer: &gst::BufferRef,
|
buffer: &gst::Buffer,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||||
|
|
||||||
fn prepare(
|
fn prepare(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseSink,
|
element: &BaseSink,
|
||||||
buffer: &gst::BufferRef,
|
buffer: &gst::Buffer,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
self.parent_prepare(element, buffer)
|
self.parent_prepare(element, buffer)
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ pub trait BaseSinkImpl: BaseSinkImplExt + ElementImpl + Send + Sync + 'static {
|
||||||
fn render_list(
|
fn render_list(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseSink,
|
element: &BaseSink,
|
||||||
list: &gst::BufferListRef,
|
list: &gst::BufferList,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
self.parent_render_list(element, list)
|
self.parent_render_list(element, list)
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ pub trait BaseSinkImpl: BaseSinkImplExt + ElementImpl + Send + Sync + 'static {
|
||||||
fn prepare_list(
|
fn prepare_list(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseSink,
|
element: &BaseSink,
|
||||||
list: &gst::BufferListRef,
|
list: &gst::BufferList,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
self.parent_prepare_list(element, list)
|
self.parent_prepare_list(element, list)
|
||||||
}
|
}
|
||||||
|
@ -69,11 +69,11 @@ pub trait BaseSinkImpl: BaseSinkImplExt + ElementImpl + Send + Sync + 'static {
|
||||||
self.parent_event(element, event)
|
self.parent_event(element, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_caps(&self, element: &BaseSink, filter: Option<&gst::CapsRef>) -> Option<gst::Caps> {
|
fn get_caps(&self, element: &BaseSink, filter: Option<&gst::Caps>) -> Option<gst::Caps> {
|
||||||
self.parent_get_caps(element, filter)
|
self.parent_get_caps(element, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_caps(&self, element: &BaseSink, caps: &gst::CapsRef) -> Result<(), gst::LoggableError> {
|
fn set_caps(&self, element: &BaseSink, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||||
self.parent_set_caps(element, caps)
|
self.parent_set_caps(element, caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,41 +98,37 @@ pub trait BaseSinkImplExt {
|
||||||
fn parent_render(
|
fn parent_render(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseSink,
|
element: &BaseSink,
|
||||||
buffer: &gst::BufferRef,
|
buffer: &gst::Buffer,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||||
|
|
||||||
fn parent_prepare(
|
fn parent_prepare(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseSink,
|
element: &BaseSink,
|
||||||
buffer: &gst::BufferRef,
|
buffer: &gst::Buffer,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||||
|
|
||||||
fn parent_render_list(
|
fn parent_render_list(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseSink,
|
element: &BaseSink,
|
||||||
list: &gst::BufferListRef,
|
list: &gst::BufferList,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||||
|
|
||||||
fn parent_prepare_list(
|
fn parent_prepare_list(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseSink,
|
element: &BaseSink,
|
||||||
list: &gst::BufferListRef,
|
list: &gst::BufferList,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||||
|
|
||||||
fn parent_query(&self, element: &BaseSink, query: &mut gst::QueryRef) -> bool;
|
fn parent_query(&self, element: &BaseSink, query: &mut gst::QueryRef) -> bool;
|
||||||
|
|
||||||
fn parent_event(&self, element: &BaseSink, event: gst::Event) -> bool;
|
fn parent_event(&self, element: &BaseSink, event: gst::Event) -> bool;
|
||||||
|
|
||||||
fn parent_get_caps(
|
fn parent_get_caps(&self, element: &BaseSink, filter: Option<&gst::Caps>) -> Option<gst::Caps>;
|
||||||
&self,
|
|
||||||
element: &BaseSink,
|
|
||||||
filter: Option<&gst::CapsRef>,
|
|
||||||
) -> Option<gst::Caps>;
|
|
||||||
|
|
||||||
fn parent_set_caps(
|
fn parent_set_caps(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseSink,
|
element: &BaseSink,
|
||||||
caps: &gst::CapsRef,
|
caps: &gst::Caps,
|
||||||
) -> Result<(), gst::LoggableError>;
|
) -> Result<(), gst::LoggableError>;
|
||||||
|
|
||||||
fn parent_fixate(&self, element: &BaseSink, caps: gst::Caps) -> gst::Caps;
|
fn parent_fixate(&self, element: &BaseSink, caps: gst::Caps) -> gst::Caps;
|
||||||
|
@ -188,7 +184,7 @@ impl<T: BaseSinkImpl + ObjectImpl> BaseSinkImplExt for T {
|
||||||
fn parent_render(
|
fn parent_render(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseSink,
|
element: &BaseSink,
|
||||||
buffer: &gst::BufferRef,
|
buffer: &gst::Buffer,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = self.get_type_data();
|
let data = self.get_type_data();
|
||||||
|
@ -197,7 +193,7 @@ impl<T: BaseSinkImpl + ObjectImpl> BaseSinkImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.render
|
.render
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst::FlowReturn::from_glib(f(element.to_glib_none().0, buffer.as_mut_ptr()))
|
gst::FlowReturn::from_glib(f(element.to_glib_none().0, buffer.to_glib_none().0))
|
||||||
})
|
})
|
||||||
.unwrap_or(gst::FlowReturn::Ok)
|
.unwrap_or(gst::FlowReturn::Ok)
|
||||||
.into_result()
|
.into_result()
|
||||||
|
@ -207,7 +203,7 @@ impl<T: BaseSinkImpl + ObjectImpl> BaseSinkImplExt for T {
|
||||||
fn parent_prepare(
|
fn parent_prepare(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseSink,
|
element: &BaseSink,
|
||||||
buffer: &gst::BufferRef,
|
buffer: &gst::Buffer,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = self.get_type_data();
|
let data = self.get_type_data();
|
||||||
|
@ -215,7 +211,7 @@ impl<T: BaseSinkImpl + ObjectImpl> BaseSinkImplExt for T {
|
||||||
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseSinkClass;
|
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseSinkClass;
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.prepare
|
.prepare
|
||||||
.map(|f| from_glib(f(element.to_glib_none().0, buffer.as_mut_ptr())))
|
.map(|f| from_glib(f(element.to_glib_none().0, buffer.to_glib_none().0)))
|
||||||
.unwrap_or(gst::FlowReturn::Ok)
|
.unwrap_or(gst::FlowReturn::Ok)
|
||||||
.into_result()
|
.into_result()
|
||||||
}
|
}
|
||||||
|
@ -224,7 +220,7 @@ impl<T: BaseSinkImpl + ObjectImpl> BaseSinkImplExt for T {
|
||||||
fn parent_render_list(
|
fn parent_render_list(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseSink,
|
element: &BaseSink,
|
||||||
list: &gst::BufferListRef,
|
list: &gst::BufferList,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = self.get_type_data();
|
let data = self.get_type_data();
|
||||||
|
@ -233,12 +229,12 @@ impl<T: BaseSinkImpl + ObjectImpl> BaseSinkImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.render_list
|
.render_list
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst::FlowReturn::from_glib(f(element.to_glib_none().0, list.as_mut_ptr()))
|
gst::FlowReturn::from_glib(f(element.to_glib_none().0, list.to_glib_none().0))
|
||||||
.into_result()
|
.into_result()
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
for buffer in list.iter() {
|
for buffer in list.iter() {
|
||||||
self.render(element, buffer)?;
|
self.render(element, &from_glib_borrow(buffer.as_ptr()))?;
|
||||||
}
|
}
|
||||||
Ok(gst::FlowSuccess::Ok)
|
Ok(gst::FlowSuccess::Ok)
|
||||||
})
|
})
|
||||||
|
@ -248,7 +244,7 @@ impl<T: BaseSinkImpl + ObjectImpl> BaseSinkImplExt for T {
|
||||||
fn parent_prepare_list(
|
fn parent_prepare_list(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseSink,
|
element: &BaseSink,
|
||||||
list: &gst::BufferListRef,
|
list: &gst::BufferList,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = self.get_type_data();
|
let data = self.get_type_data();
|
||||||
|
@ -257,12 +253,12 @@ impl<T: BaseSinkImpl + ObjectImpl> BaseSinkImplExt for T {
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.prepare_list
|
.prepare_list
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst::FlowReturn::from_glib(f(element.to_glib_none().0, list.as_mut_ptr()))
|
gst::FlowReturn::from_glib(f(element.to_glib_none().0, list.to_glib_none().0))
|
||||||
.into_result()
|
.into_result()
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| {
|
.unwrap_or_else(|| {
|
||||||
for buffer in list.iter() {
|
for buffer in list.iter() {
|
||||||
self.prepare(element, buffer)?;
|
self.prepare(element, &from_glib_borrow(buffer.as_ptr()))?;
|
||||||
}
|
}
|
||||||
Ok(gst::FlowSuccess::Ok)
|
Ok(gst::FlowSuccess::Ok)
|
||||||
})
|
})
|
||||||
|
@ -293,24 +289,15 @@ impl<T: BaseSinkImpl + ObjectImpl> BaseSinkImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_get_caps(
|
fn parent_get_caps(&self, element: &BaseSink, filter: Option<&gst::Caps>) -> Option<gst::Caps> {
|
||||||
&self,
|
|
||||||
element: &BaseSink,
|
|
||||||
filter: Option<&gst::CapsRef>,
|
|
||||||
) -> Option<gst::Caps> {
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = self.get_type_data();
|
let data = self.get_type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseSinkClass;
|
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseSinkClass;
|
||||||
let filter_ptr = if let Some(filter) = filter {
|
|
||||||
filter.as_mut_ptr()
|
|
||||||
} else {
|
|
||||||
ptr::null_mut()
|
|
||||||
};
|
|
||||||
|
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.get_caps
|
.get_caps
|
||||||
.map(|f| from_glib_full(f(element.to_glib_none().0, filter_ptr)))
|
.map(|f| from_glib_full(f(element.to_glib_none().0, filter.to_glib_none().0)))
|
||||||
.unwrap_or(None)
|
.unwrap_or(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,7 +305,7 @@ impl<T: BaseSinkImpl + ObjectImpl> BaseSinkImplExt for T {
|
||||||
fn parent_set_caps(
|
fn parent_set_caps(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseSink,
|
element: &BaseSink,
|
||||||
caps: &gst::CapsRef,
|
caps: &gst::Caps,
|
||||||
) -> Result<(), gst::LoggableError> {
|
) -> Result<(), gst::LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = self.get_type_data();
|
let data = self.get_type_data();
|
||||||
|
@ -328,7 +315,7 @@ impl<T: BaseSinkImpl + ObjectImpl> BaseSinkImplExt for T {
|
||||||
.set_caps
|
.set_caps
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(element.to_glib_none().0, caps.as_mut_ptr()),
|
f(element.to_glib_none().0, caps.to_glib_none().0),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"Parent function `set_caps` failed"
|
"Parent function `set_caps` failed"
|
||||||
)
|
)
|
||||||
|
@ -478,10 +465,10 @@ where
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut T::Instance);
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: BaseSink = from_glib_borrow(ptr);
|
let wrap: BaseSink = from_glib_borrow(ptr);
|
||||||
let buffer = gst::BufferRef::from_ptr(buffer);
|
let buffer = from_glib_borrow(buffer);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||||
imp.render(&wrap, buffer).into()
|
imp.render(&wrap, &buffer).into()
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -498,10 +485,10 @@ where
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut T::Instance);
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: BaseSink = from_glib_borrow(ptr);
|
let wrap: BaseSink = from_glib_borrow(ptr);
|
||||||
let buffer = gst::BufferRef::from_ptr(buffer);
|
let buffer = from_glib_borrow(buffer);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||||
imp.prepare(&wrap, buffer).into()
|
imp.prepare(&wrap, &buffer).into()
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -518,10 +505,10 @@ where
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut T::Instance);
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: BaseSink = from_glib_borrow(ptr);
|
let wrap: BaseSink = from_glib_borrow(ptr);
|
||||||
let list = gst::BufferListRef::from_ptr(list);
|
let list = from_glib_borrow(list);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||||
imp.render_list(&wrap, list).into()
|
imp.render_list(&wrap, &list).into()
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -538,10 +525,10 @@ where
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut T::Instance);
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: BaseSink = from_glib_borrow(ptr);
|
let wrap: BaseSink = from_glib_borrow(ptr);
|
||||||
let list = gst::BufferListRef::from_ptr(list);
|
let list = from_glib_borrow(list);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||||
imp.prepare_list(&wrap, list).into()
|
imp.prepare_list(&wrap, &list).into()
|
||||||
})
|
})
|
||||||
.to_glib()
|
.to_glib()
|
||||||
}
|
}
|
||||||
|
@ -597,14 +584,10 @@ where
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut T::Instance);
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: BaseSink = from_glib_borrow(ptr);
|
let wrap: BaseSink = from_glib_borrow(ptr);
|
||||||
let filter = if filter.is_null() {
|
let filter = Option::<gst::Caps>::from_glib_borrow(filter);
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(gst::CapsRef::from_ptr(filter))
|
|
||||||
};
|
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), None, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), None, {
|
||||||
imp.get_caps(&wrap, filter)
|
imp.get_caps(&wrap, filter.as_ref())
|
||||||
})
|
})
|
||||||
.map(|caps| caps.into_ptr())
|
.map(|caps| caps.into_ptr())
|
||||||
.unwrap_or(ptr::null_mut())
|
.unwrap_or(ptr::null_mut())
|
||||||
|
@ -622,10 +605,10 @@ where
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut T::Instance);
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: BaseSink = from_glib_borrow(ptr);
|
let wrap: BaseSink = from_glib_borrow(ptr);
|
||||||
let caps = gst::CapsRef::from_ptr(caps);
|
let caps = from_glib_borrow(caps);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.set_caps(&wrap, caps) {
|
match imp.set_caps(&wrap, &caps) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&wrap);
|
err.log_with_object(&wrap);
|
||||||
|
|
|
@ -70,7 +70,7 @@ pub trait BaseSrcImpl: BaseSrcImplExt + ElementImpl + Send + Sync + 'static {
|
||||||
self.parent_event(element, event)
|
self.parent_event(element, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_caps(&self, element: &BaseSrc, filter: Option<&gst::CapsRef>) -> Option<gst::Caps> {
|
fn get_caps(&self, element: &BaseSrc, filter: Option<&gst::Caps>) -> Option<gst::Caps> {
|
||||||
self.parent_get_caps(element, filter)
|
self.parent_get_caps(element, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ pub trait BaseSrcImpl: BaseSrcImplExt + ElementImpl + Send + Sync + 'static {
|
||||||
self.parent_negotiate(element)
|
self.parent_negotiate(element)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_caps(&self, element: &BaseSrc, caps: &gst::CapsRef) -> Result<(), gst::LoggableError> {
|
fn set_caps(&self, element: &BaseSrc, caps: &gst::Caps) -> Result<(), gst::LoggableError> {
|
||||||
self.parent_set_caps(element, caps)
|
self.parent_set_caps(element, caps)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,18 +125,14 @@ pub trait BaseSrcImplExt {
|
||||||
|
|
||||||
fn parent_event(&self, element: &BaseSrc, event: &gst::Event) -> bool;
|
fn parent_event(&self, element: &BaseSrc, event: &gst::Event) -> bool;
|
||||||
|
|
||||||
fn parent_get_caps(
|
fn parent_get_caps(&self, element: &BaseSrc, filter: Option<&gst::Caps>) -> Option<gst::Caps>;
|
||||||
&self,
|
|
||||||
element: &BaseSrc,
|
|
||||||
filter: Option<&gst::CapsRef>,
|
|
||||||
) -> Option<gst::Caps>;
|
|
||||||
|
|
||||||
fn parent_negotiate(&self, element: &BaseSrc) -> Result<(), gst::LoggableError>;
|
fn parent_negotiate(&self, element: &BaseSrc) -> Result<(), gst::LoggableError>;
|
||||||
|
|
||||||
fn parent_set_caps(
|
fn parent_set_caps(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseSrc,
|
element: &BaseSrc,
|
||||||
caps: &gst::CapsRef,
|
caps: &gst::Caps,
|
||||||
) -> Result<(), gst::LoggableError>;
|
) -> Result<(), gst::LoggableError>;
|
||||||
|
|
||||||
fn parent_fixate(&self, element: &BaseSrc, caps: gst::Caps) -> gst::Caps;
|
fn parent_fixate(&self, element: &BaseSrc, caps: gst::Caps) -> gst::Caps;
|
||||||
|
@ -308,24 +304,15 @@ impl<T: BaseSrcImpl + ObjectImpl> BaseSrcImplExt for T {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parent_get_caps(
|
fn parent_get_caps(&self, element: &BaseSrc, filter: Option<&gst::Caps>) -> Option<gst::Caps> {
|
||||||
&self,
|
|
||||||
element: &BaseSrc,
|
|
||||||
filter: Option<&gst::CapsRef>,
|
|
||||||
) -> Option<gst::Caps> {
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = self.get_type_data();
|
let data = self.get_type_data();
|
||||||
let parent_class =
|
let parent_class =
|
||||||
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseSrcClass;
|
data.as_ref().get_parent_class() as *mut gst_base_sys::GstBaseSrcClass;
|
||||||
let filter_ptr = if let Some(filter) = filter {
|
|
||||||
filter.as_mut_ptr()
|
|
||||||
} else {
|
|
||||||
ptr::null_mut()
|
|
||||||
};
|
|
||||||
|
|
||||||
(*parent_class)
|
(*parent_class)
|
||||||
.get_caps
|
.get_caps
|
||||||
.map(|f| from_glib_full(f(element.to_glib_none().0, filter_ptr)))
|
.map(|f| from_glib_full(f(element.to_glib_none().0, filter.to_glib_none().0)))
|
||||||
.unwrap_or(None)
|
.unwrap_or(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -351,7 +338,7 @@ impl<T: BaseSrcImpl + ObjectImpl> BaseSrcImplExt for T {
|
||||||
fn parent_set_caps(
|
fn parent_set_caps(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseSrc,
|
element: &BaseSrc,
|
||||||
caps: &gst::CapsRef,
|
caps: &gst::Caps,
|
||||||
) -> Result<(), gst::LoggableError> {
|
) -> Result<(), gst::LoggableError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = self.get_type_data();
|
let data = self.get_type_data();
|
||||||
|
@ -361,7 +348,7 @@ impl<T: BaseSrcImpl + ObjectImpl> BaseSrcImplExt for T {
|
||||||
.set_caps
|
.set_caps
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
gst_result_from_gboolean!(
|
gst_result_from_gboolean!(
|
||||||
f(element.to_glib_none().0, caps.as_mut_ptr()),
|
f(element.to_glib_none().0, caps.to_glib_none().0),
|
||||||
gst::CAT_RUST,
|
gst::CAT_RUST,
|
||||||
"Parent function `set_caps` failed"
|
"Parent function `set_caps` failed"
|
||||||
)
|
)
|
||||||
|
@ -666,14 +653,10 @@ where
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut T::Instance);
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: BaseSrc = from_glib_borrow(ptr);
|
let wrap: BaseSrc = from_glib_borrow(ptr);
|
||||||
let filter = if filter.is_null() {
|
let filter = Option::<gst::Caps>::from_glib_borrow(filter);
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(gst::CapsRef::from_ptr(filter))
|
|
||||||
};
|
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), None, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), None, {
|
||||||
imp.get_caps(&wrap, filter)
|
imp.get_caps(&wrap, filter.as_ref())
|
||||||
})
|
})
|
||||||
.map(|caps| caps.into_ptr())
|
.map(|caps| caps.into_ptr())
|
||||||
.unwrap_or(ptr::null_mut())
|
.unwrap_or(ptr::null_mut())
|
||||||
|
@ -715,10 +698,10 @@ where
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut T::Instance);
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: BaseSrc = from_glib_borrow(ptr);
|
let wrap: BaseSrc = from_glib_borrow(ptr);
|
||||||
let caps = gst::CapsRef::from_ptr(caps);
|
let caps = from_glib_borrow(caps);
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), false, {
|
||||||
match imp.set_caps(&wrap, caps) {
|
match imp.set_caps(&wrap, &caps) {
|
||||||
Ok(()) => true,
|
Ok(()) => true,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
err.log_with_object(&wrap);
|
err.log_with_object(&wrap);
|
||||||
|
|
|
@ -114,7 +114,7 @@ pub trait BaseTransformImpl: BaseTransformImplExt + ElementImpl + Send + Sync +
|
||||||
fn transform_ip_passthrough(
|
fn transform_ip_passthrough(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseTransform,
|
element: &BaseTransform,
|
||||||
buf: &gst::BufferRef,
|
buf: &gst::Buffer,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
self.parent_transform_ip_passthrough(element, buf)
|
self.parent_transform_ip_passthrough(element, buf)
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ pub trait BaseTransformImplExt {
|
||||||
fn parent_transform_ip_passthrough(
|
fn parent_transform_ip_passthrough(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseTransform,
|
element: &BaseTransform,
|
||||||
buf: &gst::BufferRef,
|
buf: &gst::Buffer,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
) -> Result<gst::FlowSuccess, gst::FlowError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,7 +503,7 @@ impl<T: BaseTransformImpl + ObjectImpl> BaseTransformImplExt for T {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
gst::FlowReturn::from_glib(f(element.to_glib_none().0, &mut buf.as_mut_ptr()))
|
gst::FlowReturn::from_glib(f(element.to_glib_none().0, buf.as_mut_ptr() as *mut _))
|
||||||
.into_result()
|
.into_result()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -511,7 +511,7 @@ impl<T: BaseTransformImpl + ObjectImpl> BaseTransformImplExt for T {
|
||||||
fn parent_transform_ip_passthrough(
|
fn parent_transform_ip_passthrough(
|
||||||
&self,
|
&self,
|
||||||
element: &BaseTransform,
|
element: &BaseTransform,
|
||||||
buf: &gst::BufferRef,
|
buf: &gst::Buffer,
|
||||||
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
) -> Result<gst::FlowSuccess, gst::FlowError> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = self.get_type_data();
|
let data = self.get_type_data();
|
||||||
|
@ -531,8 +531,9 @@ impl<T: BaseTransformImpl + ObjectImpl> BaseTransformImplExt for T {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
gst::FlowReturn::from_glib(f(element.to_glib_none().0, &mut buf.as_mut_ptr()))
|
// FIXME: Wrong signature in FFI
|
||||||
.into_result()
|
let buf: *mut gst_sys::GstBuffer = buf.to_glib_none().0;
|
||||||
|
gst::FlowReturn::from_glib(f(element.to_glib_none().0, buf as *mut _)).into_result()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -920,7 +921,7 @@ where
|
||||||
|
|
||||||
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
gst_panic_to_error!(&wrap, &instance.panicked(), gst::FlowReturn::Error, {
|
||||||
if from_glib(gst_base_sys::gst_base_transform_is_passthrough(ptr)) {
|
if from_glib(gst_base_sys::gst_base_transform_is_passthrough(ptr)) {
|
||||||
imp.transform_ip_passthrough(&wrap, gst::BufferRef::from_ptr(buf))
|
imp.transform_ip_passthrough(&wrap, &from_glib_borrow(buf))
|
||||||
.into()
|
.into()
|
||||||
} else {
|
} else {
|
||||||
imp.transform_ip(&wrap, gst::BufferRef::from_mut_ptr(buf))
|
imp.transform_ip(&wrap, gst::BufferRef::from_mut_ptr(buf))
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use glib;
|
use glib;
|
||||||
use glib::translate::{from_glib, ToGlib};
|
use glib::translate::{from_glib, from_glib_none, ToGlib};
|
||||||
use gst;
|
use gst;
|
||||||
use gst::prelude::*;
|
use gst::prelude::*;
|
||||||
use gst_sys;
|
use gst_sys;
|
||||||
|
@ -154,6 +154,10 @@ impl VideoOverlayCompositionMeta {
|
||||||
unsafe { ::VideoOverlayCompositionRef::from_ptr(self.0.overlay) }
|
unsafe { ::VideoOverlayCompositionRef::from_ptr(self.0.overlay) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_overlay_owned(&self) -> ::VideoOverlayComposition {
|
||||||
|
unsafe { from_glib_none(self.get_overlay().as_ptr()) }
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_overlay(&mut self, overlay: &::VideoOverlayComposition) {
|
pub fn set_overlay(&mut self, overlay: &::VideoOverlayComposition) {
|
||||||
#![allow(clippy::cast_ptr_alignment)]
|
#![allow(clippy::cast_ptr_alignment)]
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -13,7 +13,7 @@ use gst::miniobject::*;
|
||||||
use gst_video_sys;
|
use gst_video_sys;
|
||||||
|
|
||||||
use glib;
|
use glib;
|
||||||
use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlib};
|
use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlib, ToGlibPtr};
|
||||||
|
|
||||||
gst_define_mini_object_wrapper!(
|
gst_define_mini_object_wrapper!(
|
||||||
VideoOverlayRectangle,
|
VideoOverlayRectangle,
|
||||||
|
@ -35,7 +35,7 @@ impl fmt::Debug for VideoOverlayRectangleRef {
|
||||||
|
|
||||||
impl VideoOverlayRectangle {
|
impl VideoOverlayRectangle {
|
||||||
pub fn new_raw(
|
pub fn new_raw(
|
||||||
buffer: &gst::BufferRef,
|
buffer: &gst::Buffer,
|
||||||
render_x: i32,
|
render_x: i32,
|
||||||
render_y: i32,
|
render_y: i32,
|
||||||
render_width: u32,
|
render_width: u32,
|
||||||
|
@ -45,7 +45,7 @@ impl VideoOverlayRectangle {
|
||||||
assert!(buffer.get_meta::<::VideoMeta>().is_some());
|
assert!(buffer.get_meta::<::VideoMeta>().is_some());
|
||||||
unsafe {
|
unsafe {
|
||||||
from_glib_full(gst_video_sys::gst_video_overlay_rectangle_new_raw(
|
from_glib_full(gst_video_sys::gst_video_overlay_rectangle_new_raw(
|
||||||
buffer.as_mut_ptr(),
|
buffer.to_glib_none().0,
|
||||||
render_x,
|
render_x,
|
||||||
render_y,
|
render_y,
|
||||||
render_width,
|
render_width,
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use glib;
|
use glib;
|
||||||
use glib::translate::from_glib_full;
|
use glib::translate::{from_glib_full, from_glib_none};
|
||||||
use gst_sys;
|
use gst_sys;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
|
@ -65,6 +65,13 @@ impl BufferListRef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_owned(&self, idx: u32) -> Option<Buffer> {
|
||||||
|
unsafe {
|
||||||
|
let ptr = gst_sys::gst_buffer_list_get(self.as_mut_ptr(), idx);
|
||||||
|
from_glib_none(ptr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
||||||
pub fn get_writable(&mut self, idx: u32) -> Option<&mut BufferRef> {
|
pub fn get_writable(&mut self, idx: u32) -> Option<&mut BufferRef> {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -93,6 +100,10 @@ impl BufferListRef {
|
||||||
pub fn iter(&self) -> Iter {
|
pub fn iter(&self) -> Iter {
|
||||||
Iter::new(self)
|
Iter::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn iter_owned(&self) -> IterOwned {
|
||||||
|
IterOwned::new(self)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for BufferList {
|
impl Default for BufferList {
|
||||||
|
@ -119,17 +130,19 @@ impl fmt::Debug for BufferListRef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! define_iter(
|
||||||
|
($name:ident, $styp:ty, $get_item:expr) => {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Iter<'a> {
|
pub struct $name<'a> {
|
||||||
list: &'a BufferListRef,
|
list: &'a BufferListRef,
|
||||||
idx: u32,
|
idx: u32,
|
||||||
size: u32,
|
size: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iter<'a> {
|
impl<'a> $name<'a> {
|
||||||
fn new(list: &'a BufferListRef) -> Iter<'a> {
|
fn new(list: &'a BufferListRef) -> $name<'a> {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
Iter {
|
$name {
|
||||||
list,
|
list,
|
||||||
idx: 0,
|
idx: 0,
|
||||||
size: list.len() as u32,
|
size: list.len() as u32,
|
||||||
|
@ -137,18 +150,18 @@ impl<'a> Iter<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator for Iter<'a> {
|
impl<'a> Iterator for $name<'a> {
|
||||||
type Item = &'a BufferRef;
|
type Item = $styp;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
if self.idx >= self.size {
|
if self.idx >= self.size {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let item = self.list.get(self.idx);
|
let item = $get_item(self.list, self.idx)?;
|
||||||
self.idx += 1;
|
self.idx += 1;
|
||||||
|
|
||||||
item
|
Some(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
|
@ -162,15 +175,25 @@ impl<'a> Iterator for Iter<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> DoubleEndedIterator for Iter<'a> {
|
impl<'a> DoubleEndedIterator for $name<'a> {
|
||||||
fn next_back(&mut self) -> Option<Self::Item> {
|
fn next_back(&mut self) -> Option<Self::Item> {
|
||||||
if self.idx == self.size {
|
if self.idx == self.size {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.size -= 1;
|
self.size -= 1;
|
||||||
self.list.get(self.size)
|
$get_item(self.list, self.size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ExactSizeIterator for Iter<'a> {}
|
impl<'a> ExactSizeIterator for $name<'a> {}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
define_iter!(Iter, &'a BufferRef, |list: &'a BufferListRef, idx| {
|
||||||
|
list.get(idx)
|
||||||
|
});
|
||||||
|
|
||||||
|
define_iter!(IterOwned, Buffer, |list: &BufferListRef, idx| {
|
||||||
|
list.get_owned(idx)
|
||||||
|
});
|
||||||
|
|
|
@ -19,7 +19,7 @@ use std::ops::Deref;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
use glib;
|
use glib;
|
||||||
use glib::translate::{from_glib, from_glib_full, FromGlib, ToGlib, ToGlibPtr};
|
use glib::translate::{from_glib, from_glib_full, from_glib_none, FromGlib, ToGlib, ToGlibPtr};
|
||||||
use glib::value::ToSendValue;
|
use glib::value::ToSendValue;
|
||||||
|
|
||||||
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
#[cfg(any(feature = "v1_10", feature = "dox"))]
|
||||||
|
@ -571,6 +571,10 @@ impl<'a> Caps<'a> {
|
||||||
::CapsRef::from_ptr(caps)
|
::CapsRef::from_ptr(caps)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_caps_owned(&self) -> ::Caps {
|
||||||
|
unsafe { from_glib_none(self.get_caps().as_ptr()) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_concrete_event!(Segment);
|
declare_concrete_event!(Segment);
|
||||||
|
@ -608,6 +612,10 @@ impl<'a> Tag<'a> {
|
||||||
::TagListRef::from_ptr(tags)
|
::TagListRef::from_ptr(tags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_tag_owned(&self) -> ::TagList {
|
||||||
|
unsafe { from_glib_none(self.get_tag().as_ptr()) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_concrete_event!(BufferSize);
|
declare_concrete_event!(BufferSize);
|
||||||
|
@ -674,6 +682,13 @@ impl<'a> Toc<'a> {
|
||||||
(::TocRef::from_ptr(toc), from_glib(updated))
|
(::TocRef::from_ptr(toc), from_glib(updated))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_toc_owned(&self) -> (::Toc, bool) {
|
||||||
|
unsafe {
|
||||||
|
let (toc, updated) = self.get_toc();
|
||||||
|
(from_glib_none(toc.as_ptr()), updated)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_concrete_event!(Protection);
|
declare_concrete_event!(Protection);
|
||||||
|
@ -702,6 +717,13 @@ impl<'a> Protection<'a> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_owned(&self) -> (&'a str, ::Buffer, Option<&'a str>) {
|
||||||
|
unsafe {
|
||||||
|
let (system_id, buffer, origin) = self.get();
|
||||||
|
(system_id, from_glib_none(buffer.as_ptr()), origin)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_concrete_event!(SegmentDone);
|
declare_concrete_event!(SegmentDone);
|
||||||
|
|
|
@ -11,10 +11,11 @@ use std::marker::PhantomData;
|
||||||
use std::ops;
|
use std::ops;
|
||||||
|
|
||||||
use miniobject::MiniObject;
|
use miniobject::MiniObject;
|
||||||
|
use Buffer;
|
||||||
use BufferRef;
|
use BufferRef;
|
||||||
|
|
||||||
use glib;
|
use glib;
|
||||||
use glib::translate::{from_glib, FromGlib};
|
use glib::translate::{from_glib, from_glib_none, FromGlib, ToGlibPtr};
|
||||||
use glib_sys;
|
use glib_sys;
|
||||||
use gst_sys;
|
use gst_sys;
|
||||||
|
|
||||||
|
@ -227,14 +228,11 @@ impl fmt::Debug for Meta {
|
||||||
pub struct ParentBufferMeta(gst_sys::GstParentBufferMeta);
|
pub struct ParentBufferMeta(gst_sys::GstParentBufferMeta);
|
||||||
|
|
||||||
impl ParentBufferMeta {
|
impl ParentBufferMeta {
|
||||||
pub fn add<'a>(
|
pub fn add<'a>(buffer: &'a mut BufferRef, parent: &Buffer) -> MetaRefMut<'a, Self, Standalone> {
|
||||||
buffer: &'a mut BufferRef,
|
|
||||||
parent: &BufferRef,
|
|
||||||
) -> MetaRefMut<'a, Self, Standalone> {
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let meta = gst_sys::gst_buffer_add_parent_buffer_meta(
|
let meta = gst_sys::gst_buffer_add_parent_buffer_meta(
|
||||||
buffer.as_mut_ptr(),
|
buffer.as_mut_ptr(),
|
||||||
parent.as_mut_ptr(),
|
parent.to_glib_none().0,
|
||||||
);
|
);
|
||||||
|
|
||||||
Self::from_mut_ptr(buffer, meta)
|
Self::from_mut_ptr(buffer, meta)
|
||||||
|
@ -244,6 +242,10 @@ impl ParentBufferMeta {
|
||||||
pub fn get_parent(&self) -> &BufferRef {
|
pub fn get_parent(&self) -> &BufferRef {
|
||||||
unsafe { BufferRef::from_ptr(self.0.buffer) }
|
unsafe { BufferRef::from_ptr(self.0.buffer) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_parent_owned(&self) -> Buffer {
|
||||||
|
unsafe { from_glib_none(self.0.buffer) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl MetaAPI for ParentBufferMeta {
|
unsafe impl MetaAPI for ParentBufferMeta {
|
||||||
|
@ -273,7 +275,7 @@ mod tests {
|
||||||
let mut buffer = ::Buffer::new();
|
let mut buffer = ::Buffer::new();
|
||||||
let parent = ::Buffer::new();
|
let parent = ::Buffer::new();
|
||||||
{
|
{
|
||||||
let meta = ParentBufferMeta::add(buffer.get_mut().unwrap(), &*parent);
|
let meta = ParentBufferMeta::add(buffer.get_mut().unwrap(), &parent);
|
||||||
unsafe {
|
unsafe {
|
||||||
assert_eq!(meta.get_parent().as_ptr(), parent.as_ptr());
|
assert_eq!(meta.get_parent().as_ptr(), parent.as_ptr());
|
||||||
}
|
}
|
||||||
|
|
|
@ -914,6 +914,13 @@ impl<T: AsPtr> Allocation<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_owned(&self) -> (::Caps, bool) {
|
||||||
|
unsafe {
|
||||||
|
let (caps, need_pool) = self.get();
|
||||||
|
(from_glib_none(caps.as_ptr()), need_pool)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_allocation_pools(&self) -> Vec<(Option<::BufferPool>, u32, u32, u32)> {
|
pub fn get_allocation_pools(&self) -> Vec<(Option<::BufferPool>, u32, u32, u32)> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let n = gst_sys::gst_query_get_n_allocation_pools(self.0.as_ptr());
|
let n = gst_sys::gst_query_get_n_allocation_pools(self.0.as_ptr());
|
||||||
|
@ -1141,6 +1148,10 @@ impl<T: AsPtr> AcceptCaps<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_caps_owned(&self) -> ::Caps {
|
||||||
|
unsafe { from_glib_none(self.get_caps().as_ptr()) }
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_result(&self) -> bool {
|
pub fn get_result(&self) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut accepted = mem::uninitialized();
|
let mut accepted = mem::uninitialized();
|
||||||
|
@ -1172,6 +1183,10 @@ impl<T: AsPtr> Caps<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_filter_owned(&self) -> Option<::Caps> {
|
||||||
|
unsafe { self.get_filter().map(|caps| from_glib_none(caps.as_ptr())) }
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_result(&self) -> Option<&::CapsRef> {
|
pub fn get_result(&self) -> Option<&::CapsRef> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut caps = ptr::null_mut();
|
let mut caps = ptr::null_mut();
|
||||||
|
@ -1183,6 +1198,10 @@ impl<T: AsPtr> Caps<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_result_owned(&self) -> Option<::Caps> {
|
||||||
|
unsafe { self.get_result().map(|caps| from_glib_none(caps.as_ptr())) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: AsMutPtr> Caps<T> {
|
impl<T: AsMutPtr> Caps<T> {
|
||||||
|
@ -1209,6 +1228,13 @@ impl<T: AsPtr> Context<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_context_owned(&self) -> Option<::Context> {
|
||||||
|
unsafe {
|
||||||
|
self.get_context()
|
||||||
|
.map(|context| from_glib_none(context.as_ptr()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_context_type(&self) -> &str {
|
pub fn get_context_type(&self) -> &str {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut context_type = ptr::null();
|
let mut context_type = ptr::null();
|
||||||
|
|
|
@ -15,8 +15,11 @@ use glib;
|
||||||
use glib::translate::{from_glib_full, from_glib_none, mut_override, ToGlibPtr};
|
use glib::translate::{from_glib_full, from_glib_none, mut_override, ToGlibPtr};
|
||||||
|
|
||||||
use miniobject::*;
|
use miniobject::*;
|
||||||
|
use Buffer;
|
||||||
|
use BufferList;
|
||||||
use BufferListRef;
|
use BufferListRef;
|
||||||
use BufferRef;
|
use BufferRef;
|
||||||
|
use Caps;
|
||||||
use CapsRef;
|
use CapsRef;
|
||||||
use FormattedSegment;
|
use FormattedSegment;
|
||||||
use FormattedValue;
|
use FormattedValue;
|
||||||
|
@ -30,8 +33,8 @@ gst_define_mini_object_wrapper!(Sample, SampleRef, gst_sys::GstSample, [Debug,],
|
||||||
|
|
||||||
impl Sample {
|
impl Sample {
|
||||||
pub fn new<F: FormattedValue>(
|
pub fn new<F: FormattedValue>(
|
||||||
buffer: Option<&BufferRef>,
|
buffer: Option<&Buffer>,
|
||||||
caps: Option<&CapsRef>,
|
caps: Option<&Caps>,
|
||||||
segment: Option<&FormattedSegment<F>>,
|
segment: Option<&FormattedSegment<F>>,
|
||||||
info: Option<Structure>,
|
info: Option<Structure>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -40,11 +43,8 @@ impl Sample {
|
||||||
let info = info.map(|i| i.into_ptr()).unwrap_or(ptr::null_mut());
|
let info = info.map(|i| i.into_ptr()).unwrap_or(ptr::null_mut());
|
||||||
|
|
||||||
from_glib_full(gst_sys::gst_sample_new(
|
from_glib_full(gst_sys::gst_sample_new(
|
||||||
buffer
|
buffer.to_glib_none().0,
|
||||||
.map(|buffer| buffer.as_mut_ptr())
|
caps.to_glib_none().0,
|
||||||
.unwrap_or(ptr::null_mut()),
|
|
||||||
caps.map(|caps| caps.as_mut_ptr())
|
|
||||||
.unwrap_or(ptr::null_mut()),
|
|
||||||
segment.to_glib_none().0,
|
segment.to_glib_none().0,
|
||||||
mut_override(info),
|
mut_override(info),
|
||||||
))
|
))
|
||||||
|
@ -52,8 +52,8 @@ impl Sample {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_buffer_list<F: FormattedValue>(
|
pub fn with_buffer_list<F: FormattedValue>(
|
||||||
buffer_list: Option<&BufferListRef>,
|
buffer_list: Option<&BufferList>,
|
||||||
caps: Option<&CapsRef>,
|
caps: Option<&Caps>,
|
||||||
segment: Option<&FormattedSegment<F>>,
|
segment: Option<&FormattedSegment<F>>,
|
||||||
info: Option<Structure>,
|
info: Option<Structure>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -62,9 +62,7 @@ impl Sample {
|
||||||
unsafe {
|
unsafe {
|
||||||
gst_sys::gst_sample_set_buffer_list(
|
gst_sys::gst_sample_set_buffer_list(
|
||||||
sample.to_glib_none().0,
|
sample.to_glib_none().0,
|
||||||
buffer_list
|
buffer_list.to_glib_none().0,
|
||||||
.map(|buffer_list| buffer_list.as_mut_ptr())
|
|
||||||
.unwrap_or(ptr::null_mut()),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
sample
|
sample
|
||||||
|
@ -83,6 +81,13 @@ impl SampleRef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_buffer_owned(&self) -> Option<Buffer> {
|
||||||
|
unsafe {
|
||||||
|
self.get_buffer()
|
||||||
|
.map(|buffer| from_glib_none(buffer.as_ptr()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_buffer_list(&self) -> Option<&BufferListRef> {
|
pub fn get_buffer_list(&self) -> Option<&BufferListRef> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ptr = gst_sys::gst_sample_get_buffer_list(self.as_mut_ptr());
|
let ptr = gst_sys::gst_sample_get_buffer_list(self.as_mut_ptr());
|
||||||
|
@ -94,6 +99,13 @@ impl SampleRef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_buffer_list_owned(&self) -> Option<BufferList> {
|
||||||
|
unsafe {
|
||||||
|
self.get_buffer_list()
|
||||||
|
.map(|list| from_glib_none(list.as_ptr()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_caps(&self) -> Option<&CapsRef> {
|
pub fn get_caps(&self) -> Option<&CapsRef> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let ptr = gst_sys::gst_sample_get_caps(self.as_mut_ptr());
|
let ptr = gst_sys::gst_sample_get_caps(self.as_mut_ptr());
|
||||||
|
@ -105,6 +117,10 @@ impl SampleRef {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_caps_owned(&self) -> Option<Caps> {
|
||||||
|
unsafe { self.get_caps().map(|caps| from_glib_none(caps.as_ptr())) }
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_segment(&self) -> Option<Segment> {
|
pub fn get_segment(&self) -> Option<Segment> {
|
||||||
unsafe { from_glib_none(gst_sys::gst_sample_get_segment(self.as_mut_ptr())) }
|
unsafe { from_glib_none(gst_sys::gst_sample_get_segment(self.as_mut_ptr())) }
|
||||||
}
|
}
|
||||||
|
@ -121,38 +137,20 @@ impl SampleRef {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||||
pub fn set_buffer(&mut self, buffer: Option<&BufferRef>) {
|
pub fn set_buffer(&mut self, buffer: Option<&Buffer>) {
|
||||||
|
unsafe { gst_sys::gst_sample_set_buffer(self.as_mut_ptr(), buffer.to_glib_none().0) }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||||
|
pub fn set_buffer_list(&mut self, buffer_list: Option<&BufferList>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
gst_sys::gst_sample_set_buffer(
|
gst_sys::gst_sample_set_buffer_list(self.as_mut_ptr(), buffer_list.to_glib_none().0)
|
||||||
self.as_mut_ptr(),
|
|
||||||
buffer
|
|
||||||
.map(|buffer| buffer.as_mut_ptr())
|
|
||||||
.unwrap_or(ptr::null_mut()),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||||
pub fn set_buffer_list(&mut self, buffer_list: Option<&BufferListRef>) {
|
pub fn set_caps(&mut self, caps: Option<&Caps>) {
|
||||||
unsafe {
|
unsafe { gst_sys::gst_sample_set_caps(self.as_mut_ptr(), caps.to_glib_none().0) }
|
||||||
gst_sys::gst_sample_set_buffer_list(
|
|
||||||
self.as_mut_ptr(),
|
|
||||||
buffer_list
|
|
||||||
.map(|buffer_list| buffer_list.as_mut_ptr())
|
|
||||||
.unwrap_or(ptr::null_mut()),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
|
||||||
pub fn set_caps(&mut self, caps: Option<&CapsRef>) {
|
|
||||||
unsafe {
|
|
||||||
gst_sys::gst_sample_set_caps(
|
|
||||||
self.as_mut_ptr(),
|
|
||||||
caps.map(|caps| caps.as_mut_ptr())
|
|
||||||
.unwrap_or(ptr::null_mut()),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||||
|
|
|
@ -42,7 +42,7 @@ pub trait ElementImpl: ElementImplExt + ObjectImpl + Send + Sync + 'static {
|
||||||
element: &::Element,
|
element: &::Element,
|
||||||
templ: &::PadTemplate,
|
templ: &::PadTemplate,
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
caps: Option<&::CapsRef>,
|
caps: Option<&::Caps>,
|
||||||
) -> Option<::Pad> {
|
) -> Option<::Pad> {
|
||||||
self.parent_request_new_pad(element, templ, name, caps)
|
self.parent_request_new_pad(element, templ, name, caps)
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ pub trait ElementImplExt {
|
||||||
element: &::Element,
|
element: &::Element,
|
||||||
templ: &::PadTemplate,
|
templ: &::PadTemplate,
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
caps: Option<&::CapsRef>,
|
caps: Option<&::Caps>,
|
||||||
) -> Option<::Pad>;
|
) -> Option<::Pad>;
|
||||||
|
|
||||||
fn parent_release_pad(&self, element: &::Element, pad: &::Pad);
|
fn parent_release_pad(&self, element: &::Element, pad: &::Pad);
|
||||||
|
@ -132,7 +132,7 @@ where
|
||||||
element: &::Element,
|
element: &::Element,
|
||||||
templ: &::PadTemplate,
|
templ: &::PadTemplate,
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
caps: Option<&::CapsRef>,
|
caps: Option<&::Caps>,
|
||||||
) -> Option<::Pad> {
|
) -> Option<::Pad> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = self.get_type_data();
|
let data = self.get_type_data();
|
||||||
|
@ -145,7 +145,7 @@ where
|
||||||
element.to_glib_none().0,
|
element.to_glib_none().0,
|
||||||
templ.to_glib_none().0,
|
templ.to_glib_none().0,
|
||||||
name.to_glib_full(),
|
name.to_glib_full(),
|
||||||
caps.map(|caps| caps.as_ptr()).unwrap_or(std::ptr::null()),
|
caps.to_glib_none().0,
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
.unwrap_or(None)
|
.unwrap_or(None)
|
||||||
|
@ -336,16 +336,17 @@ where
|
||||||
let imp = instance.get_impl();
|
let imp = instance.get_impl();
|
||||||
let wrap: Element = from_glib_borrow(ptr);
|
let wrap: Element = from_glib_borrow(ptr);
|
||||||
|
|
||||||
let caps = if caps.is_null() {
|
let caps = Option::<::Caps>::from_glib_borrow(caps);
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(::CapsRef::from_ptr(caps))
|
|
||||||
};
|
|
||||||
|
|
||||||
// XXX: This is effectively unsafe but the best we can do
|
// XXX: This is effectively unsafe but the best we can do
|
||||||
// See https://bugzilla.gnome.org/show_bug.cgi?id=791193
|
// See https://bugzilla.gnome.org/show_bug.cgi?id=791193
|
||||||
let pad = gst_panic_to_error!(&wrap, &instance.panicked(), None, {
|
let pad = gst_panic_to_error!(&wrap, &instance.panicked(), None, {
|
||||||
imp.request_new_pad(&wrap, &from_glib_borrow(templ), from_glib_none(name), caps)
|
imp.request_new_pad(
|
||||||
|
&wrap,
|
||||||
|
&from_glib_borrow(templ),
|
||||||
|
from_glib_none(name),
|
||||||
|
caps.as_ref(),
|
||||||
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
// Ensure that the pad is owned by the element now, if a pad was returned
|
// Ensure that the pad is owned by the element now, if a pad was returned
|
||||||
|
|
|
@ -99,7 +99,7 @@ fn tutorial_main() {
|
||||||
.expect("Unable to set the playbin to the `Null` state");
|
.expect("Unable to set the playbin to the `Null` state");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_message(custom_data: &mut CustomData, msg: &gst::GstRc<gst::MessageRef>) {
|
fn handle_message(custom_data: &mut CustomData, msg: &gst::Message) {
|
||||||
match msg.view() {
|
match msg.view() {
|
||||||
MessageView::Error(err) => {
|
MessageView::Error(err) => {
|
||||||
println!(
|
println!(
|
||||||
|
|
Loading…
Reference in a new issue