plugins/elements/: Small cleanups. Add note adbout g_fopen() on windows and why we...
authorWim Taymans <wim.taymans@gmail.com>
Wed, 21 May 2008 16:06:53 +0000 (16:06 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Wed, 21 May 2008 16:06:53 +0000 (16:06 +0000)
Original commit message from CVS:
* plugins/elements/gstfilesink.c: (gst_file_sink_set_location),
(gst_file_sink_render):
* plugins/elements/gstfilesrc.c: (gst_file_src_set_location),
(gst_file_src_start):
Small cleanups. Add note adbout g_fopen() on windows and why we don't
use it yet.

ChangeLog
plugins/elements/gstfilesink.c
plugins/elements/gstfilesrc.c

index 768539f..eb0eae2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2008-05-21  Wim Taymans  <wim.taymans@collabora.co.uk>
 
+       * plugins/elements/gstfilesink.c: (gst_file_sink_set_location),
+       (gst_file_sink_render):
+       * plugins/elements/gstfilesrc.c: (gst_file_src_set_location),
+       (gst_file_src_start):
+       Small cleanups. Add note adbout g_fopen() on windows and why we don't
+       use it yet.
+
+2008-05-21  Wim Taymans  <wim.taymans@collabora.co.uk>
+
        * gst/gstpad.c: (gst_pad_load_and_link):
        * gst/gstutils.c: (gst_element_link_pads),
        (gst_element_unlink_pads):
index 61f5f80..7116568 100644 (file)
@@ -228,8 +228,10 @@ gst_file_sink_set_location (GstFileSink * sink, const gchar * location)
   g_free (sink->filename);
   g_free (sink->uri);
   if (location != NULL) {
+    /* we store the filename as we received it from the application. On Windows
+     * this should be in UTF8 */
     sink->filename = g_strdup (location);
-    sink->uri = gst_uri_construct ("file", location);
+    sink->uri = gst_uri_construct ("file", sink->filename);
   } else {
     sink->filename = NULL;
     sink->uri = NULL;
@@ -298,6 +300,9 @@ gst_file_sink_open_file (GstFileSink * sink)
   if (sink->filename == NULL || sink->filename[0] == '\0')
     goto no_filename;
 
+  /* FIXME, can we use g_fopen here? some people say that the FILE object is
+   * local to the .so that performed the fopen call, which would not be us when
+   * we use g_fopen. */
   sink->file = fopen (sink->filename, "wb");
   if (sink->file == NULL)
     goto open_failed;
@@ -552,16 +557,18 @@ gst_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
 {
   GstFileSink *filesink;
   guint size;
-
-  size = GST_BUFFER_SIZE (buffer);
+  guint8 *data;
 
   filesink = GST_FILE_SINK (sink);
 
+  size = GST_BUFFER_SIZE (buffer);
+  data = GST_BUFFER_DATA (buffer);
+
   GST_DEBUG_OBJECT (filesink, "writing %u bytes at %" G_GUINT64_FORMAT,
       size, filesink->current_pos);
 
-  if (size > 0 && GST_BUFFER_DATA (buffer) != NULL) {
-    if (fwrite (GST_BUFFER_DATA (buffer), size, 1, filesink->file) != 1)
+  if (size > 0 && data != NULL) {
+    if (fwrite (data, size, 1, filesink->file) != 1)
       goto handle_error;
 
     filesink->current_pos += size;
index 7aab9dd..e9d60fd 100644 (file)
@@ -317,6 +317,8 @@ gst_file_src_set_location (GstFileSrc * src, const gchar * location)
     src->filename = NULL;
     src->uri = NULL;
   } else {
+    /* we store the filename as received by the application. On Windoes this
+     * should be UTF8 */
     src->filename = g_strdup (location);
     src->uri = gst_uri_construct ("file", src->filename);
   }
@@ -909,6 +911,7 @@ gst_file_src_start (GstBaseSrc * basesrc)
 
   /* open the file */
   src->fd = open (src->filename, O_RDONLY | O_BINARY);
+
   if (src->fd < 0)
     goto open_failed;