forked from mirrors/gstreamer-rs
gstreamer: Use glib::List
in various places for reducing allocations when working with factory lists
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/359
This commit is contained in:
parent
9263c9f42e
commit
668b2b3fdf
20 changed files with 316 additions and 210 deletions
|
@ -1091,6 +1091,28 @@ final_type = true
|
|||
# separate name/value arrays need to be merged
|
||||
manual = true
|
||||
|
||||
[[object.function]]
|
||||
name = "get_static_pad_templates"
|
||||
# Use glib::List as return type
|
||||
manual = true
|
||||
|
||||
[[object.function]]
|
||||
name = "list_is_type"
|
||||
rename = "has_type"
|
||||
# Renamed flags type
|
||||
manual = true
|
||||
|
||||
[[object.function]]
|
||||
name = "list_filter"
|
||||
# can_{sink,src}_{all,any}_caps() around an iterator is the same
|
||||
ignore = true
|
||||
|
||||
[[object.function]]
|
||||
name = "list_get_elements"
|
||||
rename = "factories_with_type"
|
||||
# Use glib::List as return type
|
||||
manual = true
|
||||
|
||||
[[object]]
|
||||
name = "Gst.TypeFindFactory"
|
||||
status = "generate"
|
||||
|
@ -1101,10 +1123,21 @@ final_type = true
|
|||
# Set up native functions in `TypeFind`, calling into trait argument
|
||||
manual = true
|
||||
|
||||
[[object.function]]
|
||||
name = "get_list"
|
||||
rename = "factories"
|
||||
# Use glib::List as return type
|
||||
manual = true
|
||||
|
||||
[[object]]
|
||||
name = "Gst.DeviceProviderFactory"
|
||||
status = "generate"
|
||||
final_type = true
|
||||
[[object.function]]
|
||||
name = "list_get_device_providers"
|
||||
rename = "factories"
|
||||
# Use glib::List as return type
|
||||
manual = true
|
||||
|
||||
[[object]]
|
||||
name = "Gst.DeviceProvider"
|
||||
|
@ -1124,6 +1157,11 @@ manual_traits = ["DeviceProviderExtManual"]
|
|||
# better manual function
|
||||
manual = true
|
||||
|
||||
[[object.function]]
|
||||
name = "get_devices"
|
||||
# Use glib::List as return type
|
||||
manual = true
|
||||
|
||||
[[object]]
|
||||
name = "Gst.DeviceMonitor"
|
||||
status = "generate"
|
||||
|
@ -1148,6 +1186,11 @@ manual_traits = ["DeviceMonitorExtManual"]
|
|||
# Use DeviceMonitorFilterId and return Result<(), glib::BoolError>
|
||||
manual = true
|
||||
|
||||
[[object.function]]
|
||||
name = "get_devices"
|
||||
# Use glib::List as return type
|
||||
manual = true
|
||||
|
||||
[[object]]
|
||||
name = "Gst.Device"
|
||||
status = "generate"
|
||||
|
@ -1655,6 +1698,36 @@ final_type = true
|
|||
[object.function.return]
|
||||
bool_return_is_error = "Failed to add plugin"
|
||||
|
||||
[[object.function]]
|
||||
name = "feature_filter"
|
||||
rename = "features_filtered"
|
||||
# Use glib::List as return type
|
||||
manual = true
|
||||
|
||||
[[object.function]]
|
||||
name = "get_feature_list"
|
||||
rename = "features"
|
||||
# Use glib::List as return type
|
||||
manual = true
|
||||
|
||||
[[object.function]]
|
||||
name = "get_feature_list_by_plugin"
|
||||
rename = "features_by_plugin"
|
||||
# Use glib::List as return type
|
||||
manual = true
|
||||
|
||||
[[object.function]]
|
||||
name = "get_plugin_list"
|
||||
rename = "plugins"
|
||||
# Use glib::List as return type
|
||||
manual = true
|
||||
|
||||
[[object.function]]
|
||||
name = "plugin_filter"
|
||||
rename = "plugins_filtered"
|
||||
# Use glib::List as return type
|
||||
manual = true
|
||||
|
||||
[[object]]
|
||||
name = "Gst.BufferPool"
|
||||
status = "generate"
|
||||
|
@ -2041,6 +2114,12 @@ status = "generate"
|
|||
# implemented as part of Tracer subclassing
|
||||
manual = true
|
||||
|
||||
[[object.function]]
|
||||
name = "tracing_get_active_tracers"
|
||||
rename = "active_tracers"
|
||||
# Use glib::List as return type
|
||||
manual = true
|
||||
|
||||
[[object]]
|
||||
name = "Gst.State"
|
||||
status = "generate"
|
||||
|
@ -2262,6 +2341,12 @@ status = "generate"
|
|||
name = "Gst.TracerFactory"
|
||||
status = "generate"
|
||||
|
||||
[[object.function]]
|
||||
name = "get_list"
|
||||
rename = "factories"
|
||||
# Use glib::List as return type
|
||||
manual = true
|
||||
|
||||
[[object]]
|
||||
name = "Gst.URIType"
|
||||
status = "generate"
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
// DO NOT EDIT
|
||||
|
||||
use crate::Bus;
|
||||
use crate::Device;
|
||||
use crate::Object;
|
||||
use glib::object::Cast;
|
||||
use glib::object::IsA;
|
||||
|
@ -37,10 +36,6 @@ pub trait DeviceMonitorExt: 'static {
|
|||
#[doc(alias = "get_bus")]
|
||||
fn bus(&self) -> Bus;
|
||||
|
||||
#[doc(alias = "gst_device_monitor_get_devices")]
|
||||
#[doc(alias = "get_devices")]
|
||||
fn devices(&self) -> Vec<Device>;
|
||||
|
||||
#[doc(alias = "gst_device_monitor_get_providers")]
|
||||
#[doc(alias = "get_providers")]
|
||||
fn providers(&self) -> Vec<glib::GString>;
|
||||
|
@ -80,14 +75,6 @@ impl<O: IsA<DeviceMonitor>> DeviceMonitorExt for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn devices(&self) -> Vec<Device> {
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_device_monitor_get_devices(
|
||||
self.as_ref().to_glib_none().0,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn providers(&self) -> Vec<glib::GString> {
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_device_monitor_get_providers(
|
||||
|
|
|
@ -50,10 +50,6 @@ pub trait DeviceProviderExt: 'static {
|
|||
#[doc(alias = "get_bus")]
|
||||
fn bus(&self) -> Bus;
|
||||
|
||||
#[doc(alias = "gst_device_provider_get_devices")]
|
||||
#[doc(alias = "get_devices")]
|
||||
fn devices(&self) -> Vec<Device>;
|
||||
|
||||
#[doc(alias = "gst_device_provider_get_factory")]
|
||||
#[doc(alias = "get_factory")]
|
||||
fn factory(&self) -> Option<DeviceProviderFactory>;
|
||||
|
@ -139,14 +135,6 @@ impl<O: IsA<DeviceProvider>> DeviceProviderExt for O {
|
|||
}
|
||||
}
|
||||
|
||||
fn devices(&self) -> Vec<Device> {
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_device_provider_get_devices(
|
||||
self.as_ref().to_glib_none().0,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn factory(&self) -> Option<DeviceProviderFactory> {
|
||||
unsafe {
|
||||
from_glib_none(ffi::gst_device_provider_get_factory(
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
use crate::DeviceProvider;
|
||||
use crate::Object;
|
||||
use crate::PluginFeature;
|
||||
use crate::Rank;
|
||||
use glib::translate::*;
|
||||
|
||||
glib::wrapper! {
|
||||
|
@ -91,16 +90,6 @@ impl DeviceProviderFactory {
|
|||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_device_provider_factory_list_get_device_providers")]
|
||||
pub fn list_get_device_providers(minrank: Rank) -> Vec<DeviceProviderFactory> {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(
|
||||
ffi::gst_device_provider_factory_list_get_device_providers(minrank.into_glib()),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Send for DeviceProviderFactory {}
|
||||
|
|
|
@ -5,12 +5,8 @@
|
|||
|
||||
use crate::Caps;
|
||||
use crate::Element;
|
||||
use crate::ElementFactoryListType;
|
||||
use crate::Object;
|
||||
use crate::PadDirection;
|
||||
use crate::PluginFeature;
|
||||
use crate::Rank;
|
||||
use crate::StaticPadTemplate;
|
||||
use crate::URIType;
|
||||
use glib::translate::*;
|
||||
|
||||
|
@ -112,16 +108,6 @@ impl ElementFactory {
|
|||
unsafe { ffi::gst_element_factory_get_num_pad_templates(self.to_glib_none().0) }
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_element_factory_get_static_pad_templates")]
|
||||
#[doc(alias = "get_static_pad_templates")]
|
||||
pub fn static_pad_templates(&self) -> Vec<StaticPadTemplate> {
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_none(ffi::gst_element_factory_get_static_pad_templates(
|
||||
self.to_glib_none().0,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_element_factory_get_uri_protocols")]
|
||||
#[doc(alias = "get_uri_protocols")]
|
||||
pub fn uri_protocols(&self) -> Vec<glib::GString> {
|
||||
|
@ -148,51 +134,12 @@ impl ElementFactory {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_element_factory_list_is_type")]
|
||||
pub fn list_is_type(&self, type_: ElementFactoryListType) -> bool {
|
||||
unsafe {
|
||||
from_glib(ffi::gst_element_factory_list_is_type(
|
||||
self.to_glib_none().0,
|
||||
type_.into_glib(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_element_factory_find")]
|
||||
pub fn find(name: &str) -> Option<ElementFactory> {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe { from_glib_full(ffi::gst_element_factory_find(name.to_glib_none().0)) }
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_element_factory_list_filter")]
|
||||
pub fn list_filter(
|
||||
list: &[ElementFactory],
|
||||
caps: &Caps,
|
||||
direction: PadDirection,
|
||||
subsetonly: bool,
|
||||
) -> Vec<ElementFactory> {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_element_factory_list_filter(
|
||||
list.to_glib_none().0,
|
||||
caps.to_glib_none().0,
|
||||
direction.into_glib(),
|
||||
subsetonly.into_glib(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_element_factory_list_get_elements")]
|
||||
pub fn list_get_elements(type_: ElementFactoryListType, minrank: Rank) -> Vec<ElementFactory> {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_element_factory_list_get_elements(
|
||||
type_.into_glib(),
|
||||
minrank.into_glib(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_element_factory_make")]
|
||||
pub fn make(factoryname: &str, name: Option<&str>) -> Result<Element, glib::BoolError> {
|
||||
assert_initialized_main_thread!();
|
||||
|
|
|
@ -14,9 +14,6 @@ use crate::PluginAPIFlags;
|
|||
#[cfg(any(feature = "v1_12", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_12")))]
|
||||
use crate::StackTraceFlags;
|
||||
#[cfg(any(feature = "v1_18", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
|
||||
use crate::Tracer;
|
||||
use glib::object::IsA;
|
||||
use glib::translate::*;
|
||||
use std::mem;
|
||||
|
@ -239,14 +236,6 @@ pub fn parse_launchv(argv: &[&str]) -> Result<Element, glib::Error> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_18", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
|
||||
#[doc(alias = "gst_tracing_get_active_tracers")]
|
||||
pub fn tracing_get_active_tracers() -> Vec<Tracer> {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe { FromGlibPtrContainer::from_glib_full(ffi::gst_tracing_get_active_tracers()) }
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_18", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
|
||||
#[doc(alias = "gst_type_mark_as_plugin_api")]
|
||||
|
|
|
@ -69,34 +69,6 @@ impl Registry {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_registry_feature_filter")]
|
||||
pub fn feature_filter<P: FnMut(&PluginFeature) -> bool>(
|
||||
&self,
|
||||
filter: P,
|
||||
first: bool,
|
||||
) -> Vec<PluginFeature> {
|
||||
let filter_data: P = filter;
|
||||
unsafe extern "C" fn filter_func<P: FnMut(&PluginFeature) -> bool>(
|
||||
feature: *mut ffi::GstPluginFeature,
|
||||
user_data: glib::ffi::gpointer,
|
||||
) -> glib::ffi::gboolean {
|
||||
let feature = from_glib_borrow(feature);
|
||||
let callback: *mut P = user_data as *const _ as usize as *mut P;
|
||||
let res = (*callback)(&feature);
|
||||
res.into_glib()
|
||||
}
|
||||
let filter = Some(filter_func::<P> as _);
|
||||
let super_callback0: &P = &filter_data;
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_registry_feature_filter(
|
||||
self.to_glib_none().0,
|
||||
filter,
|
||||
first.into_glib(),
|
||||
super_callback0 as *const _ as usize as *mut _,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_registry_find_feature")]
|
||||
pub fn find_feature(&self, name: &str, type_: glib::types::Type) -> Option<PluginFeature> {
|
||||
unsafe {
|
||||
|
@ -118,44 +90,12 @@ impl Registry {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_registry_get_feature_list")]
|
||||
#[doc(alias = "get_feature_list")]
|
||||
pub fn feature_list(&self, type_: glib::types::Type) -> Vec<PluginFeature> {
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_registry_get_feature_list(
|
||||
self.to_glib_none().0,
|
||||
type_.into_glib(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_registry_get_feature_list_by_plugin")]
|
||||
#[doc(alias = "get_feature_list_by_plugin")]
|
||||
pub fn feature_list_by_plugin(&self, name: &str) -> Vec<PluginFeature> {
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_registry_get_feature_list_by_plugin(
|
||||
self.to_glib_none().0,
|
||||
name.to_glib_none().0,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_registry_get_feature_list_cookie")]
|
||||
#[doc(alias = "get_feature_list_cookie")]
|
||||
pub fn feature_list_cookie(&self) -> u32 {
|
||||
unsafe { ffi::gst_registry_get_feature_list_cookie(self.to_glib_none().0) }
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_registry_get_plugin_list")]
|
||||
#[doc(alias = "get_plugin_list")]
|
||||
pub fn plugin_list(&self) -> Vec<Plugin> {
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_registry_get_plugin_list(
|
||||
self.to_glib_none().0,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_registry_lookup")]
|
||||
pub fn lookup(&self, filename: &str) -> Option<Plugin> {
|
||||
unsafe {
|
||||
|
@ -176,30 +116,6 @@ impl Registry {
|
|||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_registry_plugin_filter")]
|
||||
pub fn plugin_filter<P: FnMut(&Plugin) -> bool>(&self, filter: P, first: bool) -> Vec<Plugin> {
|
||||
let filter_data: P = filter;
|
||||
unsafe extern "C" fn filter_func<P: FnMut(&Plugin) -> bool>(
|
||||
plugin: *mut ffi::GstPlugin,
|
||||
user_data: glib::ffi::gpointer,
|
||||
) -> glib::ffi::gboolean {
|
||||
let plugin = from_glib_borrow(plugin);
|
||||
let callback: *mut P = user_data as *const _ as usize as *mut P;
|
||||
let res = (*callback)(&plugin);
|
||||
res.into_glib()
|
||||
}
|
||||
let filter = Some(filter_func::<P> as _);
|
||||
let super_callback0: &P = &filter_data;
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_registry_plugin_filter(
|
||||
self.to_glib_none().0,
|
||||
filter,
|
||||
first.into_glib(),
|
||||
super_callback0 as *const _ as usize as *mut _,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_registry_remove_feature")]
|
||||
pub fn remove_feature(&self, feature: &impl IsA<PluginFeature>) {
|
||||
unsafe {
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
use crate::Object;
|
||||
use crate::PluginFeature;
|
||||
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
|
||||
use glib::translate::*;
|
||||
|
||||
glib::wrapper! {
|
||||
|
@ -28,13 +30,6 @@ impl TracerFactory {
|
|||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_tracer_factory_get_list")]
|
||||
#[doc(alias = "get_list")]
|
||||
pub fn list() -> Vec<TracerFactory> {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe { FromGlibPtrContainer::from_glib_full(ffi::gst_tracer_factory_get_list()) }
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Send for TracerFactory {}
|
||||
|
|
|
@ -42,13 +42,6 @@ impl TypeFindFactory {
|
|||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_type_find_factory_get_list")]
|
||||
#[doc(alias = "get_list")]
|
||||
pub fn list() -> Vec<TypeFindFactory> {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe { FromGlibPtrContainer::from_glib_full(ffi::gst_type_find_factory_get_list()) }
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Send for TypeFindFactory {}
|
||||
|
|
|
@ -58,6 +58,10 @@ pub trait DeviceMonitorExtManual: 'static {
|
|||
#[doc(alias = "gst_device_monitor_remove_filter")]
|
||||
fn remove_filter(&self, filter_id: DeviceMonitorFilterId)
|
||||
-> Result<(), glib::error::BoolError>;
|
||||
|
||||
#[doc(alias = "gst_device_monitor_get_devices")]
|
||||
#[doc(alias = "get_devices")]
|
||||
fn devices(&self) -> glib::List<crate::Device>;
|
||||
}
|
||||
|
||||
impl<O: IsA<DeviceMonitor>> DeviceMonitorExtManual for O {
|
||||
|
@ -95,4 +99,12 @@ impl<O: IsA<DeviceMonitor>> DeviceMonitorExtManual for O {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn devices(&self) -> glib::List<crate::Device> {
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_device_monitor_get_devices(
|
||||
self.as_ref().to_glib_none().0,
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,10 @@ pub trait DeviceProviderExtManual: 'static {
|
|||
#[doc(alias = "get_metadata")]
|
||||
#[doc(alias = "gst_device_provider_class_get_metadata")]
|
||||
fn metadata<'a>(&self, key: &str) -> Option<&'a str>;
|
||||
|
||||
#[doc(alias = "gst_device_provider_get_devices")]
|
||||
#[doc(alias = "get_devices")]
|
||||
fn devices(&self) -> glib::List<crate::Device>;
|
||||
}
|
||||
|
||||
impl<O: IsA<DeviceProvider>> DeviceProviderExtManual for O {
|
||||
|
@ -53,4 +57,12 @@ impl<O: IsA<DeviceProvider>> DeviceProviderExtManual for O {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn devices(&self) -> glib::List<crate::Device> {
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_device_provider_get_devices(
|
||||
self.as_ref().to_glib_none().0,
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
16
gstreamer/src/device_provider_factory.rs
Normal file
16
gstreamer/src/device_provider_factory.rs
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
|
||||
use crate::DeviceProviderFactory;
|
||||
use glib::translate::*;
|
||||
|
||||
impl DeviceProviderFactory {
|
||||
#[doc(alias = "gst_device_provider_factory_list_get_device_providers")]
|
||||
pub fn factories(minrank: crate::Rank) -> glib::List<DeviceProviderFactory> {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(
|
||||
ffi::gst_device_provider_factory_list_get_device_providers(minrank.into_glib()),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,10 +3,11 @@
|
|||
#[cfg(any(feature = "v1_20", feature = "dox"))]
|
||||
use crate::Element;
|
||||
use crate::ElementFactory;
|
||||
use crate::Rank;
|
||||
use crate::StaticPadTemplate;
|
||||
|
||||
#[cfg(any(feature = "v1_20", feature = "dox"))]
|
||||
use glib::prelude::*;
|
||||
#[cfg(any(feature = "v1_20", feature = "dox"))]
|
||||
use glib::translate::*;
|
||||
|
||||
impl ElementFactory {
|
||||
|
@ -62,4 +63,38 @@ impl ElementFactory {
|
|||
.ok_or_else(|| glib::bool_error!("Failed to create element from factory name"))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_element_factory_get_static_pad_templates")]
|
||||
#[doc(alias = "get_static_pad_templates")]
|
||||
pub fn static_pad_templates(&self) -> glib::List<StaticPadTemplate> {
|
||||
unsafe {
|
||||
glib::List::from_glib_none_static(ffi::gst_element_factory_get_static_pad_templates(
|
||||
self.to_glib_none().0,
|
||||
) as *mut _)
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_element_factory_list_is_type")]
|
||||
pub fn has_type(&self, type_: crate::ElementFactoryType) -> bool {
|
||||
unsafe {
|
||||
from_glib(ffi::gst_element_factory_list_is_type(
|
||||
self.to_glib_none().0,
|
||||
type_.into_glib(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_element_factory_list_get_elements")]
|
||||
pub fn factories_with_type(
|
||||
type_: crate::ElementFactoryType,
|
||||
minrank: Rank,
|
||||
) -> glib::List<ElementFactory> {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_element_factory_list_get_elements(
|
||||
type_.into_glib(),
|
||||
minrank.into_glib(),
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use glib::translate::*;
|
|||
|
||||
bitflags! {
|
||||
#[doc(alias = "GstElementFactoryListType")]
|
||||
pub struct ElementFactoryListType: u64 {
|
||||
pub struct ElementFactoryType: u64 {
|
||||
#[doc(alias = "GST_ELEMENT_FACTORY_TYPE_DECODER")]
|
||||
const DECODER = ffi::GST_ELEMENT_FACTORY_TYPE_DECODER as u64;
|
||||
#[doc(alias = "GST_ELEMENT_FACTORY_TYPE_ENCODER")]
|
||||
|
@ -57,7 +57,7 @@ bitflags! {
|
|||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
impl IntoGlib for ElementFactoryListType {
|
||||
impl IntoGlib for ElementFactoryType {
|
||||
type GlibType = ffi::GstElementFactoryListType;
|
||||
|
||||
fn into_glib(self) -> ffi::GstElementFactoryListType {
|
||||
|
@ -66,9 +66,9 @@ impl IntoGlib for ElementFactoryListType {
|
|||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
impl FromGlib<ffi::GstElementFactoryListType> for ElementFactoryListType {
|
||||
unsafe fn from_glib(value: ffi::GstElementFactoryListType) -> ElementFactoryListType {
|
||||
impl FromGlib<ffi::GstElementFactoryListType> for ElementFactoryType {
|
||||
unsafe fn from_glib(value: ffi::GstElementFactoryListType) -> ElementFactoryType {
|
||||
skip_assert_initialized!();
|
||||
ElementFactoryListType::from_bits_truncate(value)
|
||||
ElementFactoryType::from_bits_truncate(value)
|
||||
}
|
||||
}
|
|
@ -10,6 +10,9 @@ use crate::Element;
|
|||
use crate::Object;
|
||||
use crate::ParseContext;
|
||||
use crate::ParseFlags;
|
||||
#[cfg(any(feature = "v1_18", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
|
||||
use crate::Tracer;
|
||||
|
||||
pub fn parse_bin_from_description_with_name(
|
||||
bin_description: &str,
|
||||
|
@ -190,6 +193,14 @@ pub fn type_is_plugin_api(type_: glib::types::Type) -> Option<crate::PluginAPIFl
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_18", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
|
||||
#[doc(alias = "gst_tracing_get_active_tracers")]
|
||||
pub fn active_tracers() -> glib::List<Tracer> {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe { FromGlibPtrContainer::from_glib_full(ffi::gst_tracing_get_active_tracers()) }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
@ -142,10 +142,11 @@ mod pipeline;
|
|||
mod allocation_params;
|
||||
pub use self::allocation_params::AllocationParams;
|
||||
|
||||
mod element_factory_list_type;
|
||||
pub use element_factory_list_type::*;
|
||||
mod element_factory_type;
|
||||
pub use element_factory_type::*;
|
||||
|
||||
mod tracer;
|
||||
mod tracer_factory;
|
||||
|
||||
// OS dependent Bus extensions (also import the other platform mod for doc)
|
||||
#[cfg(any(all(unix, feature = "v1_14"), feature = "dox"))]
|
||||
|
@ -164,6 +165,7 @@ mod date_time;
|
|||
mod date_time_serde;
|
||||
mod device_monitor;
|
||||
mod device_provider;
|
||||
mod device_provider_factory;
|
||||
mod enums;
|
||||
pub use crate::enums::MessageType;
|
||||
mod ghost_pad;
|
||||
|
@ -171,6 +173,7 @@ mod gobject;
|
|||
mod iterator;
|
||||
mod object;
|
||||
mod pad;
|
||||
mod registry;
|
||||
pub use crate::pad::PadBuilder;
|
||||
mod control_binding;
|
||||
mod control_source;
|
||||
|
@ -204,6 +207,7 @@ pub mod stream_collection;
|
|||
|
||||
mod typefind;
|
||||
pub use crate::typefind::*;
|
||||
mod typefind_factory;
|
||||
|
||||
pub mod format;
|
||||
pub use crate::format::{
|
||||
|
|
97
gstreamer/src/registry.rs
Normal file
97
gstreamer/src/registry.rs
Normal file
|
@ -0,0 +1,97 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
|
||||
use crate::Plugin;
|
||||
use crate::PluginFeature;
|
||||
use crate::Registry;
|
||||
|
||||
use glib::translate::*;
|
||||
|
||||
impl Registry {
|
||||
#[doc(alias = "gst_registry_feature_filter")]
|
||||
pub fn features_filtered<P: FnMut(&PluginFeature) -> bool>(
|
||||
&self,
|
||||
filter: P,
|
||||
first: bool,
|
||||
) -> glib::List<PluginFeature> {
|
||||
let filter_data: P = filter;
|
||||
unsafe extern "C" fn filter_func<P: FnMut(&PluginFeature) -> bool>(
|
||||
feature: *mut ffi::GstPluginFeature,
|
||||
user_data: glib::ffi::gpointer,
|
||||
) -> glib::ffi::gboolean {
|
||||
let feature = from_glib_borrow(feature);
|
||||
let callback: *mut P = user_data as *const _ as usize as *mut P;
|
||||
let res = (*callback)(&feature);
|
||||
res.into_glib()
|
||||
}
|
||||
let filter = Some(filter_func::<P> as _);
|
||||
let super_callback0: &P = &filter_data;
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_registry_feature_filter(
|
||||
self.to_glib_none().0,
|
||||
filter,
|
||||
first.into_glib(),
|
||||
super_callback0 as *const _ as usize as *mut _,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_registry_get_feature_list")]
|
||||
#[doc(alias = "get_feature_list")]
|
||||
pub fn features(&self, type_: glib::types::Type) -> glib::List<PluginFeature> {
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_registry_get_feature_list(
|
||||
self.to_glib_none().0,
|
||||
type_.into_glib(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_registry_get_feature_list_by_plugin")]
|
||||
#[doc(alias = "get_feature_list_by_plugin")]
|
||||
pub fn features_by_plugin(&self, name: &str) -> glib::List<PluginFeature> {
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_registry_get_feature_list_by_plugin(
|
||||
self.to_glib_none().0,
|
||||
name.to_glib_none().0,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_registry_get_plugin_list")]
|
||||
#[doc(alias = "get_plugin_list")]
|
||||
pub fn plugins(&self) -> glib::List<Plugin> {
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_registry_get_plugin_list(
|
||||
self.to_glib_none().0,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_registry_plugin_filter")]
|
||||
pub fn plugins_filtered<P: FnMut(&Plugin) -> bool>(
|
||||
&self,
|
||||
filter: P,
|
||||
first: bool,
|
||||
) -> glib::List<Plugin> {
|
||||
let filter_data: P = filter;
|
||||
unsafe extern "C" fn filter_func<P: FnMut(&Plugin) -> bool>(
|
||||
plugin: *mut ffi::GstPlugin,
|
||||
user_data: glib::ffi::gpointer,
|
||||
) -> glib::ffi::gboolean {
|
||||
let plugin = from_glib_borrow(plugin);
|
||||
let callback: *mut P = user_data as *const _ as usize as *mut P;
|
||||
let res = (*callback)(&plugin);
|
||||
res.into_glib()
|
||||
}
|
||||
let filter = Some(filter_func::<P> as _);
|
||||
let super_callback0: &P = &filter_data;
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_registry_plugin_filter(
|
||||
self.to_glib_none().0,
|
||||
filter,
|
||||
first.into_glib(),
|
||||
super_callback0 as *const _ as usize as *mut _,
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
18
gstreamer/src/tracer_factory.rs
Normal file
18
gstreamer/src/tracer_factory.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
|
||||
use crate::TracerFactory;
|
||||
|
||||
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
|
||||
use glib::translate::*;
|
||||
|
||||
impl TracerFactory {
|
||||
#[cfg(any(feature = "v1_14", feature = "dox"))]
|
||||
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]
|
||||
#[doc(alias = "gst_tracer_factory_get_list")]
|
||||
#[doc(alias = "get_list")]
|
||||
pub fn factories() -> glib::List<TracerFactory> {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe { FromGlibPtrContainer::from_glib_full(ffi::gst_tracer_factory_get_list()) }
|
||||
}
|
||||
}
|
|
@ -172,7 +172,7 @@ impl<T: AsRef<[u8]>> SliceTypeFind<T> {
|
|||
}
|
||||
|
||||
pub fn run(&mut self) {
|
||||
let factories = TypeFindFactory::list();
|
||||
let factories = TypeFindFactory::factories();
|
||||
|
||||
for factory in factories {
|
||||
factory.call_function(self);
|
||||
|
@ -247,9 +247,7 @@ mod tests {
|
|||
fn test_typefind_call_function() {
|
||||
crate::init().unwrap();
|
||||
|
||||
let xml_factory = TypeFindFactory::list()
|
||||
.iter()
|
||||
.cloned()
|
||||
let xml_factory = TypeFindFactory::factories()
|
||||
.find(|f| {
|
||||
f.caps()
|
||||
.map(|c| {
|
||||
|
|
14
gstreamer/src/typefind_factory.rs
Normal file
14
gstreamer/src/typefind_factory.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
|
||||
use crate::TypeFindFactory;
|
||||
|
||||
use glib::translate::*;
|
||||
|
||||
impl TypeFindFactory {
|
||||
#[doc(alias = "gst_type_find_factory_get_list")]
|
||||
#[doc(alias = "get_list")]
|
||||
pub fn factories() -> glib::List<TypeFindFactory> {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe { FromGlibPtrContainer::from_glib_full(ffi::gst_type_find_factory_get_list()) }
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue