fdsrc: enable large file support in Android
[platform/upstream/gstreamer.git] / plugins / elements / gstfdsrc.c
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *                    2005 Philippe Khalaf <burger@speedy.org>
5  *
6  * gstfdsrc.c:
7  *
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.
12  *
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.
17  *
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.
22  */
23 /**
24  * SECTION:element-fdsrc
25  * @see_also: #GstFdSink
26  *
27  * Read data from a unix file descriptor.
28  *
29  * To generate data, enter some data on the console followed by enter.
30  * The above mentioned pipeline should dump data packets to the console.
31  *
32  * If the #GstFdSrc:timeout property is set to a value bigger than 0, fdsrc will
33  * generate an element message named <classname>&quot;GstFdSrcTimeout&quot;</classname>
34  * if no data was received in the given timeout.
35  *
36  * The message's structure contains one field:
37  * <itemizedlist>
38  * <listitem>
39  *   <para>
40  *   #guint64
41  *   <classname>&quot;timeout&quot;</classname>: the timeout in microseconds that
42  *   expired when waiting for data.
43  *   </para>
44  * </listitem>
45  * </itemizedlist>
46  *
47  * <refsect2>
48  * <title>Example launch line</title>
49  * |[
50  * echo "Hello GStreamer" | gst-launch-1.0 -v fdsrc ! fakesink dump=true
51  * ]| A simple pipeline to read from the standard input and dump the data
52  * with a fakesink as hex ascii block.
53  * </refsect2>
54  */
55
56 #ifdef HAVE_CONFIG_H
57 #  include "config.h"
58 #endif
59 #include "gst/gst_private.h"
60
61 #include <sys/types.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 #include <sys/stat.h>
72 #ifdef HAVE_SYS_SOCKET_H
73 #include <sys/socket.h>
74 #endif
75 #include <fcntl.h>
76 #include <stdio.h>
77 #ifdef HAVE_UNISTD_H
78 #include <unistd.h>
79 #endif
80 #ifdef _MSC_VER
81 #undef stat
82 #define stat _stat
83 #define fstat _fstat
84 #define S_ISREG(m)      (((m)&S_IFREG)==S_IFREG)
85 #endif
86 #include <stdlib.h>
87 #include <errno.h>
88
89 #include "gstfdsrc.h"
90
91 #ifdef __BIONIC__               /* Android */
92 #undef lseek
93 #define lseek lseek64
94 #undef fstat
95 #define fstat fstat64
96 #endif
97
98 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
99     GST_PAD_SRC,
100     GST_PAD_ALWAYS,
101     GST_STATIC_CAPS_ANY);
102
103 GST_DEBUG_CATEGORY_STATIC (gst_fd_src_debug);
104 #define GST_CAT_DEFAULT gst_fd_src_debug
105
106 #define DEFAULT_FD              0
107 #define DEFAULT_TIMEOUT         0
108
109 enum
110 {
111   PROP_0,
112
113   PROP_FD,
114   PROP_TIMEOUT,
115
116   PROP_LAST
117 };
118
119 static void gst_fd_src_uri_handler_init (gpointer g_iface, gpointer iface_data);
120
121 #define _do_init \
122   G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_fd_src_uri_handler_init); \
123   GST_DEBUG_CATEGORY_INIT (gst_fd_src_debug, "fdsrc", 0, "fdsrc element");
124 #define gst_fd_src_parent_class parent_class
125 G_DEFINE_TYPE_WITH_CODE (GstFdSrc, gst_fd_src, GST_TYPE_PUSH_SRC, _do_init);
126
127 static void gst_fd_src_set_property (GObject * object, guint prop_id,
128     const GValue * value, GParamSpec * pspec);
129 static void gst_fd_src_get_property (GObject * object, guint prop_id,
130     GValue * value, GParamSpec * pspec);
131 static void gst_fd_src_dispose (GObject * obj);
132
133 static gboolean gst_fd_src_start (GstBaseSrc * bsrc);
134 static gboolean gst_fd_src_stop (GstBaseSrc * bsrc);
135 static gboolean gst_fd_src_unlock (GstBaseSrc * bsrc);
136 static gboolean gst_fd_src_unlock_stop (GstBaseSrc * bsrc);
137 static gboolean gst_fd_src_is_seekable (GstBaseSrc * bsrc);
138 static gboolean gst_fd_src_get_size (GstBaseSrc * src, guint64 * size);
139 static gboolean gst_fd_src_do_seek (GstBaseSrc * src, GstSegment * segment);
140 static gboolean gst_fd_src_query (GstBaseSrc * src, GstQuery * query);
141
142 static GstFlowReturn gst_fd_src_create (GstPushSrc * psrc, GstBuffer ** outbuf);
143
144 static void
145 gst_fd_src_class_init (GstFdSrcClass * klass)
146 {
147   GObjectClass *gobject_class;
148   GstElementClass *gstelement_class;
149   GstBaseSrcClass *gstbasesrc_class;
150   GstPushSrcClass *gstpush_src_class;
151
152   gobject_class = G_OBJECT_CLASS (klass);
153   gstelement_class = GST_ELEMENT_CLASS (klass);
154   gstbasesrc_class = GST_BASE_SRC_CLASS (klass);
155   gstpush_src_class = GST_PUSH_SRC_CLASS (klass);
156
157   gobject_class->set_property = gst_fd_src_set_property;
158   gobject_class->get_property = gst_fd_src_get_property;
159   gobject_class->dispose = gst_fd_src_dispose;
160
161   g_object_class_install_property (gobject_class, PROP_FD,
162       g_param_spec_int ("fd", "fd", "An open file descriptor to read from",
163           0, G_MAXINT, DEFAULT_FD, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
164   /**
165    * GstFdSrc:timeout
166    *
167    * Post a message after timeout microseconds
168    */
169   g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_TIMEOUT,
170       g_param_spec_uint64 ("timeout", "Timeout",
171           "Post a message after timeout microseconds (0 = disabled)", 0,
172           G_MAXUINT64, DEFAULT_TIMEOUT,
173           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
174
175   gst_element_class_set_static_metadata (gstelement_class,
176       "Filedescriptor Source",
177       "Source/File",
178       "Read from a file descriptor", "Erik Walthinsen <omega@cse.ogi.edu>");
179   gst_element_class_add_pad_template (gstelement_class,
180       gst_static_pad_template_get (&srctemplate));
181
182   gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_fd_src_start);
183   gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_fd_src_stop);
184   gstbasesrc_class->unlock = GST_DEBUG_FUNCPTR (gst_fd_src_unlock);
185   gstbasesrc_class->unlock_stop = GST_DEBUG_FUNCPTR (gst_fd_src_unlock_stop);
186   gstbasesrc_class->is_seekable = GST_DEBUG_FUNCPTR (gst_fd_src_is_seekable);
187   gstbasesrc_class->get_size = GST_DEBUG_FUNCPTR (gst_fd_src_get_size);
188   gstbasesrc_class->do_seek = GST_DEBUG_FUNCPTR (gst_fd_src_do_seek);
189   gstbasesrc_class->query = GST_DEBUG_FUNCPTR (gst_fd_src_query);
190
191   gstpush_src_class->create = GST_DEBUG_FUNCPTR (gst_fd_src_create);
192 }
193
194 static void
195 gst_fd_src_init (GstFdSrc * fdsrc)
196 {
197   fdsrc->new_fd = DEFAULT_FD;
198   fdsrc->seekable_fd = FALSE;
199   fdsrc->fd = -1;
200   fdsrc->size = -1;
201   fdsrc->timeout = DEFAULT_TIMEOUT;
202   fdsrc->uri = g_strdup_printf ("fd://0");
203   fdsrc->curoffset = 0;
204 }
205
206 static void
207 gst_fd_src_dispose (GObject * obj)
208 {
209   GstFdSrc *src = GST_FD_SRC (obj);
210
211   g_free (src->uri);
212   src->uri = NULL;
213
214   G_OBJECT_CLASS (parent_class)->dispose (obj);
215 }
216
217 static void
218 gst_fd_src_update_fd (GstFdSrc * src, guint64 size)
219 {
220   struct stat stat_results;
221
222   GST_DEBUG_OBJECT (src, "fdset %p, old_fd %d, new_fd %d", src->fdset, src->fd,
223       src->new_fd);
224
225   /* we need to always update the fdset since it may not have existed when
226    * gst_fd_src_update_fd () was called earlier */
227   if (src->fdset != NULL) {
228     GstPollFD fd = GST_POLL_FD_INIT;
229
230     if (src->fd >= 0) {
231       fd.fd = src->fd;
232       /* this will log a harmless warning, if it was never added */
233       gst_poll_remove_fd (src->fdset, &fd);
234     }
235
236     fd.fd = src->new_fd;
237     gst_poll_add_fd (src->fdset, &fd);
238     gst_poll_fd_ctl_read (src->fdset, &fd, TRUE);
239   }
240
241
242   if (src->fd != src->new_fd) {
243     GST_INFO_OBJECT (src, "Updating to fd %d", src->new_fd);
244
245     src->fd = src->new_fd;
246
247     GST_INFO_OBJECT (src, "Setting size to fd %" G_GUINT64_FORMAT, size);
248     src->size = size;
249
250     g_free (src->uri);
251     src->uri = g_strdup_printf ("fd://%d", src->fd);
252
253     if (fstat (src->fd, &stat_results) < 0)
254       goto not_seekable;
255
256     if (!S_ISREG (stat_results.st_mode))
257       goto not_seekable;
258
259     /* Try a seek of 0 bytes offset to check for seekability */
260     if (lseek (src->fd, 0, SEEK_CUR) < 0)
261       goto not_seekable;
262
263     GST_INFO_OBJECT (src, "marking fd %d as seekable", src->fd);
264     src->seekable_fd = TRUE;
265
266     gst_base_src_set_dynamic_size (GST_BASE_SRC (src), TRUE);
267   }
268   return;
269
270 not_seekable:
271   {
272     GST_INFO_OBJECT (src, "marking fd %d as NOT seekable", src->fd);
273     src->seekable_fd = FALSE;
274     gst_base_src_set_dynamic_size (GST_BASE_SRC (src), FALSE);
275   }
276 }
277
278 static gboolean
279 gst_fd_src_start (GstBaseSrc * bsrc)
280 {
281   GstFdSrc *src = GST_FD_SRC (bsrc);
282
283   src->curoffset = 0;
284
285   if ((src->fdset = gst_poll_new (TRUE)) == NULL)
286     goto socket_pair;
287
288   gst_fd_src_update_fd (src, -1);
289
290   return TRUE;
291
292   /* ERRORS */
293 socket_pair:
294   {
295     GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ_WRITE, (NULL),
296         GST_ERROR_SYSTEM);
297     return FALSE;
298   }
299 }
300
301 static gboolean
302 gst_fd_src_stop (GstBaseSrc * bsrc)
303 {
304   GstFdSrc *src = GST_FD_SRC (bsrc);
305
306   if (src->fdset) {
307     gst_poll_free (src->fdset);
308     src->fdset = NULL;
309   }
310
311   return TRUE;
312 }
313
314 static gboolean
315 gst_fd_src_unlock (GstBaseSrc * bsrc)
316 {
317   GstFdSrc *src = GST_FD_SRC (bsrc);
318
319   GST_LOG_OBJECT (src, "Flushing");
320   GST_OBJECT_LOCK (src);
321   gst_poll_set_flushing (src->fdset, TRUE);
322   GST_OBJECT_UNLOCK (src);
323
324   return TRUE;
325 }
326
327 static gboolean
328 gst_fd_src_unlock_stop (GstBaseSrc * bsrc)
329 {
330   GstFdSrc *src = GST_FD_SRC (bsrc);
331
332   GST_LOG_OBJECT (src, "No longer flushing");
333   GST_OBJECT_LOCK (src);
334   gst_poll_set_flushing (src->fdset, FALSE);
335   GST_OBJECT_UNLOCK (src);
336
337   return TRUE;
338 }
339
340 static void
341 gst_fd_src_set_property (GObject * object, guint prop_id, const GValue * value,
342     GParamSpec * pspec)
343 {
344   GstFdSrc *src = GST_FD_SRC (object);
345
346   switch (prop_id) {
347     case PROP_FD:
348       src->new_fd = g_value_get_int (value);
349
350       /* If state is ready or below, update the current fd immediately
351        * so it is reflected in get_properties and uri */
352       GST_OBJECT_LOCK (object);
353       if (GST_STATE (GST_ELEMENT (src)) <= GST_STATE_READY) {
354         GST_DEBUG_OBJECT (src, "state ready or lower, updating to use new fd");
355         gst_fd_src_update_fd (src, -1);
356       } else {
357         GST_DEBUG_OBJECT (src, "state above ready, not updating to new fd yet");
358       }
359       GST_OBJECT_UNLOCK (object);
360       break;
361     case PROP_TIMEOUT:
362       src->timeout = g_value_get_uint64 (value);
363       GST_DEBUG_OBJECT (src, "poll timeout set to %" GST_TIME_FORMAT,
364           GST_TIME_ARGS (src->timeout));
365       break;
366     default:
367       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
368       break;
369   }
370 }
371
372 static void
373 gst_fd_src_get_property (GObject * object, guint prop_id, GValue * value,
374     GParamSpec * pspec)
375 {
376   GstFdSrc *src = GST_FD_SRC (object);
377
378   switch (prop_id) {
379     case PROP_FD:
380       g_value_set_int (value, src->fd);
381       break;
382     case PROP_TIMEOUT:
383       g_value_set_uint64 (value, src->timeout);
384       break;
385     default:
386       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
387       break;
388   }
389 }
390
391 static GstFlowReturn
392 gst_fd_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
393 {
394   GstFdSrc *src;
395   GstBuffer *buf;
396   gssize readbytes;
397   guint blocksize;
398   GstMapInfo info;
399
400 #ifndef HAVE_WIN32
401   GstClockTime timeout;
402   gboolean try_again;
403   gint retval;
404 #endif
405
406   src = GST_FD_SRC (psrc);
407
408 #ifndef HAVE_WIN32
409   if (src->timeout > 0) {
410     timeout = src->timeout * GST_USECOND;
411   } else {
412     timeout = GST_CLOCK_TIME_NONE;
413   }
414
415   do {
416     try_again = FALSE;
417
418     GST_LOG_OBJECT (src, "doing poll, timeout %" GST_TIME_FORMAT,
419         GST_TIME_ARGS (src->timeout));
420
421     retval = gst_poll_wait (src->fdset, timeout);
422     GST_LOG_OBJECT (src, "poll returned %d", retval);
423
424     if (G_UNLIKELY (retval == -1)) {
425       if (errno == EINTR || errno == EAGAIN) {
426         /* retry if interrupted */
427         try_again = TRUE;
428       } else if (errno == EBUSY) {
429         goto stopped;
430       } else {
431         goto poll_error;
432       }
433     } else if (G_UNLIKELY (retval == 0)) {
434       try_again = TRUE;
435       /* timeout, post element message */
436       gst_element_post_message (GST_ELEMENT_CAST (src),
437           gst_message_new_element (GST_OBJECT_CAST (src),
438               gst_structure_new ("GstFdSrcTimeout",
439                   "timeout", G_TYPE_UINT64, src->timeout, NULL)));
440     }
441   } while (G_UNLIKELY (try_again));     /* retry if interrupted or timeout */
442 #endif
443
444   blocksize = GST_BASE_SRC (src)->blocksize;
445
446   /* create the buffer */
447   buf = gst_buffer_new_allocate (NULL, blocksize, NULL);
448   if (G_UNLIKELY (buf == NULL))
449     goto alloc_failed;
450
451   gst_buffer_map (buf, &info, GST_MAP_WRITE);
452
453   do {
454     readbytes = read (src->fd, info.data, blocksize);
455     GST_LOG_OBJECT (src, "read %" G_GSSIZE_FORMAT, readbytes);
456   } while (readbytes == -1 && errno == EINTR);  /* retry if interrupted */
457
458   if (readbytes < 0)
459     goto read_error;
460
461   gst_buffer_unmap (buf, &info);
462   gst_buffer_resize (buf, 0, readbytes);
463
464   if (readbytes == 0)
465     goto eos;
466
467   GST_BUFFER_OFFSET (buf) = src->curoffset;
468   GST_BUFFER_TIMESTAMP (buf) = GST_CLOCK_TIME_NONE;
469   src->curoffset += readbytes;
470
471   GST_LOG_OBJECT (psrc, "Read buffer of size %" G_GSSIZE_FORMAT, readbytes);
472
473   /* we're done, return the buffer */
474   *outbuf = buf;
475
476   return GST_FLOW_OK;
477
478   /* ERRORS */
479 #ifndef HAVE_WIN32
480 poll_error:
481   {
482     GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
483         ("poll on file descriptor: %s.", g_strerror (errno)));
484     GST_DEBUG_OBJECT (psrc, "Error during poll");
485     return GST_FLOW_ERROR;
486   }
487 stopped:
488   {
489     GST_DEBUG_OBJECT (psrc, "Poll stopped");
490     return GST_FLOW_FLUSHING;
491   }
492 #endif
493 alloc_failed:
494   {
495     GST_ERROR_OBJECT (src, "Failed to allocate %u bytes", blocksize);
496     return GST_FLOW_ERROR;
497   }
498 eos:
499   {
500     GST_DEBUG_OBJECT (psrc, "Read 0 bytes. EOS.");
501     gst_buffer_unref (buf);
502     return GST_FLOW_EOS;
503   }
504 read_error:
505   {
506     GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
507         ("read on file descriptor: %s.", g_strerror (errno)));
508     GST_DEBUG_OBJECT (psrc, "Error reading from fd");
509     gst_buffer_unmap (buf, &info);
510     gst_buffer_unref (buf);
511     return GST_FLOW_ERROR;
512   }
513 }
514
515 static gboolean
516 gst_fd_src_query (GstBaseSrc * basesrc, GstQuery * query)
517 {
518   gboolean ret = FALSE;
519   GstFdSrc *src = GST_FD_SRC (basesrc);
520
521   switch (GST_QUERY_TYPE (query)) {
522     case GST_QUERY_URI:
523       gst_query_set_uri (query, src->uri);
524       ret = TRUE;
525       break;
526     default:
527       ret = FALSE;
528       break;
529   }
530
531   if (!ret)
532     ret = GST_BASE_SRC_CLASS (parent_class)->query (basesrc, query);
533
534   return ret;
535 }
536
537 static gboolean
538 gst_fd_src_is_seekable (GstBaseSrc * bsrc)
539 {
540   GstFdSrc *src = GST_FD_SRC (bsrc);
541
542   return src->seekable_fd;
543 }
544
545 static gboolean
546 gst_fd_src_get_size (GstBaseSrc * bsrc, guint64 * size)
547 {
548   GstFdSrc *src = GST_FD_SRC (bsrc);
549   struct stat stat_results;
550
551   if (src->size != -1) {
552     *size = src->size;
553     return TRUE;
554   }
555
556   if (!src->seekable_fd) {
557     /* If it isn't seekable, we won't know the length (but fstat will still
558      * succeed, and wrongly say our length is zero. */
559     return FALSE;
560   }
561
562   if (fstat (src->fd, &stat_results) < 0)
563     goto could_not_stat;
564
565   *size = stat_results.st_size;
566
567   return TRUE;
568
569   /* ERROR */
570 could_not_stat:
571   {
572     return FALSE;
573   }
574 }
575
576 static gboolean
577 gst_fd_src_do_seek (GstBaseSrc * bsrc, GstSegment * segment)
578 {
579   gint res;
580   gint64 offset;
581   GstFdSrc *src = GST_FD_SRC (bsrc);
582
583   offset = segment->start;
584
585   /* No need to seek to the current position */
586   if (offset == src->curoffset)
587     return TRUE;
588
589   res = lseek (src->fd, offset, SEEK_SET);
590   if (G_UNLIKELY (res < 0 || res != offset))
591     goto seek_failed;
592
593   segment->position = segment->start;
594   segment->time = segment->start;
595
596   return TRUE;
597
598 seek_failed:
599   GST_DEBUG_OBJECT (src, "lseek returned %" G_GINT64_FORMAT, offset);
600   return FALSE;
601 }
602
603 /*** GSTURIHANDLER INTERFACE *************************************************/
604
605 static GstURIType
606 gst_fd_src_uri_get_type (GType type)
607 {
608   return GST_URI_SRC;
609 }
610
611 static const gchar *const *
612 gst_fd_src_uri_get_protocols (GType type)
613 {
614   static const gchar *protocols[] = { "fd", NULL };
615
616   return protocols;
617 }
618
619 static gchar *
620 gst_fd_src_uri_get_uri (GstURIHandler * handler)
621 {
622   GstFdSrc *src = GST_FD_SRC (handler);
623
624   /* FIXME: make thread-safe */
625   return g_strdup (src->uri);
626 }
627
628 static gboolean
629 gst_fd_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
630     GError ** err)
631 {
632   gchar *protocol, *q;
633   GstFdSrc *src = GST_FD_SRC (handler);
634   gint fd;
635   guint64 size = (guint64) - 1;
636
637   GST_INFO_OBJECT (src, "checking uri %s", uri);
638
639   protocol = gst_uri_get_protocol (uri);
640   if (strcmp (protocol, "fd") != 0) {
641     g_set_error (err, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
642         "Wrong protocol for fdsrc in uri: '%s'", uri);
643     g_free (protocol);
644     return FALSE;
645   }
646   g_free (protocol);
647
648   if (sscanf (uri, "fd://%d", &fd) != 1 || fd < 0) {
649     g_set_error (err, GST_URI_ERROR, GST_URI_ERROR_BAD_URI,
650         "Bad file descriptor number in uri: '%s'", uri);
651     return FALSE;
652   }
653
654   if ((q = g_strstr_len (uri, -1, "?"))) {
655     gchar *sp, *end = NULL;
656
657     GST_INFO_OBJECT (src, "found ?");
658
659     if ((sp = g_strstr_len (q, -1, "size="))) {
660       sp += strlen ("size=");
661       size = g_ascii_strtoull (sp, &end, 10);
662       if ((size == 0 && errno == EINVAL) || size == G_MAXUINT64 || end == sp) {
663         GST_INFO_OBJECT (src, "parsing size failed");
664         size = -1;
665       } else {
666         GST_INFO_OBJECT (src, "found size %" G_GUINT64_FORMAT, size);
667       }
668     }
669   }
670
671   src->new_fd = fd;
672
673   GST_OBJECT_LOCK (src);
674   if (GST_STATE (GST_ELEMENT (src)) <= GST_STATE_READY) {
675     gst_fd_src_update_fd (src, size);
676   }
677   GST_OBJECT_UNLOCK (src);
678
679   return TRUE;
680 }
681
682 static void
683 gst_fd_src_uri_handler_init (gpointer g_iface, gpointer iface_data)
684 {
685   GstURIHandlerInterface *iface = (GstURIHandlerInterface *) g_iface;
686
687   iface->get_type = gst_fd_src_uri_get_type;
688   iface->get_protocols = gst_fd_src_uri_get_protocols;
689   iface->get_uri = gst_fd_src_uri_get_uri;
690   iface->set_uri = gst_fd_src_uri_set_uri;
691 }