-/* GStreamer
+/* GStreamer aggregator base class
* Copyright (C) 2014 Mathieu Duponchelle <mathieu.duponchelle@opencreed.com>
* Copyright (C) 2014 Thibault Saunier <tsaunier@gnome.org>
*
};
static gboolean
-_aggpad_flush (GstAggregatorPad * aggpad, GstAggregator * agg)
+gst_aggregator_pad_flush (GstAggregatorPad * aggpad, GstAggregator * agg)
{
GstAggregatorPadClass *klass = GST_AGGREGATOR_PAD_GET_CLASS (aggpad);
}
static void
-_reset_flow_values (GstAggregator * self)
+gst_aggregator_reset_flow_values (GstAggregator * self)
{
self->priv->flow_return = GST_FLOW_FLUSHING;
self->priv->send_stream_start = TRUE;
}
static inline void
-_push_mandatory_events (GstAggregator * self)
+gst_aggregator_push_mandatory_events (GstAggregator * self)
{
GstAggregatorPrivate *priv = self->priv;
{
GST_AGGREGATOR_SETCAPS_LOCK (self);
gst_caps_replace (&self->priv->srccaps, caps);
- _push_mandatory_events (self);
+ gst_aggregator_push_mandatory_events (self);
GST_AGGREGATOR_SETCAPS_UNLOCK (self);
}
GstFlowReturn
gst_aggregator_finish_buffer (GstAggregator * self, GstBuffer * buffer)
{
- _push_mandatory_events (self);
+ gst_aggregator_push_mandatory_events (self);
if (!g_atomic_int_get (&self->priv->flush_seeking) &&
gst_pad_is_active (self->srcpad)) {
}
static void
-_push_eos (GstAggregator * self)
+gst_aggregator_push_eos (GstAggregator * self)
{
GstEvent *event;
- _push_mandatory_events (self);
+ gst_aggregator_push_mandatory_events (self);
self->priv->send_eos = FALSE;
event = gst_event_new_eos ();
/* called with the src STREAM lock */
static gboolean
-_wait_and_check (GstAggregator * self, gboolean * timeout)
+gst_aggregator_wait_and_check (GstAggregator * self, gboolean * timeout)
{
GstClockTime latency_max, latency_min;
GstClockTime start;
}
static void
-aggregate_func (GstAggregator * self)
+gst_aggregator_aggregate_func (GstAggregator * self)
{
GstAggregatorPrivate *priv = self->priv;
GstAggregatorClass *klass = GST_AGGREGATOR_GET_CLASS (self);
GST_LOG_OBJECT (self, "Checking aggregate");
while (priv->send_eos && priv->running) {
- if (!_wait_and_check (self, &timeout))
+ if (!gst_aggregator_wait_and_check (self, &timeout))
continue;
GST_TRACE_OBJECT (self, "Actually aggregating!");
priv->flow_return = klass->aggregate (self, timeout);
if (priv->flow_return == GST_FLOW_EOS) {
- _push_eos (self);
+ gst_aggregator_push_eos (self);
}
if (priv->flow_return == GST_FLOW_FLUSHING &&
}
static gboolean
-_stop_srcpad_task (GstAggregator * self, GstEvent * flush_start)
+gst_aggregator_stop_srcpad_task (GstAggregator * self, GstEvent * flush_start)
{
gboolean res = TRUE;
}
static void
-_start_srcpad_task (GstAggregator * self)
+gst_aggregator_start_srcpad_task (GstAggregator * self)
{
GST_INFO_OBJECT (self, "Starting srcpad task");
self->priv->running = TRUE;
gst_pad_start_task (GST_PAD (self->srcpad),
- (GstTaskFunction) aggregate_func, self, NULL);
+ (GstTaskFunction) gst_aggregator_aggregate_func, self, NULL);
}
static GstFlowReturn
-_flush (GstAggregator * self)
+gst_aggregator_flush (GstAggregator * self)
{
GstFlowReturn ret = GST_FLOW_OK;
GstAggregatorPrivate *priv = self->priv;
}
static gboolean
-_all_flush_stop_received (GstAggregator * self)
+gst_aggregator_all_flush_stop_received (GstAggregator * self)
{
GList *tmp;
GstAggregatorPad *tmppad;
}
static void
-_flush_start (GstAggregator * self, GstAggregatorPad * aggpad, GstEvent * event)
+gst_aggregator_flush_start (GstAggregator * self, GstAggregatorPad * aggpad,
+ GstEvent * event)
{
GstBuffer *tmpbuf;
GstAggregatorPrivate *priv = self->priv;
TRUE, FALSE) == TRUE) {
GST_INFO_OBJECT (self, "Flushing, pausing srcpad task");
- _stop_srcpad_task (self, event);
+ gst_aggregator_stop_srcpad_task (self, event);
priv->flow_return = GST_FLOW_OK;
GST_INFO_OBJECT (self, "Getting STREAM_LOCK while seeking");
/* GstAggregator vmethods default implementations */
static gboolean
-_sink_event (GstAggregator * self, GstAggregatorPad * aggpad, GstEvent * event)
+gst_aggregator_default_sink_event (GstAggregator * self,
+ GstAggregatorPad * aggpad, GstEvent * event)
{
gboolean res = TRUE;
GstPad *pad = GST_PAD (aggpad);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_START:
{
- _flush_start (self, aggpad, event);
+ gst_aggregator_flush_start (self, aggpad, event);
/* We forward only in one case: right after flush_seeking */
event = NULL;
goto eat;
{
GST_DEBUG_OBJECT (aggpad, "Got FLUSH_STOP");
- _aggpad_flush (aggpad, self);
+ gst_aggregator_pad_flush (aggpad, self);
if (g_atomic_int_get (&priv->flush_seeking)) {
g_atomic_int_set (&aggpad->priv->pending_flush_stop, FALSE);
if (g_atomic_int_get (&priv->flush_seeking)) {
- if (_all_flush_stop_received (self)) {
+ if (gst_aggregator_all_flush_stop_received (self)) {
/* That means we received FLUSH_STOP/FLUSH_STOP on
* all sinkpads -- Seeking is Done... sending FLUSH_STOP */
- _flush (self);
+ gst_aggregator_flush (self);
gst_pad_push_event (self->srcpad, event);
priv->send_eos = TRUE;
event = NULL;
GST_INFO_OBJECT (self, "Releasing source pad STREAM_LOCK");
GST_PAD_STREAM_UNLOCK (self->srcpad);
- _start_srcpad_task (self);
+ gst_aggregator_start_srcpad_task (self);
}
}
}
gst_aggregator_stop_pad (GstAggregator * self, GstAggregatorPad * pad,
gpointer unused_udata)
{
- _aggpad_flush (pad, self);
+ gst_aggregator_pad_flush (pad, self);
return TRUE;
}
GstAggregatorClass *klass;
gboolean result;
- _reset_flow_values (agg);
+ gst_aggregator_reset_flow_values (agg);
gst_aggregator_iterate_sinkpads (agg, gst_aggregator_stop_pad, NULL);
/* GstElement vmethods implementations */
static GstStateChangeReturn
-_change_state (GstElement * element, GstStateChange transition)
+gst_aggregator_change_state (GstElement * element, GstStateChange transition)
{
GstStateChangeReturn ret;
GstAggregator *self = GST_AGGREGATOR (element);
}
static void
-_release_pad (GstElement * element, GstPad * pad)
+gst_aggregator_release_pad (GstElement * element, GstPad * pad)
{
GstAggregator *self = GST_AGGREGATOR (element);
GstBuffer *tmpbuf;
}
static GstPad *
-_request_new_pad (GstElement * element,
+gst_aggregator_request_new_pad (GstElement * element,
GstPadTemplate * templ, const gchar * req_name, const GstCaps * caps)
{
GstAggregator *self;
} LatencyData;
static gboolean
-_latency_query (GstAggregator * self, GstPad * pad, gpointer user_data)
+gst_aggregator_query_sink_latency_foreach (GstAggregator * self,
+ GstAggregatorPad * pad, gpointer user_data)
{
LatencyData *data = user_data;
GstClockTime min, max;
gboolean live, res;
query = gst_query_new_latency ();
- res = gst_pad_peer_query (pad, query);
+ res = gst_pad_peer_query (GST_PAD_CAST (pad), query);
if (res) {
gst_query_parse_latency (query, &live, &min, &max);
/* query upstream's latency */
SRC_STREAM_LOCK (self);
gst_aggregator_iterate_sinkpads (self,
- (GstAggregatorPadForeachFunc) _latency_query, &data);
+ gst_aggregator_query_sink_latency_foreach, &data);
SRC_STREAM_UNLOCK (self);
if (data.live && GST_CLOCK_TIME_IS_VALID (self->latency) &&
}
static gboolean
-_send_event (GstElement * element, GstEvent * event)
+gst_aggregator_send_event (GstElement * element, GstEvent * event)
{
GstAggregator *self = GST_AGGREGATOR (element);
}
static gboolean
-_src_query (GstAggregator * self, GstQuery * query)
+gst_aggregator_default_src_query (GstAggregator * self, GstQuery * query)
{
gboolean res = TRUE;
}
static gboolean
-event_forward_func (GstPad * pad, EventData * evdata)
+gst_aggregator_event_forward_func (GstPad * pad, gpointer user_data)
{
+ EventData *evdata = user_data;
gboolean ret = TRUE;
GstPad *peer = gst_pad_get_peer (pad);
GstAggregatorPadPrivate *padpriv = GST_AGGREGATOR_PAD (pad)->priv;
}
static gboolean
-_set_flush_pending (GstAggregator * self, GstAggregatorPad * pad,
+gst_aggregator_set_flush_pending (GstAggregator * self, GstAggregatorPad * pad,
gpointer udata)
{
pad->priv->pending_flush_start = TRUE;
}
static EventData
-_forward_event_to_all_sinkpads (GstAggregator * self, GstEvent * event,
- gboolean flush)
+gst_aggregator_forward_event_to_all_sinkpads (GstAggregator * self,
+ GstEvent * event, gboolean flush)
{
EventData evdata;
* while we send the seek event */
if (flush)
gst_aggregator_iterate_sinkpads (self,
- (GstAggregatorPadForeachFunc) _set_flush_pending, NULL);
- gst_pad_forward (self->srcpad, (GstPadForwardFunction) event_forward_func,
- &evdata);
+ gst_aggregator_set_flush_pending, NULL);
+
+ gst_pad_forward (self->srcpad, gst_aggregator_event_forward_func, &evdata);
gst_event_unref (event);
}
static gboolean
-_do_seek (GstAggregator * self, GstEvent * event)
+gst_aggregator_do_seek (GstAggregator * self, GstEvent * event)
{
gdouble rate;
GstFormat fmt;
stop_type, stop, NULL);
/* forward the seek upstream */
- evdata = _forward_event_to_all_sinkpads (self, event, flush);
+ evdata = gst_aggregator_forward_event_to_all_sinkpads (self, event, flush);
event = NULL;
if (!evdata.result || !evdata.one_actually_seeked) {
}
static gboolean
-_src_event (GstAggregator * self, GstEvent * event)
+gst_aggregator_default_src_event (GstAggregator * self, GstEvent * event)
{
EventData evdata;
gboolean res = TRUE;
case GST_EVENT_SEEK:
{
gst_event_ref (event);
- res = _do_seek (self, event);
+ res = gst_aggregator_do_seek (self, event);
gst_event_unref (event);
event = NULL;
goto done;
}
}
- evdata = _forward_event_to_all_sinkpads (self, event, FALSE);
+ evdata = gst_aggregator_forward_event_to_all_sinkpads (self, event, FALSE);
res = evdata.result;
done:
}
static gboolean
-src_event_func (GstPad * pad, GstObject * parent, GstEvent * event)
+gst_aggregator_src_pad_event_func (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstAggregatorClass *klass = GST_AGGREGATOR_GET_CLASS (parent);
}
static gboolean
-src_query_func (GstPad * pad, GstObject * parent, GstQuery * query)
+gst_aggregator_src_pad_query_func (GstPad * pad, GstObject * parent,
+ GstQuery * query)
{
GstAggregatorClass *klass = GST_AGGREGATOR_GET_CLASS (parent);
}
static gboolean
-src_activate_mode (GstPad * pad,
+gst_aggregator_src_pad_activate_mode_func (GstPad * pad,
GstObject * parent, GstPadMode mode, gboolean active)
{
GstAggregator *self = GST_AGGREGATOR (parent);
case GST_PAD_MODE_PUSH:
{
GST_INFO_OBJECT (pad, "Activating pad!");
- _start_srcpad_task (self);
+ gst_aggregator_start_srcpad_task (self);
return TRUE;
}
default:
/* deactivating */
GST_INFO_OBJECT (self, "Deactivating srcpad");
- _stop_srcpad_task (self, FALSE);
+ gst_aggregator_stop_srcpad_task (self, FALSE);
return TRUE;
}
static gboolean
-_sink_query (GstAggregator * self, GstAggregatorPad * aggpad, GstQuery * query)
+gst_aggregator_default_sink_query (GstAggregator * self,
+ GstAggregatorPad * aggpad, GstQuery * query)
{
GstPad *pad = GST_PAD (aggpad);
klass->sinkpads_type = GST_TYPE_AGGREGATOR_PAD;
- klass->sink_event = _sink_event;
- klass->sink_query = _sink_query;
+ klass->sink_event = gst_aggregator_default_sink_event;
+ klass->sink_query = gst_aggregator_default_sink_query;
- klass->src_event = _src_event;
- klass->src_query = _src_query;
+ klass->src_event = gst_aggregator_default_src_event;
+ klass->src_query = gst_aggregator_default_src_query;
- gstelement_class->request_new_pad = GST_DEBUG_FUNCPTR (_request_new_pad);
- gstelement_class->send_event = GST_DEBUG_FUNCPTR (_send_event);
- gstelement_class->release_pad = GST_DEBUG_FUNCPTR (_release_pad);
- gstelement_class->change_state = GST_DEBUG_FUNCPTR (_change_state);
+ gstelement_class->request_new_pad =
+ GST_DEBUG_FUNCPTR (gst_aggregator_request_new_pad);
+ gstelement_class->send_event = GST_DEBUG_FUNCPTR (gst_aggregator_send_event);
+ gstelement_class->release_pad =
+ GST_DEBUG_FUNCPTR (gst_aggregator_release_pad);
+ gstelement_class->change_state =
+ GST_DEBUG_FUNCPTR (gst_aggregator_change_state);
gobject_class->set_property = gst_aggregator_set_property;
gobject_class->get_property = gst_aggregator_get_property;
self->priv->latency_live = FALSE;
self->priv->latency_min = self->priv->sub_latency_min = 0;
self->priv->latency_max = self->priv->sub_latency_max = GST_CLOCK_TIME_NONE;
- _reset_flow_values (self);
+ gst_aggregator_reset_flow_values (self);
self->srcpad = gst_pad_new_from_template (pad_template, "src");
gst_pad_set_event_function (self->srcpad,
- GST_DEBUG_FUNCPTR ((GstPadEventFunction) src_event_func));
+ GST_DEBUG_FUNCPTR (gst_aggregator_src_pad_event_func));
gst_pad_set_query_function (self->srcpad,
- GST_DEBUG_FUNCPTR ((GstPadQueryFunction) src_query_func));
+ GST_DEBUG_FUNCPTR (gst_aggregator_src_pad_query_func));
gst_pad_set_activatemode_function (self->srcpad,
- GST_DEBUG_FUNCPTR ((GstPadActivateModeFunction) src_activate_mode));
+ GST_DEBUG_FUNCPTR (gst_aggregator_src_pad_activate_mode_func));
gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
}
static GstFlowReturn
-_chain (GstPad * pad, GstObject * object, GstBuffer * buffer)
+gst_aggregator_pad_chain (GstPad * pad, GstObject * object, GstBuffer * buffer)
{
GstBuffer *actual_buf = buffer;
GstAggregator *self = GST_AGGREGATOR (object);
}
static gboolean
-pad_query_func (GstPad * pad, GstObject * parent, GstQuery * query)
+gst_aggregator_pad_query_func (GstPad * pad, GstObject * parent,
+ GstQuery * query)
{
GstAggregatorPad *aggpad = GST_AGGREGATOR_PAD (pad);
GstAggregatorClass *klass = GST_AGGREGATOR_GET_CLASS (parent);
}
static gboolean
-pad_event_func (GstPad * pad, GstObject * parent, GstEvent * event)
+gst_aggregator_pad_event_func (GstPad * pad, GstObject * parent,
+ GstEvent * event)
{
GstAggregatorPad *aggpad = GST_AGGREGATOR_PAD (pad);
GstAggregatorClass *klass = GST_AGGREGATOR_GET_CLASS (parent);
}
static gboolean
-pad_activate_mode_func (GstPad * pad,
+gst_aggregator_pad_activate_mode_func (GstPad * pad,
GstObject * parent, GstPadMode mode, gboolean active)
{
GstAggregatorPad *aggpad = GST_AGGREGATOR_PAD (pad);
GstPad *pad = GST_PAD (object);
gst_pad_set_chain_function (pad,
- GST_DEBUG_FUNCPTR ((GstPadChainFunction) _chain));
+ GST_DEBUG_FUNCPTR (gst_aggregator_pad_chain));
gst_pad_set_event_function (pad,
- GST_DEBUG_FUNCPTR ((GstPadEventFunction) pad_event_func));
+ GST_DEBUG_FUNCPTR (gst_aggregator_pad_event_func));
gst_pad_set_query_function (pad,
- GST_DEBUG_FUNCPTR ((GstPadQueryFunction) pad_query_func));
+ GST_DEBUG_FUNCPTR (gst_aggregator_pad_query_func));
gst_pad_set_activatemode_function (pad,
- GST_DEBUG_FUNCPTR ((GstPadActivateModeFunction) pad_activate_mode_func));
+ GST_DEBUG_FUNCPTR (gst_aggregator_pad_activate_mode_func));
}
static void