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