Add various global functions to the pbutils library

This commit is contained in:
Sebastian Dröge 2018-10-28 12:39:27 +00:00
parent 0947c8f087
commit 7207bbed69
5 changed files with 197 additions and 0 deletions

View file

@ -234,3 +234,55 @@ trait = false
pattern = "set_.*"
ignore = true
[[object]]
name = "GstPbutils.*"
status = "generate"
# We'll opt-in for constants at a later time
[[object.constant]]
pattern = ".+"
ignore = true
# Codec utils need some special care
[[object.function]]
pattern = "codec_utils.*"
ignore = true
# Plugin installer API needs some manual impls
[[object.function]]
pattern = "install_plugins.*"
ignore = true
# Plugin installer API needs some manual impls
[[object.function]]
pattern = "missing_.*"
ignore = true
# Plugin installer API needs some manual impls
[[object.function]]
name = "is_missing_plugin_message"
ignore = true
# Initialization is handled implicitely
[[object.function]]
name = "pb_utils_init"
ignore = true
# Needs special handling for mutable taglists
[[object.function]]
name = "pb_utils_add_codec_description_to_tag_list"
ignore = true
# Needs special handling for caps refs
[[object.function]]
name = "pb_utils_get_codec_description"
ignore = true
# Needs special handling for caps refs
[[object.function]]
name = "pb_utils_get_decoder_description"
ignore = true
# Needs special handling for caps refs
[[object.function]]
name = "pb_utils_get_encoder_description"
ignore = true

View file

@ -0,0 +1,65 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use EncodingTarget;
use ffi;
use glib::translate::*;
use std::mem;
pub fn encoding_list_all_targets<'a, P: Into<Option<&'a str>>>(categoryname: P) -> Vec<EncodingTarget> {
assert_initialized_main_thread!();
let categoryname = categoryname.into();
let categoryname = categoryname.to_glib_none();
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::gst_encoding_list_all_targets(categoryname.0))
}
}
pub fn encoding_list_available_categories() -> Vec<String> {
assert_initialized_main_thread!();
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::gst_encoding_list_available_categories())
}
}
pub fn pb_utils_get_element_description(factory_name: &str) -> Option<String> {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_pb_utils_get_element_description(factory_name.to_glib_none().0))
}
}
pub fn pb_utils_get_sink_description(protocol: &str) -> Option<String> {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_pb_utils_get_sink_description(protocol.to_glib_none().0))
}
}
pub fn pb_utils_get_source_description(protocol: &str) -> Option<String> {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_pb_utils_get_source_description(protocol.to_glib_none().0))
}
}
pub fn plugins_base_version() -> (u32, u32, u32, u32) {
assert_initialized_main_thread!();
unsafe {
let mut major = mem::uninitialized();
let mut minor = mem::uninitialized();
let mut micro = mem::uninitialized();
let mut nano = mem::uninitialized();
ffi::gst_plugins_base_version(&mut major, &mut minor, &mut micro, &mut nano);
(major, minor, micro, nano)
}
}
pub fn plugins_base_version_string() -> Option<String> {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_plugins_base_version_string())
}
}

View file

@ -49,6 +49,8 @@ pub use self::enums::DiscovererResult;
mod flags;
pub use self::flags::DiscovererSerializeFlags;
pub mod functions;
#[doc(hidden)]
pub mod traits {
pub use super::DiscovererInfoExt;

View file

@ -0,0 +1,72 @@
// Copyright (C) 2018 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use ffi;
use glib;
use glib::translate::*;
use gst;
use gst::MiniObject;
use std::ptr;
pub unsafe trait CodecTag<'a>: gst::Tag<'a, TagType = &'a str> {}
unsafe impl<'a> CodecTag<'a> for gst::tags::ContainerFormat {}
unsafe impl<'a> CodecTag<'a> for gst::tags::AudioCodec {}
unsafe impl<'a> CodecTag<'a> for gst::tags::VideoCodec {}
unsafe impl<'a> CodecTag<'a> for gst::tags::SubtitleCodec {}
unsafe impl<'a> CodecTag<'a> for gst::tags::Codec {}
pub fn pb_utils_add_codec_description_to_tag_list_for_tag<'a, T: CodecTag<'a>>(
taglist: &mut gst::TagListRef,
caps: &gst::CapsRef,
) -> Result<(), glib::BoolError> {
assert_initialized_main_thread!();
let codec_tag = T::tag_name();
unsafe {
glib::BoolError::from_glib(
ffi::gst_pb_utils_add_codec_description_to_tag_list(
taglist.as_mut_ptr(),
codec_tag.to_glib_none().0,
caps.as_ptr(),
),
"Failed to find codec description",
)
}
}
pub fn pb_utils_add_codec_description_to_tag_list(
taglist: &mut gst::TagListRef,
caps: &gst::CapsRef,
) -> Result<(), glib::BoolError> {
assert_initialized_main_thread!();
unsafe {
glib::BoolError::from_glib(
ffi::gst_pb_utils_add_codec_description_to_tag_list(
taglist.as_mut_ptr(),
ptr::null_mut(),
caps.as_ptr(),
),
"Failed to find codec description",
)
}
}
pub fn pb_utils_get_encoder_description(caps: &gst::CapsRef) -> Option<String> {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::gst_pb_utils_get_encoder_description(caps.as_ptr())) }
}
pub fn pb_utils_get_decoder_description(caps: &gst::CapsRef) -> Option<String> {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::gst_pb_utils_get_decoder_description(caps.as_ptr())) }
}
pub fn pb_utils_get_codec_description(caps: &gst::CapsRef) -> Option<String> {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::gst_pb_utils_get_codec_description(caps.as_ptr())) }
}

View file

@ -45,6 +45,7 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
mod auto;
pub use auto::functions::*;
pub use auto::*;
mod discoverer;
@ -58,6 +59,9 @@ pub use discoverer_video_info::*;
mod encoding_profile;
pub use encoding_profile::*;
pub mod functions;
pub use functions::*;
// Re-export all the traits in a prelude module, so that applications
// can always "use gst::prelude::*" without getting conflicts
pub mod prelude {
@ -66,4 +70,6 @@ pub mod prelude {
pub use auto::traits::*;
pub use encoding_profile::EncodingProfileBuilder;
pub use functions::CodecTag;
}