From 095ce0b2b3835882fc38fb7f09f6b168f4396557 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 21 May 2008 16:06:53 +0000 Subject: [PATCH] plugins/elements/: Small cleanups. Add note adbout g_fopen() on windows and why we don't use it yet. 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 | 9 +++++++++ plugins/elements/gstfilesink.c | 17 ++++++++++++----- plugins/elements/gstfilesrc.c | 3 +++ 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 768539fc9c..eb0eae243f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-05-21 Wim Taymans + + * 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 * gst/gstpad.c: (gst_pad_load_and_link): diff --git a/plugins/elements/gstfilesink.c b/plugins/elements/gstfilesink.c index 61f5f800a1..7116568552 100644 --- a/plugins/elements/gstfilesink.c +++ b/plugins/elements/gstfilesink.c @@ -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; diff --git a/plugins/elements/gstfilesrc.c b/plugins/elements/gstfilesrc.c index 7aab9dd5b7..e9d60fd15e 100644 --- a/plugins/elements/gstfilesrc.c +++ b/plugins/elements/gstfilesrc.c @@ -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;