"Location of the file to read", NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
GST_PARAM_MUTABLE_READY));
-
+
g_object_class_install_property (gobject_class, ARG_EOS,
g_param_spec_boolean ("eos",
"EOS recived on downloading pipeline",
"download of clip is over",
0,
G_PARAM_READWRITE));
-
+
gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_pd_pushsrc_start);
gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_pd_pushsrc_stop);
gstbasesrc_class->is_seekable = GST_DEBUG_FUNCPTR (gst_pd_pushsrc_is_seekable);
}
GST_LOG ("OUT");
-
+
}
static void
src->uri = NULL;
src->is_regular = FALSE;
src->is_eos = FALSE;
-
+
gst_pad_set_checkgetrange_function (basesrc->srcpad, GST_DEBUG_FUNCPTR (gst_pd_pushsrc_checkgetrange));
GST_LOG ("OUT");
}
g_object_notify (G_OBJECT (src), "location");
gst_uri_handler_new_uri (GST_URI_HANDLER (src), src->uri);
-
+
GST_LOG ("OUT");
return TRUE;
GST_LOG ("IN");
int ret;
- GstBuffer *buf;
+ GstBuffer *buf = NULL;
struct stat stat_results;
GstPDPushSrc *src;
+ if(length < 1)
+ return GST_FLOW_ERROR;
+
src = GST_PD_PUSHSRC_CAST (basesrc);
-
- GST_LOG_OBJECT (src, "read position = %"G_GUINT64_FORMAT ", offset = %"G_GUINT64_FORMAT", length = %d",
- src->read_position, offset, length);
-
+
+ GST_LOG_OBJECT (src, "read position = %"G_GUINT64_FORMAT ", offset = %"G_GUINT64_FORMAT", length = %d",
+ src->read_position, offset, length);
+
memset (&stat_results, 0, sizeof (stat_results));
-
+
if (fstat (src->fd, &stat_results) < 0)
goto could_not_stat;
GST_DEBUG_OBJECT (src, "Going to wait for %ld msec", timeout.tv_usec);
ret = select (src->fd + 1, &fds, NULL, NULL, &timeout);
- if (-1 == ret)
+ if (-1 == ret)
{
- GST_ERROR_OBJECT (src, "ERROR in select () : reason - %s...\n", strerror(errno));
+ GST_ERROR_OBJECT (src, "ERROR in select () : reason - %s...\n", g_strerror(errno));
return GST_FLOW_ERROR;
}
else if (0 == ret)
else
{
memset (&stat_results, 0, sizeof (stat_results));
-
+
if (fstat (src->fd, &stat_results) < 0)
goto could_not_stat;
goto seek_failed;
src->read_position = offset;
}
-
+
buf = gst_buffer_try_new_and_alloc (length);
- if (G_UNLIKELY (buf == NULL && length > 0)) {
+ if (G_UNLIKELY (buf == NULL)) {
GST_ERROR_OBJECT (src, "Failed to allocate %u bytes", length);
return GST_FLOW_ERROR;
}
- /* No need to read anything if length is 0 */
- if (length > 0) {
- GST_LOG_OBJECT (src, "Reading %d bytes at offset 0x%" G_GINT64_MODIFIER "x",
- length, offset);
- ret = read (src->fd, GST_BUFFER_DATA (buf), length);
- if (G_UNLIKELY (ret < 0))
- goto could_not_read;
+ GST_LOG_OBJECT (src, "Reading %d bytes at offset 0x%" G_GINT64_MODIFIER "x",
+ length, offset);
+ ret = read (src->fd, GST_BUFFER_DATA (buf), length);
+ if (G_UNLIKELY (ret < 0))
+ goto could_not_read;
- /* seekable regular files should have given us what we expected */
- if (G_UNLIKELY ((guint) ret < length && src->seekable))
- goto unexpected_eos;
+ /* seekable regular files should have given us what we expected */
+ if (G_UNLIKELY ((guint) ret < length && src->seekable))
+ goto unexpected_eos;
- /* other files should eos if they read 0 and more was requested */
- if (G_UNLIKELY (ret == 0 && length > 0))
- goto eos;
+ /* other files should eos if they read 0 and more was requested */
+ if (G_UNLIKELY (ret == 0 && length > 0))
+ goto eos;
- length = ret;
- GST_BUFFER_SIZE (buf) = length;
- GST_BUFFER_OFFSET (buf) = offset;
- GST_BUFFER_OFFSET_END (buf) = offset + length;
+ length = ret;
+ GST_BUFFER_SIZE (buf) = length;
+ GST_BUFFER_OFFSET (buf) = offset;
+ GST_BUFFER_OFFSET_END (buf) = offset + length;
- src->read_position += length;
- }
+ src->read_position += length;
*buffer = buf;
GST_LOG ("OUT");
unexpected_eos:
{
GST_ERROR_OBJECT (src, "Unexpected EOS occured...");
- GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL),
- ("unexpected end of file."));
+ GST_ELEMENT_ERROR (src, RESOURCE, READ, (NULL), ("unexpected end of file."));
gst_buffer_unref (buf);
return GST_FLOW_ERROR;
}
eos:
{
GST_ERROR_OBJECT (src, "non-regular file hits EOS");
- gst_buffer_unref (buf);
+ if (buf)
+ gst_buffer_unref (buf);
return GST_FLOW_UNEXPECTED;
}
}
*size = G_MAXUINT64;
GST_DEBUG ("size of the file = %"G_GUINT64_FORMAT, *size);
-
+
GST_LOG ("OUT");
return TRUE;
}
no_stat:
{
- GST_ERROR_OBJECT (src, "Could not get stat info...");
+ GST_ERROR_OBJECT (src, "Could not get stat info...");
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
("Could not get info on \"\"."), (NULL));
close (src->fd);
}
was_socket:
{
- GST_ERROR_OBJECT (src, "Is a Socket");
+ GST_ERROR_OBJECT (src, "Is a Socket");
GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ,
("File \"\" is a socket."), (NULL));
close (src->fd);
#ifdef G_OS_WIN32
/* Unfortunately, g_filename_from_uri() doesn't handle some UNC paths
* correctly on windows, it leaves them with an extra backslash
- * at the start if they're of the mozilla-style file://///host/path/file
+ * at the start if they're of the mozilla-style file://///host/path/file
* form. Correct this.
*/
if (location[0] == '\\' && location[1] == '\\' && location[2] == '\\')