pbutils/encoding_profile: Move doc aliases to the correct function definitions/declarations

And also add `::builder()` functions on the audio/video/container
encoding profile types.
This commit is contained in:
Sebastian Dröge 2021-10-24 18:23:22 +03:00
parent e95a75fdab
commit 9e1fb4570f

View file

@ -32,7 +32,6 @@ trait EncodingProfileBuilderCommon {
} }
impl<O: IsA<EncodingProfile>> EncodingProfileBuilderCommon for O { impl<O: IsA<EncodingProfile>> EncodingProfileBuilderCommon for O {
#[doc(alias = "gst_encoding_profile_set_allow_dynamic_output")]
fn set_allow_dynamic_output(&self, allow_dynamic_output: bool) { fn set_allow_dynamic_output(&self, allow_dynamic_output: bool) {
unsafe { unsafe {
ffi::gst_encoding_profile_set_allow_dynamic_output( ffi::gst_encoding_profile_set_allow_dynamic_output(
@ -42,7 +41,6 @@ impl<O: IsA<EncodingProfile>> EncodingProfileBuilderCommon for O {
} }
} }
#[doc(alias = "gst_encoding_profile_set_description")]
fn set_description(&self, description: Option<&str>) { fn set_description(&self, description: Option<&str>) {
let description = description.to_glib_none(); let description = description.to_glib_none();
unsafe { unsafe {
@ -53,7 +51,6 @@ impl<O: IsA<EncodingProfile>> EncodingProfileBuilderCommon for O {
} }
} }
#[doc(alias = "gst_encoding_profile_set_enabled")]
fn set_enabled(&self, enabled: bool) { fn set_enabled(&self, enabled: bool) {
unsafe { unsafe {
ffi::gst_encoding_profile_set_enabled( ffi::gst_encoding_profile_set_enabled(
@ -63,7 +60,6 @@ impl<O: IsA<EncodingProfile>> EncodingProfileBuilderCommon for O {
} }
} }
#[doc(alias = "gst_encoding_profile_set_format")]
fn set_format(&self, format: &gst::Caps) { fn set_format(&self, format: &gst::Caps) {
unsafe { unsafe {
ffi::gst_encoding_profile_set_format( ffi::gst_encoding_profile_set_format(
@ -73,7 +69,6 @@ impl<O: IsA<EncodingProfile>> EncodingProfileBuilderCommon for O {
} }
} }
#[doc(alias = "gst_encoding_profile_set_name")]
fn set_name(&self, name: Option<&str>) { fn set_name(&self, name: Option<&str>) {
let name = name.to_glib_none(); let name = name.to_glib_none();
unsafe { unsafe {
@ -81,14 +76,12 @@ impl<O: IsA<EncodingProfile>> EncodingProfileBuilderCommon for O {
} }
} }
#[doc(alias = "gst_encoding_profile_set_presence")]
fn set_presence(&self, presence: u32) { fn set_presence(&self, presence: u32) {
unsafe { unsafe {
ffi::gst_encoding_profile_set_presence(self.as_ref().to_glib_none().0, presence); ffi::gst_encoding_profile_set_presence(self.as_ref().to_glib_none().0, presence);
} }
} }
#[doc(alias = "gst_encoding_profile_set_preset")]
fn set_preset(&self, preset: Option<&str>) { fn set_preset(&self, preset: Option<&str>) {
let preset = preset.to_glib_none(); let preset = preset.to_glib_none();
unsafe { unsafe {
@ -96,7 +89,6 @@ impl<O: IsA<EncodingProfile>> EncodingProfileBuilderCommon for O {
} }
} }
#[doc(alias = "gst_encoding_profile_set_preset_name")]
fn set_preset_name(&self, preset_name: Option<&str>) { fn set_preset_name(&self, preset_name: Option<&str>) {
let preset_name = preset_name.to_glib_none(); let preset_name = preset_name.to_glib_none();
unsafe { unsafe {
@ -125,13 +117,13 @@ trait EncodingProfileHasRestrictionSetter {
pub trait EncodingProfileHasRestrictionGetter { pub trait EncodingProfileHasRestrictionGetter {
#[doc(alias = "get_restriction")] #[doc(alias = "get_restriction")]
#[doc(alias = "gst_encoding_profile_get_restriction")]
fn restriction(&self) -> Option<gst::Caps>; fn restriction(&self) -> Option<gst::Caps>;
} }
macro_rules! declare_encoding_profile_has_restriction( macro_rules! declare_encoding_profile_has_restriction(
($name:ident) => { ($name:ident) => {
impl EncodingProfileHasRestrictionSetter for $name { impl EncodingProfileHasRestrictionSetter for $name {
#[doc(alias = "gst_encoding_profile_set_restriction")]
fn set_restriction(&self, restriction: Option<&gst::Caps>) { fn set_restriction(&self, restriction: Option<&gst::Caps>) {
let profile: &EncodingProfile = glib::object::Cast::upcast_ref(self); let profile: &EncodingProfile = glib::object::Cast::upcast_ref(self);
@ -150,7 +142,6 @@ macro_rules! declare_encoding_profile_has_restriction(
} }
impl EncodingProfileHasRestrictionGetter for $name { impl EncodingProfileHasRestrictionGetter for $name {
#[doc(alias = "gst_encoding_profile_get_restriction")]
fn restriction(&self) -> Option<gst::Caps> { fn restriction(&self) -> Option<gst::Caps> {
let profile: &EncodingProfile = glib::object::Cast::upcast_ref(self); let profile: &EncodingProfile = glib::object::Cast::upcast_ref(self);
@ -165,7 +156,6 @@ macro_rules! declare_encoding_profile_has_restriction(
); );
impl EncodingAudioProfile { impl EncodingAudioProfile {
#[doc(alias = "gst_encoding_audio_profile_new")]
fn new( fn new(
format: &gst::Caps, format: &gst::Caps,
preset: Option<&str>, preset: Option<&str>,
@ -184,12 +174,16 @@ impl EncodingAudioProfile {
)) ))
} }
} }
#[doc(alias = "gst_encoding_audio_profile_new")]
pub fn builder<'a>() -> EncodingAudioProfileBuilder<'a> {
EncodingAudioProfileBuilder::new()
}
} }
declare_encoding_profile_has_restriction!(EncodingAudioProfile); declare_encoding_profile_has_restriction!(EncodingAudioProfile);
impl EncodingVideoProfile { impl EncodingVideoProfile {
#[doc(alias = "gst_encoding_video_profile_new")]
fn new( fn new(
format: &gst::Caps, format: &gst::Caps,
preset: Option<&str>, preset: Option<&str>,
@ -209,14 +203,17 @@ impl EncodingVideoProfile {
} }
} }
#[doc(alias = "gst_encoding_video_profile_set_pass")] #[doc(alias = "gst_encoding_video_profile_new")]
pub fn builder<'a>() -> EncodingVideoProfileBuilder<'a> {
EncodingVideoProfileBuilder::new()
}
fn set_pass(&self, pass: u32) { fn set_pass(&self, pass: u32) {
unsafe { unsafe {
ffi::gst_encoding_video_profile_set_pass(self.to_glib_none().0, pass); ffi::gst_encoding_video_profile_set_pass(self.to_glib_none().0, pass);
} }
} }
#[doc(alias = "gst_encoding_video_profile_set_variableframerate")]
fn set_variableframerate(&self, variableframerate: bool) { fn set_variableframerate(&self, variableframerate: bool) {
unsafe { unsafe {
ffi::gst_encoding_video_profile_set_variableframerate( ffi::gst_encoding_video_profile_set_variableframerate(
@ -230,7 +227,6 @@ impl EncodingVideoProfile {
declare_encoding_profile_has_restriction!(EncodingVideoProfile); declare_encoding_profile_has_restriction!(EncodingVideoProfile);
impl EncodingContainerProfile { impl EncodingContainerProfile {
#[doc(alias = "gst_encoding_container_profile_new")]
fn new( fn new(
name: Option<&str>, name: Option<&str>,
description: Option<&str>, description: Option<&str>,
@ -251,7 +247,11 @@ impl EncodingContainerProfile {
} }
} }
#[doc(alias = "gst_encoding_container_profile_add_profile")] #[doc(alias = "gst_encoding_container_profile_new")]
pub fn builder<'a>() -> EncodingContainerProfileBuilder<'a> {
EncodingContainerProfileBuilder::new()
}
fn add_profile<P: IsA<EncodingProfile>>( fn add_profile<P: IsA<EncodingProfile>>(
&self, &self,
profile: &P, profile: &P,
@ -304,15 +304,24 @@ impl<'a> EncodingProfileBuilderCommonData<'a> {
} }
pub trait EncodingProfileBuilder<'a>: Sized { pub trait EncodingProfileBuilder<'a>: Sized {
#[doc(alias = "gst_encoding_profile_set_name")]
fn name(self, name: &'a str) -> Self; fn name(self, name: &'a str) -> Self;
#[doc(alias = "gst_encoding_profile_set_description")]
fn description(self, description: &'a str) -> Self; fn description(self, description: &'a str) -> Self;
#[doc(alias = "gst_encoding_profile_set_format")]
fn format(self, format: &'a gst::Caps) -> Self; fn format(self, format: &'a gst::Caps) -> Self;
#[doc(alias = "gst_encoding_profile_set_preset")]
fn preset(self, preset: &'a str) -> Self; fn preset(self, preset: &'a str) -> Self;
#[doc(alias = "gst_encoding_profile_set_preset_name")]
fn preset_name(self, preset_name: &'a str) -> Self; fn preset_name(self, preset_name: &'a str) -> Self;
#[doc(alias = "gst_encoding_profile_set_presence")]
fn presence(self, presence: u32) -> Self; fn presence(self, presence: u32) -> Self;
#[doc(alias = "gst_encoding_profile_set_allow_dynamic_output")]
fn allow_dynamic_output(self, allow: bool) -> Self; fn allow_dynamic_output(self, allow: bool) -> Self;
#[doc(alias = "gst_encoding_profile_set_enabled")]
fn enabled(self, enabled: bool) -> Self; fn enabled(self, enabled: bool) -> Self;
#[cfg(feature = "v1_18")] #[cfg(feature = "v1_18")]
#[doc(alias = "gst_encoding_profile_set_single_segment")]
fn single_segment(self, single_segment: bool) -> Self; fn single_segment(self, single_segment: bool) -> Self;
} }
@ -408,6 +417,7 @@ impl<'a> EncodingAudioProfileBuilder<'a> {
} }
} }
#[doc(alias = "gst_encoding_profile_set_restriction")]
pub fn restriction(mut self, restriction: &'a gst::Caps) -> Self { pub fn restriction(mut self, restriction: &'a gst::Caps) -> Self {
self.restriction = Some(restriction); self.restriction = Some(restriction);
self self
@ -450,16 +460,19 @@ impl<'a> EncodingVideoProfileBuilder<'a> {
} }
} }
#[doc(alias = "gst_encoding_video_profile_set_pass")]
pub fn pass(mut self, pass: u32) -> Self { pub fn pass(mut self, pass: u32) -> Self {
self.pass = pass; self.pass = pass;
self self
} }
#[doc(alias = "gst_encoding_video_profile_set_variableframerate")]
pub fn variable_framerate(mut self, variable_framerate: bool) -> Self { pub fn variable_framerate(mut self, variable_framerate: bool) -> Self {
self.variable_framerate = variable_framerate; self.variable_framerate = variable_framerate;
self self
} }
#[doc(alias = "gst_encoding_profile_set_restriction")]
pub fn restriction(mut self, restriction: &'a gst::Caps) -> Self { pub fn restriction(mut self, restriction: &'a gst::Caps) -> Self {
self.restriction = Some(restriction); self.restriction = Some(restriction);
self self
@ -523,6 +536,7 @@ impl<'a> EncodingContainerProfileBuilder<'a> {
Ok(container_profile) Ok(container_profile)
} }
#[doc(alias = "gst_encoding_container_profile_add_profile")]
pub fn add_profile<P: IsA<EncodingProfile>>(mut self, profile: &P) -> Self { pub fn add_profile<P: IsA<EncodingProfile>>(mut self, profile: &P) -> Self {
self.profiles.push(profile.as_ref().clone()); self.profiles.push(profile.as_ref().clone());
self self