2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
4 * 2006 Wim Taymans <wim@fluendo.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
24 * SECTION:element-filesink
26 * @see_also: #GstFileSrc
28 * Write incoming data to a file in the local file system.
30 * ## Example launch line
32 * gst-launch-1.0 v4l2src num-buffers=1 ! jpegenc ! filesink location=capture1.jpeg
33 * ]| Capture one frame from a v4l2 camera and save as jpeg image.
41 #include "../../gst/gst-i18n-lib.h"
44 #include <stdio.h> /* for fseeko() */
45 #ifdef HAVE_STDIO_EXT_H
46 #include <stdio_ext.h> /* for __fbufsize, for debugging */
49 #include "gstfilesink.h"
51 #include <sys/types.h>
54 #include <io.h> /* lseek, open, close, read */
56 #define lseek _lseeki64
60 #define ftruncate _chsize
63 #ifdef _MSC_VER /* Check if we are using MSVC, fileno is deprecated in favour */
64 #define fileno _fileno /* of _fileno */
73 #include "gstelements_private.h"
74 #include "gstfilesink.h"
76 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
81 #define GST_TYPE_FILE_SINK_BUFFER_MODE (gst_file_sink_buffer_mode_get_type ())
83 gst_file_sink_buffer_mode_get_type (void)
85 static GType buffer_mode_type = 0;
86 static const GEnumValue buffer_mode[] = {
87 {GST_FILE_SINK_BUFFER_MODE_DEFAULT, "Default buffering", "default"},
88 {GST_FILE_SINK_BUFFER_MODE_FULL, "Fully buffered", "full"},
89 {GST_FILE_SINK_BUFFER_MODE_LINE, "Line buffered (deprecated, like full)",
91 {GST_FILE_SINK_BUFFER_MODE_UNBUFFERED, "Unbuffered", "unbuffered"},
95 if (!buffer_mode_type) {
97 g_enum_register_static ("GstFileSinkBufferMode", buffer_mode);
99 return buffer_mode_type;
102 GST_DEBUG_CATEGORY_STATIC (gst_file_sink_debug);
103 #define GST_CAT_DEFAULT gst_file_sink_debug
105 #define DEFAULT_LOCATION NULL
106 #define DEFAULT_BUFFER_MODE GST_FILE_SINK_BUFFER_MODE_DEFAULT
107 #define DEFAULT_BUFFER_SIZE 64 * 1024
108 #define DEFAULT_APPEND FALSE
120 /* Copy of glib's g_fopen due to win32 libc/cross-DLL brokenness: we can't
121 * use the 'file pointer' opened in glib (and returned from this function)
122 * in this library, as they may have unrelated C runtimes. */
124 gst_fopen (const gchar * filename, const gchar * mode)
127 wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL);
132 if (wfilename == NULL) {
137 wmode = g_utf8_to_utf16 (mode, -1, NULL, NULL, NULL);
145 retval = _wfopen (wfilename, wmode);
154 return fopen (filename, mode);
158 static void gst_file_sink_dispose (GObject * object);
160 static void gst_file_sink_set_property (GObject * object, guint prop_id,
161 const GValue * value, GParamSpec * pspec);
162 static void gst_file_sink_get_property (GObject * object, guint prop_id,
163 GValue * value, GParamSpec * pspec);
165 static gboolean gst_file_sink_open_file (GstFileSink * sink);
166 static void gst_file_sink_close_file (GstFileSink * sink);
168 static gboolean gst_file_sink_start (GstBaseSink * sink);
169 static gboolean gst_file_sink_stop (GstBaseSink * sink);
170 static gboolean gst_file_sink_event (GstBaseSink * sink, GstEvent * event);
171 static GstFlowReturn gst_file_sink_render (GstBaseSink * sink,
173 static GstFlowReturn gst_file_sink_render_list (GstBaseSink * sink,
174 GstBufferList * list);
176 static gboolean gst_file_sink_do_seek (GstFileSink * filesink,
178 static gboolean gst_file_sink_get_current_offset (GstFileSink * filesink,
181 static gboolean gst_file_sink_query (GstBaseSink * bsink, GstQuery * query);
183 static void gst_file_sink_uri_handler_init (gpointer g_iface,
184 gpointer iface_data);
186 static GstFlowReturn gst_file_sink_flush_buffer (GstFileSink * filesink);
189 G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_file_sink_uri_handler_init); \
190 GST_DEBUG_CATEGORY_INIT (gst_file_sink_debug, "filesink", 0, "filesink element");
191 #define gst_file_sink_parent_class parent_class
192 G_DEFINE_TYPE_WITH_CODE (GstFileSink, gst_file_sink, GST_TYPE_BASE_SINK,
196 gst_file_sink_class_init (GstFileSinkClass * klass)
198 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
199 GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
200 GstBaseSinkClass *gstbasesink_class = GST_BASE_SINK_CLASS (klass);
202 gobject_class->dispose = gst_file_sink_dispose;
204 gobject_class->set_property = gst_file_sink_set_property;
205 gobject_class->get_property = gst_file_sink_get_property;
207 g_object_class_install_property (gobject_class, PROP_LOCATION,
208 g_param_spec_string ("location", "File Location",
209 "Location of the file to write", NULL,
210 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
212 g_object_class_install_property (gobject_class, PROP_BUFFER_MODE,
213 g_param_spec_enum ("buffer-mode", "Buffering mode",
214 "The buffering mode to use", GST_TYPE_FILE_SINK_BUFFER_MODE,
215 DEFAULT_BUFFER_MODE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
217 g_object_class_install_property (gobject_class, PROP_BUFFER_SIZE,
218 g_param_spec_uint ("buffer-size", "Buffering size",
219 "Size of buffer in number of bytes for line or full buffer-mode", 0,
220 G_MAXUINT, DEFAULT_BUFFER_SIZE,
221 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
226 * Append to an already existing file.
228 g_object_class_install_property (gobject_class, PROP_APPEND,
229 g_param_spec_boolean ("append", "Append",
230 "Append to an already existing file", DEFAULT_APPEND,
231 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
233 gst_element_class_set_static_metadata (gstelement_class,
235 "Sink/File", "Write stream to a file",
236 "Thomas Vander Stichele <thomas at apestaart dot org>");
237 gst_element_class_add_static_pad_template (gstelement_class, &sinktemplate);
239 gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_file_sink_start);
240 gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_file_sink_stop);
241 gstbasesink_class->query = GST_DEBUG_FUNCPTR (gst_file_sink_query);
242 gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_file_sink_render);
243 gstbasesink_class->render_list =
244 GST_DEBUG_FUNCPTR (gst_file_sink_render_list);
245 gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_file_sink_event);
247 if (sizeof (off_t) < 8) {
248 GST_LOG ("No large file support, sizeof (off_t) = %" G_GSIZE_FORMAT "!",
254 gst_file_sink_init (GstFileSink * filesink)
256 filesink->filename = NULL;
257 filesink->file = NULL;
258 filesink->current_pos = 0;
259 filesink->buffer_mode = DEFAULT_BUFFER_MODE;
260 filesink->buffer_size = DEFAULT_BUFFER_SIZE;
261 filesink->append = FALSE;
263 gst_base_sink_set_sync (GST_BASE_SINK (filesink), FALSE);
267 gst_file_sink_dispose (GObject * object)
269 GstFileSink *sink = GST_FILE_SINK (object);
271 G_OBJECT_CLASS (parent_class)->dispose (object);
275 g_free (sink->filename);
276 sink->filename = NULL;
280 gst_file_sink_set_location (GstFileSink * sink, const gchar * location,
286 g_free (sink->filename);
288 if (location != NULL) {
289 /* we store the filename as we received it from the application. On Windows
290 * this should be in UTF8 */
291 sink->filename = g_strdup (location);
292 sink->uri = gst_filename_to_uri (location, NULL);
293 GST_INFO_OBJECT (sink, "filename : %s", sink->filename);
294 GST_INFO_OBJECT (sink, "uri : %s", sink->uri);
296 sink->filename = NULL;
305 g_warning ("Changing the `location' property on filesink when a file is "
306 "open is not supported.");
307 g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_STATE,
308 "Changing the 'location' property on filesink when a file is "
309 "open is not supported");
315 gst_file_sink_set_property (GObject * object, guint prop_id,
316 const GValue * value, GParamSpec * pspec)
318 GstFileSink *sink = GST_FILE_SINK (object);
322 gst_file_sink_set_location (sink, g_value_get_string (value), NULL);
324 case PROP_BUFFER_MODE:
325 sink->buffer_mode = g_value_get_enum (value);
327 case PROP_BUFFER_SIZE:
328 sink->buffer_size = g_value_get_uint (value);
331 sink->append = g_value_get_boolean (value);
334 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
340 gst_file_sink_get_property (GObject * object, guint prop_id, GValue * value,
343 GstFileSink *sink = GST_FILE_SINK (object);
347 g_value_set_string (value, sink->filename);
349 case PROP_BUFFER_MODE:
350 g_value_set_enum (value, sink->buffer_mode);
352 case PROP_BUFFER_SIZE:
353 g_value_set_uint (value, sink->buffer_size);
356 g_value_set_boolean (value, sink->append);
359 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
365 gst_file_sink_open_file (GstFileSink * sink)
368 if (sink->filename == NULL || sink->filename[0] == '\0')
372 sink->file = gst_fopen (sink->filename, "ab");
374 sink->file = gst_fopen (sink->filename, "wb");
375 if (sink->file == NULL)
378 sink->current_pos = 0;
379 /* try to seek in the file to figure out if it is seekable */
380 sink->seekable = gst_file_sink_do_seek (sink, 0);
383 gst_buffer_list_unref (sink->buffer);
385 if (sink->buffer_mode != GST_FILE_SINK_BUFFER_MODE_UNBUFFERED) {
386 if (sink->buffer_size == 0) {
387 sink->buffer_size = DEFAULT_BUFFER_SIZE;
388 g_object_notify (G_OBJECT (sink), "buffer-size");
391 sink->buffer = gst_buffer_list_new ();
394 GST_DEBUG_OBJECT (sink, "opened file %s, seekable %d",
395 sink->filename, sink->seekable);
402 GST_ELEMENT_ERROR (sink, RESOURCE, NOT_FOUND,
403 (_("No file name specified for writing.")), (NULL));
408 GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE,
409 (_("Could not open file \"%s\" for writing."), sink->filename),
416 gst_file_sink_close_file (GstFileSink * sink)
419 if (gst_file_sink_flush_buffer (sink) != GST_FLOW_OK)
420 GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
421 (_("Error closing file \"%s\"."), sink->filename), NULL);
423 if (fclose (sink->file) != 0)
424 GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE,
425 (_("Error closing file \"%s\"."), sink->filename), GST_ERROR_SYSTEM);
427 GST_DEBUG_OBJECT (sink, "closed file");
432 gst_buffer_list_unref (sink->buffer);
438 gst_file_sink_query (GstBaseSink * bsink, GstQuery * query)
444 self = GST_FILE_SINK (bsink);
446 switch (GST_QUERY_TYPE (query)) {
447 case GST_QUERY_POSITION:
448 gst_query_parse_position (query, &format, NULL);
451 case GST_FORMAT_DEFAULT:
452 case GST_FORMAT_BYTES:
453 gst_query_set_position (query, GST_FORMAT_BYTES, self->current_pos);
462 case GST_QUERY_FORMATS:
463 gst_query_set_formats (query, 2, GST_FORMAT_DEFAULT, GST_FORMAT_BYTES);
468 gst_query_set_uri (query, self->uri);
472 case GST_QUERY_SEEKING:
473 gst_query_parse_seeking (query, &format, NULL, NULL, NULL);
474 if (format == GST_FORMAT_BYTES || format == GST_FORMAT_DEFAULT) {
475 gst_query_set_seeking (query, GST_FORMAT_BYTES, self->seekable, 0, -1);
477 gst_query_set_seeking (query, format, FALSE, 0, -1);
483 res = GST_BASE_SINK_CLASS (parent_class)->query (bsink, query);
490 # define __GST_STDIO_SEEK_FUNCTION "fseeko"
491 #elif defined (G_OS_UNIX) || defined (G_OS_WIN32)
492 # define __GST_STDIO_SEEK_FUNCTION "lseek"
494 # define __GST_STDIO_SEEK_FUNCTION "fseek"
498 gst_file_sink_do_seek (GstFileSink * filesink, guint64 new_offset)
500 GST_DEBUG_OBJECT (filesink, "Seeking to offset %" G_GUINT64_FORMAT
501 " using " __GST_STDIO_SEEK_FUNCTION, new_offset);
503 if (gst_file_sink_flush_buffer (filesink) != GST_FLOW_OK)
504 goto flush_buffer_failed;
507 if (fseeko (filesink->file, (off_t) new_offset, SEEK_SET) != 0)
509 #elif defined (G_OS_UNIX) || defined (G_OS_WIN32)
510 if (lseek (fileno (filesink->file), (off_t) new_offset,
511 SEEK_SET) == (off_t) - 1)
514 if (fseek (filesink->file, (long) new_offset, SEEK_SET) != 0)
518 /* adjust position reporting after seek;
519 * presumably this should basically yield new_offset */
520 gst_file_sink_get_current_offset (filesink, &filesink->current_pos);
527 GST_DEBUG_OBJECT (filesink, "Flushing buffer failed");
532 GST_DEBUG_OBJECT (filesink, "Seeking failed: %s", g_strerror (errno));
537 /* handle events (search) */
539 gst_file_sink_event (GstBaseSink * sink, GstEvent * event)
542 GstFileSink *filesink;
544 filesink = GST_FILE_SINK (sink);
546 type = GST_EVENT_TYPE (event);
549 case GST_EVENT_SEGMENT:
551 const GstSegment *segment;
553 gst_event_parse_segment (event, &segment);
555 if (segment->format == GST_FORMAT_BYTES) {
556 /* only try to seek and fail when we are going to a different
558 if (filesink->current_pos != segment->start) {
559 /* FIXME, the seek should be performed on the pos field, start/stop are
560 * just boundaries for valid bytes offsets. We should also fill the file
561 * with zeroes if the new position extends the current EOF (sparse streams
562 * and segment accumulation). */
563 if (!gst_file_sink_do_seek (filesink, (guint64) segment->start))
566 GST_DEBUG_OBJECT (filesink, "Ignored SEGMENT, no seek needed");
569 GST_DEBUG_OBJECT (filesink,
570 "Ignored SEGMENT event of format %u (%s)", (guint) segment->format,
571 gst_format_get_name (segment->format));
575 case GST_EVENT_FLUSH_STOP:
576 if (filesink->current_pos != 0 && filesink->seekable) {
577 gst_file_sink_do_seek (filesink, 0);
578 if (ftruncate (fileno (filesink->file), 0))
579 goto truncate_failed;
583 if (gst_file_sink_flush_buffer (filesink) != GST_FLOW_OK)
584 goto flush_buffer_failed;
590 return GST_BASE_SINK_CLASS (parent_class)->event (sink, event);
595 GST_ELEMENT_ERROR (filesink, RESOURCE, SEEK,
596 (_("Error while seeking in file \"%s\"."), filesink->filename),
598 gst_event_unref (event);
603 GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
604 (_("Error while writing to file \"%s\"."), filesink->filename), NULL);
605 gst_event_unref (event);
610 GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
611 (_("Error while writing to file \"%s\"."), filesink->filename),
613 gst_event_unref (event);
619 gst_file_sink_get_current_offset (GstFileSink * filesink, guint64 * p_pos)
623 /* no need to flush internal buffer here as this is only called right
624 * after a seek. If this changes then the buffer should be flushed here
629 ret = ftello (filesink->file);
630 #elif defined (G_OS_UNIX) || defined (G_OS_WIN32)
631 ret = lseek (fileno (filesink->file), 0, SEEK_CUR);
633 ret = (off_t) ftell (filesink->file);
636 if (ret != (off_t) - 1)
637 *p_pos = (guint64) ret;
639 return (ret != (off_t) - 1);
643 gst_file_sink_render_buffers (GstFileSink * sink, GstBuffer ** buffers,
644 guint num_buffers, guint8 * mem_nums, guint total_mems)
646 GST_DEBUG_OBJECT (sink,
647 "writing %u buffers (%u memories) at position %" G_GUINT64_FORMAT,
648 num_buffers, total_mems, sink->current_pos);
650 return gst_writev_buffers (GST_OBJECT_CAST (sink), fileno (sink->file), NULL,
651 buffers, num_buffers, mem_nums, total_mems, &sink->current_pos, 0);
655 gst_file_sink_render_list_internal (GstFileSink * sink,
656 GstBufferList * buffer_list)
662 guint i, num_buffers;
664 num_buffers = gst_buffer_list_length (buffer_list);
665 if (num_buffers == 0)
668 /* extract buffers from list and count memories */
669 buffers = g_newa (GstBuffer *, num_buffers);
670 mem_nums = g_newa (guint8, num_buffers);
671 for (i = 0, total_mems = 0; i < num_buffers; ++i) {
672 buffers[i] = gst_buffer_list_get (buffer_list, i);
673 mem_nums[i] = gst_buffer_n_memory (buffers[i]);
674 total_mems += mem_nums[i];
678 gst_file_sink_render_buffers (sink, buffers, num_buffers, mem_nums,
685 GST_LOG_OBJECT (sink, "empty buffer list");
691 gst_file_sink_flush_buffer (GstFileSink * filesink)
693 GstFlowReturn flow_ret = GST_FLOW_OK;
695 if (filesink->buffer) {
698 length = gst_buffer_list_length (filesink->buffer);
701 GST_DEBUG_OBJECT (filesink, "Flushing out buffer of size %u",
702 filesink->current_buffer_size);
704 gst_file_sink_render_list_internal (filesink, filesink->buffer);
705 /* Remove all buffers from the list but keep the list. This ensures that
706 * we don't re-allocate the array storing the buffers all the time */
707 gst_buffer_list_remove (filesink->buffer, 0, length);
708 filesink->current_buffer_size = 0;
716 has_sync_after_buffer (GstBuffer ** buffer, guint idx, gpointer user_data)
718 if (GST_BUFFER_FLAG_IS_SET (*buffer, GST_BUFFER_FLAG_SYNC_AFTER)) {
719 gboolean *sync_after = user_data;
729 accumulate_size (GstBuffer ** buffer, guint idx, gpointer user_data)
731 guint *size = user_data;
733 *size += gst_buffer_get_size (*buffer);
739 gst_file_sink_render_list (GstBaseSink * bsink, GstBufferList * buffer_list)
743 guint i, num_buffers;
744 gboolean sync_after = FALSE;
746 sink = GST_FILE_SINK_CAST (bsink);
748 num_buffers = gst_buffer_list_length (buffer_list);
749 if (num_buffers == 0)
752 gst_buffer_list_foreach (buffer_list, has_sync_after_buffer, &sync_after);
754 if (sync_after || !sink->buffer) {
755 flow = gst_file_sink_render_list_internal (sink, buffer_list);
758 gst_buffer_list_foreach (buffer_list, accumulate_size, &size);
760 for (i = 0; i < num_buffers; ++i)
761 gst_buffer_list_add (sink->buffer,
762 gst_buffer_ref (gst_buffer_list_get (buffer_list, i)));
763 sink->current_buffer_size += size;
765 if (sink->current_buffer_size > sink->buffer_size)
766 flow = gst_file_sink_flush_buffer (sink);
771 if (flow == GST_FLOW_OK && sync_after) {
772 if (fsync (fileno (sink->file))) {
773 GST_ELEMENT_ERROR (sink, RESOURCE, WRITE,
774 (_("Error while writing to file \"%s\"."), sink->filename),
775 ("%s", g_strerror (errno)));
776 flow = GST_FLOW_ERROR;
784 GST_LOG_OBJECT (sink, "empty buffer list");
790 gst_file_sink_render (GstBaseSink * sink, GstBuffer * buffer)
792 GstFileSink *filesink;
797 filesink = GST_FILE_SINK_CAST (sink);
799 sync_after = GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_SYNC_AFTER);
801 n_mem = gst_buffer_n_memory (buffer);
803 if (n_mem > 0 && (sync_after || !filesink->buffer)) {
804 flow = gst_file_sink_render_buffers (filesink, &buffer, 1, &n_mem, n_mem);
805 } else if (n_mem > 0) {
807 filesink->current_buffer_size += gst_buffer_get_size (buffer);
808 gst_buffer_list_add (filesink->buffer, gst_buffer_ref (buffer));
810 if (filesink->current_buffer_size > filesink->buffer_size)
811 flow = gst_file_sink_flush_buffer (filesink);
818 if (flow == GST_FLOW_OK && sync_after) {
819 if (fsync (fileno (filesink->file))) {
820 GST_ELEMENT_ERROR (filesink, RESOURCE, WRITE,
821 (_("Error while writing to file \"%s\"."), filesink->filename),
822 ("%s", g_strerror (errno)));
823 flow = GST_FLOW_ERROR;
831 gst_file_sink_start (GstBaseSink * basesink)
833 return gst_file_sink_open_file (GST_FILE_SINK (basesink));
837 gst_file_sink_stop (GstBaseSink * basesink)
839 gst_file_sink_close_file (GST_FILE_SINK (basesink));
843 /*** GSTURIHANDLER INTERFACE *************************************************/
846 gst_file_sink_uri_get_type (GType type)
851 static const gchar *const *
852 gst_file_sink_uri_get_protocols (GType type)
854 static const gchar *protocols[] = { "file", NULL };
860 gst_file_sink_uri_get_uri (GstURIHandler * handler)
862 GstFileSink *sink = GST_FILE_SINK (handler);
864 /* FIXME: make thread-safe */
865 return g_strdup (sink->uri);
869 gst_file_sink_uri_set_uri (GstURIHandler * handler, const gchar * uri,
874 GstFileSink *sink = GST_FILE_SINK (handler);
876 /* allow file://localhost/foo/bar by stripping localhost but fail
877 * for every other hostname */
878 if (g_str_has_prefix (uri, "file://localhost/")) {
881 /* 16 == strlen ("file://localhost") */
882 tmp = g_strconcat ("file://", uri + 16, NULL);
883 /* we use gst_uri_get_location() although we already have the
884 * "location" with uri + 16 because it provides unescaping */
885 location = gst_uri_get_location (tmp);
887 } else if (strcmp (uri, "file://") == 0) {
888 /* Special case for "file://" as this is used by some applications
889 * to test with gst_element_make_from_uri if there's an element
890 * that supports the URI protocol. */
891 gst_file_sink_set_location (sink, NULL, NULL);
894 location = gst_uri_get_location (uri);
898 g_set_error_literal (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
899 "File URI without location");
903 if (!g_path_is_absolute (location)) {
904 g_set_error_literal (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
905 "File URI location must be an absolute path");
910 ret = gst_file_sink_set_location (sink, location, error);
917 gst_file_sink_uri_handler_init (gpointer g_iface, gpointer iface_data)
919 GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
921 iface->get_type = gst_file_sink_uri_get_type;
922 iface->get_protocols = gst_file_sink_uri_get_protocols;
923 iface->get_uri = gst_file_sink_uri_get_uri;
924 iface->set_uri = gst_file_sink_uri_set_uri;