From f791ec1f10500fa6806506f0cd27ca1821cf7d3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 30 Mar 2012 12:15:27 +0200 Subject: [PATCH] audioencoder: Rename ::event() to ::sink_event() and add ::src_event() --- gst-libs/gst/audio/gstaudioencoder.c | 49 ++++++++++++++++++++++++++-- gst-libs/gst/audio/gstaudioencoder.h | 15 ++++++--- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/gst-libs/gst/audio/gstaudioencoder.c b/gst-libs/gst/audio/gstaudioencoder.c index 95bd949d43..645ca44548 100644 --- a/gst-libs/gst/audio/gstaudioencoder.c +++ b/gst-libs/gst/audio/gstaudioencoder.c @@ -305,8 +305,12 @@ static GstCaps *gst_audio_encoder_getcaps_default (GstAudioEncoder * enc, static gboolean gst_audio_encoder_sink_event_default (GstAudioEncoder * enc, GstEvent * event); +static gboolean gst_audio_encoder_src_event_default (GstAudioEncoder * enc, + GstEvent * event); static gboolean gst_audio_encoder_sink_event (GstPad * pad, GstObject * parent, GstEvent * event); +static gboolean gst_audio_encoder_src_event (GstPad * pad, GstObject * parent, + GstEvent * event); static gboolean gst_audio_encoder_sink_setcaps (GstAudioEncoder * enc, GstCaps * caps); static GstFlowReturn gst_audio_encoder_chain (GstPad * pad, GstObject * parent, @@ -361,7 +365,8 @@ gst_audio_encoder_class_init (GstAudioEncoderClass * klass) GST_DEBUG_FUNCPTR (gst_audio_encoder_change_state); klass->getcaps = gst_audio_encoder_getcaps_default; - klass->event = gst_audio_encoder_sink_event_default; + klass->sink_event = gst_audio_encoder_sink_event_default; + klass->src_event = gst_audio_encoder_src_event_default; } static void @@ -395,6 +400,8 @@ gst_audio_encoder_init (GstAudioEncoder * enc, GstAudioEncoderClass * bclass) gst_element_class_get_pad_template (GST_ELEMENT_CLASS (bclass), "src"); g_return_if_fail (pad_template != NULL); enc->srcpad = gst_pad_new_from_template (pad_template, "src"); + gst_pad_set_event_function (enc->srcpad, + GST_DEBUG_FUNCPTR (gst_audio_encoder_src_event)); gst_pad_set_query_function (enc->srcpad, GST_DEBUG_FUNCPTR (gst_audio_encoder_src_query)); gst_pad_use_fixed_caps (enc->srcpad); @@ -1438,8 +1445,8 @@ gst_audio_encoder_sink_event (GstPad * pad, GstObject * parent, GST_DEBUG_OBJECT (enc, "received event %d, %s", GST_EVENT_TYPE (event), GST_EVENT_TYPE_NAME (event)); - if (klass->event) - ret = klass->event (enc, event); + if (klass->sink_event) + ret = klass->sink_event (enc, event); else { gst_event_unref (event); ret = FALSE; @@ -1505,6 +1512,42 @@ error: return res; } +static gboolean +gst_audio_encoder_src_event_default (GstAudioEncoder * enc, GstEvent * event) +{ + gboolean res; + + switch (GST_EVENT_TYPE (event)) { + default: + res = gst_pad_event_default (enc->srcpad, GST_OBJECT_CAST (enc), event); + break; + } + return res; +} + +static gboolean +gst_audio_encoder_src_event (GstPad * pad, GstObject * parent, GstEvent * event) +{ + GstAudioEncoder *enc; + GstAudioEncoderClass *klass; + gboolean ret; + + enc = GST_AUDIO_ENCODER (parent); + klass = GST_AUDIO_ENCODER_GET_CLASS (enc); + + GST_DEBUG_OBJECT (enc, "received event %d, %s", GST_EVENT_TYPE (event), + GST_EVENT_TYPE_NAME (event)); + + if (klass->src_event) + ret = klass->src_event (enc, event); + else { + gst_event_unref (event); + ret = FALSE; + } + + return ret; +} + /* * gst_audio_encoded_audio_convert: * @fmt: audio format of the encoded audio diff --git a/gst-libs/gst/audio/gstaudioencoder.h b/gst-libs/gst/audio/gstaudioencoder.h index a154eb57c5..fca74f6acf 100644 --- a/gst-libs/gst/audio/gstaudioencoder.h +++ b/gst-libs/gst/audio/gstaudioencoder.h @@ -139,10 +139,12 @@ struct _GstAudioEncoder { * @flush: Optional. * Instructs subclass to clear any codec caches and discard * any pending samples and not yet returned encoded data. - * @event: Optional. - * Event handler on the sink pad. This function should return - * TRUE if the event was handled and should be discarded - * (i.e. not unref'ed). + * @sink_event: Optional. + * Event handler on the sink pad. Subclasses should chain up to + * the parent implementation to invoke the default handler. + * @src_event: Optional. + * Event handler on the src pad. Subclasses should chain up to + * the parent implementation to invoke the default handler. * @pre_push: Optional. * Called just prior to pushing (encoded data) buffer downstream. * Subclass has full discretionary access to buffer, @@ -185,7 +187,10 @@ struct _GstAudioEncoderClass { GstFlowReturn (*pre_push) (GstAudioEncoder *enc, GstBuffer **buffer); - gboolean (*event) (GstAudioEncoder *enc, + gboolean (*sink_event) (GstAudioEncoder *enc, + GstEvent *event); + + gboolean (*src_event) (GstAudioEncoder *enc, GstEvent *event); GstCaps * (*getcaps) (GstAudioEncoder *enc, GstCaps *filter);