--- a/gstreamer_core/plugins/elements/gstfdsink.c Tue Aug 31 15:30:33 2010 +0300
+++ b/gstreamer_core/plugins/elements/gstfdsink.c Wed Sep 01 12:16:41 2010 +0100
@@ -22,6 +22,7 @@
/**
* SECTION:element-fdsink
+ * @short_description: write to a unix file descriptor
* @see_also: #GstFdSrc
*
* Write data to a unix file descriptor.
@@ -37,18 +38,12 @@
# include "config.h"
#endif
+#ifdef __SYMBIAN32__
+#include <gst_global.h>
+#endif
#include "../../gst/gst-i18n-lib.h"
#include <sys/types.h>
-
-#ifdef G_OS_WIN32
-#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 <sys/socket.h>
#include <fcntl.h>
@@ -63,6 +58,12 @@
#include <string.h>
#include "gstfdsink.h"
+#ifdef __SYMBIAN32__
+#include <glib_global.h>
+#include <gobject_global.h>
+#include <gstpoll.h>
+#include <gstelement.h>
+#endif
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
@@ -120,9 +121,6 @@
static gboolean gst_fd_sink_stop (GstBaseSink * basesink);
static gboolean gst_fd_sink_unlock (GstBaseSink * basesink);
static gboolean gst_fd_sink_unlock_stop (GstBaseSink * basesink);
-static gboolean gst_fd_sink_event (GstBaseSink * sink, GstEvent * event);
-
-static gboolean gst_fd_sink_do_seek (GstFdSink * fdsink, guint64 new_offset);
static void
gst_fd_sink_base_init (gpointer g_class)
@@ -156,11 +154,11 @@
gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_fd_sink_stop);
gstbasesink_class->unlock = GST_DEBUG_FUNCPTR (gst_fd_sink_unlock);
gstbasesink_class->unlock_stop = GST_DEBUG_FUNCPTR (gst_fd_sink_unlock_stop);
- gstbasesink_class->event = GST_DEBUG_FUNCPTR (gst_fd_sink_event);
+ gstbasesink_class->event = NULL;
g_object_class_install_property (gobject_class, ARG_FD,
g_param_spec_int ("fd", "fd", "An open file descriptor to write to",
- 0, G_MAXINT, 1, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ 0, G_MAXINT, 1, G_PARAM_READWRITE));
}
static void
@@ -174,7 +172,6 @@
fdsink->fd = 1;
fdsink->uri = g_strdup_printf ("fd://%d", fdsink->fd);
fdsink->bytes_written = 0;
- fdsink->current_pos = 0;
GST_BASE_SINK (fdsink)->sync = TRUE;
}
@@ -204,7 +201,8 @@
switch (format) {
case GST_FORMAT_DEFAULT:
case GST_FORMAT_BYTES:
- gst_query_set_position (query, GST_FORMAT_BYTES, fdsink->current_pos);
+ gst_query_set_position (query, GST_FORMAT_BYTES,
+ fdsink->bytes_written);
return TRUE;
default:
return FALSE;
@@ -214,10 +212,6 @@
gst_query_set_formats (query, 2, GST_FORMAT_DEFAULT, GST_FORMAT_BYTES);
return TRUE;
- case GST_QUERY_URI:
- gst_query_set_uri (query, fdsink->uri);
- return TRUE;
-
default:
return gst_pad_query_default (pad, query);
}
@@ -277,7 +271,6 @@
size -= written;
data += written;
fdsink->bytes_written += written;
- fdsink->current_pos += written;
GST_DEBUG_OBJECT (fdsink, "wrote %d bytes, %d left", written, size);
@@ -309,9 +302,9 @@
GST_ELEMENT_ERROR (fdsink, RESOURCE, NO_SPACE_LEFT, (NULL), (NULL));
break;
default:{
- GST_ELEMENT_ERROR (fdsink, RESOURCE, WRITE, (NULL),
- ("Error while writing to file descriptor %d: %s",
- fdsink->fd, g_strerror (errno)));
+ GST_ELEMENT_ERROR (fdsink, RESOURCE, WRITE,
+ (_("Error while writing to file descriptor \"%d\"."), fdsink->fd),
+ ("%s", g_strerror (errno)));
}
}
return GST_FLOW_ERROR;
@@ -343,19 +336,20 @@
goto not_seekable;
}
} else
- GST_DEBUG_OBJECT (fdsink, "File descriptor %d is seekable", fd);
+ GST_DEBUG_OBJECT (fdsink, "File descriptor \"%d\" is seekable", fd);
return TRUE;
invalid:
{
- GST_ELEMENT_ERROR (fdsink, RESOURCE, WRITE, (NULL),
- ("File descriptor %d is not valid: %s", fd, g_strerror (errno)));
+ GST_ELEMENT_ERROR (fdsink, RESOURCE, WRITE,
+ (_("File descriptor \"%d\" is not valid."), fd),
+ ("%s", g_strerror (errno)));
return FALSE;
}
not_seekable:
{
- GST_DEBUG_OBJECT (fdsink, "File descriptor %d is a pipe", fd);
+ GST_DEBUG_OBJECT (fdsink, "File descriptor \"%d\" is a pipe", fd);
return TRUE;
}
}
@@ -377,9 +371,6 @@
gst_poll_add_fd (fdsink->fdset, &fd);
gst_poll_fd_ctl_write (fdsink->fdset, &fd, TRUE);
- fdsink->bytes_written = 0;
- fdsink->current_pos = 0;
-
return TRUE;
/* ERRORS */
@@ -507,92 +498,16 @@
}
}
-static gboolean
-gst_fd_sink_do_seek (GstFdSink * fdsink, guint64 new_offset)
-{
- off_t result;
-
- result = lseek (fdsink->fd, new_offset, SEEK_SET);
-
- if (result == -1)
- goto seek_failed;
-
- fdsink->current_pos = new_offset;
-
- GST_DEBUG_OBJECT (fdsink, "File desciptor %d to seek to position "
- "%" G_GUINT64_FORMAT, fdsink->fd, fdsink->current_pos);
-
- return TRUE;
-
- /* ERRORS */
-seek_failed:
- {
- GST_DEBUG_OBJECT (fdsink, "File desciptor %d failed to seek to position "
- "%" G_GUINT64_FORMAT, fdsink->fd, new_offset);
- return FALSE;
- }
-}
-
-static gboolean
-gst_fd_sink_event (GstBaseSink * sink, GstEvent * event)
-{
- GstEventType type;
- GstFdSink *fdsink;
-
- fdsink = GST_FD_SINK (sink);
-
- type = GST_EVENT_TYPE (event);
-
- switch (type) {
- case GST_EVENT_NEWSEGMENT:
- {
- gint64 start, stop, pos;
- GstFormat format;
- gst_event_parse_new_segment (event, NULL, NULL, &format, &start,
- &stop, &pos);
-
- if (format == GST_FORMAT_BYTES) {
- /* only try to seek and fail when we are going to a different
- * position */
- if (fdsink->current_pos != start) {
- /* FIXME, the seek should be performed on the pos field, start/stop are
- * just boundaries for valid bytes offsets. We should also fill the file
- * with zeroes if the new position extends the current EOF (sparse streams
- * and segment accumulation). */
- if (!gst_fd_sink_do_seek (fdsink, (guint64) start))
- goto seek_failed;
- }
- } else {
- GST_DEBUG_OBJECT (fdsink,
- "Ignored NEWSEGMENT event of format %u (%s)", (guint) format,
- gst_format_get_name (format));
- }
- break;
- }
- default:
- break;
- }
-
- return TRUE;
-
-seek_failed:
- {
- GST_ELEMENT_ERROR (fdsink, RESOURCE, SEEK, (NULL),
- ("Error while seeking on file descriptor %d: %s",
- fdsink->fd, g_strerror (errno)));
- return FALSE;
- }
-
-}
-
/*** GSTURIHANDLER INTERFACE *************************************************/
-
-static GstURIType
+#ifdef __SYMBIAN32__
+GstURIType
+#else
+static guint
+#endif
gst_fd_sink_uri_get_type (void)
{
return GST_URI_SINK;
}
-
static gchar **
gst_fd_sink_uri_get_protocols (void)
{
@@ -600,7 +515,6 @@
return protocols;
}
-
static const gchar *
gst_fd_sink_uri_get_uri (GstURIHandler * handler)
{