- Implemented seekmasks, query types and formats in various plugins

Original commit message from CVS:
- Implemented seekmasks, query types and formats in various plugins
- use GST_PAD_IS_USABLE if possible
This commit is contained in:
Wim Taymans 2002-07-24 21:08:43 +00:00
parent a1a3d3455f
commit 6db19b953c
8 changed files with 154 additions and 8 deletions

View file

@ -338,6 +338,18 @@ gst_fakesrc_event_handler (GstPad *pad, GstEvent *event)
return TRUE; return TRUE;
} }
static const GstEventMask*
gst_fakesrc_get_event_mask (GstPad *pad)
{
static const GstEventMask gst_fakesrc_event_mask[] = {
{ GST_EVENT_SEEK, GST_SEEK_FLAG_FLUSH },
{ GST_EVENT_FLUSH, 0 },
{ 0, }
};
return gst_fakesrc_event_mask;
}
static void static void
gst_fakesrc_update_functions (GstFakeSrc *src) gst_fakesrc_update_functions (GstFakeSrc *src)
{ {
@ -362,6 +374,7 @@ gst_fakesrc_update_functions (GstFakeSrc *src)
} }
gst_pad_set_event_function (pad, gst_fakesrc_event_handler); gst_pad_set_event_function (pad, gst_fakesrc_event_handler);
gst_pad_set_event_mask_function (pad, gst_fakesrc_get_event_mask);
pads = g_list_next (pads); pads = g_list_next (pads);
} }
} }

View file

