012feafe527b9191848d7da095c1db5a9cf1d176
[platform/upstream/gstreamer.git] / plugins / elements / gstfdsink.c
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *
5  * gstfdsink.c:
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20  * Boston, MA 02110-1301, USA.
21  */
22
23 /**
24  * SECTION:element-fdsink
25  * @see_also: #GstFdSrc
26  *
27  * Write data to a unix file descriptor.
28  *
29  * This element will synchronize on the clock before writing the data on the
30  * socket. For file descriptors where this does not make sense (files, ...) the
31  * #GstBaseSink:sync property can be used to disable synchronisation.
32  */
33
34 #ifdef HAVE_CONFIG_H
35 #  include "config.h"
36 #endif
37
38 #include "../../gst/gst-i18n-lib.h"
39
40 #include <sys/types.h>
41
42 #include <sys/stat.h>
43 #ifdef HAVE_SYS_SOCKET_H
44 #include <sys/socket.h>
45 #endif
46 #include <fcntl.h>
47 #include <stdio.h>
48 #ifdef HAVE_UNISTD_H
49 #include <unistd.h>
50 #endif
51 #ifdef _MSC_VER
52 #undef stat
53 #define stat _stat
54 #define fstat _fstat
55 #define S_ISREG(m)      (((m)&S_IFREG)==S_IFREG)
56 #endif
57 #include <errno.h>
58 #include <string.h>
59
60 #include "gstfdsink.h"
61 #include "gstelements_private.h"
62
63 #ifdef G_OS_WIN32
64 #include <io.h>                 /* lseek, open, close, read */
65 #undef lseek
66 #define lseek _lseeki64
67 #undef off_t
68 #define off_t guint64
69 #endif
70
71 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
72     GST_PAD_SINK,
73     GST_PAD_ALWAYS,
74     GST_STATIC_CAPS_ANY);
75
76 GST_DEBUG_CATEGORY_STATIC (gst_fd_sink__debug);
77 #define GST_CAT_DEFAULT gst_fd_sink__debug
78
79
80 /* FdSink signals and args */
81 enum
82 {
83   /* FILL ME */
84   LAST_SIGNAL
85 };
86
87 enum
88 {
89   ARG_0,
90   ARG_FD
91 };
92
93 static void gst_fd_sink_uri_handler_init (gpointer g_iface,
94     gpointer iface_data);
95
96 #define _do_init \
97   G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_fd_sink_uri_handler_init); \
98   GST_DEBUG_CATEGORY_INIT (gst_fd_sink__debug, "fdsink", 0, "fdsink element");
99 #define gst_fd_sink_parent_class parent_class
100 G_DEFINE_TYPE_WITH_CODE (GstFdSink, gst_fd_sink, GST_TYPE_BASE_SINK, _do_init);
101
102 static void gst_fd_sink_set_property (GObject * object, guint prop_id,
103     const GValue * value, GParamSpec * pspec);
104 static void gst_fd_sink_get_property (GObject * object, guint prop_id,
105     GValue * value, GParamSpec * pspec);
106 static void gst_fd_sink_dispose (GObject * obj);
107
108 static gboolean gst_fd_sink_query (GstBaseSink * bsink, GstQuery * query);
109 static GstFlowReturn gst_fd_sink_render (GstBaseSink * sink,
110     GstBuffer * buffer);
111 static GstFlowReturn gst_fd_sink_render_list (GstBaseSink * bsink,
112     GstBufferList * buffer_list);
113 static gboolean gst_fd_sink_start (GstBaseSink * basesink);
114 static gboolean gst_fd_sink_stop (GstBaseSink * basesink);
115 static gboolean gst_fd_sink_unlock (GstBaseSink * basesink);
116 static gboolean gst_fd_sink_unlock_stop (GstBaseSink * basesink);
117 static gboolean gst_fd_sink_event (GstBaseSink * sink, GstEvent * event);
118
119 static gboolean gst_fd_sink_do_seek (GstFdSink * fdsink, guint64 new_offset);
120
121 static void
122 gst_fd_sink_class_init (GstFdSinkClass * klass)
123 {
124   GObjectClass *gobject_class;
125   GstElementClass *gstelement_class;
126   GstBaseSinkClass *gstbasesink_class;
127
128   gobject_class = G_OBJECT_CLASS (klass);
129   gstelement_class = GST_ELEMENT_CLASS (klass);
130   gstbasesink_class = GST_BASE_SINK_CLASS (klass);
131
132   gobject_class->set_property = gst_fd_sink_set_property;
133   gobject_class->get_property = gst_fd_sink_get_property;
134   gobject_class->dispose = gst_fd_sink_dispose;
135
136   gst_element_class_set_static_metadata (gstelement_class,
137       "Filedescriptor Sink",
138       "Sink/File",
139       "Write data to a file descriptor", "Erik Walthinsen <omega@cse.ogi.edu>");
140   gst_element_class_add_pad_template (gstelement_class,
141       gst_static_pad_template_get (&sinktemplate));
142
143   gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_fd_sink_render);
144   gstbasesink_class->render_list = GST_DEBUG_FUNCPTR (gst_fd_sink_render_list);
145   gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_fd_sink_start);
146   gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_fd_sink_stop);
147   gstbasesink_class->unlock = GST_DEBUG_FUNCPTR (gst_fd_sink_unlock);
148   gstbasesink_class->unlock_stop = GST_DEBUG_FUNCPTR (gst_fd_sink_unlock_stop);
149   gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_fd_sink_event);
150   gstbasesink_class->query = GST_DEBUG_FUNCPTR (gst_fd_sink_query);
151
152   g_object_class_install_property (gobject_class, ARG_FD,
153       g_param_spec_int ("fd", "fd", "An open file descriptor to write to",
154           0, G_MAXINT, 1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
155 }
156
157 static void
158 gst_fd_sink_init (GstFdSink * fdsink)
159 {
160   fdsink->fd = 1;
161   fdsink->uri = g_strdup_printf ("fd://%d", fdsink->fd);
162   fdsink->bytes_written = 0;
163   fdsink->current_pos = 0;
164
165   gst_base_sink_set_sync (GST_BASE_SINK (fdsink), FALSE);
166 }
167
168 static void
169 gst_fd_sink_dispose (GObject * obj)
170 {
171   GstFdSink *fdsink = GST_FD_SINK (obj);
172
173   g_free (fdsink->uri);
174   fdsink->uri = NULL;
175
176   G_OBJECT_CLASS (parent_class)->dispose (obj);
177 }
178
179 static gboolean
180 gst_fd_sink_query (GstBaseSink * bsink, GstQuery * query)
181 {
182   gboolean res = FALSE;
183   GstFdSink *fdsink;
184
185   fdsink = GST_FD_SINK (bsink);
186
187   switch (GST_QUERY_TYPE (query)) {
188     case GST_QUERY_POSITION:
189     {
190       GstFormat format;
191
192       gst_query_parse_position (query, &format, NULL);
193
194       switch (format) {
195         case GST_FORMAT_DEFAULT:
196         case GST_FORMAT_BYTES:
197           gst_query_set_position (query, GST_FORMAT_BYTES, fdsink->current_pos);
198           res = TRUE;
199           break;
200         default:
201           break;
202       }
203       break;
204     }
205     case GST_QUERY_FORMATS:
206       gst_query_set_formats (query, 2, GST_FORMAT_DEFAULT, GST_FORMAT_BYTES);
207       res = TRUE;
208       break;
209     case GST_QUERY_URI:
210       gst_query_set_uri (query, fdsink->uri);
211       res = TRUE;
212       break;
213     case GST_QUERY_SEEKING:{
214       GstFormat format;
215
216       gst_query_parse_seeking (query, &format, NULL, NULL, NULL);
217       if (format == GST_FORMAT_BYTES || format == GST_FORMAT_DEFAULT) {
218         gst_query_set_seeking (query, GST_FORMAT_BYTES, fdsink->seekable, 0,
219             -1);
220       } else {
221         gst_query_set_seeking (query, format, FALSE, 0, -1);
222       }
223       res = TRUE;
224       break;
225     }
226     default:
227       res = GST_BASE_SINK_CLASS (parent_class)->query (bsink, query);
228       break;
229
230   }
231   return res;
232 }
233
234 static GstFlowReturn
235 gst_fd_sink_render_buffers (GstFdSink * sink, GstBuffer ** buffers,
236     guint num_buffers, guint8 * mem_nums, guint total_mems)
237 {
238   return gst_writev_buffers (GST_OBJECT_CAST (sink), sink->fd, sink->fdset,
239       buffers, num_buffers, mem_nums, total_mems, &sink->bytes_written,
240       &sink->current_pos);
241 }
242
243 static GstFlowReturn
244 gst_fd_sink_render_list (GstBaseSink * bsink, GstBufferList * buffer_list)
245 {
246   GstFlowReturn flow;
247   GstBuffer **buffers;
248   GstFdSink *sink;
249   guint8 *mem_nums;
250   guint total_mems;
251   guint i, num_buffers;
252
253   sink = GST_FD_SINK_CAST (bsink);
254
255   num_buffers = gst_buffer_list_length (buffer_list);
256   if (num_buffers == 0)
257     goto no_data;
258
259   /* extract buffers from list and count memories */
260   buffers = g_newa (GstBuffer *, num_buffers);
261   mem_nums = g_newa (guint8, num_buffers);
262   for (i = 0, total_mems = 0; i < num_buffers; ++i) {
263     buffers[i] = gst_buffer_list_get (buffer_list, i);
264     mem_nums[i] = gst_buffer_n_memory (buffers[i]);
265     total_mems += mem_nums[i];
266   }
267
268   flow =
269       gst_fd_sink_render_buffers (sink, buffers, num_buffers, mem_nums,
270       total_mems);
271
272   return flow;
273
274 no_data:
275   {
276     GST_LOG_OBJECT (sink, "empty buffer list");
277     return GST_FLOW_OK;
278   }
279 }
280
281 static GstFlowReturn
282 gst_fd_sink_render (GstBaseSink * sink, GstBuffer * buffer)
283 {
284   GstFdSink *fdsink;
285   GstMapInfo info;
286   guint8 *ptr;
287   gsize left;
288   gint written;
289
290 #ifndef HAVE_WIN32
291   gint retval;
292 #endif
293
294   fdsink = GST_FD_SINK (sink);
295
296   g_return_val_if_fail (fdsink->fd >= 0, GST_FLOW_ERROR);
297
298   gst_buffer_map (buffer, &info, GST_MAP_READ);
299
300   ptr = info.data;
301   left = info.size;
302
303 again:
304 #ifndef HAVE_WIN32
305   do {
306     GST_DEBUG_OBJECT (fdsink, "going into select, have %" G_GSIZE_FORMAT
307         " bytes to write", info.size);
308     retval = gst_poll_wait (fdsink->fdset, GST_CLOCK_TIME_NONE);
309   } while (retval == -1 && (errno == EINTR || errno == EAGAIN));
310
311   if (retval == -1) {
312     if (errno == EBUSY)
313       goto stopped;
314     else
315       goto select_error;
316   }
317 #endif
318
319   GST_DEBUG_OBJECT (fdsink, "writing %" G_GSIZE_FORMAT " bytes to"
320       " file descriptor %d", info.size, fdsink->fd);
321
322   written = write (fdsink->fd, ptr, left);
323
324   /* check for errors */
325   if (G_UNLIKELY (written < 0)) {
326     /* try to write again on non-fatal errors */
327     if (errno == EAGAIN || errno == EINTR)
328       goto again;
329
330     /* else go to our error handler */
331     goto write_error;
332   }
333
334   /* all is fine when we get here */
335   left -= written;
336   ptr += written;
337   fdsink->bytes_written += written;
338   fdsink->current_pos += written;
339
340   GST_DEBUG_OBJECT (fdsink, "wrote %d bytes, %" G_GSIZE_FORMAT " left", written,
341       left);
342
343   /* short write, select and try to write the remainder */
344   if (G_UNLIKELY (left > 0))
345     goto again;
346
347   gst_buffer_unmap (buffer, &info);
348
349   return GST_FLOW_OK;
350
351 #ifndef HAVE_WIN32
352 select_error:
353   {
354     GST_ELEMENT_ERROR (fdsink, RESOURCE, READ, (NULL),
355         ("select on file descriptor: %s.", g_strerror (errno)));
356     GST_DEBUG_OBJECT (fdsink, "Error during select");
357     gst_buffer_unmap (buffer, &info);
358     return GST_FLOW_ERROR;
359   }
360 stopped:
361   {
362     GST_DEBUG_OBJECT (fdsink, "Select stopped");
363     gst_buffer_unmap (buffer, &info);
364     return GST_FLOW_FLUSHING;
365   }
366 #endif
367
368 write_error:
369   {
370     switch (errno) {
371       case ENOSPC:
372         GST_ELEMENT_ERROR (fdsink, RESOURCE, NO_SPACE_LEFT, (NULL), (NULL));
373         break;
374       default:{
375         GST_ELEMENT_ERROR (fdsink, RESOURCE, WRITE, (NULL),
376             ("Error while writing to file descriptor %d: %s",
377                 fdsink->fd, g_strerror (errno)));
378       }
379     }
380     gst_buffer_unmap (buffer, &info);
381     return GST_FLOW_ERROR;
382   }
383 }
384
385 static gboolean
386 gst_fd_sink_check_fd (GstFdSink * fdsink, int fd, GError ** error)
387 {
388   struct stat stat_results;
389   off_t result;
390
391   /* see that it is a valid file descriptor */
392   if (fstat (fd, &stat_results) < 0)
393     goto invalid;
394
395   if (!S_ISREG (stat_results.st_mode))
396     goto not_seekable;
397
398   /* see if it is a seekable stream */
399   result = lseek (fd, 0, SEEK_CUR);
400   if (result == -1) {
401     switch (errno) {
402       case EINVAL:
403       case EBADF:
404         goto invalid;
405
406       case ESPIPE:
407         goto not_seekable;
408     }
409   } else
410     GST_DEBUG_OBJECT (fdsink, "File descriptor %d is seekable", fd);
411
412   return TRUE;
413
414 invalid:
415   {
416     GST_ELEMENT_ERROR (fdsink, RESOURCE, WRITE, (NULL),
417         ("File descriptor %d is not valid: %s", fd, g_strerror (errno)));
418     g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_REFERENCE,
419         "File descriptor %d is not valid: %s", fd, g_strerror (errno));
420     return FALSE;
421   }
422 not_seekable:
423   {
424     GST_DEBUG_OBJECT (fdsink, "File descriptor %d is a pipe", fd);
425     return TRUE;
426   }
427 }
428
429 static gboolean
430 gst_fd_sink_start (GstBaseSink * basesink)
431 {
432   GstFdSink *fdsink;
433   GstPollFD fd = GST_POLL_FD_INIT;
434
435   fdsink = GST_FD_SINK (basesink);
436   if (!gst_fd_sink_check_fd (fdsink, fdsink->fd, NULL))
437     return FALSE;
438
439   if ((fdsink->fdset = gst_poll_new (TRUE)) == NULL)
440     goto socket_pair;
441
442   fd.fd = fdsink->fd;
443   gst_poll_add_fd (fdsink->fdset, &fd);
444   gst_poll_fd_ctl_write (fdsink->fdset, &fd, TRUE);
445
446   fdsink->bytes_written = 0;
447   fdsink->current_pos = 0;
448
449   fdsink->seekable = gst_fd_sink_do_seek (fdsink, 0);
450   GST_INFO_OBJECT (fdsink, "seeking supported: %d", fdsink->seekable);
451
452   return TRUE;
453
454   /* ERRORS */
455 socket_pair:
456   {
457     GST_ELEMENT_ERROR (fdsink, RESOURCE, OPEN_READ_WRITE, (NULL),
458         GST_ERROR_SYSTEM);
459     return FALSE;
460   }
461 }
462
463 static gboolean
464 gst_fd_sink_stop (GstBaseSink * basesink)
465 {
466   GstFdSink *fdsink = GST_FD_SINK (basesink);
467
468   if (fdsink->fdset) {
469     gst_poll_free (fdsink->fdset);
470     fdsink->fdset = NULL;
471   }
472
473   return TRUE;
474 }
475
476 static gboolean
477 gst_fd_sink_unlock (GstBaseSink * basesink)
478 {
479   GstFdSink *fdsink = GST_FD_SINK (basesink);
480
481   GST_LOG_OBJECT (fdsink, "Flushing");
482   GST_OBJECT_LOCK (fdsink);
483   gst_poll_set_flushing (fdsink->fdset, TRUE);
484   GST_OBJECT_UNLOCK (fdsink);
485
486   return TRUE;
487 }
488
489 static gboolean
490 gst_fd_sink_unlock_stop (GstBaseSink * basesink)
491 {
492   GstFdSink *fdsink = GST_FD_SINK (basesink);
493
494   GST_LOG_OBJECT (fdsink, "No longer flushing");
495   GST_OBJECT_LOCK (fdsink);
496   gst_poll_set_flushing (fdsink->fdset, FALSE);
497   GST_OBJECT_UNLOCK (fdsink);
498
499   return TRUE;
500 }
501
502 static gboolean
503 gst_fd_sink_update_fd (GstFdSink * fdsink, int new_fd, GError ** error)
504 {
505   if (new_fd < 0) {
506     g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_REFERENCE,
507         "File descriptor %d is not valid", new_fd);
508     return FALSE;
509   }
510
511   if (!gst_fd_sink_check_fd (fdsink, new_fd, error))
512     goto invalid;
513
514   /* assign the fd */
515   GST_OBJECT_LOCK (fdsink);
516   if (fdsink->fdset) {
517     GstPollFD fd = GST_POLL_FD_INIT;
518
519     fd.fd = fdsink->fd;
520     gst_poll_remove_fd (fdsink->fdset, &fd);
521
522     fd.fd = new_fd;
523     gst_poll_add_fd (fdsink->fdset, &fd);
524     gst_poll_fd_ctl_write (fdsink->fdset, &fd, TRUE);
525   }
526   fdsink->fd = new_fd;
527   g_free (fdsink->uri);
528   fdsink->uri = g_strdup_printf ("fd://%d", fdsink->fd);
529
530   GST_OBJECT_UNLOCK (fdsink);
531
532   return TRUE;
533
534 invalid:
535   {
536     return FALSE;
537   }
538 }
539
540 static void
541 gst_fd_sink_set_property (GObject * object, guint prop_id,
542     const GValue * value, GParamSpec * pspec)
543 {
544   GstFdSink *fdsink;
545
546   fdsink = GST_FD_SINK (object);
547
548   switch (prop_id) {
549     case ARG_FD:{
550       int fd;
551
552       fd = g_value_get_int (value);
553       gst_fd_sink_update_fd (fdsink, fd, NULL);
554       break;
555     }
556     default:
557       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
558       break;
559   }
560 }
561
562 static void
563 gst_fd_sink_get_property (GObject * object, guint prop_id, GValue * value,
564     GParamSpec * pspec)
565 {
566   GstFdSink *fdsink;
567
568   fdsink = GST_FD_SINK (object);
569
570   switch (prop_id) {
571     case ARG_FD:
572       g_value_set_int (value, fdsink->fd);
573       break;
574     default:
575       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
576       break;
577   }
578 }
579
580 static gboolean
581 gst_fd_sink_do_seek (GstFdSink * fdsink, guint64 new_offset)
582 {
583   off_t result;
584
585   result = lseek (fdsink->fd, new_offset, SEEK_SET);
586
587   if (result == -1)
588     goto seek_failed;
589
590   fdsink->current_pos = new_offset;
591
592   GST_DEBUG_OBJECT (fdsink, "File descriptor %d to seek to position "
593       "%" G_GUINT64_FORMAT, fdsink->fd, fdsink->current_pos);
594
595   return TRUE;
596
597   /* ERRORS */
598 seek_failed:
599   {
600     GST_DEBUG_OBJECT (fdsink, "File descriptor %d failed to seek to position "
601         "%" G_GUINT64_FORMAT, fdsink->fd, new_offset);
602     return FALSE;
603   }
604 }
605
606 static gboolean
607 gst_fd_sink_event (GstBaseSink * sink, GstEvent * event)
608 {
609   GstEventType type;
610   GstFdSink *fdsink;
611
612   fdsink = GST_FD_SINK (sink);
613
614   type = GST_EVENT_TYPE (event);
615
616   switch (type) {
617     case GST_EVENT_SEGMENT:
618     {
619       const GstSegment *segment;
620
621       gst_event_parse_segment (event, &segment);
622
623       if (segment->format == GST_FORMAT_BYTES) {
624         /* only try to seek and fail when we are going to a different
625          * position */
626         if (fdsink->current_pos != segment->start) {
627           /* FIXME, the seek should be performed on the pos field, start/stop are
628            * just boundaries for valid bytes offsets. We should also fill the file
629            * with zeroes if the new position extends the current EOF (sparse streams
630            * and segment accumulation). */
631           if (!gst_fd_sink_do_seek (fdsink, (guint64) segment->start))
632             goto seek_failed;
633         }
634       } else {
635         GST_DEBUG_OBJECT (fdsink,
636             "Ignored SEGMENT event of format %u (%s)", (guint) segment->format,
637             gst_format_get_name (segment->format));
638       }
639       break;
640     }
641     default:
642       break;
643   }
644
645   return GST_BASE_SINK_CLASS (parent_class)->event (sink, event);
646
647 seek_failed:
648   {
649     GST_ELEMENT_ERROR (fdsink, RESOURCE, SEEK, (NULL),
650         ("Error while seeking on file descriptor %d: %s",
651             fdsink->fd, g_strerror (errno)));
652     gst_event_unref (event);
653     return FALSE;
654   }
655
656 }
657
658 /*** GSTURIHANDLER INTERFACE *************************************************/
659
660 static GstURIType
661 gst_fd_sink_uri_get_type (GType type)
662 {
663   return GST_URI_SINK;
664 }
665
666 static const gchar *const *
667 gst_fd_sink_uri_get_protocols (GType type)
668 {
669   static const gchar *protocols[] = { "fd", NULL };
670
671   return protocols;
672 }
673
674 static gchar *
675 gst_fd_sink_uri_get_uri (GstURIHandler * handler)
676 {
677   GstFdSink *sink = GST_FD_SINK (handler);
678
679   /* FIXME: make thread-safe */
680   return g_strdup (sink->uri);
681 }
682
683 static gboolean
684 gst_fd_sink_uri_set_uri (GstURIHandler * handler, const gchar * uri,
685     GError ** error)
686 {
687   GstFdSink *sink = GST_FD_SINK (handler);
688   gint fd;
689
690   if (sscanf (uri, "fd://%d", &fd) != 1) {
691     g_set_error (error, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
692         "File descriptor URI could not be parsed");
693     return FALSE;
694   }
695
696   return gst_fd_sink_update_fd (sink, fd, error);
697 }
698
699 static void
700 gst_fd_sink_uri_handler_init (gpointer g_iface, gpointer iface_data)
701 {
702   GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
703
704   iface->get_type = gst_fd_sink_uri_get_type;
705   iface->get_protocols = gst_fd_sink_uri_get_protocols;
706   iface->get_uri = gst_fd_sink_uri_get_uri;
707   iface->set_uri = gst_fd_sink_uri_set_uri;
708 }