[sound-juicer/wip/encoding-presets: 3/7] Add functions to get and set profile presets



commit 77404dacc155ac1304a6536ac95a9a1b8f5fc75f
Author: Phillip Wood <phillip wood dunelm org uk>
Date:   Mon Feb 9 15:30:37 2015 +0000

    Add functions to get and set profile presets
    
    These are based on similar functions from rhythmbox. We use an empty
    string rather than null to signify that no preset is set as null is not
    a valid GtkComboBox item id.

 libjuicer/rb-gst-media-types.c |   46 ++++++++++++++++++++++++++++++++++++++++
 libjuicer/rb-gst-media-types.h |    6 +++++
 2 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/libjuicer/rb-gst-media-types.c b/libjuicer/rb-gst-media-types.c
index 2fcdc92..11fbc55 100644
--- a/libjuicer/rb-gst-media-types.c
+++ b/libjuicer/rb-gst-media-types.c
@@ -26,6 +26,7 @@
  */
 
 #include "config.h"
+#include "sj-util.h"
 
 #include <memory.h>
 
@@ -275,6 +276,51 @@ rb_gst_media_type_is_lossless (const char *media_type)
        return FALSE;
 }
 
+GstEncodingProfile *
+rb_gst_get_audio_encoding_profile (GstEncodingProfile *profile)
+{
+       if (GST_IS_ENCODING_AUDIO_PROFILE (profile)) {
+               return profile;
+       } else if (GST_IS_ENCODING_CONTAINER_PROFILE (profile)) {
+               const GList *l = gst_encoding_container_profile_get_profiles (GST_ENCODING_CONTAINER_PROFILE 
(profile));
+               for (; l != NULL; l = l->next) {
+                       GstEncodingProfile *p = rb_gst_get_audio_encoding_profile (l->data);
+                       if (p != NULL) {
+                               return p;
+                       }
+               }
+       }
+
+       g_warning ("no audio encoding profile in profile %s", gst_encoding_profile_get_name (profile));
+       return NULL;
+}
+
+void
+rb_gst_encoding_profile_set_preset (GstEncodingProfile *profile, const char *preset)
+{
+       GstEncodingProfile *p;
+       const gchar *pre;
+
+       pre = sj_str_is_empty (preset) ? NULL : preset;
+       p = rb_gst_get_audio_encoding_profile (profile);
+       if (p != NULL) {
+               gst_encoding_profile_set_preset (p, pre);
+       }
+}
+
+const gchar*
+rb_gst_encoding_profile_get_preset (GstEncodingProfile *profile)
+{
+       GstEncodingProfile *p;
+       const gchar *preset = NULL;
+
+       p = rb_gst_get_audio_encoding_profile (profile);
+       if (p != NULL) {
+               preset = gst_encoding_profile_get_preset (p);
+       }
+       return (preset == NULL) ? "" : preset;
+}
+
 gboolean
 rb_gst_check_missing_plugins (GstEncodingProfile *profile,
                              char ***details,
diff --git a/libjuicer/rb-gst-media-types.h b/libjuicer/rb-gst-media-types.h
index 9211361..65f97b4 100644
--- a/libjuicer/rb-gst-media-types.h
+++ b/libjuicer/rb-gst-media-types.h
@@ -66,6 +66,12 @@ gboolean     rb_gst_media_type_matches_profile (GstEncodingProfile *profile, const c
 
 char *         rb_gst_encoding_profile_get_media_type (GstEncodingProfile *profile);
 
+GstEncodingProfile *rb_gst_get_audio_encoding_profile (GstEncodingProfile *profile);
+
+void           rb_gst_encoding_profile_set_preset (GstEncodingProfile *profile, const char *preset);
+
+const char *   rb_gst_encoding_profile_get_preset (GstEncodingProfile *profile);
+
 gboolean       rb_gst_media_type_is_lossless (const char *media_type);
 gboolean       rb_gst_check_missing_plugins (GstEncodingProfile *profile,
                                              char ***details,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]