@ -121,6 +121,23 @@ gst_filesink_class_init (GstFileSinkClass *klass)
gstelement_class->change_state = gst_filesink_change_state; gstelement_class->change_state = gst_filesink_change_state;
} }
static const GstEventMask*
gst_filesink_get_event_mask (GstPad *pad)
{
static GstEventMask gst_filesink_event_mask[] = {
{ GST_EVENT_SEEK, GST_SEEK_METHOD_CUR |
GST_SEEK_METHOD_SET |
GST_SEEK_METHOD_END |
GST_SEEK_FLAG_FLUSH },
{ GST_EVENT_FLUSH, 0 },
{ GST_EVENT_DISCONTINUOUS, 0 },
{ GST_EVENT_NEW_MEDIA, 0 },
{ 0, }
};
return gst_filesink_event_mask;
}
static void static void
gst_filesink_init (GstFileSink *filesink) gst_filesink_init (GstFileSink *filesink)
{ {
@ -132,6 +149,7 @@ gst_filesink_init (GstFileSink *filesink)
GST_FLAG_SET (GST_ELEMENT(filesink), GST_ELEMENT_EVENT_AWARE); GST_FLAG_SET (GST_ELEMENT(filesink), GST_ELEMENT_EVENT_AWARE);
gst_pad_set_event_function(pad, gst_filesink_handle_event); gst_pad_set_event_function(pad, gst_filesink_handle_event);
gst_pad_set_event_mask_function(pad, gst_filesink_get_event_mask);
filesink->filename = NULL; filesink->filename = NULL;
filesink->file = NULL; filesink->file = NULL;

View file

@ -98,7 +98,6 @@ enum {
ARG_TOUCH, ARG_TOUCH,
}; };
static void gst_filesrc_class_init (GstFileSrcClass *klass); static void gst_filesrc_class_init (GstFileSrcClass *klass);
static void gst_filesrc_init (GstFileSrc *filesrc); static void gst_filesrc_init (GstFileSrc *filesrc);
static void gst_filesrc_dispose (GObject *object); static void gst_filesrc_dispose (GObject *object);
@ -109,6 +108,7 @@ static void gst_filesrc_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec); GValue *value, GParamSpec *pspec);
static GstBuffer * gst_filesrc_get (GstPad *pad); static GstBuffer * gst_filesrc_get (GstPad *pad);
static const GstFormat* gst_filesrc_get_formats (GstPad *pad);
static gboolean gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event); static gboolean gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event);
static gboolean gst_filesrc_srcpad_query (GstPad *pad, GstPadQueryType type, static gboolean gst_filesrc_srcpad_query (GstPad *pad, GstPadQueryType type,
GstSeekType *format, gint64 *value); GstSeekType *format, gint64 *value);
@ -182,13 +182,44 @@ gst_filesrc_bufcmp (gconstpointer a, gconstpointer b)
else return 0; else return 0;
} }
static const GstEventMask*
gst_filesrc_get_event_mask (GstPad *pad)
{
static GstEventMask gst_filesrc_event_mask[] = {
{ GST_EVENT_SEEK, GST_SEEK_METHOD_CUR |
GST_SEEK_METHOD_SET |
GST_SEEK_METHOD_END |
GST_SEEK_FLAG_FLUSH },
{ GST_EVENT_FLUSH, 0 },
{ GST_EVENT_SIZE, 0 },
{ 0, }
};
return gst_filesrc_event_mask;
}
static const GstPadQueryType*
gst_filesrc_get_query_types (GstPad *pad)
{
static GstPadQueryType gst_filesrc_query_types[] = {
GST_PAD_QUERY_TOTAL,
GST_PAD_QUERY_POSITION,
0
};
return gst_filesrc_query_types;
}
static void static void
gst_filesrc_init (GstFileSrc *src) gst_filesrc_init (GstFileSrc *src)
{ {
src->srcpad = gst_pad_new ("src", GST_PAD_SRC); src->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_pad_set_get_function (src->srcpad, gst_filesrc_get); gst_pad_set_get_function (src->srcpad, gst_filesrc_get);
gst_pad_set_event_function (src->srcpad, gst_filesrc_srcpad_event); gst_pad_set_event_function (src->srcpad, gst_filesrc_srcpad_event);
gst_pad_set_event_mask_function (src->srcpad, gst_filesrc_get_event_mask);
gst_pad_set_query_function (src->srcpad, gst_filesrc_srcpad_query); gst_pad_set_query_function (src->srcpad, gst_filesrc_srcpad_query);
gst_pad_set_query_type_function (src->srcpad, gst_filesrc_get_query_types);
gst_pad_set_formats_function (src->srcpad, gst_filesrc_get_formats);
gst_element_add_pad (GST_ELEMENT (src), src->srcpad); gst_element_add_pad (GST_ELEMENT (src), src->srcpad);
src->pagesize = getpagesize(); src->pagesize = getpagesize();
@ -681,6 +712,17 @@ gst_filesrc_change_state (GstElement *element)
return GST_STATE_SUCCESS; return GST_STATE_SUCCESS;
} }
static const GstFormat*
gst_filesrc_get_formats (GstPad *pad)
{
static const GstFormat gst_filesrc_formats[] = {
GST_FORMAT_BYTES,
0
};
return gst_filesrc_formats;
}
static gboolean static gboolean
gst_filesrc_srcpad_query (GstPad *pad, GstPadQueryType type, gst_filesrc_srcpad_query (GstPad *pad, GstPadQueryType type,
GstFormat *format, gint64 *value) GstFormat *format, gint64 *value)

View file

@ -137,7 +137,7 @@ gst_tee_sinkconnect (GstPad *pad, GstCaps *caps)
GstPad *outpad = GST_PAD (pads->data); GstPad *outpad = GST_PAD (pads->data);
pads = g_list_next (pads); pads = g_list_next (pads);
if (GST_PAD_DIRECTION (outpad) != GST_PAD_SRC || !GST_PAD_IS_CONNECTED (outpad)) if (GST_PAD_DIRECTION (outpad) != GST_PAD_SRC || !GST_PAD_IS_USABLE (outpad))
continue; continue;
if (!(gst_pad_try_set_caps (outpad, caps))) { if (!(gst_pad_try_set_caps (outpad, caps))) {
@ -304,7 +304,7 @@ gst_tee_chain (GstPad *pad, GstBuffer *buf)
g_object_notify (G_OBJECT (tee), "last_message"); g_object_notify (G_OBJECT (tee), "last_message");
} }
if (GST_PAD_IS_CONNECTED (outpad)) if (GST_PAD_IS_USABLE (outpad))
gst_pad_push (outpad, buf); gst_pad_push (outpad, buf);
else else
gst_buffer_unref (buf); gst_buffer_unref (buf);

