gst-editing-services: timeline-pipeline: use standard GLib API to save thumbnail data to file

Wim Taymans wtay at kemper.freedesktop.org
Mon Mar 26 08:05:38 PDT 2012


Module: gst-editing-services
Branch: master
Commit: 1b2bb14aab6b29bfe2c433da7648c6933d47961a
URL:    http://cgit.freedesktop.org/gstreamer/gst-editing-services/commit/?id=1b2bb14aab6b29bfe2c433da7648c6933d47961a

Author: Tim-Philipp Müller <tim.muller at collabora.co.uk>
Date:   Fri Feb 10 18:43:51 2012 +0000

timeline-pipeline: use standard GLib API to save thumbnail data to file

---

 ges/ges-timeline-pipeline.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/ges/ges-timeline-pipeline.c b/ges/ges-timeline-pipeline.c
index ff1a514..8b25575 100644
--- a/ges/ges-timeline-pipeline.c
+++ b/ges/ges-timeline-pipeline.c
@@ -265,8 +265,8 @@ ges_timeline_pipeline_change_state (GstElement * element,
         ret = GST_STATE_CHANGE_FAILURE;
         goto done;
       }
-      if (self->
-          priv->mode & (TIMELINE_MODE_RENDER | TIMELINE_MODE_SMART_RENDER))
+      if (self->priv->
+          mode & (TIMELINE_MODE_RENDER | TIMELINE_MODE_SMART_RENDER))
         GST_DEBUG ("rendering => Updating pipeline caps");
       if (!ges_timeline_pipeline_update_caps (self)) {
         GST_ERROR_OBJECT (element, "Error setting the caps for rendering");
@@ -809,7 +809,7 @@ ges_timeline_pipeline_get_thumbnail (GESTimelinePipeline * self, GstCaps * caps)
  * 
  * Returns: %TRUE if the thumbnail was properly save, else %FALSE.
  */
-
+/* FIXME 0.11: save_thumbnail should have a GError parameter */
 gboolean
 ges_timeline_pipeline_save_thumbnail (GESTimelinePipeline * self, int width, int
     height, const gchar * format, const gchar * location)
@@ -817,7 +817,6 @@ ges_timeline_pipeline_save_thumbnail (GESTimelinePipeline * self, int width, int
   GstMapInfo map_info;
   GstBuffer *b;
   GstSample *sample;
-  FILE *fp;
   GstCaps *caps;
   gboolean res = TRUE;
 
@@ -836,12 +835,14 @@ ges_timeline_pipeline_save_thumbnail (GESTimelinePipeline * self, int width, int
 
   b = gst_sample_get_buffer (sample);
   if (gst_buffer_map (b, &map_info, GST_MAP_READ)) {
-    /* FIXME : Use standard glib methods */
-    fp = fopen (location, "w+");
-    if (!fwrite (map_info.data, map_info.size, 1, fp) || ferror (fp)) {
+    GError *err = NULL;
+
+    if (!g_file_set_contents (location, (const char *) map_info.data,
+            map_info.size, &err)) {
+      GST_WARNING ("Could not save thumbnail: %s", err->message);
+      g_error_free (err);
       res = FALSE;
     }
-    fclose (fp);
   }
 
   gst_caps_unref (caps);



More information about the gstreamer-commits mailing list