mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-31 03:29:50 +00:00
Created an overridable method for seeking on an element, along with a default implementation.
Original commit message from CVS: Created an overridable method for seeking on an element, along with a default implementation. make queue flush on discont (not entirely correct) removed the new_media from the discont event.
This commit is contained in:
parent
0aa7b2db8c
commit
a599a5b1df
6 changed files with 47 additions and 10 deletions
|
@ -63,6 +63,8 @@ static void gst_element_dispatch_properties_changed (GObject * object, guint n
|
|||
|
||||
static void gst_element_dispose (GObject *object);
|
||||
|
||||
static gboolean gst_element_send_event_default (GstElement *element, GstEvent *event);
|
||||
|
||||
static GstElementStateReturn gst_element_change_state (GstElement *element);
|
||||
static void gst_element_error_func (GstElement* element, GstElement *source, gchar *errormsg);
|
||||
|
||||
|
@ -159,6 +161,7 @@ gst_element_class_init (GstElementClass *klass)
|
|||
klass->elementfactory = NULL;
|
||||
klass->padtemplates = NULL;
|
||||
klass->numpadtemplates = 0;
|
||||
klass->send_event = GST_DEBUG_FUNCPTR (gst_element_send_event_default);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1592,7 +1595,7 @@ gst_element_disconnect (GstElement *src, GstElement *dest)
|
|||
srcpads = gst_element_get_pad_list (src);
|
||||
|
||||
while (srcpads) {
|
||||
pad = GST_PAD (srcpads->data);
|
||||
pad = GST_PAD_CAST (srcpads->data);
|
||||
|
||||
if (GST_PAD_DIRECTION (pad) == GST_PAD_SRC)
|
||||
if (GST_OBJECT_PARENT (GST_PAD_PEER (pad)) == (GstObject*) dest)
|
||||
|
@ -1616,6 +1619,39 @@ gst_element_error_func (GstElement* element, GstElement *source, gchar *errormsg
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_element_send_event_default (GstElement *element, GstEvent *event)
|
||||
{
|
||||
GList *pads = element->pads;
|
||||
gboolean res = FALSE;
|
||||
|
||||
while (pads) {
|
||||
GstPad *pad = GST_PAD_CAST (pads->data);
|
||||
|
||||
if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK) {
|
||||
if (GST_PAD_IS_CONNECTED (pad)) {
|
||||
res = gst_pad_send_event (GST_PAD_PEER (pad), event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
pads = g_list_next (pads);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_element_send_event (GstElement *element, GstEvent *event)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
|
||||
g_return_val_if_fail (event != NULL, FALSE);
|
||||
|
||||
if (CLASS (element)->send_event)
|
||||
return CLASS (element)->send_event (element, event);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gst_element_error:
|
||||
* @element: Element with the error
|
||||
|
@ -1633,7 +1669,6 @@ gst_element_error (GstElement *element, const gchar *error, ...)
|
|||
|
||||
/* checks */
|
||||
g_return_if_fail (GST_IS_ELEMENT (element));
|
||||
g_return_if_fail (element != NULL);
|
||||
g_return_if_fail (error != NULL);
|
||||
|
||||
/* create error message */
|
||||
|
|
|
@ -171,6 +171,7 @@ struct _GstElementClass {
|
|||
|
||||
/* vtable*/
|
||||
gboolean (*release_locks) (GstElement *element);
|
||||
gboolean (*send_event) (GstElement *element, GstEvent *event);
|
||||
/* change the element state */
|
||||
GstElementStateReturn (*change_state) (GstElement *element);
|
||||
/* request a new pad */
|
||||
|
@ -261,6 +262,8 @@ gboolean gst_element_connect_pads_filtered (GstElement *src, const gchar *srcpa
|
|||
void gst_element_disconnect_pads (GstElement *src, const gchar *srcpadname,
|
||||
GstElement *dest, const gchar *destpadname);
|
||||
|
||||
gboolean gst_element_send_event (GstElement *element, GstEvent *event);
|
||||
|
||||
void gst_element_set_eos (GstElement *element);
|
||||
|
||||
void gst_element_error (GstElement *element, const gchar *error, ...);
|
||||
|
|
|
@ -168,14 +168,14 @@ gst_event_new_seek (GstSeekType type, gint64 offset)
|
|||
}
|
||||
|
||||
GstEvent*
|
||||
gst_event_new_discontinuous (gboolean new_media, GstSeekType format1, ...)
|
||||
gst_event_new_discontinuous (gboolean flush, GstSeekType format1, ...)
|
||||
{
|
||||
va_list var_args;
|
||||
GstEvent *event;
|
||||
gint count = 0;
|
||||
|
||||
event = gst_event_new (GST_EVENT_DISCONTINUOUS);
|
||||
GST_EVENT_DISCONT_NEW_MEDIA (event) = new_media;
|
||||
GST_EVENT_DISCONT_FLUSH (event) = flush;
|
||||
|
||||
va_start (var_args, format1);
|
||||
|
||||
|
|
|
@ -88,7 +88,6 @@ typedef struct
|
|||
#define GST_EVENT_SEEK_OFFSET(event) (GST_EVENT(event)->event_data.seek.offset)
|
||||
#define GST_EVENT_SEEK_ACCURACY(event) (GST_EVENT(event)->event_data.seek.accuracy)
|
||||
|
||||
#define GST_EVENT_DISCONT_NEW_MEDIA(event) (GST_EVENT(event)->event_data.discont.new_media)
|
||||
#define GST_EVENT_DISCONT_FLUSH(event) (GST_EVENT(event)->event_data.discont.flush)
|
||||
#define GST_EVENT_DISCONT_OFFSET(event,i) (GST_EVENT(event)->event_data.discont.offsets[i])
|
||||
#define GST_EVENT_DISCONT_OFFSET_LEN(event) (GST_EVENT(event)->event_data.discont.noffsets)
|
||||
|
@ -109,9 +108,7 @@ struct _GstEvent {
|
|||
struct {
|
||||
GstFormatValue offsets[8];
|
||||
gint noffsets;
|
||||
gboolean new_media;
|
||||
gboolean flush;
|
||||
GstSeekAccuracy accuracy;
|
||||
} discont;
|
||||
} event_data;
|
||||
};
|
||||
|
@ -122,8 +119,10 @@ GstEvent* gst_event_new (GstEventType type);
|
|||
GstEvent* gst_event_copy (GstEvent *event);
|
||||
void gst_event_free (GstEvent *event);
|
||||
|
||||
/* seek events */
|
||||
/* seek event */
|
||||
GstEvent* gst_event_new_seek (GstSeekType type, gint64 offset);
|
||||
|
||||
/* discontinous event */
|
||||
GstEvent* gst_event_new_discontinuous (gboolean new_media,
|
||||
GstFormat format1, ...);
|
||||
gboolean gst_event_discont_get_value (GstEvent *event, GstFormat format, gint64 *value);
|
||||
|
|
|
@ -308,7 +308,7 @@ restart:
|
|||
GST_ELEMENT_NAME (queue), queue->level_buffers);
|
||||
break;
|
||||
case GST_EVENT_DISCONTINUOUS:
|
||||
//gst_queue_locked_flush (queue);
|
||||
gst_queue_locked_flush (queue);
|
||||
break;
|
||||
default:
|
||||
/*gst_pad_event_default (pad, GST_EVENT (buf)); */
|
||||
|
|
|
@ -308,7 +308,7 @@ restart:
|
|||
GST_ELEMENT_NAME (queue), queue->level_buffers);
|
||||
break;
|
||||
case GST_EVENT_DISCONTINUOUS:
|
||||
//gst_queue_locked_flush (queue);
|
||||
gst_queue_locked_flush (queue);
|
||||
break;
|
||||
default:
|
||||
/*gst_pad_event_default (pad, GST_EVENT (buf)); */
|
||||
|
|
Loading…
Reference in a new issue