mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 05:59:10 +00:00
- updated to new seek api... i think it works, dunno, i'm not a rocket scientist
Original commit message from CVS: - updated to new seek api... i think it works, dunno, i'm not a rocket scientist
This commit is contained in:
parent
66f04431ff
commit
eed66d0d2b
1 changed files with 71 additions and 22 deletions
|
@ -71,6 +71,9 @@ struct _GstGnomeVFSSrc {
|
||||||
|
|
||||||
/* handle */
|
/* handle */
|
||||||
GnomeVFSHandle *handle;
|
GnomeVFSHandle *handle;
|
||||||
|
/* Seek stuff */
|
||||||
|
gboolean seek_happened;
|
||||||
|
gboolean need_flush;
|
||||||
|
|
||||||
/* local filename */
|
/* local filename */
|
||||||
gchar *local_name;
|
gchar *local_name;
|
||||||
|
@ -126,6 +129,7 @@ static GstElementStateReturn gst_gnomevfssrc_change_state(GstElement *element);
|
||||||
|
|
||||||
static void gst_gnomevfssrc_close_file(GstGnomeVFSSrc *src);
|
static void gst_gnomevfssrc_close_file(GstGnomeVFSSrc *src);
|
||||||
static gboolean gst_gnomevfssrc_open_file(GstGnomeVFSSrc *src);
|
static gboolean gst_gnomevfssrc_open_file(GstGnomeVFSSrc *src);
|
||||||
|
static gboolean gst_gnomevfssrc_srcpad_event (GstPad *pad, GstEvent *event);
|
||||||
|
|
||||||
|
|
||||||
static GstElementClass *parent_class = NULL;
|
static GstElementClass *parent_class = NULL;
|
||||||
|
@ -146,7 +150,10 @@ GType gst_gnomevfssrc_get_type(void)
|
||||||
(GInstanceInitFunc) gst_gnomevfssrc_init,
|
(GInstanceInitFunc) gst_gnomevfssrc_init,
|
||||||
};
|
};
|
||||||
gnomevfssrc_type =
|
gnomevfssrc_type =
|
||||||
g_type_register_static(GST_TYPE_ELEMENT, "GstGnomeVFSSrc", &gnomevfssrc_info, 0);
|
g_type_register_static(GST_TYPE_ELEMENT,
|
||||||
|
"GstGnomeVFSSrc",
|
||||||
|
&gnomevfssrc_info,
|
||||||
|
0);
|
||||||
}
|
}
|
||||||
return gnomevfssrc_type;
|
return gnomevfssrc_type;
|
||||||
}
|
}
|
||||||
|
@ -184,6 +191,8 @@ static void gst_gnomevfssrc_init(GstGnomeVFSSrc *gnomevfssrc)
|
||||||
|
|
||||||
gnomevfssrc->srcpad = gst_pad_new("src", GST_PAD_SRC);
|
gnomevfssrc->srcpad = gst_pad_new("src", GST_PAD_SRC);
|
||||||
gst_pad_set_get_function(gnomevfssrc->srcpad, gst_gnomevfssrc_get);
|
gst_pad_set_get_function(gnomevfssrc->srcpad, gst_gnomevfssrc_get);
|
||||||
|
gst_pad_set_event_function (gnomevfssrc->srcpad,
|
||||||
|
gst_gnomevfssrc_srcpad_event);
|
||||||
gst_element_add_pad(GST_ELEMENT(gnomevfssrc), gnomevfssrc->srcpad);
|
gst_element_add_pad(GST_ELEMENT(gnomevfssrc), gnomevfssrc->srcpad);
|
||||||
|
|
||||||
gnomevfssrc->filename = NULL;
|
gnomevfssrc->filename = NULL;
|
||||||
|
@ -214,7 +223,6 @@ static void gst_gnomevfssrc_set_property(GObject *object, guint prop_id, const G
|
||||||
g_return_if_fail((GST_STATE(src) < GST_STATE_PLAYING)
|
g_return_if_fail((GST_STATE(src) < GST_STATE_PLAYING)
|
||||||
|| (GST_STATE(src) == GST_STATE_PAUSED));
|
|| (GST_STATE(src) == GST_STATE_PAUSED));
|
||||||
|
|
||||||
if (src->filename)
|
|
||||||
g_free(src->filename);
|
g_free(src->filename);
|
||||||
|
|
||||||
/* clear the filename if we get a NULL (is that possible?) */
|
/* clear the filename if we get a NULL (is that possible?) */
|
||||||
|
@ -483,11 +491,8 @@ static void gst_gnomevfssrc_close_file(GstGnomeVFSSrc *src)
|
||||||
|
|
||||||
/* zero out a lot of our state */
|
/* zero out a lot of our state */
|
||||||
src->is_local = FALSE;
|
src->is_local = FALSE;
|
||||||
if (src->uri)
|
|
||||||
g_free(src->uri);
|
g_free(src->uri);
|
||||||
if (src->handle)
|
|
||||||
g_free(src->handle);
|
g_free(src->handle);
|
||||||
if (src->local_name)
|
|
||||||
g_free(src->local_name);
|
g_free(src->local_name);
|
||||||
src->fd = 0;
|
src->fd = 0;
|
||||||
src->map = NULL;
|
src->map = NULL;
|
||||||
|
@ -503,17 +508,23 @@ static GstElementStateReturn gst_gnomevfssrc_change_state(GstElement *element)
|
||||||
g_return_val_if_fail(GST_IS_GNOMEVFSSRC(element),
|
g_return_val_if_fail(GST_IS_GNOMEVFSSRC(element),
|
||||||
GST_STATE_FAILURE);
|
GST_STATE_FAILURE);
|
||||||
|
|
||||||
if (GST_STATE_TRANSITION(element) == GST_STATE_NULL_TO_READY) {
|
switch (GST_STATE_TRANSITION (element)) {
|
||||||
|
case GST_STATE_NULL_TO_READY:
|
||||||
if (!GST_FLAG_IS_SET(element, GST_GNOMEVFSSRC_OPEN)) {
|
if (!GST_FLAG_IS_SET(element, GST_GNOMEVFSSRC_OPEN)) {
|
||||||
if (!gst_gnomevfssrc_open_file
|
if (!gst_gnomevfssrc_open_file
|
||||||
(GST_GNOMEVFSSRC(element)))
|
(GST_GNOMEVFSSRC(element)))
|
||||||
return GST_STATE_FAILURE;
|
return GST_STATE_FAILURE;
|
||||||
}
|
}
|
||||||
} else if (GST_STATE_TRANSITION(element) ==
|
break;
|
||||||
GST_STATE_READY_TO_NULL) {
|
case GST_STATE_READY_TO_NULL:
|
||||||
if (GST_FLAG_IS_SET(element, GST_GNOMEVFSSRC_OPEN))
|
if (GST_FLAG_IS_SET(element, GST_GNOMEVFSSRC_OPEN))
|
||||||
gst_gnomevfssrc_close_file(GST_GNOMEVFSSRC
|
gst_gnomevfssrc_close_file(GST_GNOMEVFSSRC
|
||||||
(element));
|
(element));
|
||||||
|
break;
|
||||||
|
case GST_STATE_READY_TO_PAUSED:
|
||||||
|
case GST_STATE_PAUSED_TO_READY:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GST_ELEMENT_CLASS(parent_class)->change_state)
|
if (GST_ELEMENT_CLASS(parent_class)->change_state)
|
||||||
|
@ -538,6 +549,44 @@ static gboolean plugin_init(GModule *module, GstPlugin *plugin)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_gnomevfssrc_srcpad_event (GstPad *pad, GstEvent *event)
|
||||||
|
{
|
||||||
|
GstGnomeVFSSrc *src = GST_GNOMEVFSSRC(GST_PAD_PARENT(pad));
|
||||||
|
|
||||||
|
switch (GST_EVENT_TYPE (event)) {
|
||||||
|
case GST_EVENT_SEEK:
|
||||||
|
switch (GST_EVENT_SEEK_TYPE (event)) {
|
||||||
|
case GST_SEEK_BYTEOFFSET_SET:
|
||||||
|
src->curoffset = (guint64) GST_EVENT_SEEK_OFFSET (event);
|
||||||
|
break;
|
||||||
|
case GST_SEEK_BYTEOFFSET_CUR:
|
||||||
|
src->curoffset += GST_EVENT_SEEK_OFFSET (event);
|
||||||
|
break;
|
||||||
|
case GST_SEEK_BYTEOFFSET_END:
|
||||||
|
src->curoffset = src->size - ABS (GST_EVENT_SEEK_OFFSET (event));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
g_object_notify (G_OBJECT (src), "offset");
|
||||||
|
src->seek_happened = TRUE;
|
||||||
|
src->need_flush = GST_EVENT_SEEK_FLUSH(event);
|
||||||
|
gst_event_free (event);
|
||||||
|
/* push a discontinuous event? */
|
||||||
|
break;
|
||||||
|
case GST_EVENT_FLUSH:
|
||||||
|
src->need_flush = TRUE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
GstPluginDesc plugin_desc = {
|
GstPluginDesc plugin_desc = {
|
||||||
GST_VERSION_MAJOR,
|
GST_VERSION_MAJOR,
|
||||||
GST_VERSION_MINOR,
|
GST_VERSION_MINOR,
|
||||||
|
|
Loading…
Reference in a new issue