pbutils: adding encoding-profile bindings

This commit is contained in:
Thiago Santos 2018-03-18 10:42:45 -07:00 committed by Sebastian Dröge
parent 7a0310a1f5
commit 485d7e4881
8 changed files with 657 additions and 2 deletions

View file

@ -141,3 +141,66 @@ trait = false
name = "GstPbutils.DiscovererContainerInfo"
status = "generate"
trait = false
[[object]]
name = "GstPbutils.EncodingProfile"
status = "generate"
[[object.function]]
name = "is_equal"
ignore = true
[[object.function]]
name = "copy"
[object.function.return]
nullable = false
[[object.function]]
name = "get_input_caps"
[object.function.return]
nullable = false
[[object.function]]
name = "get_format"
[object.function.return]
nullable = false
[[object]]
name = "GstPbutils.EncodingContainerProfile"
status = "generate"
[[object.function]]
name = "add_profile"
[object.function.return]
bool_return_is_error = "Failed to add profile"
[[object]]
name = "GstPbutils.EncodingTarget"
status = "generate"
[[object.function]]
name = "add_profile"
[object.function.return]
bool_return_is_error = "Failed to add profile"
[[object.function]]
name = "get_category"
[object.function.return]
nullable = false
[[object.function]]
name = "get_description"
[object.function.return]
nullable = false
[[object.function]]
name = "get_name"
[object.function.return]
nullable = false
[[object]]
name = "GstPbutils.EncodingAudioProfile"
status = "generate"
trait = false
[[object]]
name = "GstPbutils.EncodingVideoProfile"
status = "generate"
trait = false

View file

@ -1684,8 +1684,11 @@ information like name, description, format and preset.</doc>
<doc xml:space="preserve">The name of the target</doc>
<type name="utf8" c:type="const gchar*"/>
</parameter>
<parameter name="profilename" transfer-ownership="none">
<doc xml:space="preserve">(allow-none): The name of the profile, if %NULL
<parameter name="profilename"
transfer-ownership="none"
nullable="1"
allow-none="1">
<doc xml:space="preserve">The name of the profile, if %NULL
provided, it will default to the encoding profile called `default`.</doc>
<type name="utf8" c:type="const gchar*"/>
</parameter>

View file

@ -0,0 +1,36 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff+)
// from gir-files (https://github.com/gtk-rs/gir-files @ ???)
// DO NOT EDIT
use EncodingProfile;
use ffi;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
use std::mem;
use std::ptr;
glib_wrapper! {
pub struct EncodingAudioProfile(Object<ffi::GstEncodingAudioProfile, ffi::GstEncodingAudioProfileClass>): EncodingProfile;
match fn {
get_type => || ffi::gst_encoding_audio_profile_get_type(),
}
}
impl EncodingAudioProfile {
pub fn new<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b gst::Caps>>>(format: &gst::Caps, preset: P, restriction: Q, presence: u32) -> EncodingAudioProfile {
assert_initialized_main_thread!();
let preset = preset.into();
let preset = preset.to_glib_none();
let restriction = restriction.into();
let restriction = restriction.to_glib_none();
unsafe {
from_glib_full(ffi::gst_encoding_audio_profile_new(format.to_glib_none().0, preset.0, restriction.0, presence))
}
}
}
unsafe impl Send for EncodingAudioProfile {}
unsafe impl Sync for EncodingAudioProfile {}

View file