View file

@ -338,6 +338,18 @@ gst_fakesrc_event_handler (GstPad *pad, GstEvent *event)
return TRUE; return TRUE;
} }
static const GstEventMask*
gst_fakesrc_get_event_mask (GstPad *pad)
{
static const GstEventMask gst_fakesrc_event_mask[] = {
{ GST_EVENT_SEEK, GST_SEEK_FLAG_FLUSH },
{ GST_EVENT_FLUSH, 0 },
{ 0, }
};
return gst_fakesrc_event_mask;
}
static void static void
gst_fakesrc_update_functions (GstFakeSrc *src) gst_fakesrc_update_functions (GstFakeSrc *src)
{ {
@ -362,6 +374,7 @@ gst_fakesrc_update_functions (GstFakeSrc *src)
} }
gst_pad_set_event_function (pad, gst_fakesrc_event_handler); gst_pad_set_event_function (pad, gst_fakesrc_event_handler);
gst_pad_set_event_mask_function (pad, gst_fakesrc_get_event_mask);
pads = g_list_next (pads); pads = g_list_next (pads);
} }
} }

View file

@ -121,6 +121,23 @@ gst_filesink_class_init (GstFileSinkClass *klass)
gstelement_class->change_state = gst_filesink_change_state; gstelement_class->change_state = gst_filesink_change_state;
} }
static const GstEventMask*
gst_filesink_get_event_mask (GstPad *pad)
{
static GstEventMask gst_filesink_event_mask[] = {
{ GST_EVENT_SEEK, GST_SEEK_METHOD_CUR |
GST_SEEK_METHOD_SET |
GST_SEEK_METHOD_END |
GST_SEEK_FLAG_FLUSH },
{ GST_EVENT_FLUSH, 0 },
{ GST_EVENT_DISCONTINUOUS, 0 },
{ GST_EVENT_NEW_MEDIA, 0 },
{ 0, }
};
return gst_filesink_event_mask;
}
static void static void
gst_filesink_init (GstFileSink *filesink) gst_filesink_init (GstFileSink *filesink)
{ {
@ -132,6 +149,7 @@ gst_filesink_init (GstFileSink *filesink)
GST_FLAG_SET (GST_ELEMENT(filesink), GST_ELEMENT_EVENT_AWARE); GST_FLAG_SET (GST_ELEMENT(filesink), GST_ELEMENT_EVENT_AWARE);
gst_pad_set_event_function(pad, gst_filesink_handle_event); gst_pad_set_event_function(pad, gst_filesink_handle_event);
gst_pad_set_event_mask_function(pad, gst_filesink_get_event_mask);
filesink->filename = NULL; filesink->filename = NULL;
filesink->file = NULL; filesink->file = NULL;

View file

@ -98,7 +98,6 @@ enum {
ARG_TOUCH, ARG_TOUCH,
}; };
static void gst_filesrc_class_init (GstFileSrcClass *klass); static void gst_filesrc_class_init (GstFileSrcClass *klass);
static void gst_filesrc_init (GstFileSrc *filesrc); static void gst_filesrc_init (GstFileSrc *filesrc);
static void gst_filesrc_dispose (GObject *object); static void gst_filesrc_dispose (GObject *object);
@ -109,6 +108,7 @@ static void gst_filesrc_get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec); GValue *value, GParamSpec *pspec);
static GstBuffer * gst_filesrc_get (GstPad *pad); static GstBuffer * gst_filesrc_get (GstPad *pad);
static const GstFormat* gst_filesrc_get_formats (GstPad *pad);
static gboolean gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event); static gboolean gst_filesrc_srcpad_event (GstPad *pad, GstEvent *event);
static gboolean gst_filesrc_srcpad_query (GstPad *pad, GstPadQueryType type, static gboolean gst_filesrc_srcpad_query (GstPad *pad, GstPadQueryType type,
GstSeekType *format, gint64 *value); GstSeekType *format, gint64 *value);
@ -182,13 +182,44 @@ gst_filesrc_bufcmp (gconstpointer a, gconstpointer b)
else return 0; else return 0;
} }
static const GstEventMask*
gst_filesrc_get_event_mask (GstPad *pad)
{
static GstEventMask gst_filesrc_event_mask[] = {
{ GST_EVENT_SEEK, GST_SEEK_METHOD_CUR |
GST_SEEK_METHOD_SET |
GST_SEEK_METHOD_END |
GST_SEEK_FLAG_FLUSH },
{ GST_EVENT_FLUSH, 0 },
{ GST_EVENT_SIZE, 0 },
{ 0, }
};
return gst_filesrc_event_mask;
}
static const GstPadQueryType*
gst_filesrc_get_query_types (GstPad *pad)
{
static GstPadQueryType gst_filesrc_query_types[] = {
GST_PAD_QUERY_TOTAL,
GST_PAD_QUERY_POSITION,
0
};
return gst_filesrc_query_types;
}
static void static void
gst_filesrc_init (GstFileSrc *src) gst_filesrc_init (GstFileSrc *src)
{ {
src->srcpad = gst_pad_new ("src", GST_PAD_SRC); src->srcpad = gst_pad_new ("src", GST_PAD_SRC);
gst_pad_set_get_function (src->srcpad, gst_filesrc_get); gst_pad_set_get_function (src->srcpad, gst_filesrc_get);
gst_pad_set_event_function (src->srcpad, gst_filesrc_srcpad_event); gst_pad_set_event_function (src->srcpad, gst_filesrc_srcpad_event);
gst_pad_set_event_mask_function (src->srcpad, gst_filesrc_get_event_mask);
gst_pad_set_query_function (src->srcpad, gst_filesrc_srcpad_query); gst_pad_set_query_function (src->srcpad, gst_filesrc_srcpad_query);
gst_pad_set_query_type_function (src->srcpad, gst_filesrc_get_query_types);
gst_pad_set_formats_function (src->srcpad, gst_filesrc_get_formats);
gst_element_add_pad (GST_ELEMENT (src), src->srcpad); gst_element_add_pad (GST_ELEMENT (src), src->srcpad);
src->pagesize = getpagesize(); src->pagesize = getpagesize();
@ -681,6 +712,17 @@ gst_filesrc_change_state (GstElement *element)
return GST_STATE_SUCCESS; return GST_STATE_SUCCESS;
} }
static const GstFormat*
gst_filesrc_get_formats (GstPad *pad)
{
static const GstFormat gst_filesrc_formats[] = {
GST_FORMAT_BYTES,
0
};
return gst_filesrc_formats;
}
static gboolean static gboolean
gst_filesrc_srcpad_query (GstPad *pad, GstPadQueryType type, gst_filesrc_srcpad_query (GstPad *pad, GstPadQueryType type,
GstFormat *format, gint64 *value) GstFormat *format, gint64 *value)

View file

@ -137,7 +137,7 @@ gst_tee_sinkconnect (GstPad *pad, GstCaps *caps)
GstPad *outpad = GST_PAD (pads->data); GstPad *outpad = GST_PAD (pads->data);
pads = g_list_next (pads); pads = g_list_next (pads);
if (GST_PAD_DIRECTION (outpad) != GST_PAD_SRC || !GST_PAD_IS_CONNECTED (outpad)) if (GST_PAD_DIRECTION (outpad) != GST_PAD_SRC || !GST_PAD_IS_USABLE (outpad))
continue; continue;
if (!(gst_pad_try_set_caps (outpad, caps))) { if (!(gst_pad_try_set_caps (outpad, caps))) {
@ -304,7 +304,7 @@ gst_tee_chain (GstPad *pad, GstBuffer *buf)
g_object_notify (G_OBJECT (tee), "last_message"); g_object_notify (G_OBJECT (tee), "last_message");
} }
if (GST_PAD_IS_CONNECTED (outpad)) if (GST_PAD_IS_USABLE (outpad))
gst_pad_push (outpad, buf); gst_pad_push (outpad, buf);
else else
gst_buffer_unref (buf); gst_buffer_unref (buf);