gstreamer: Provide better bindings for ElementFactoryListType

Make it an actual bitflags type instead of just an u64 alias and add all
the constants. As it's not defined as bitflags in C this needs to be
done manually.
This commit is contained in:
Sebastian Dröge 2021-02-19 12:53:35 +02:00
parent ce67076f26
commit d746bf91e1
6 changed files with 63 additions and 5 deletions

View file

@ -25,7 +25,6 @@ generate = [
"Gst.DebugColorFlags",
"Gst.DebugGraphDetails",
"Gst.DebugLevel",
"Gst.ElementFactoryListType",
"Gst.EventTypeFlags",
"Gst.LibraryError",
"Gst.PadDirection",
@ -232,6 +231,11 @@ status = "generate"
name = "last"
ignore = true
[[object]]
name = "Gst.ElementFactoryListType"
status = "manual"
conversion_type = "scalar"
[[object]]
name = "Gst.Format"
status = "generate"

View file

@ -6,4 +6,3 @@
use crate::auto::*;
pub type ClockTimeDiff = i64;
pub type ElementFactoryListType = u64;

View file

@ -144,7 +144,7 @@ impl ElementFactory {
unsafe {
from_glib(ffi::gst_element_factory_list_is_type(
self.to_glib_none().0,
type_,
type_.to_glib(),
))
}
}
@ -178,7 +178,7 @@ impl ElementFactory {
assert_initialized_main_thread!();
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::gst_element_factory_list_get_elements(
type_,
type_.to_glib(),
minrank.to_glib(),
))
}

View file

@ -208,7 +208,6 @@ pub use self::flags::StreamType;
mod alias;
pub use self::alias::ClockTimeDiff;
pub use self::alias::ElementFactoryListType;
pub mod functions;

View file

@ -0,0 +1,53 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use bitflags::bitflags;
use glib::translate::*;
bitflags! {
pub struct ElementFactoryListType: u64 {
const DECODER = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0001;
const ENCODER = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0010;
const SINK = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0100;
const SRC = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_1000;
const MUXER = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0001_0000;
const DEMUXER = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0010_0000;
const PARSER = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0100_0000;
const PAYLOADER = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_1000_0000;
const DEPAYLOADER = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0001_0000_0000;
const FORMATTER = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0010_0000_0000;
const DECRYPTOR = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0100_0000_0000;
const ENCRYPTOR = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_1000_0000_0000;
const HARDWARE = 0b_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0001_0000_0000_0000;
const MEDIA_VIDEO = 0b_0000_0000_0000_0010_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000;
const MEDIA_AUDIO = 0b_0000_0000_0000_0100_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000;
const MEDIA_IMAGE = 0b_0000_0000_0000_1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000;
const MEDIA_SUBTITLE = 0b_0000_0000_0001_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000;
const MEDIA_METADATA = 0b_0000_0000_0010_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000;
const ANY = 0b_0000_0000_0000_0001_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111;
const MEDIA_ANY = 0b_1111_1111_1111_1110_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000;
const VIDEO_ENCODER = Self::ENCODER.bits | Self::MEDIA_VIDEO.bits | Self::MEDIA_IMAGE.bits;
const AUDIO_ENCODER = Self::ENCODER.bits | Self::MEDIA_AUDIO.bits;
const AUDIOVIDEO_SINKS = Self::SINK.bits | Self::MEDIA_AUDIO.bits | Self::MEDIA_VIDEO.bits | Self::MEDIA_IMAGE.bits;
const DECODABLE = Self::DECODER.bits | Self::DEMUXER.bits | Self::DEPAYLOADER.bits | Self::PARSER.bits | Self::DECRYPTOR.bits;
}
}
#[doc(hidden)]
impl ToGlib for ElementFactoryListType {
type GlibType = ffi::GstElementFactoryListType;
fn to_glib(&self) -> ffi::GstElementFactoryListType {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::GstElementFactoryListType> for ElementFactoryListType {
unsafe fn from_glib(value: ffi::GstElementFactoryListType) -> ElementFactoryListType {
skip_assert_initialized!();
ElementFactoryListType::from_bits_truncate(value)
}
}

View file

@ -132,6 +132,9 @@ pub use crate::pipeline::GstPipelineExtManual;
mod allocation_params;
pub use self::allocation_params::AllocationParams;
mod element_factory_list_type;
pub use element_factory_list_type::*;
// OS dependent Bus extensions (also import the other plateform mod for doc)
#[cfg(any(feature = "v1_14", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_14")))]