audioencoder: Rename ::event() to ::sink_event() and add ::src_event()

This commit is contained in:
Sebastian Dröge 2012-03-30 12:15:27 +02:00
parent d8cb235fe4
commit f791ec1f10
2 changed files with 56 additions and 8 deletions

View file

@ -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

View file

@ -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);