@ -0,0 +1,68 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff+)
// from gir-files (https://github.com/gtk-rs/gir-files @ ???)
// DO NOT EDIT
use EncodingProfile;
use ffi;
use glib;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
use std::mem;
use std::ptr;
glib_wrapper! {
pub struct EncodingContainerProfile(Object<ffi::GstEncodingContainerProfile, ffi::GstEncodingContainerProfileClass>): EncodingProfile;
match fn {
get_type => || ffi::gst_encoding_container_profile_get_type(),
}
}
impl EncodingContainerProfile {
pub fn new<'a, 'b, 'c, P: Into<Option<&'a str>>, Q: Into<Option<&'b str>>, R: Into<Option<&'c str>>>(name: P, description: Q, format: &gst::Caps, preset: R) -> EncodingContainerProfile {
assert_initialized_main_thread!();
let name = name.into();
let name = name.to_glib_none();
let description = description.into();
let description = description.to_glib_none();
let preset = preset.into();
let preset = preset.to_glib_none();
unsafe {
from_glib_full(ffi::gst_encoding_container_profile_new(name.0, description.0, format.to_glib_none().0, preset.0))
}
}
}
unsafe impl Send for EncodingContainerProfile {}
unsafe impl Sync for EncodingContainerProfile {}
pub trait EncodingContainerProfileExt {
fn add_profile<P: IsA<EncodingProfile>>(&self, profile: &P) -> Result<(), glib::error::BoolError>;
fn contains_profile<P: IsA<EncodingProfile>>(&self, profile: &P) -> bool;
fn get_profiles(&self) -> Vec<EncodingProfile>;
}
impl<O: IsA<EncodingContainerProfile>> EncodingContainerProfileExt for O {
fn add_profile<P: IsA<EncodingProfile>>(&self, profile: &P) -> Result<(), glib::error::BoolError> {
unsafe {
glib::error::BoolError::from_glib(ffi::gst_encoding_container_profile_add_profile(self.to_glib_none().0, profile.to_glib_full()), "Failed to add profile")
}
}
fn contains_profile<P: IsA<EncodingProfile>>(&self, profile: &P) -> bool {
unsafe {
from_glib(ffi::gst_encoding_container_profile_contains_profile(self.to_glib_none().0, profile.to_glib_none().0))
}
}
fn get_profiles(&self) -> Vec<EncodingProfile> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::gst_encoding_container_profile_get_profiles(self.to_glib_none().0))
}
}
}

View file

