From 8e413fa3c928587c865790936cd7d2a780dd9f04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 8 Oct 2018 09:17:26 +0300 Subject: [PATCH] Store encoding profiles inside the container builder as a Vec --- gstreamer-pbutils/src/encoding_profile.rs | 26 ++++++----------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/gstreamer-pbutils/src/encoding_profile.rs b/gstreamer-pbutils/src/encoding_profile.rs index b60e2ea86..7e096f932 100644 --- a/gstreamer-pbutils/src/encoding_profile.rs +++ b/gstreamer-pbutils/src/encoding_profile.rs @@ -11,7 +11,6 @@ use glib::translate::*; use auto::EncodingAudioProfile; use auto::EncodingContainerProfile; -use auto::EncodingContainerProfileExt; use auto::EncodingProfile; use auto::EncodingVideoProfile; @@ -419,15 +418,7 @@ impl<'a> EncodingVideoProfileBuilder<'a> { pub struct EncodingContainerProfileBuilder<'a> { base: EncodingProfileBuilderCommonData<'a>, - /* - * Not proud of this. - * Couldn't figure out how to store a IsA to be used - * only when building the final profile object. So I'm using a real - * EncodingContainerProfile object just as a means to store it under - * the ffi APIs. This preserves the public APIs of this builder as - * they should be at the end. - */ - helper_profile: EncodingContainerProfile, + profiles: Vec, } declare_encoding_profile_builder_common!(EncodingContainerProfileBuilder); @@ -436,12 +427,7 @@ impl<'a> EncodingContainerProfileBuilder<'a> { pub fn new() -> Self { EncodingContainerProfileBuilder { base: EncodingProfileBuilderCommonData::new(), - helper_profile: EncodingContainerProfile::new( - "helper", - None, - &gst::Caps::new_any(), - None, - ), + profiles: Vec::new(), } } @@ -457,7 +443,7 @@ impl<'a> EncodingContainerProfileBuilder<'a> { self.base.preset, ); - for profile in self.helper_profile.get_profiles() { + for profile in self.profiles { container_profile .add_profile(&profile) .or_else(|_error| Err(EncodingProfileBuilderError))?; @@ -467,8 +453,10 @@ impl<'a> EncodingContainerProfileBuilder<'a> { Ok(container_profile) } - pub fn add_profile>(self, profile: &P) -> Self { - self.helper_profile.add_profile(profile).unwrap(); + pub fn add_profile>(mut self, profile: &P) -> Self { + unsafe { + self.profiles.push(from_glib_none(profile.to_glib_none().0)); + } self } }