mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
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.
This commit is contained in:
parent
cc8334905c
commit
095ce0b2b3
3 changed files with 24 additions and 5 deletions
|
@ -1,3 +1,12 @@
|
|||
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):
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue