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