Merge branch 'master' into 0.11
[platform/upstream/gstreamer.git] / plugins / elements / gstfdsrc.c
index 0eef85c..0ca9115 100644 (file)
@@ -132,7 +132,7 @@ static gboolean gst_fd_src_unlock_stop (GstBaseSrc * bsrc);
 static gboolean gst_fd_src_is_seekable (GstBaseSrc * bsrc);
 static gboolean gst_fd_src_get_size (GstBaseSrc * src, guint64 * size);
 static gboolean gst_fd_src_do_seek (GstBaseSrc * src, GstSegment * segment);
-static gboolean gst_fd_src_query (GstBaseSrc * src, GstQuery ** query);
+static gboolean gst_fd_src_query (GstBaseSrc * src, GstQuery * query);
 
 static GstFlowReturn gst_fd_src_create (GstPushSrc * psrc, GstBuffer ** outbuf);
 
@@ -259,6 +259,8 @@ gst_fd_src_update_fd (GstFdSrc * src, guint64 size)
 
     GST_INFO_OBJECT (src, "marking fd %d as seekable", src->fd);
     src->seekable_fd = TRUE;
+
+    gst_base_src_set_dynamic_size (GST_BASE_SRC (src), TRUE);
   }
   return;
 
@@ -266,6 +268,7 @@ not_seekable:
   {
     GST_INFO_OBJECT (src, "marking fd %d as NOT seekable", src->fd);
     src->seekable_fd = FALSE;
+    gst_base_src_set_dynamic_size (GST_BASE_SRC (src), FALSE);
   }
 }
 
@@ -439,7 +442,7 @@ gst_fd_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
   blocksize = GST_BASE_SRC (src)->blocksize;
 
   /* create the buffer */
-  buf = gst_buffer_new_and_alloc (blocksize);
+  buf = gst_buffer_new_allocate (NULL, blocksize, 0);
   if (G_UNLIKELY (buf == NULL))
     goto alloc_failed;
 
@@ -493,7 +496,7 @@ eos:
   {
     GST_DEBUG_OBJECT (psrc, "Read 0 bytes. EOS.");
     gst_buffer_unref (buf);
-    return GST_FLOW_UNEXPECTED;
+    return GST_FLOW_EOS;
   }
 read_error:
   {
@@ -507,14 +510,14 @@ read_error:
 }
 
 static gboolean
-gst_fd_src_query (GstBaseSrc * basesrc, GstQuery ** query)
+gst_fd_src_query (GstBaseSrc * basesrc, GstQuery * query)
 {
   gboolean ret = FALSE;
   GstFdSrc *src = GST_FD_SRC (basesrc);
 
-  switch (GST_QUERY_TYPE (*query)) {
+  switch (GST_QUERY_TYPE (query)) {
     case GST_QUERY_URI:
-      gst_query_set_uri (*query, src->uri);
+      gst_query_set_uri (query, src->uri);
       ret = TRUE;
       break;
     default:
@@ -584,7 +587,7 @@ gst_fd_src_do_seek (GstBaseSrc * bsrc, GstSegment * segment)
   if (G_UNLIKELY (res < 0 || res != offset))
     goto seek_failed;
 
-  segment->last_stop = segment->start;
+  segment->position = segment->start;
   segment->time = segment->start;
 
   return TRUE;
@@ -597,34 +600,36 @@ seek_failed:
 /*** GSTURIHANDLER INTERFACE *************************************************/
 
 static GstURIType
-gst_fd_src_uri_get_type (void)
+gst_fd_src_uri_get_type (GType type)
 {
   return GST_URI_SRC;
 }
 
-static gchar **
-gst_fd_src_uri_get_protocols (void)
+static const gchar *const *
+gst_fd_src_uri_get_protocols (GType type)
 {
-  static gchar *protocols[] = { (char *) "fd", NULL };
+  static const gchar *protocols[] = { "fd", NULL };
 
   return protocols;
 }
 
-static const gchar *
+static gchar *
 gst_fd_src_uri_get_uri (GstURIHandler * handler)
 {
   GstFdSrc *src = GST_FD_SRC (handler);
 
-  return src->uri;
+  /* FIXME: make thread-safe */
+  return g_strdup (src->uri);
 }
 
 static gboolean
-gst_fd_src_uri_set_uri (GstURIHandler * handler, const gchar * uri)
+gst_fd_src_uri_set_uri (GstURIHandler * handler, const gchar * uri,
+    GError ** err)
 {
   gchar *protocol, *q;
   GstFdSrc *src = GST_FD_SRC (handler);
   gint fd;
-  guint64 size = -1;
+  guint64 size = (guint64) - 1;
 
   GST_INFO_OBJECT (src, "checking uri %s", uri);