@ -0,0 +1,277 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff+)
// from gir-files (https://github.com/gtk-rs/gir-files @ ???)
// DO NOT EDIT
use DiscovererInfo;
use ffi;
use glib;
use glib::StaticType;
use glib::Value;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;
glib_wrapper! {
pub struct EncodingProfile(Object<ffi::GstEncodingProfile, ffi::GstEncodingProfileClass>);
match fn {
get_type => || ffi::gst_encoding_profile_get_type(),
}
}
impl EncodingProfile {
pub fn find<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b str>>>(targetname: &str, profilename: P, category: Q) -> Option<EncodingProfile> {
assert_initialized_main_thread!();
let profilename = profilename.into();
let profilename = profilename.to_glib_none();
let category = category.into();
let category = category.to_glib_none();
unsafe {
from_glib_full(ffi::gst_encoding_profile_find(targetname.to_glib_none().0, profilename.0, category.0))
}
}
pub fn from_discoverer(info: &DiscovererInfo) -> Option<EncodingProfile> {
skip_assert_initialized!();
unsafe {
from_glib_full(ffi::gst_encoding_profile_from_discoverer(info.to_glib_none().0))
}
}
}
unsafe impl Send for EncodingProfile {}
unsafe impl Sync for EncodingProfile {}
pub trait EncodingProfileExt {
fn copy(&self) -> EncodingProfile;
fn get_allow_dynamic_output(&self) -> bool;
fn get_description(&self) -> Option<String>;
fn get_file_extension(&self) -> Option<String>;
fn get_format(&self) -> gst::Caps;
fn get_input_caps(&self) -> gst::Caps;
fn get_name(&self) -> Option<String>;
fn get_presence(&self) -> u32;
fn get_preset(&self) -> Option<String>;
fn get_preset_name(&self) -> Option<String>;
fn get_restriction(&self) -> Option<gst::Caps>;
fn get_type_nick(&self) -> Option<String>;
fn is_enabled(&self) -> bool;
fn set_allow_dynamic_output(&self, allow_dynamic_output: bool);
fn set_description<'a, P: Into<Option<&'a str>>>(&self, description: P);
fn set_enabled(&self, enabled: bool);
fn set_format(&self, format: &gst::Caps);
fn set_name<'a, P: Into<Option<&'a str>>>(&self, name: P);
fn set_presence(&self, presence: u32);
fn set_preset<'a, P: Into<Option<&'a str>>>(&self, preset: P);
fn set_preset_name<'a, P: Into<Option<&'a str>>>(&self, preset_name: P);
fn set_restriction<'a, P: Into<Option<&'a gst::Caps>>>(&self, restriction: P);
fn get_property_restriction_caps(&self) -> Option<gst::Caps>;
fn set_property_restriction_caps(&self, restriction_caps: Option<&gst::Caps>);
fn connect_property_restriction_caps_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<EncodingProfile> + IsA<glib::object::Object>> EncodingProfileExt for O {
fn copy(&self) -> EncodingProfile {
unsafe {
from_glib_full(ffi::gst_encoding_profile_copy(self.to_glib_none().0))
}
}
fn get_allow_dynamic_output(&self) -> bool {
unsafe {
from_glib(ffi::gst_encoding_profile_get_allow_dynamic_output(self.to_glib_none().0))
}
}
fn get_description(&self) -> Option<String> {
unsafe {
from_glib_none(ffi::gst_encoding_profile_get_description(self.to_glib_none().0))
}
}
fn get_file_extension(&self) -> Option<String> {
unsafe {
from_glib_none(ffi::gst_encoding_profile_get_file_extension(self.to_glib_none().0))
}
}
fn get_format(&self) -> gst::Caps {
unsafe {
from_glib_full(ffi::gst_encoding_profile_get_format(self.to_glib_none().0))
}
}
fn get_input_caps(&self) -> gst::Caps {
unsafe {
from_glib_full(ffi::gst_encoding_profile_get_input_caps(self.to_glib_none().0))
}
}
fn get_name(&self) -> Option<String> {
unsafe {
from_glib_none(ffi::gst_encoding_profile_get_name(self.to_glib_none().0))
}
}
fn get_presence(&self) -> u32 {
unsafe {
ffi::gst_encoding_profile_get_presence(self.to_glib_none().0)
}
}
fn get_preset(&self) -> Option<String> {
unsafe {
from_glib_none(ffi::gst_encoding_profile_get_preset(self.to_glib_none().0))
}
}
fn get_preset_name(&self) -> Option<String> {
unsafe {
from_glib_none(ffi::gst_encoding_profile_get_preset_name(self.to_glib_none().0))
}
}
fn get_restriction(&self) -> Option<gst::Caps> {
unsafe {
from_glib_full(ffi::gst_encoding_profile_get_restriction(self.to_glib_none().0))
}
}
fn get_type_nick(&self) -> Option<String> {
unsafe {
from_glib_none(ffi::gst_encoding_profile_get_type_nick(self.to_glib_none().0))
}
}
fn is_enabled(&self) -> bool {
unsafe {
from_glib(ffi::gst_encoding_profile_is_enabled(self.to_glib_none().0))
}
}
fn set_allow_dynamic_output(&self, allow_dynamic_output: bool) {
unsafe {
ffi::gst_encoding_profile_set_allow_dynamic_output(self.to_glib_none().0, allow_dynamic_output.to_glib());
}
}
fn set_description<'a, P: Into<Option<&'a str>>>(&self, description: P) {
let description = description.into();
let description = description.to_glib_none();
unsafe {
ffi::gst_encoding_profile_set_description(self.to_glib_none().0, description.0);
}
}
fn set_enabled(&self, enabled: bool) {
unsafe {
ffi::gst_encoding_profile_set_enabled(self.to_glib_none().0, enabled.to_glib());
}
}
fn set_format(&self, format: &gst::Caps) {
unsafe {
ffi::gst_encoding_profile_set_format(self.to_glib_none().0, format.to_glib_none().0);
}
}
fn set_name<'a, P: Into<Option<&'a str>>>(&self, name: P) {
let name = name.into();
let name = name.to_glib_none();
unsafe {
ffi::gst_encoding_profile_set_name(self.to_glib_none().0, name.0);
}
}
fn set_presence(&self, presence: u32) {
unsafe {
ffi::gst_encoding_profile_set_presence(self.to_glib_none().0, presence);
}
}
fn set_preset<'a, P: Into<Option<&'a str>>>(&self, preset: P) {
let preset = preset.into();
let preset = preset.to_glib_none();
unsafe {
ffi::gst_encoding_profile_set_preset(self.to_glib_none().0, preset.0);
}
}
fn set_preset_name<'a, P: Into<Option<&'a str>>>(&self, preset_name: P) {
let preset_name = preset_name.into();
let preset_name = preset_name.to_glib_none();
unsafe {
ffi::gst_encoding_profile_set_preset_name(self.to_glib_none().0, preset_name.0);
}
}
fn set_restriction<'a, P: Into<Option<&'a gst::Caps>>>(&self, restriction: P) {
let restriction = restriction.into();
let restriction = restriction.to_glib_none();
unsafe {
ffi::gst_encoding_profile_set_restriction(self.to_glib_none().0, restriction.0);
}
}
fn get_property_restriction_caps(&self) -> Option<gst::Caps> {
unsafe {
let mut value = Value::from_type(<gst::Caps as StaticType>::static_type());
gobject_ffi::g_object_get_property(self.to_glib_none().0, "restriction-caps".to_glib_none().0, value.to_glib_none_mut().0);
value.get()
}
}
fn set_property_restriction_caps(&self, restriction_caps: Option<&gst::Caps>) {
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "restriction-caps".to_glib_none().0, Value::from(restriction_caps).to_glib_none().0);
}
}
fn connect_property_restriction_caps_notify<F: Fn(&Self) + Send + Sync + 'static>(&self, f: F) -> SignalHandlerId {
unsafe {
let f: Box_<Box_<Fn(&Self) + Send + Sync + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "notify::restriction-caps",
transmute(notify_restriction_caps_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
}
}
unsafe extern "C" fn notify_restriction_caps_trampoline<P>(this: *mut ffi::GstEncodingProfile, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<EncodingProfile> {
callback_guard!();
let f: &&(Fn(&P) + Send + Sync + 'static) = transmute(f);
f(&EncodingProfile::from_glib_borrow(this).downcast_unchecked())
}

View file

@ -0,0 +1,127 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff+)
// from gir-files (https://github.com/gtk-rs/gir-files @ ???)
// DO NOT EDIT
use EncodingProfile;
use Error;
use ffi;
use glib;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std;
use std::mem;
use std::ptr;
glib_wrapper! {
pub struct EncodingTarget(Object<ffi::GstEncodingTarget>);
match fn {
get_type => || ffi::gst_encoding_target_get_type(),
}
}
impl EncodingTarget {
pub fn new(name: &str, category: &str, description: &str, profiles: &[EncodingProfile]) -> EncodingTarget {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_encoding_target_new(name.to_glib_none().0, category.to_glib_none().0, description.to_glib_none().0, profiles.to_glib_none().0))
}
}
pub fn load<'a, P: Into<Option<&'a str>>>(name: &str, category: P) -> Result<EncodingTarget, Error> {
assert_initialized_main_thread!();
let category = category.into();
let category = category.to_glib_none();
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::gst_encoding_target_load(name.to_glib_none().0, category.0, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}
pub fn load_from_file<P: AsRef<std::path::Path>>(filepath: P) -> Result<EncodingTarget, Error> {
assert_initialized_main_thread!();
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::gst_encoding_target_load_from_file(filepath.as_ref().to_glib_none().0, &mut error);
if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }
}
}
}
unsafe impl Send for EncodingTarget {}
unsafe impl Sync for EncodingTarget {}
pub trait EncodingTargetExt {
fn add_profile<P: IsA<EncodingProfile>>(&self, profile: &P) -> Result<(), glib::error::BoolError>;
fn get_category(&self) -> String;
fn get_description(&self) -> String;
fn get_name(&self) -> String;
fn get_profile(&self, name: &str) -> Option<EncodingProfile>;
fn get_profiles(&self) -> Vec<EncodingProfile>;
fn save(&self) -> Result<(), Error>;
fn save_to_file<P: AsRef<std::path::Path>>(&self, filepath: P) -> Result<(), Error>;
}
impl<O: IsA<EncodingTarget>> EncodingTargetExt for O {
fn add_profile<P: IsA<EncodingProfile>>(&self, profile: &P) -> Result<(), glib::error::BoolError> {
unsafe {
glib::error::BoolError::from_glib(ffi::gst_encoding_target_add_profile(self.to_glib_none().0, profile.to_glib_full()), "Failed to add profile")
}
}
fn get_category(&self) -> String {
unsafe {
from_glib_none(ffi::gst_encoding_target_get_category(self.to_glib_none().0))
}
}
fn get_description(&self) -> String {
unsafe {
from_glib_none(ffi::gst_encoding_target_get_description(self.to_glib_none().0))
}
}
fn get_name(&self) -> String {
unsafe {
from_glib_none(ffi::gst_encoding_target_get_name(self.to_glib_none().0))
}
}
fn get_profile(&self, name: &str) -> Option<EncodingProfile> {
unsafe {
from_glib_full(ffi::gst_encoding_target_get_profile(self.to_glib_none().0, name.to_glib_none().0))
}
}
fn get_profiles(&self) -> Vec<EncodingProfile> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::gst_encoding_target_get_profiles(self.to_glib_none().0))
}
}
fn save(&self) -> Result<(), Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::gst_encoding_target_save(self.to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
fn save_to_file<P: AsRef<std::path::Path>>(&self, filepath: P) -> Result<(), Error> {
unsafe {
let mut error = ptr::null_mut();
let _ = ffi::gst_encoding_target_save_to_file(self.to_glib_none().0, filepath.as_ref().to_glib_none().0, &mut error);
if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
}
}
}

