gstreamer/proxy_pad.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use std::ptr;
4
5use glib::{prelude::*, translate::*};
6
7use crate::{ffi, Buffer, BufferList, FlowError, FlowSuccess, Pad, ProxyPad};
8
9impl ProxyPad {
10 /// Invoke the default chain function of the proxy pad.
11 /// ## `pad`
12 /// a sink [`Pad`][crate::Pad], returns GST_FLOW_ERROR if not.
13 /// ## `parent`
14 /// the parent of `pad` or [`None`]
15 /// ## `buffer`
16 /// the [`Buffer`][crate::Buffer] to send, return GST_FLOW_ERROR
17 /// if not.
18 ///
19 /// # Returns
20 ///
21 /// a [`FlowReturn`][crate::FlowReturn] from the pad.
22 #[doc(alias = "gst_proxy_pad_chain_default")]
23 pub fn chain_default<O: IsA<ProxyPad>>(
24 pad: &O,
25 parent: Option<&impl IsA<crate::Object>>,
26 buffer: Buffer,
27 ) -> Result<FlowSuccess, FlowError> {
28 skip_assert_initialized!();
29 unsafe {
30 try_from_glib(ffi::gst_proxy_pad_chain_default(
31 pad.as_ptr() as *mut ffi::GstPad,
32 parent.map(|p| p.as_ref()).to_glib_none().0,
33 buffer.into_glib_ptr(),
34 ))
35 }
36 }
37
38 /// Invoke the default chain list function of the proxy pad.
39 /// ## `pad`
40 /// a sink [`Pad`][crate::Pad], returns GST_FLOW_ERROR if not.
41 /// ## `parent`
42 /// the parent of `pad` or [`None`]
43 /// ## `list`
44 /// the [`BufferList`][crate::BufferList] to send, return GST_FLOW_ERROR
45 /// if not.
46 ///
47 /// # Returns
48 ///
49 /// a [`FlowReturn`][crate::FlowReturn] from the pad.
50 #[doc(alias = "gst_proxy_pad_chain_list_default")]
51 pub fn chain_list_default<O: IsA<ProxyPad>>(
52 pad: &O,
53 parent: Option<&impl IsA<crate::Object>>,
54 list: BufferList,
55 ) -> Result<FlowSuccess, FlowError> {
56 skip_assert_initialized!();
57 unsafe {
58 try_from_glib(ffi::gst_proxy_pad_chain_list_default(
59 pad.as_ptr() as *mut ffi::GstPad,
60 parent.map(|p| p.as_ref()).to_glib_none().0,
61 list.into_glib_ptr(),
62 ))
63 }
64 }
65
66 /// Invoke the default getrange function of the proxy pad.
67 /// ## `pad`
68 /// a src [`Pad`][crate::Pad], returns [`FlowReturn::Error`][crate::FlowReturn::Error] if not.
69 /// ## `parent`
70 /// the parent of `pad`
71 /// ## `offset`
72 /// The start offset of the buffer
73 /// ## `size`
74 /// The length of the buffer
75 ///
76 /// # Returns
77 ///
78 /// a [`FlowReturn`][crate::FlowReturn] from the pad.
79 ///
80 /// ## `buffer`
81 /// a pointer to hold the [`Buffer`][crate::Buffer],
82 /// returns [`FlowReturn::Error`][crate::FlowReturn::Error] if [`None`].
83 #[doc(alias = "gst_proxy_pad_getrange_default")]
84 pub fn getrange_default<O: IsA<ProxyPad>>(
85 pad: &O,
86 parent: Option<&impl IsA<crate::Object>>,
87 offset: u64,
88 size: u32,
89 ) -> Result<Buffer, FlowError> {
90 skip_assert_initialized!();
91 unsafe {
92 let mut buffer = ptr::null_mut();
93 FlowSuccess::try_from_glib(ffi::gst_proxy_pad_getrange_default(
94 pad.as_ptr() as *mut ffi::GstPad,
95 parent.map(|p| p.as_ref()).to_glib_none().0,
96 offset,
97 size,
98 &mut buffer,
99 ))
100 .map(|_| from_glib_full(buffer))
101 }
102 }
103
104 /// Invoke the default iterate internal links function of the proxy pad.
105 /// ## `pad`
106 /// the [`Pad`][crate::Pad] to get the internal links of.
107 /// ## `parent`
108 /// the parent of `pad` or [`None`]
109 ///
110 /// # Returns
111 ///
112 /// a `GstIterator` of [`Pad`][crate::Pad], or [`None`] if `pad`
113 /// has no parent. Unref each returned pad with `gst_object_unref()`.
114 #[doc(alias = "gst_proxy_pad_iterate_internal_links_default")]
115 pub fn iterate_internal_links_default<O: IsA<ProxyPad>>(
116 pad: &O,
117 parent: Option<&impl IsA<crate::Object>>,
118 ) -> Option<crate::Iterator<Pad>> {
119 skip_assert_initialized!();
120 unsafe {
121 from_glib_full(ffi::gst_proxy_pad_iterate_internal_links_default(
122 pad.as_ptr() as *mut ffi::GstPad,
123 parent.map(|p| p.as_ref()).to_glib_none().0,
124 ))
125 }
126 }
127}