event: add new CAPS event

Add a new CAPS event that will be used to negotiate downstream elements. It'll
also stick on pad so that we can remove the GstCaps field on pads and the
GstCaps field on buffers.
This commit is contained in:
Wim Taymans 2011-05-04 11:03:05 +02:00
parent bc9cffda90
commit 6cfd9d57e2
4 changed files with 54 additions and 6 deletions

View file

@ -99,6 +99,7 @@ static GstEventQuarks event_quarks[] = {
{GST_EVENT_FLUSH_START, "flush-start", 0},
{GST_EVENT_FLUSH_STOP, "flush-stop", 0},
{GST_EVENT_EOS, "eos", 0},
{GST_EVENT_CAPS, "caps", 0},
{GST_EVENT_NEWSEGMENT, "newsegment", 0},
{GST_EVENT_TAG, "tag", 0},
{GST_EVENT_BUFFERSIZE, "buffersize", 0},
@ -475,6 +476,47 @@ gst_event_new_eos (void)
return gst_event_new (GST_EVENT_EOS);
}
/**
* gst_event_new_caps:
* @caps: a #GstCaps
*
* Create a new CAPS event for @caps. The caps event can only travel downstream
* synchronized with the buffer flow and contain the format of the buffers
* that will follow after the event.
*
* Returns: (transfer full): the new CAPS event.
*/
GstEvent *
gst_event_new_caps (GstCaps * caps)
{
GstEvent *event;
GST_CAT_INFO (GST_CAT_EVENT, "creating caps event %" GST_PTR_FORMAT, caps);
event = gst_event_new_custom (GST_EVENT_BUFFERSIZE,
gst_structure_id_new (GST_QUARK (EVENT_CAPS),
GST_QUARK (CAPS), GST_TYPE_CAPS, caps, NULL));
return event;
}
/**
* gst_event_parse_caps:
* @event: The event to parse
* @caps: (out): A pointer to the caps
*
* Get the caps from @event.
*/
void
gst_event_parse_caps (GstEvent * event, GstCaps ** caps)
{
g_return_if_fail (GST_IS_EVENT (event));
g_return_if_fail (GST_EVENT_TYPE (event) == GST_EVENT_CAPS);
gst_structure_id_get (event->structure,
GST_QUARK (CAPS), GST_TYPE_CAPS, caps, NULL);
}
/**
* gst_event_new_new_segment:
* @update: is this segment an update to a previous one

View file

@ -138,10 +138,11 @@ typedef enum {
GST_EVENT_FLUSH_STOP = GST_EVENT_MAKE_TYPE (2, 0, FLAG(BOTH) | FLAG(SERIALIZED)),
/* downstream serialized events */
GST_EVENT_EOS = GST_EVENT_MAKE_TYPE (5, 0, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
GST_EVENT_NEWSEGMENT = GST_EVENT_MAKE_TYPE (6, 1, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
GST_EVENT_TAG = GST_EVENT_MAKE_TYPE (7, 2, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
GST_EVENT_BUFFERSIZE = GST_EVENT_MAKE_TYPE (8, 3, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
GST_EVENT_SINK_MESSAGE = GST_EVENT_MAKE_TYPE (9, 4, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
GST_EVENT_CAPS = GST_EVENT_MAKE_TYPE (6, 5, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
GST_EVENT_NEWSEGMENT = GST_EVENT_MAKE_TYPE (7, 1, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
GST_EVENT_TAG = GST_EVENT_MAKE_TYPE (8, 2, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
GST_EVENT_BUFFERSIZE = GST_EVENT_MAKE_TYPE (9, 3, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
GST_EVENT_SINK_MESSAGE = GST_EVENT_MAKE_TYPE (10, 4, FLAG(DOWNSTREAM) | FLAG(SERIALIZED) | FLAG(STICKY)),
/* upstream events */
GST_EVENT_QOS = GST_EVENT_MAKE_TYPE (15, 0, FLAG(UPSTREAM)),
GST_EVENT_SEEK = GST_EVENT_MAKE_TYPE (16, 0, FLAG(UPSTREAM)),
@ -452,6 +453,10 @@ GstEvent * gst_event_new_flush_stop (void);
/* EOS event */
GstEvent * gst_event_new_eos (void);
/* Caps events */
GstEvent * gst_event_new_caps (GstCaps *caps);
void gst_event_parse_caps (GstEvent *event, GstCaps **caps);
/* newsegment events */
GstEvent* gst_event_new_new_segment (gboolean update, gdouble rate,
GstFormat format,

View file

@ -52,7 +52,7 @@ static const gchar *_quark_strings[] = {
"quality", "processed", "dropped", "buffering-ranges", "GstMessageProgress",
"code", "text", "percent", "timeout", "GstBufferPoolConfig", "caps", "size",
"min-buffers", "max-buffers", "prefix", "postfix", "align", "time",
"GstQueryAllocation", "need-pool", "meta", "pool"
"GstQueryAllocation", "need-pool", "meta", "pool", "GstEventCaps"
};
GQuark _priv_gst_quark_table[GST_QUARK_MAX];

View file

@ -145,8 +145,9 @@ typedef enum _GstQuarkId
GST_QUARK_NEED_POOL = 116,
GST_QUARK_META = 117,
GST_QUARK_POOL = 118,
GST_QUARK_EVENT_CAPS = 119,
GST_QUARK_MAX = 119
GST_QUARK_MAX = 120
} GstQuarkId;
extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];