gstreamer: Add many new doc aliases for C function

This commit is contained in:
Sebastian Dröge 2021-12-12 17:52:32 +02:00
parent d1cc8d1298
commit 1541fbf32a
13 changed files with 180 additions and 0 deletions

View file

@ -16,9 +16,12 @@ use std::mem::transmute;
use std::path;
pub trait GstBinExtManual: 'static {
#[doc(alias = "gst_bin_add_many")]
fn add_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError>;
#[doc(alias = "gst_bin_remove_many")]
fn remove_many<E: IsA<Element>>(&self, elements: &[&E]) -> Result<(), glib::BoolError>;
#[doc(alias = "do-latency")]
fn connect_do_latency<F: Fn(&Self) -> Result<(), LoggableError> + Send + Sync + 'static>(
&self,
f: F,
@ -43,12 +46,17 @@ pub trait GstBinExtManual: 'static {
#[doc(alias = "get_children")]
fn children(&self) -> Vec<Element>;
#[doc(alias = "gst_debug_bin_to_dot_data")]
fn debug_to_dot_data(&self, details: crate::DebugGraphDetails) -> GString;
#[doc(alias = "GST_DEBUG_BIN_TO_DOT_FILE")]
#[doc(alias = "gst_debug_bin_to_dot_file")]
fn debug_to_dot_file(
&self,
details: crate::DebugGraphDetails,
file_name: impl AsRef<path::Path>,
);
#[doc(alias = "GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS")]
#[doc(alias = "gst_debug_bin_to_dot_file_with_ts")]
fn debug_to_dot_file_with_ts(
&self,
details: crate::DebugGraphDetails,

View file

@ -53,6 +53,8 @@ impl Buffer {
unsafe { from_glib_full(ffi::gst_buffer_new()) }
}
#[doc(alias = "gst_buffer_new_allocate")]
#[doc(alias = "gst_buffer_new_and_alloc")]
pub fn with_size(size: usize) -> Result<Self, glib::BoolError> {
assert_initialized_main_thread!();
@ -71,6 +73,7 @@ impl Buffer {
drop(slice);
}
#[doc(alias = "gst_buffer_new_wrapped_full")]
pub fn from_mut_slice<T: AsMut<[u8]> + Send + 'static>(slice: T) -> Self {
assert_initialized_main_thread!();
@ -93,6 +96,7 @@ impl Buffer {
}
}
#[doc(alias = "gst_buffer_new_wrapped_full")]
pub fn from_slice<T: AsRef<[u8]> + Send + 'static>(slice: T) -> Self {
assert_initialized_main_thread!();
@ -115,6 +119,7 @@ impl Buffer {
}
}
#[doc(alias = "gst_buffer_map")]
pub fn into_mapped_buffer_readable(self) -> Result<MappedBuffer<Readable>, Self> {
unsafe {
let mut map_info = mem::MaybeUninit::zeroed();
@ -135,6 +140,7 @@ impl Buffer {
}
}
#[doc(alias = "gst_buffer_map")]
pub fn into_mapped_buffer_writable(self) -> Result<MappedBuffer<Writable>, Self> {
unsafe {
let mut map_info = mem::MaybeUninit::zeroed();
@ -180,6 +186,7 @@ impl Default for Buffer {
}
impl BufferRef {
#[doc(alias = "gst_buffer_map")]
pub fn map_readable(&self) -> Result<BufferMap<Readable>, glib::BoolError> {
unsafe {
let mut map_info = mem::MaybeUninit::zeroed();
@ -197,6 +204,7 @@ impl BufferRef {
}
}
#[doc(alias = "gst_buffer_map")]
pub fn map_writable(&mut self) -> Result<BufferMap<Writable>, glib::BoolError> {
unsafe {
let mut map_info = mem::MaybeUninit::zeroed();
@ -259,6 +267,7 @@ impl BufferRef {
}
}
#[doc(alias = "gst_buffer_fill")]
pub fn copy_from_slice(&mut self, offset: usize, slice: &[u8]) -> Result<(), usize> {
let maxsize = self.maxsize();
let size = slice.len();
@ -282,6 +291,7 @@ impl BufferRef {
}
}
#[doc(alias = "gst_buffer_extract")]
pub fn copy_to_slice(&self, offset: usize, slice: &mut [u8]) -> Result<(), usize> {
let maxsize = self.size();
let size = slice.len();
@ -340,6 +350,7 @@ impl BufferRef {
}
#[doc(alias = "get_offset")]
#[doc(alias = "GST_BUFFER_OFFSET")]
pub fn offset(&self) -> u64 {
self.0.offset
}
@ -349,6 +360,7 @@ impl BufferRef {
}
#[doc(alias = "get_offset_end")]
#[doc(alias = "GST_BUFFER_OFFSET_END")]
pub fn offset_end(&self) -> u64 {
self.0.offset_end
}
@ -358,6 +370,7 @@ impl BufferRef {
}
#[doc(alias = "get_pts")]
#[doc(alias = "GST_BUFFER_PTS")]
pub fn pts(&self) -> Option<ClockTime> {
unsafe { from_glib(self.0.pts) }
}
@ -367,6 +380,7 @@ impl BufferRef {
}
#[doc(alias = "get_dts")]
#[doc(alias = "GST_BUFFER_DTS")]
pub fn dts(&self) -> Option<ClockTime> {
unsafe { from_glib(self.0.dts) }
}
@ -376,6 +390,7 @@ impl BufferRef {
}
#[doc(alias = "get_dts_or_pts")]
#[doc(alias = "GST_BUFFER_DTS_OR_PTS")]
pub fn dts_or_pts(&self) -> Option<ClockTime> {
let val = self.dts();
if val.is_none() {
@ -386,6 +401,7 @@ impl BufferRef {
}
#[doc(alias = "get_duration")]
#[doc(alias = "GST_BUFFER_DURATION")]
pub fn duration(&self) -> Option<ClockTime> {
unsafe { from_glib(self.0.duration) }
}
@ -395,14 +411,17 @@ impl BufferRef {
}
#[doc(alias = "get_flags")]
#[doc(alias = "GST_BUFFER_FLAGS")]
pub fn flags(&self) -> BufferFlags {
BufferFlags::from_bits_truncate(self.0.mini_object.flags)
}
#[doc(alias = "GST_BUFFER_FLAG_SET")]
pub fn set_flags(&mut self, flags: BufferFlags) {
self.0.mini_object.flags |= flags.bits();
}
#[doc(alias = "GST_BUFFER_FLAG_UNSET")]
pub fn unset_flags(&mut self, flags: BufferFlags) {
self.0.mini_object.flags &= !flags.bits();
}
@ -464,6 +483,7 @@ impl BufferRef {
}
}
#[doc(alias = "gst_buffer_foreach_meta")]
pub fn foreach_meta_mut<
F: FnMut(
MetaRefMut<Meta, crate::meta::Iterated>,
@ -637,6 +657,7 @@ impl BufferRef {
unsafe { MemoryRef::from_ptr(ffi::gst_buffer_peek_memory(self.as_mut_ptr(), idx)) }
}
#[doc(alias = "gst_buffer_peek_memory")]
pub fn peek_memory_mut(&mut self, idx: u32) -> Result<&mut MemoryRef, glib::BoolError> {
assert!(idx < self.n_memory());
unsafe {

View file

@ -34,6 +34,7 @@ impl BufferListRef {
}
}
#[doc(alias = "gst_buffer_list_add")]
pub fn add(&mut self, buffer: Buffer) {
self.insert(-1, buffer);
}
@ -60,6 +61,7 @@ impl BufferListRef {
}
}
#[doc(alias = "gst_buffer_list_get")]
pub fn get_owned(&self, idx: u32) -> Option<Buffer> {
unsafe {
let ptr = ffi::gst_buffer_list_get(self.as_mut_ptr(), idx);
@ -130,6 +132,7 @@ impl BufferListRef {
}
}
#[doc(alias = "gst_buffer_list_foreach")]
pub fn foreach_mut<F: FnMut(Buffer, u32) -> ControlFlow<Option<Buffer>, Option<Buffer>>>(
&mut self,
func: F,

View file

@ -98,6 +98,7 @@ fn into_raw_sync<F: Fn(&Bus, &Message) -> BusSyncReply + Send + Sync + 'static>(
}
impl Bus {
#[doc(alias = "gst_bus_add_signal_watch")]
#[doc(alias = "gst_bus_add_signal_watch_full")]
pub fn add_signal_watch_full(&self, priority: Priority) {
unsafe {
@ -132,6 +133,7 @@ impl Bus {
}
}
#[doc(alias = "gst_bus_add_watch")]
#[doc(alias = "gst_bus_add_watch_full")]
pub fn add_watch<F>(&self, func: F) -> Result<SourceId, glib::BoolError>
where
@ -154,6 +156,8 @@ impl Bus {
}
}
#[doc(alias = "gst_bus_add_watch")]
#[doc(alias = "gst_bus_add_watch_full")]
pub fn add_watch_local<F>(&self, func: F) -> Result<SourceId, glib::BoolError>
where
F: FnMut(&Bus, &Message) -> Continue + 'static,
@ -231,10 +235,12 @@ impl Bus {
}
}
#[doc(alias = "gst_bus_pop")]
pub fn iter(&self) -> Iter {
self.iter_timed(Some(crate::ClockTime::ZERO))
}
#[doc(alias = "gst_bus_timed_pop")]
pub fn iter_timed(&self, timeout: impl Into<Option<crate::ClockTime>>) -> Iter {
Iter {
bus: self,
@ -242,6 +248,7 @@ impl Bus {
}
}
#[doc(alias = "gst_bus_pop_filtered")]
pub fn iter_filtered<'a>(
&'a self,
msg_types: &'a [MessageType],
@ -249,6 +256,7 @@ impl Bus {
self.iter_timed_filtered(Some(crate::ClockTime::ZERO), msg_types)
}
#[doc(alias = "gst_bus_timed_pop_filtered")]
pub fn iter_timed_filtered<'a>(
&'a self,
timeout: impl Into<Option<crate::ClockTime>>,
@ -258,6 +266,7 @@ impl Bus {
.filter(move |msg| msg_types.contains(&msg.type_()))
}
#[doc(alias = "gst_bus_timed_pop_filtered")]
pub fn timed_pop_filtered(
&self,
timeout: impl Into<Option<crate::ClockTime>> + Clone,
@ -271,6 +280,7 @@ impl Bus {
}
}
#[doc(alias = "gst_bus_pop_filtered")]
pub fn pop_filtered(&self, msg_types: &[MessageType]) -> Option<Message> {
loop {
let msg = self.pop()?;

View file

@ -15,21 +15,25 @@ use glib::value::ToSendValue;
mini_object_wrapper!(Caps, CapsRef, ffi::GstCaps, || { ffi::gst_caps_get_type() });
impl Caps {
#[doc(alias = "gst_caps_new_simple")]
pub fn builder(name: &str) -> Builder<NoFeature> {
assert_initialized_main_thread!();
Builder::new(name)
}
#[doc(alias = "gst_caps_new_full")]
pub fn builder_full() -> BuilderFull<SomeFeatures> {
assert_initialized_main_thread!();
BuilderFull::new()
}
#[doc(alias = "gst_caps_new_full")]
pub fn builder_full_with_features(features: CapsFeatures) -> BuilderFull<SomeFeatures> {
assert_initialized_main_thread!();
BuilderFull::with_features(features)
}
#[doc(alias = "gst_caps_new_full")]
pub fn builder_full_with_any_features() -> BuilderFull<AnyFeatures> {
assert_initialized_main_thread!();
BuilderFull::with_any_features()
@ -47,6 +51,7 @@ impl Caps {
unsafe { from_glib_full(ffi::gst_caps_new_any()) }
}
#[doc(alias = "gst_caps_new_simple")]
pub fn new_simple(name: &str, values: &[(&str, &(dyn ToSendValue + Sync))]) -> Self {
assert_initialized_main_thread!();
let mut caps = Caps::new_empty();
@ -209,6 +214,7 @@ impl std::iter::Extend<(Structure, Option<CapsFeatures>)> for CapsRef {
}
impl CapsRef {
#[doc(alias = "gst_caps_set_simple")]
pub fn set_simple(&mut self, values: &[(&str, &(dyn ToSendValue + Sync))]) {
for &(name, value) in values {
let value = value.to_value();
@ -241,6 +247,7 @@ impl CapsRef {
}
#[doc(alias = "get_mut_structure")]
#[doc(alias = "gst_caps_get_structure")]
pub fn structure_mut(&mut self, idx: u32) -> Option<&mut StructureRef> {
if idx >= self.size() {
return None;
@ -270,6 +277,7 @@ impl CapsRef {
}
#[doc(alias = "get_mut_features")]
#[doc(alias = "gst_caps_get_features")]
pub fn features_mut(&mut self, idx: u32) -> Option<&mut CapsFeaturesRef> {
if idx >= self.size() {
return None;
@ -369,6 +377,7 @@ impl CapsRef {
}
}
#[doc(alias = "gst_caps_intersect_full")]
pub fn intersect_with_mode(&self, other: &Self, mode: CapsIntersectMode) -> Caps {
unsafe {
from_glib_full(ffi::gst_caps_intersect_full(

View file

@ -19,6 +19,7 @@ unsafe impl Send for CapsFeatures {}
unsafe impl Sync for CapsFeatures {}
impl CapsFeatures {
#[doc(alias = "gst_caps_features_new")]
pub fn new(features: &[&str]) -> Self {
assert_initialized_main_thread!();
let mut f = Self::new_empty();
@ -30,6 +31,7 @@ impl CapsFeatures {
f
}
#[doc(alias = "gst_caps_features_new_id")]
pub fn from_quarks(features: &[glib::Quark]) -> Self {
assert_initialized_main_thread!();
let mut f = Self::new_empty();
@ -324,6 +326,7 @@ impl CapsFeaturesRef {
}
}
#[doc(alias = "gst_caps_features_contains_id")]
pub fn contains_quark(&self, feature: glib::Quark) -> bool {
unsafe {
from_glib(ffi::gst_caps_features_contains_id(
@ -356,6 +359,7 @@ impl CapsFeaturesRef {
}
}
#[doc(alias = "gst_caps_features_get_nth_id")]
pub fn nth_quark(&self, idx: u32) -> Option<glib::Quark> {
if idx >= self.size() {
return None;
@ -377,10 +381,12 @@ impl CapsFeaturesRef {
unsafe { ffi::gst_caps_features_remove(self.as_mut_ptr(), feature.to_glib_none().0) }
}
#[doc(alias = "gst_caps_features_add_id")]
pub fn add_from_quark(&mut self, feature: glib::Quark) {
unsafe { ffi::gst_caps_features_add_id(self.as_mut_ptr(), feature.into_glib()) }
}
#[doc(alias = "gst_caps_features_remove_id")]
pub fn remove_by_quark(&mut self, feature: glib::Quark) {
unsafe { ffi::gst_caps_features_remove_id(self.as_mut_ptr(), feature.into_glib()) }
}

View file

@ -34,6 +34,7 @@ glib::wrapper! {
impl ClockId {
#[doc(alias = "get_time")]
#[doc(alias = "gst_clock_id_get_time")]
#[doc(alias = "GST_CLOCK_ENTRY_TIME")]
pub fn time(&self) -> ClockTime {
unsafe {
try_from_glib(ffi::gst_clock_id_get_time(self.to_glib_none().0))
@ -55,6 +56,7 @@ impl ClockId {
}
}
#[doc(alias = "gst_clock_id_compare_func")]
pub fn compare_by_time(&self, other: &Self) -> cmp::Ordering {
unsafe {
let res = ffi::gst_clock_id_compare_func(self.to_glib_none().0, other.to_glib_none().0);
@ -83,6 +85,7 @@ impl ClockId {
}
#[doc(alias = "get_type")]
#[doc(alias = "GST_CLOCK_ENTRY_TYPE")]
pub fn type_(&self) -> ClockEntryType {
unsafe {
let ptr: *mut ffi::GstClockEntry = self.to_glib_none().0 as *mut _;
@ -91,6 +94,7 @@ impl ClockId {
}
#[doc(alias = "get_status")]
#[doc(alias = "GST_CLOCK_ENTRY_STATUS")]
pub fn status(&self) -> &AtomicClockReturn {
unsafe {
let ptr: *mut ffi::GstClockEntry = self.to_glib_none().0 as *mut _;
@ -130,6 +134,7 @@ impl TryFrom<ClockId> for SingleShotClockId {
}
impl SingleShotClockId {
#[doc(alias = "gst_clock_id_compare_func")]
pub fn compare_by_time(&self, other: &Self) -> cmp::Ordering {
self.0.compare_by_time(&other.0)
}
@ -241,6 +246,7 @@ impl TryFrom<ClockId> for PeriodicClockId {
impl PeriodicClockId {
#[doc(alias = "get_interval")]
#[doc(alias = "GST_CLOCK_ENTRY_INTERVAL")]
pub fn interval(&self) -> ClockTime {
unsafe {
let ptr: *mut ffi::GstClockEntry = self.to_glib_none().0 as *mut _;
@ -248,6 +254,7 @@ impl PeriodicClockId {
}
}
#[doc(alias = "gst_clock_id_compare_func")]
pub fn compare_by_time(&self, other: &Self) -> cmp::Ordering {
self.0.compare_by_time(&other.0)
}

View file

@ -32,6 +32,7 @@ use std::num::NonZeroU64;
use std::pin::Pin;
impl Element {
#[doc(alias = "gst_element_link_many")]
pub fn link_many<E: IsA<Element>>(elements: &[&E]) -> Result<(), glib::BoolError> {
skip_assert_initialized!();
for e in elements.windows(2) {
@ -49,6 +50,7 @@ impl Element {
Ok(())
}
#[doc(alias = "gst_element_unlink_many")]
pub fn unlink_many<E: IsA<Element>>(elements: &[&E]) {
skip_assert_initialized!();
for e in elements.windows(2) {
@ -181,10 +183,13 @@ pub trait ElementExtManual: 'static {
fn iterate_src_pads(&self) -> crate::Iterator<Pad>;
#[doc(alias = "get_pads")]
#[doc(alias = "gst_element_foreach_pad")]
fn pads(&self) -> Vec<Pad>;
#[doc(alias = "get_sink_pads")]
#[doc(alias = "gst_element_foreach_sink_pad")]
fn sink_pads(&self) -> Vec<Pad>;
#[doc(alias = "get_src_pads")]
#[doc(alias = "gst_element_foreach_src_pad")]
fn src_pads(&self) -> Vec<Pad>;
fn num_pads(&self) -> u16;
@ -227,10 +232,12 @@ pub trait ElementExtManual: 'static {
#[doc(alias = "gst_element_query_duration")]
fn query_duration<T: SpecificFormattedValueIntrinsic>(&self) -> Option<T>;
#[doc(alias = "gst_element_query_duration")]
fn query_duration_generic(&self, format: Format) -> Option<GenericFormattedValue>;
#[doc(alias = "gst_element_query_position")]
fn query_position<T: SpecificFormattedValueIntrinsic>(&self) -> Option<T>;
#[doc(alias = "gst_element_query_position")]
fn query_position_generic(&self, format: Format) -> Option<GenericFormattedValue>;
#[doc(alias = "gst_element_seek")]
@ -265,9 +272,11 @@ pub trait ElementExtManual: 'static {
T: Send + 'static;
#[doc(alias = "get_current_running_time")]
#[doc(alias = "gst_element_get_current_running_time")]
fn current_running_time(&self) -> Option<crate::ClockTime>;
#[doc(alias = "get_current_clock_time")]
#[doc(alias = "gst_element_get_current_clock_time")]
fn current_clock_time(&self) -> Option<crate::ClockTime>;
#[doc(alias = "gst_element_get_request_pad")]
@ -861,37 +870,45 @@ pub unsafe trait ElementClassExt {
unsafe impl<T: IsA<Element> + glib::object::IsClass> ElementClassExt for glib::object::Class<T> {}
#[doc(alias = "GST_ELEMENT_METADATA_AUTHOR")]
pub static ELEMENT_METADATA_AUTHOR: Lazy<&'static str> = Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_ELEMENT_METADATA_AUTHOR)
.to_str()
.unwrap()
});
#[doc(alias = "GST_ELEMENT_METADATA_DESCRIPTION")]
pub static ELEMENT_METADATA_DESCRIPTION: Lazy<&'static str> = Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_ELEMENT_METADATA_DESCRIPTION)
.to_str()
.unwrap()
});
#[doc(alias = "GST_ELEMENT_METADATA_DOC_URI")]
pub static ELEMENT_METADATA_DOC_URI: Lazy<&'static str> = Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_ELEMENT_METADATA_DOC_URI)
.to_str()
.unwrap()
});
#[doc(alias = "GST_ELEMENT_METADATA_ICON_NAME")]
pub static ELEMENT_METADATA_ICON_NAME: Lazy<&'static str> = Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_ELEMENT_METADATA_ICON_NAME)
.to_str()
.unwrap()
});
#[doc(alias = "GST_ELEMENT_METADATA_KLASS")]
pub static ELEMENT_METADATA_KLASS: Lazy<&'static str> = Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_ELEMENT_METADATA_KLASS)
.to_str()
.unwrap()
});
#[doc(alias = "GST_ELEMENT_METADATA_LONGNAME")]
pub static ELEMENT_METADATA_LONGNAME: Lazy<&'static str> = Lazy::new(|| unsafe {
CStr::from_ptr(ffi::GST_ELEMENT_METADATA_LONGNAME)
.to_str()
.unwrap()
});
#[doc(alias = "GST_ELEMENT_ERROR")]
#[doc(alias = "GST_ELEMENT_ERROR_WITH_DETAILS")]
#[macro_export]
macro_rules! element_error(
($obj:expr, $err:expr, ($msg:expr), [$debug:expr]) => { {
@ -1047,6 +1064,8 @@ macro_rules! element_error(
}};
);
#[doc(alias = "GST_ELEMENT_WARNING")]
#[doc(alias = "GST_ELEMENT_WARNING_WITH_DETAILS")]
#[macro_export]
macro_rules! element_warning(
($obj:expr, $err:expr, ($msg:expr), [$debug:expr]) => { {
@ -1202,6 +1221,8 @@ macro_rules! element_warning(
}};
);
#[doc(alias = "GST_ELEMENT_INFO")]
#[doc(alias = "GST_ELEMENT_INFO_WITH_DETAILS")]
#[macro_export]
macro_rules! element_info(
($obj:expr, $err:expr, ($msg:expr), [$debug:expr]) => { {

View file

@ -60,21 +60,25 @@ impl GhostPad {
}
}
#[doc(alias = "gst_ghost_pad_new_no_target")]
pub fn new(name: Option<&str>, direction: crate::PadDirection) -> Self {
skip_assert_initialized!();
Self::builder(name, direction).build()
}
#[doc(alias = "gst_ghost_pad_new_no_target")]
pub fn builder(name: Option<&str>, direction: crate::PadDirection) -> PadBuilder<Self> {
skip_assert_initialized!();
PadBuilder::new(name, direction)
}
#[doc(alias = "gst_ghost_pad_new_no_target_from_static_template")]
pub fn from_static_template(templ: &StaticPadTemplate, name: Option<&str>) -> Self {
skip_assert_initialized!();
Self::builder_with_static_template(templ, name).build()
}
#[doc(alias = "gst_ghost_pad_new_no_target_from_static_template")]
pub fn builder_with_static_template(
templ: &StaticPadTemplate,
name: Option<&str>,
@ -83,11 +87,13 @@ impl GhostPad {
PadBuilder::from_static_template(templ, name)
}
#[doc(alias = "gst_ghost_pad_new_no_target_from_template")]
pub fn from_template(templ: &crate::PadTemplate, name: Option<&str>) -> Self {
skip_assert_initialized!();
Self::builder_with_template(templ, name).build()
}
#[doc(alias = "gst_ghost_pad_new_no_target_from_template")]
pub fn builder_with_template(
templ: &crate::PadTemplate,
name: Option<&str>,
@ -96,6 +102,7 @@ impl GhostPad {
PadBuilder::from_template(templ, name)
}
#[doc(alias = "gst_ghost_pad_new")]
pub fn with_target<P: IsA<Pad>>(
name: Option<&str>,
target: &P,
@ -104,6 +111,7 @@ impl GhostPad {
Self::builder(name, target.direction()).build_with_target(target)
}
#[doc(alias = "gst_ghost_pad_new_from_template")]
pub fn from_template_with_target<P: IsA<Pad>>(
templ: &crate::PadTemplate,
name: Option<&str>,
@ -122,6 +130,7 @@ impl GhostPad {
}
impl<T: IsA<GhostPad> + IsA<Pad>> PadBuilder<T> {
#[doc(alias = "gst_pad_set_activate_function")]
pub fn proxy_pad_activate_function<F>(self, func: F) -> Self
where
F: Fn(&crate::ProxyPad, Option<&crate::Object>) -> Result<(), LoggableError>
@ -141,6 +150,7 @@ impl<T: IsA<GhostPad> + IsA<Pad>> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_activatemode_function")]
pub fn proxy_pad_activatemode_function<F>(self, func: F) -> Self
where
F: Fn(
@ -165,6 +175,7 @@ impl<T: IsA<GhostPad> + IsA<Pad>> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_chain_function")]
pub fn proxy_pad_chain_function<F>(self, func: F) -> Self
where
F: Fn(
@ -188,6 +199,7 @@ impl<T: IsA<GhostPad> + IsA<Pad>> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_chain_list_function")]
pub fn proxy_pad_chain_list_function<F>(self, func: F) -> Self
where
F: Fn(
@ -211,6 +223,7 @@ impl<T: IsA<GhostPad> + IsA<Pad>> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_event_function")]
pub fn proxy_pad_event_function<F>(self, func: F) -> Self
where
F: Fn(&crate::ProxyPad, Option<&crate::Object>, crate::Event) -> bool
@ -230,6 +243,7 @@ impl<T: IsA<GhostPad> + IsA<Pad>> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_event_full_function")]
pub fn proxy_pad_event_full_function<F>(self, func: F) -> Self
where
F: Fn(
@ -253,6 +267,7 @@ impl<T: IsA<GhostPad> + IsA<Pad>> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_getrange_function")]
pub fn proxy_pad_getrange_function<F>(self, func: F) -> Self
where
F: Fn(
@ -278,6 +293,7 @@ impl<T: IsA<GhostPad> + IsA<Pad>> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_iterate_internal_links_function")]
pub fn proxy_pad_iterate_internal_links_function<F>(self, func: F) -> Self
where
F: Fn(&crate::ProxyPad, Option<&crate::Object>) -> crate::Iterator<Pad>
@ -297,6 +313,7 @@ impl<T: IsA<GhostPad> + IsA<Pad>> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_link_function")]
pub fn proxy_pad_link_function<F>(self, func: F) -> Self
where
F: Fn(
@ -320,6 +337,7 @@ impl<T: IsA<GhostPad> + IsA<Pad>> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_query_function")]
pub fn proxy_pad_query_function<F>(self, func: F) -> Self
where
F: Fn(&crate::ProxyPad, Option<&crate::Object>, &mut crate::QueryRef) -> bool
@ -339,6 +357,7 @@ impl<T: IsA<GhostPad> + IsA<Pad>> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_unlink_function")]
pub fn proxy_pad_unlink_function<F>(self, func: F) -> Self
where
F: Fn(&crate::ProxyPad, Option<&crate::Object>) + Send + Sync + 'static,

View file

@ -8,6 +8,7 @@ use crate::ClockTime;
use crate::ObjectFlags;
pub trait GstObjectExtManual: 'static {
#[doc(alias = "deep-notify")]
fn connect_deep_notify<F: Fn(&Self, &crate::Object, &glib::ParamSpec) + Send + Sync + 'static>(
&self,
name: Option<&str>,

View file

@ -48,6 +48,7 @@ impl FromGlib<libc::c_ulong> for PadProbeId {
}
}
#[doc(alias = "GstPadProbeInfo")]
#[derive(Debug)]
pub struct PadProbeInfo<'a> {
pub mask: PadProbeType,
@ -168,10 +169,14 @@ pub trait PadExtManual: 'static {
fn stream_lock(&self) -> StreamLock;
#[doc(alias = "gst_pad_set_activate_function")]
#[doc(alias = "gst_pad_set_activate_function_full")]
unsafe fn set_activate_function<F>(&self, func: F)
where
F: Fn(&Self, Option<&crate::Object>) -> Result<(), LoggableError> + Send + Sync + 'static;
#[doc(alias = "gst_pad_set_activatemode_function")]
#[doc(alias = "gst_pad_set_activatemode_function_full")]
unsafe fn set_activatemode_function<F>(&self, func: F)
where
F: Fn(&Self, Option<&crate::Object>, crate::PadMode, bool) -> Result<(), LoggableError>
@ -179,6 +184,8 @@ pub trait PadExtManual: 'static {
+ Sync
+ 'static;
#[doc(alias = "gst_pad_set_chain_function")]
#[doc(alias = "gst_pad_set_chain_function_full")]
unsafe fn set_chain_function<F>(&self, func: F)
where
F: Fn(&Self, Option<&crate::Object>, crate::Buffer) -> Result<FlowSuccess, FlowError>
@ -186,6 +193,8 @@ pub trait PadExtManual: 'static {
+ Sync
+ 'static;
#[doc(alias = "gst_pad_set_chain_list_function")]
#[doc(alias = "gst_pad_set_chain_list_function_full")]
unsafe fn set_chain_list_function<F>(&self, func: F)
where
F: Fn(&Self, Option<&crate::Object>, crate::BufferList) -> Result<FlowSuccess, FlowError>
@ -193,10 +202,14 @@ pub trait PadExtManual: 'static {
+ Sync
+ 'static;
#[doc(alias = "gst_pad_set_event_function")]
#[doc(alias = "gst_pad_set_event_function_full")]
unsafe fn set_event_function<F>(&self, func: F)
where
F: Fn(&Self, Option<&crate::Object>, crate::Event) -> bool + Send + Sync + 'static;
#[doc(alias = "gst_pad_set_event_full_function")]
#[doc(alias = "gst_pad_set_event_full_function_full")]
unsafe fn set_event_full_function<F>(&self, func: F)
where
F: Fn(&Self, Option<&crate::Object>, crate::Event) -> Result<FlowSuccess, FlowError>
@ -204,6 +217,8 @@ pub trait PadExtManual: 'static {
+ Sync
+ 'static;
#[doc(alias = "gst_pad_set_getrange_function")]
#[doc(alias = "gst_pad_set_getrange_function_full")]
unsafe fn set_getrange_function<F>(&self, func: F)
where
F: Fn(
@ -217,10 +232,14 @@ pub trait PadExtManual: 'static {
+ Sync
+ 'static;
#[doc(alias = "gst_pad_set_iterate_internal_links_function")]
#[doc(alias = "gst_pad_set_iterate_internal_links_function_full")]
unsafe fn set_iterate_internal_links_function<F>(&self, func: F)
where
F: Fn(&Self, Option<&crate::Object>) -> crate::Iterator<Pad> + Send + Sync + 'static;
#[doc(alias = "gst_pad_set_link_function")]
#[doc(alias = "gst_pad_set_link_function_full")]
unsafe fn set_link_function<F>(&self, func: F)
where
F: Fn(
@ -232,10 +251,14 @@ pub trait PadExtManual: 'static {
+ Sync
+ 'static;
#[doc(alias = "gst_pad_set_query_function")]
#[doc(alias = "gst_pad_set_query_function_full")]
unsafe fn set_query_function<F>(&self, func: F)
where
F: Fn(&Self, Option<&crate::Object>, &mut crate::QueryRef) -> bool + Send + Sync + 'static;
#[doc(alias = "gst_pad_set_unlink_function")]
#[doc(alias = "gst_pad_set_unlink_function_full")]
unsafe fn set_unlink_function<F>(&self, func: F)
where
F: Fn(&Self, Option<&crate::Object>) + Send + Sync + 'static;
@ -248,6 +271,7 @@ pub trait PadExtManual: 'static {
&self,
src_val: V,
) -> Option<U>;
#[doc(alias = "gst_pad_peer_query_convert")]
fn peer_query_convert_generic<V: Into<GenericFormattedValue>>(
&self,
src_val: V,
@ -256,10 +280,12 @@ pub trait PadExtManual: 'static {
#[doc(alias = "gst_pad_peer_query_duration")]
fn peer_query_duration<T: SpecificFormattedValueIntrinsic>(&self) -> Option<T>;
#[doc(alias = "gst_pad_peer_query_duration")]
fn peer_query_duration_generic(&self, format: Format) -> Option<GenericFormattedValue>;
#[doc(alias = "gst_pad_peer_query_position")]
fn peer_query_position<T: SpecificFormattedValueIntrinsic>(&self) -> Option<T>;
#[doc(alias = "gst_pad_peer_query_position")]
fn peer_query_position_generic(&self, format: Format) -> Option<GenericFormattedValue>;
#[doc(alias = "gst_pad_query_convert")]
@ -267,6 +293,7 @@ pub trait PadExtManual: 'static {
&self,
src_val: V,
) -> Option<U>;
#[doc(alias = "gst_pad_query_convert")]
fn query_convert_generic<V: Into<GenericFormattedValue>>(
&self,
src_val: V,
@ -275,14 +302,18 @@ pub trait PadExtManual: 'static {
#[doc(alias = "gst_pad_query_duration")]
fn query_duration<T: SpecificFormattedValueIntrinsic>(&self) -> Option<T>;
#[doc(alias = "gst_pad_query_duration")]
fn query_duration_generic(&self, format: Format) -> Option<GenericFormattedValue>;
#[doc(alias = "gst_pad_query_position")]
fn query_position<T: SpecificFormattedValueIntrinsic>(&self) -> Option<T>;
#[doc(alias = "gst_pad_query_position")]
fn query_position_generic(&self, format: Format) -> Option<GenericFormattedValue>;
#[doc(alias = "get_mode")]
#[doc(alias = "GST_PAD_MODE")]
fn mode(&self) -> crate::PadMode;
#[doc(alias = "gst_pad_sticky_events_foreach")]
fn sticky_events_foreach<
F: FnMut(&Event) -> ControlFlow<EventForeachAction, EventForeachAction>,
@ -1581,21 +1612,25 @@ unsafe extern "C" fn destroy_closure_pad_task<F>(ptr: gpointer) {
}
impl Pad {
#[doc(alias = "gst_pad_new")]
pub fn new(name: Option<&str>, direction: crate::PadDirection) -> Self {
skip_assert_initialized!();
Self::builder(name, direction).build()
}
#[doc(alias = "gst_pad_new")]
pub fn builder(name: Option<&str>, direction: crate::PadDirection) -> PadBuilder<Self> {
skip_assert_initialized!();
PadBuilder::new(name, direction)
}
#[doc(alias = "gst_pad_new_from_static_template")]
pub fn from_static_template(templ: &StaticPadTemplate, name: Option<&str>) -> Self {
skip_assert_initialized!();
Self::builder_with_static_template(templ, name).build()
}
#[doc(alias = "gst_pad_new_from_static_template")]
pub fn builder_with_static_template(
templ: &StaticPadTemplate,
name: Option<&str>,
@ -1604,11 +1639,13 @@ impl Pad {
PadBuilder::from_static_template(templ, name)
}
#[doc(alias = "gst_pad_new_from_template")]
pub fn from_template(templ: &crate::PadTemplate, name: Option<&str>) -> Self {
skip_assert_initialized!();
Self::builder_with_template(templ, name).build()
}
#[doc(alias = "gst_pad_new_from_template")]
pub fn builder_with_template(
templ: &crate::PadTemplate,
name: Option<&str>,
@ -1693,6 +1730,7 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
PadBuilder(pad)
}
#[doc(alias = "gst_pad_set_activate_function")]
pub fn activate_function<F>(self, func: F) -> Self
where
F: Fn(&T, Option<&crate::Object>) -> Result<(), LoggableError> + Send + Sync + 'static,
@ -1704,6 +1742,7 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_activatemode_function")]
pub fn activatemode_function<F>(self, func: F) -> Self
where
F: Fn(&T, Option<&crate::Object>, crate::PadMode, bool) -> Result<(), LoggableError>
@ -1718,6 +1757,7 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_chain_function")]
pub fn chain_function<F>(self, func: F) -> Self
where
F: Fn(&T, Option<&crate::Object>, crate::Buffer) -> Result<FlowSuccess, FlowError>
@ -1732,6 +1772,7 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_chain_list_function")]
pub fn chain_list_function<F>(self, func: F) -> Self
where
F: Fn(&T, Option<&crate::Object>, crate::BufferList) -> Result<FlowSuccess, FlowError>
@ -1746,6 +1787,7 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_event_function")]
pub fn event_function<F>(self, func: F) -> Self
where
F: Fn(&T, Option<&crate::Object>, crate::Event) -> bool + Send + Sync + 'static,
@ -1757,6 +1799,7 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_event_full_function")]
pub fn event_full_function<F>(self, func: F) -> Self
where
F: Fn(&T, Option<&crate::Object>, crate::Event) -> Result<FlowSuccess, FlowError>
@ -1771,6 +1814,7 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_getrange_function")]
pub fn getrange_function<F>(self, func: F) -> Self
where
F: Fn(
@ -1791,6 +1835,7 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_iterate_internal_links_function")]
pub fn iterate_internal_links_function<F>(self, func: F) -> Self
where
F: Fn(&T, Option<&crate::Object>) -> crate::Iterator<Pad> + Send + Sync + 'static,
@ -1802,6 +1847,7 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_link_function")]
pub fn link_function<F>(self, func: F) -> Self
where
F: Fn(
@ -1820,6 +1866,7 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_query_function")]
pub fn query_function<F>(self, func: F) -> Self
where
F: Fn(&T, Option<&crate::Object>, &mut crate::QueryRef) -> bool + Send + Sync + 'static,
@ -1831,6 +1878,7 @@ impl<T: IsA<Pad> + IsA<glib::Object> + glib::object::IsClass> PadBuilder<T> {
self
}
#[doc(alias = "gst_pad_set_unlink_function")]
pub fn unlink_function<F>(self, func: F) -> Self
where
F: Fn(&T, Option<&crate::Object>) + Send + Sync + 'static,

View file

@ -68,6 +68,7 @@ unsafe impl Send for Structure {}
unsafe impl Sync for Structure {}
impl Structure {
#[doc(alias = "gst_structure_new")]
pub fn builder(name: &str) -> Builder {
assert_initialized_main_thread!();
Builder::new(name)
@ -83,6 +84,7 @@ impl Structure {
}
}
#[doc(alias = "gst_structure_new")]
pub fn new(name: &str, values: &[(&str, &(dyn ToSendValue + Sync))]) -> Structure {
assert_initialized_main_thread!();
let mut structure = Structure::new_empty(name);
@ -380,6 +382,7 @@ impl StructureRef {
self as *const Self as *mut ffi::GstStructure
}
#[doc(alias = "gst_structure_get")]
pub fn get<'a, T: FromValue<'a>>(&'a self, name: &str) -> Result<T, GetError>
where
<<T as FromValue<'a>>::Checker as glib::value::ValueTypeChecker>::Error: GlibValueError,
@ -388,6 +391,7 @@ impl StructureRef {
self.get_by_quark(name)
}
#[doc(alias = "gst_structure_get")]
pub fn get_optional<'a, T: FromValue<'a>>(&'a self, name: &str) -> Result<Option<T>, GetError>
where
<<T as FromValue<'a>>::Checker as glib::value::ValueTypeChecker>::Error: GlibValueError,
@ -397,11 +401,13 @@ impl StructureRef {
}
#[doc(alias = "get_value")]
#[doc(alias = "gst_structure_get_value")]
pub fn value(&self, name: &str) -> Result<&SendValue, GetError> {
let name = glib::Quark::from_string(name);
self.value_by_quark(name)
}
#[doc(alias = "gst_structure_id_get")]
pub fn get_by_quark<'a, T: FromValue<'a>>(&'a self, name: glib::Quark) -> Result<T, GetError>
where
<<T as FromValue<'a>>::Checker as glib::value::ValueTypeChecker>::Error: GlibValueError,
@ -411,6 +417,7 @@ impl StructureRef {
.map_err(|err| GetError::from_value_get_error(name.to_string(), err))
}
#[doc(alias = "gst_structure_id_get")]
pub fn get_optional_by_quark<'a, T: FromValue<'a>>(
&'a self,
name: glib::Quark,
@ -425,6 +432,7 @@ impl StructureRef {
.map_err(|err| GetError::from_value_get_error(name.to_string(), err))
}
#[doc(alias = "gst_structure_id_get_value")]
pub fn value_by_quark(&self, name: glib::Quark) -> Result<&SendValue, GetError> {
unsafe {
let value = ffi::gst_structure_id_get_value(&self.0, name.into_glib());
@ -437,11 +445,13 @@ impl StructureRef {
}
}
#[doc(alias = "gst_structure_set")]
pub fn set<T: ToSendValue + Sync>(&mut self, name: &str, value: T) {
let value = value.to_send_value();
self.set_value(name, value);
}
#[doc(alias = "gst_structure_set_value")]
pub fn set_value(&mut self, name: &str, value: SendValue) {
unsafe {
ffi::gst_structure_take_value(
@ -452,11 +462,13 @@ impl StructureRef {
}
}
#[doc(alias = "gst_structure_id_set")]
pub fn set_by_quark<T: ToSendValue + Sync>(&mut self, name: glib::Quark, value: T) {
let value = value.to_send_value();
self.set_value_by_quark(name, value);
}
#[doc(alias = "gst_structure_id_set_value")]
pub fn set_value_by_quark(&mut self, name: glib::Quark, value: SendValue) {
unsafe {
ffi::gst_structure_id_take_value(&mut self.0, name.into_glib(), &mut value.into_raw());
@ -473,6 +485,7 @@ impl StructureRef {
}
}
#[doc(alias = "gst_structure_get_name_id")]
pub fn name_quark(&self) -> glib::Quark {
unsafe { from_glib(ffi::gst_structure_get_name_id(&self.0)) }
}
@ -492,6 +505,7 @@ impl StructureRef {
}
}
#[doc(alias = "gst_structure_has_field_typed")]
pub fn has_field_with_type(&self, field: &str, type_: glib::Type) -> bool {
unsafe {
from_glib(ffi::gst_structure_has_field_typed(
@ -502,10 +516,12 @@ impl StructureRef {
}
}
#[doc(alias = "gst_structure_id_has_field")]
pub fn has_field_by_quark(&self, field: glib::Quark) -> bool {
unsafe { from_glib(ffi::gst_structure_id_has_field(&self.0, field.into_glib())) }
}
#[doc(alias = "gst_structure_id_has_field_typed")]
pub fn has_field_with_type_by_quark(&self, field: glib::Quark, type_: glib::Type) -> bool {
unsafe {
from_glib(ffi::gst_structure_id_has_field_typed(
@ -523,6 +539,7 @@ impl StructureRef {
}
}
#[doc(alias = "gst_structure_remove_fields")]
pub fn remove_fields(&mut self, fields: &[&str]) {
for f in fields {
self.remove_field(f)

View file

@ -368,12 +368,14 @@ impl<T> TagValue<T> {
}
impl TagListRef {
#[doc(alias = "gst_tag_list_add")]
pub fn add<'a, T: Tag<'a>>(&mut self, value: &T::TagType, mode: TagMergeMode) {
// result can be safely ignored here as `value`'s type is tied to `T::tag_name()`
let v = <T::TagType as ToSendValue>::to_send_value(value);
let _res = self.add_value(T::tag_name(), &v, mode);
}
#[doc(alias = "gst_tag_list_add")]
pub fn add_generic<T: ToSendValue + Sync>(
&mut self,
tag_name: &str,
@ -410,10 +412,12 @@ impl TagListRef {
Ok(())
}
#[doc(alias = "gst_tag_list_remove_tag")]
pub fn remove<'a, T: Tag<'a>>(&mut self) {
self.remove_generic(T::tag_name());
}
#[doc(alias = "gst_tag_list_remove_tag")]
pub fn remove_generic(&mut self, tag_name: &str) {
unsafe {
let tag_name = tag_name.to_glib_none();
@ -422,6 +426,7 @@ impl TagListRef {
}
}
#[doc(alias = "gst_tag_list_get")]
pub fn get<'a, T: Tag<'a>>(&self) -> Option<TagValue<T::TagType>> {
self.generic(T::tag_name()).map(|value| {
if !value.is::<T::TagType>() {
@ -435,6 +440,7 @@ impl TagListRef {
})
}
#[doc(alias = "gst_tag_list_get")]
#[doc(alias = "get_generic")]
pub fn generic(&self, tag_name: &str) -> Option<SendValue> {
unsafe {
@ -469,6 +475,7 @@ impl TagListRef {
}
#[doc(alias = "get_index")]
#[doc(alias = "gst_tag_list_get_index")]
pub fn index<'a, T: Tag<'a>>(&self, idx: u32) -> Option<&'a TagValue<T::TagType>> {
self.index_generic(T::tag_name(), idx).map(|value| {
if !value.is::<T::TagType>() {
@ -483,6 +490,7 @@ impl TagListRef {
}
#[doc(alias = "get_index_generic")]
#[doc(alias = "gst_tag_list_get_index")]
pub fn index_generic<'a>(&'a self, tag_name: &str, idx: u32) -> Option<&'a SendValue> {
unsafe {
let value =
@ -497,11 +505,13 @@ impl TagListRef {
}
#[doc(alias = "get_size")]
#[doc(alias = "gst_tag_list_get_tag_size")]
pub fn size<'a, T: Tag<'a>>(&self) -> u32 {
self.size_by_name(T::tag_name())
}
#[doc(alias = "get_size_by_name")]
#[doc(alias = "gst_tag_list_get_tag_size")]
pub fn size_by_name(&self, tag_name: &str) -> u32 {
unsafe { ffi::gst_tag_list_get_tag_size(self.as_ptr(), tag_name.to_glib_none().0) }
}