View file

@ -0,0 +1,60 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ fe7a6ff+)
// from gir-files (https://github.com/gtk-rs/gir-files @ ???)
// DO NOT EDIT
use EncodingProfile;
use ffi;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use gst;
use std::mem;
use std::ptr;
glib_wrapper! {
pub struct EncodingVideoProfile(Object<ffi::GstEncodingVideoProfile, ffi::GstEncodingVideoProfileClass>): EncodingProfile;
match fn {
get_type => || ffi::gst_encoding_video_profile_get_type(),
}
}
impl EncodingVideoProfile {
pub fn new<'a, 'b, P: Into<Option<&'a str>>, Q: Into<Option<&'b gst::Caps>>>(format: &gst::Caps, preset: P, restriction: Q, presence: u32) -> EncodingVideoProfile {
assert_initialized_main_thread!();
let preset = preset.into();
let preset = preset.to_glib_none();
let restriction = restriction.into();
let restriction = restriction.to_glib_none();
unsafe {
from_glib_full(ffi::gst_encoding_video_profile_new(format.to_glib_none().0, preset.0, restriction.0, presence))
}
}
pub fn get_pass(&self) -> u32 {
unsafe {
ffi::gst_encoding_video_profile_get_pass(self.to_glib_none().0)
}
}
pub fn get_variableframerate(&self) -> bool {
unsafe {
from_glib(ffi::gst_encoding_video_profile_get_variableframerate(self.to_glib_none().0))
}
}
pub fn set_pass(&self, pass: u32) {
unsafe {
ffi::gst_encoding_video_profile_set_pass(self.to_glib_none().0, pass);
}
}
pub fn set_variableframerate(&self, variableframerate: bool) {
unsafe {
ffi::gst_encoding_video_profile_set_variableframerate(self.to_glib_none().0, variableframerate.to_glib());
}
}
}
unsafe impl Send for EncodingVideoProfile {}
unsafe impl Sync for EncodingVideoProfile {}

View file

@ -25,6 +25,24 @@ pub use self::discoverer_subtitle_info::DiscovererSubtitleInfo;
mod discoverer_video_info;
pub use self::discoverer_video_info::DiscovererVideoInfo;
mod encoding_audio_profile;
pub use self::encoding_audio_profile::EncodingAudioProfile;
mod encoding_container_profile;
pub use self::encoding_container_profile::EncodingContainerProfile;
pub use self::encoding_container_profile::EncodingContainerProfileExt;
mod encoding_profile;
pub use self::encoding_profile::EncodingProfile;
pub use self::encoding_profile::EncodingProfileExt;
mod encoding_target;
pub use self::encoding_target::EncodingTarget;
pub use self::encoding_target::EncodingTargetExt;
mod encoding_video_profile;
pub use self::encoding_video_profile::EncodingVideoProfile;
mod enums;
pub use self::enums::DiscovererResult;
@ -35,4 +53,7 @@ pub use self::flags::DiscovererSerializeFlags;
pub mod traits {
pub use super::DiscovererInfoExt;
pub use super::DiscovererStreamInfoExt;
pub use super::EncodingContainerProfileExt;
pub use super::EncodingProfileExt;
pub use super::EncodingTargetExt;
}