[sound-juicer/wip/encoding-presets: 5/7] Add function to save encoding profiles



commit 6896df30d054dd8f4008c8c42f343a73d46619e2
Author: Phillip Wood <phillip wood dunelm org uk>
Date:   Mon Feb 9 15:40:36 2015 +0000

    Add function to save encoding profiles
    
    This allows us to store changes to an encoding profile's preset.

 libjuicer/rb-gst-media-types.c |   40 ++++++++++++++++++++++++++++++++++++++++
 libjuicer/rb-gst-media-types.h |    2 ++
 2 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/libjuicer/rb-gst-media-types.c b/libjuicer/rb-gst-media-types.c
index 9c8ca89..d4fc682 100644
--- a/libjuicer/rb-gst-media-types.c
+++ b/libjuicer/rb-gst-media-types.c
@@ -359,6 +359,46 @@ rb_gst_encoding_profile_get_preset (GstEncodingProfile *profile)
        return (preset == NULL) ? "" : preset;
 }
 
+void
+rb_gst_encoding_profile_save_profiles (void)
+{
+       GstEncodingTarget *target;
+       gchar *file_name, *directory, *display_name;
+       gboolean retrying = FALSE;
+       GError *error = NULL;
+
+       target = rb_gst_get_default_encoding_target ();
+       file_name = get_encoding_target_name ();
+ retry_save:
+       if (!gst_encoding_target_save_to_file (target, file_name, &error)) {
+               if (!retrying &&
+                   g_error_matches (error, g_file_error_quark (), G_FILE_ERROR_NOENT)) {
+                       g_error_free (error);
+                       error = NULL;
+                       retrying = TRUE;
+                       directory = g_path_get_dirname (file_name);
+                       if (g_mkdir_with_parents (directory, 0755) == 0) {
+                               g_free (directory);
+                               goto retry_save;
+                       } else {
+                               display_name = g_filename_display_name (directory);
+                               g_warning ("Error saving encoding target file, unable to create directory 
'%s'",
+                                          display_name);
+                               g_free (display_name);
+                               g_free (directory);
+                       }
+               } else {
+                       display_name = g_filename_display_name (file_name);
+                       g_warning ("Error saving encoding target file '%s' - '%s'",
+                                  display_name,
+                                  error->message);
+                       g_free (display_name);
+                       g_error_free (error);
+               }
+       }
+       g_free (file_name);
+}
+
 static void
 clear_preset_info (gpointer data)
 {
diff --git a/libjuicer/rb-gst-media-types.h b/libjuicer/rb-gst-media-types.h
index 25258d2..1f37d4b 100644
--- a/libjuicer/rb-gst-media-types.h
+++ b/libjuicer/rb-gst-media-types.h
@@ -79,6 +79,8 @@ void          rb_gst_encoding_profile_set_preset (GstEncodingProfile *profile, const cha
 
 const char *   rb_gst_encoding_profile_get_preset (GstEncodingProfile *profile);
 
+void           rb_gst_encoding_profile_save_profiles (void);
+
 GstElement *   rb_gst_encoding_profile_get_encoder (GstEncodingProfile *profile);
 
 gboolean       rb_gst_media_type_is_lossless (const char *media_type);


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