mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-23 06:26:23 +00:00
audioencoder: add src and sink query methods
Allows subclasses to do their own handling of GstQuery and still chain up to the parent class to handle the ones that they don't want to handle
This commit is contained in:
parent
7fc856ff5c
commit
5a0bee3f13
2 changed files with 70 additions and 12 deletions
|
@ -347,6 +347,11 @@ static gboolean gst_audio_encoder_negotiate_unlocked (GstAudioEncoder * enc);
|
|||
static gboolean gst_audio_encoder_transform_meta_default (GstAudioEncoder *
|
||||
encoder, GstBuffer * outbuf, GstMeta * meta, GstBuffer * inbuf);
|
||||
|
||||
static gboolean gst_audio_encoder_sink_query_default (GstAudioEncoder * encoder,
|
||||
GstQuery * query);
|
||||
static gboolean gst_audio_encoder_src_query_default (GstAudioEncoder * encoder,
|
||||
GstQuery * query);
|
||||
|
||||
static void
|
||||
gst_audio_encoder_class_init (GstAudioEncoderClass * klass)
|
||||
{
|
||||
|
@ -392,6 +397,8 @@ gst_audio_encoder_class_init (GstAudioEncoderClass * klass)
|
|||
klass->getcaps = gst_audio_encoder_getcaps_default;
|
||||
klass->sink_event = gst_audio_encoder_sink_event_default;
|
||||
klass->src_event = gst_audio_encoder_src_event_default;
|
||||
klass->sink_query = gst_audio_encoder_sink_query_default;
|
||||
klass->src_query = gst_audio_encoder_src_query_default;
|
||||
klass->propose_allocation = gst_audio_encoder_propose_allocation_default;
|
||||
klass->decide_allocation = gst_audio_encoder_decide_allocation_default;
|
||||
klass->negotiate = gst_audio_encoder_negotiate_default;
|
||||
|
@ -1630,13 +1637,10 @@ gst_audio_encoder_sink_event (GstPad * pad, GstObject * parent,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_audio_encoder_sink_query (GstPad * pad, GstObject * parent,
|
||||
GstQuery * query)
|
||||
gst_audio_encoder_sink_query_default (GstAudioEncoder * enc, GstQuery * query)
|
||||
{
|
||||
GstPad *pad = GST_AUDIO_ENCODER_SINK_PAD (enc);
|
||||
gboolean res = FALSE;
|
||||
GstAudioEncoder *enc;
|
||||
|
||||
enc = GST_AUDIO_ENCODER (parent);
|
||||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_FORMATS:
|
||||
|
@ -1684,7 +1688,7 @@ gst_audio_encoder_sink_query (GstPad * pad, GstObject * parent,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
res = gst_pad_query_default (pad, parent, query);
|
||||
res = gst_pad_query_default (pad, GST_OBJECT (enc), query);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1692,6 +1696,26 @@ error:
|
|||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_audio_encoder_sink_query (GstPad * pad, GstObject * parent,
|
||||
GstQuery * query)
|
||||
{
|
||||
GstAudioEncoder *encoder;
|
||||
GstAudioEncoderClass *encoder_class;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
encoder = GST_AUDIO_ENCODER (parent);
|
||||
encoder_class = GST_AUDIO_ENCODER_GET_CLASS (encoder);
|
||||
|
||||
GST_DEBUG_OBJECT (encoder, "received query %d, %s", GST_QUERY_TYPE (query),
|
||||
GST_QUERY_TYPE_NAME (query));
|
||||
|
||||
if (encoder_class->sink_query)
|
||||
ret = encoder_class->sink_query (encoder, query);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_audio_encoder_src_event_default (GstAudioEncoder * enc, GstEvent * event)
|
||||
{
|
||||
|
@ -1841,13 +1865,11 @@ exit:
|
|||
* segment stuff etc at all
|
||||
* Supposedly that's backward compatibility ... */
|
||||
static gboolean
|
||||
gst_audio_encoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||
gst_audio_encoder_src_query_default (GstAudioEncoder * enc, GstQuery * query)
|
||||
{
|
||||
GstAudioEncoder *enc;
|
||||
GstPad *pad = GST_AUDIO_ENCODER_SRC_PAD (enc);
|
||||
gboolean res = FALSE;
|
||||
|
||||
enc = GST_AUDIO_ENCODER (parent);
|
||||
|
||||
GST_LOG_OBJECT (enc, "handling query: %" GST_PTR_FORMAT, query);
|
||||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
|
@ -1939,13 +1961,33 @@ gst_audio_encoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
res = gst_pad_query_default (pad, parent, query);
|
||||
res = gst_pad_query_default (pad, GST_OBJECT (enc), query);
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_audio_encoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||
{
|
||||
GstAudioEncoder *encoder;
|
||||
GstAudioEncoderClass *encoder_class;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
encoder = GST_AUDIO_ENCODER (parent);
|
||||
encoder_class = GST_AUDIO_ENCODER_GET_CLASS (encoder);
|
||||
|
||||
GST_DEBUG_OBJECT (encoder, "received query %d, %s", GST_QUERY_TYPE (query),
|
||||
GST_QUERY_TYPE_NAME (query));
|
||||
|
||||
if (encoder_class->src_query)
|
||||
ret = encoder_class->src_query (encoder, query);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gst_audio_encoder_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
|
|
|
@ -179,6 +179,16 @@ struct _GstAudioEncoder {
|
|||
* tags and meta with only the "audio" tag. subclasses can
|
||||
* implement this method and return %TRUE if the metadata is to be
|
||||
* copied. Since 1.6
|
||||
* @sink_query: Optional.
|
||||
* Query handler on the sink pad. This function should
|
||||
* return TRUE if the query could be performed. Subclasses
|
||||
* should chain up to the parent implementation to invoke the
|
||||
* default handler. Since 1.6
|
||||
* @src_query: Optional.
|
||||
* Query handler on the source pad. This function should
|
||||
* return TRUE if the query could be performed. Subclasses
|
||||
* should chain up to the parent implementation to invoke the
|
||||
* default handler. Since 1.6
|
||||
*
|
||||
* Subclasses can override any of the available virtual methods or not, as
|
||||
* needed. At minimum @set_format and @handle_frame needs to be overridden.
|
||||
|
@ -226,9 +236,15 @@ struct _GstAudioEncoderClass {
|
|||
gboolean (*transform_meta) (GstAudioEncoder *enc, GstBuffer *outbuf,
|
||||
GstMeta *meta, GstBuffer *inbuf);
|
||||
|
||||
gboolean (*sink_query) (GstAudioEncoder *encoder,
|
||||
GstQuery *query);
|
||||
|
||||
gboolean (*src_query) (GstAudioEncoder *encoder,
|
||||
GstQuery *query);
|
||||
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE-1];
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE-3];
|
||||
};
|
||||
|
||||
GType gst_audio_encoder_get_type (void);
|
||||
|
|
Loading…
Reference in a new issue