forked from mirrors/gstreamer-rs
gstreamer: Improve accessors to various pad template fields
This commit is contained in:
parent
45856ac35b
commit
0aa59be45c
3 changed files with 88 additions and 36 deletions
|
@ -1796,6 +1796,36 @@ final_type = true
|
||||||
# static pad template manual
|
# static pad template manual
|
||||||
manual = true
|
manual = true
|
||||||
|
|
||||||
|
[[object.function]]
|
||||||
|
name = "get_caps"
|
||||||
|
# directly access the field
|
||||||
|
manual = true
|
||||||
|
|
||||||
|
[[object.function]]
|
||||||
|
name = "get_documentation_caps"
|
||||||
|
# directly access the field
|
||||||
|
manual = true
|
||||||
|
|
||||||
|
[[object.property]]
|
||||||
|
name = "name-template"
|
||||||
|
# directly access the field and borrow the string
|
||||||
|
manual = true
|
||||||
|
|
||||||
|
[[object.property]]
|
||||||
|
name = "direction"
|
||||||
|
# directly access the field
|
||||||
|
manual = true
|
||||||
|
|
||||||
|
[[object.property]]
|
||||||
|
name = "presence"
|
||||||
|
# directly access the field
|
||||||
|
manual = true
|
||||||
|
|
||||||
|
[[object.property]]
|
||||||
|
name = "gtype"
|
||||||
|
# directly access the field
|
||||||
|
manual = true
|
||||||
|
|
||||||
[[object]]
|
[[object]]
|
||||||
name = "Gst.ParseContext"
|
name = "Gst.ParseContext"
|
||||||
status = "manual"
|
status = "manual"
|
||||||
|
|
|
@ -13,7 +13,6 @@ use glib::object::ObjectType as ObjectType_;
|
||||||
use glib::signal::connect_raw;
|
use glib::signal::connect_raw;
|
||||||
use glib::signal::SignalHandlerId;
|
use glib::signal::SignalHandlerId;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
use glib::StaticType;
|
|
||||||
use std::boxed::Box as Box_;
|
use std::boxed::Box as Box_;
|
||||||
use std::mem::transmute;
|
use std::mem::transmute;
|
||||||
|
|
||||||
|
@ -68,24 +67,6 @@ impl PadTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[doc(alias = "gst_pad_template_get_caps")]
|
|
||||||
#[doc(alias = "get_caps")]
|
|
||||||
pub fn caps(&self) -> Caps {
|
|
||||||
unsafe { from_glib_full(ffi::gst_pad_template_get_caps(self.to_glib_none().0)) }
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(any(feature = "v1_18", feature = "dox"))]
|
|
||||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
|
|
||||||
#[doc(alias = "gst_pad_template_get_documentation_caps")]
|
|
||||||
#[doc(alias = "get_documentation_caps")]
|
|
||||||
pub fn documentation_caps(&self) -> Caps {
|
|
||||||
unsafe {
|
|
||||||
from_glib_full(ffi::gst_pad_template_get_documentation_caps(
|
|
||||||
self.to_glib_none().0,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[doc(alias = "gst_pad_template_pad_created")]
|
#[doc(alias = "gst_pad_template_pad_created")]
|
||||||
pub fn pad_created(&self, pad: &impl IsA<Pad>) {
|
pub fn pad_created(&self, pad: &impl IsA<Pad>) {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -105,23 +86,6 @@ impl PadTemplate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn direction(&self) -> PadDirection {
|
|
||||||
glib::ObjectExt::property(self, "direction")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn gtype(&self) -> glib::types::Type {
|
|
||||||
glib::ObjectExt::property(self, "gtype")
|
|
||||||
}
|
|
||||||
|
|
||||||
#[doc(alias = "name-template")]
|
|
||||||
pub fn name_template(&self) -> Option<glib::GString> {
|
|
||||||
glib::ObjectExt::property(self, "name-template")
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn presence(&self) -> PadPresence {
|
|
||||||
glib::ObjectExt::property(self, "presence")
|
|
||||||
}
|
|
||||||
|
|
||||||
#[doc(alias = "pad-created")]
|
#[doc(alias = "pad-created")]
|
||||||
pub fn connect_pad_created<F: Fn(&Self, &Pad) + Send + Sync + 'static>(
|
pub fn connect_pad_created<F: Fn(&Self, &Pad) + Send + Sync + 'static>(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
// Take a look at the license at the top of the repository in the LICENSE file.
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||||
|
|
||||||
|
use crate::Caps;
|
||||||
|
use crate::PadDirection;
|
||||||
|
use crate::PadPresence;
|
||||||
use crate::PadTemplate;
|
use crate::PadTemplate;
|
||||||
use crate::StaticPadTemplate;
|
use crate::StaticPadTemplate;
|
||||||
|
use glib::prelude::*;
|
||||||
use glib::translate::*;
|
use glib::translate::*;
|
||||||
|
use std::ffi::CStr;
|
||||||
|
|
||||||
impl PadTemplate {
|
impl PadTemplate {
|
||||||
#[doc(alias = "gst_pad_template_new_from_static_pad_template_with_gtype")]
|
#[doc(alias = "gst_pad_template_new_from_static_pad_template_with_gtype")]
|
||||||
|
@ -21,4 +26,57 @@ impl PadTemplate {
|
||||||
.ok_or_else(|| glib::bool_error!("Failed to create PadTemplate"))
|
.ok_or_else(|| glib::bool_error!("Failed to create PadTemplate"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[doc(alias = "gst_pad_template_get_caps")]
|
||||||
|
#[doc(alias = "get_caps")]
|
||||||
|
pub fn caps(&self) -> &Caps {
|
||||||
|
unsafe {
|
||||||
|
let templ = &*(self.as_ptr() as *const ffi::GstPadTemplate);
|
||||||
|
&*(&templ.caps as *const *mut ffi::GstCaps as *const Caps)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(any(feature = "v1_18", feature = "dox"))]
|
||||||
|
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
|
||||||
|
#[doc(alias = "gst_pad_template_get_documentation_caps")]
|
||||||
|
#[doc(alias = "get_documentation_caps")]
|
||||||
|
pub fn documentation_caps(&self) -> &Caps {
|
||||||
|
unsafe {
|
||||||
|
let templ = &*(self.as_ptr() as *const ffi::GstPadTemplate);
|
||||||
|
if !templ.ABI.abi.documentation_caps.is_null() {
|
||||||
|
&*(&templ.ABI.abi.documentation_caps as *const *mut ffi::GstCaps as *const Caps)
|
||||||
|
} else {
|
||||||
|
&*(&templ.caps as *const *mut ffi::GstCaps as *const Caps)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn direction(&self) -> PadDirection {
|
||||||
|
unsafe {
|
||||||
|
let templ = &*(self.as_ptr() as *const ffi::GstPadTemplate);
|
||||||
|
from_glib(templ.direction)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn gtype(&self) -> glib::types::Type {
|
||||||
|
unsafe {
|
||||||
|
let templ = &*(self.as_ptr() as *const ffi::GstPadTemplate);
|
||||||
|
from_glib(templ.ABI.abi.gtype)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[doc(alias = "name-template")]
|
||||||
|
pub fn name_template(&self) -> &str {
|
||||||
|
unsafe {
|
||||||
|
let templ = &*(self.as_ptr() as *const ffi::GstPadTemplate);
|
||||||
|
CStr::from_ptr(templ.name_template).to_str().unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn presence(&self) -> PadPresence {
|
||||||
|
unsafe {
|
||||||
|
let templ = &*(self.as_ptr() as *const ffi::GstPadTemplate);
|
||||||
|
from_glib(templ.presence)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue