*/
/**
* SECTION:element-fdsrc
+ * @title: fdsrc
* @see_also: #GstFdSink
*
* Read data from a unix file descriptor.
* The above mentioned pipeline should dump data packets to the console.
*
* If the #GstFdSrc:timeout property is set to a value bigger than 0, fdsrc will
- * generate an element message named
- * <classname>"GstFdSrcTimeout"</classname>
+ * generate an element message named <classname>"GstFdSrcTimeout"</classname>
* if no data was received in the given timeout.
+ *
* The message's structure contains one field:
- * <itemizedlist>
- * <listitem>
- * <para>
- * #guint64
- * <classname>"timeout"</classname>: the timeout in microseconds that
+ *
+ * * #guint64 `timeout`: the timeout in microseconds that
* expired when waiting for data.
- * </para>
- * </listitem>
- * </itemizedlist>
*
- * <refsect2>
- * <title>Example launch line</title>
+ * ## Example launch line
* |[
- * echo "Hello GStreamer" | gst-launch -v fdsrc ! fakesink dump=true
+ * echo "Hello GStreamer" | gst-launch-1.0 -v fdsrc ! fakesink dump=true
* ]| A simple pipeline to read from the standard input and dump the data
* with a fakesink as hex ascii block.
- * </refsect2>
+ *
*/
#ifdef HAVE_CONFIG_H
#include <io.h> /* lseek, open, close, read */
#undef lseek
#define lseek _lseeki64
-#undef off_t
-#define off_t guint64
#endif
#include <sys/stat.h>
#include "gstfdsrc.h"
+#ifdef __BIONIC__ /* Android */
+#if defined(__ANDROID_API__) && __ANDROID_API__ >= 21
+#undef fstat
+#define fstat fstat64
+#endif
+#endif
+
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
"Filedescriptor Source",
"Source/File",
"Read from a file descriptor", "Erik Walthinsen <omega@cse.ogi.edu>");
- gst_element_class_add_pad_template (gstelement_class,
- gst_static_pad_template_get (&srctemplate));
+ gst_element_class_add_static_pad_template (gstelement_class, &srctemplate);
gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_fd_src_start);
gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_fd_src_stop);
if (G_UNLIKELY (buf == NULL))
goto alloc_failed;
- gst_buffer_map (buf, &info, GST_MAP_WRITE);
+ if (!gst_buffer_map (buf, &info, GST_MAP_WRITE))
+ goto buffer_read_error;
do {
readbytes = read (src->fd, info.data, blocksize);
gst_buffer_unref (buf);
return GST_FLOW_ERROR;
}
+buffer_read_error:
+ {
+ GST_ELEMENT_ERROR (src, RESOURCE, WRITE, (NULL), ("Can't write to buffer"));
+ gst_buffer_unref (buf);
+ return GST_FLOW_ERROR;
+ }
}
static gboolean