audiodecoder: Add sink and src query virtual method
API: GstAudioDecoderClass::src_query() API: GstAudioDecoderClass::sink_query() https://bugzilla.gnome.org/show_bug.cgi?id=747293
This commit is contained in:
parent
2891509ec4
commit
5dffb8a311
@ -383,6 +383,10 @@ static gboolean gst_audio_decoder_negotiate_default (GstAudioDecoder * dec);
|
||||
static gboolean gst_audio_decoder_negotiate_unlocked (GstAudioDecoder * dec);
|
||||
static gboolean gst_audio_decoder_handle_gap (GstAudioDecoder * dec,
|
||||
GstEvent * event);
|
||||
static gboolean gst_audio_decoder_sink_query_default (GstAudioDecoder * dec,
|
||||
GstQuery * query);
|
||||
static gboolean gst_audio_decoder_src_query_default (GstAudioDecoder * dec,
|
||||
GstQuery * query);
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
|
||||
@ -470,6 +474,10 @@ gst_audio_decoder_class_init (GstAudioDecoderClass * klass)
|
||||
GST_DEBUG_FUNCPTR (gst_audio_decoder_decide_allocation_default);
|
||||
audiodecoder_class->negotiate =
|
||||
GST_DEBUG_FUNCPTR (gst_audio_decoder_negotiate_default);
|
||||
audiodecoder_class->sink_query =
|
||||
GST_DEBUG_FUNCPTR (gst_audio_decoder_sink_query_default);
|
||||
audiodecoder_class->src_query =
|
||||
GST_DEBUG_FUNCPTR (gst_audio_decoder_src_query_default);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -2541,15 +2549,11 @@ gst_audio_decoder_sink_getcaps (GstAudioDecoder * decoder, GstCaps * filter)
|
||||
return caps;
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
gst_audio_decoder_sink_query (GstPad * pad, GstObject * parent,
|
||||
GstQuery * query)
|
||||
gst_audio_decoder_sink_query_default (GstAudioDecoder * dec, GstQuery * query)
|
||||
{
|
||||
GstPad *pad = GST_AUDIO_DECODER_SINK_PAD (dec);
|
||||
gboolean res = FALSE;
|
||||
GstAudioDecoder *dec;
|
||||
|
||||
dec = GST_AUDIO_DECODER (parent);
|
||||
|
||||
GST_LOG_OBJECT (dec, "handling query: %" GST_PTR_FORMAT, query);
|
||||
|
||||
@ -2630,7 +2634,7 @@ gst_audio_decoder_sink_query (GstPad * pad, GstObject * parent,
|
||||
/* fall-through */
|
||||
}
|
||||
default:
|
||||
res = gst_pad_query_default (pad, parent, query);
|
||||
res = gst_pad_query_default (pad, GST_OBJECT_CAST (dec), query);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -2638,18 +2642,35 @@ error:
|
||||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_audio_decoder_sink_query (GstPad * pad, GstObject * parent,
|
||||
GstQuery * query)
|
||||
{
|
||||
GstAudioDecoderClass *dec_class;
|
||||
GstAudioDecoder *dec;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
dec = GST_AUDIO_DECODER (parent);
|
||||
dec_class = GST_AUDIO_DECODER_GET_CLASS (dec);
|
||||
|
||||
GST_DEBUG_OBJECT (pad, "received query %" GST_PTR_FORMAT, query);
|
||||
|
||||
if (dec_class->sink_query)
|
||||
ret = dec_class->sink_query (dec, query);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* FIXME ? are any of these queries (other than latency) a decoder's business ??
|
||||
* also, the conversion stuff might seem to make sense, but seems to not mind
|
||||
* segment stuff etc at all
|
||||
* Supposedly that's backward compatibility ... */
|
||||
static gboolean
|
||||
gst_audio_decoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||
gst_audio_decoder_src_query_default (GstAudioDecoder * dec, GstQuery * query)
|
||||
{
|
||||
GstAudioDecoder *dec;
|
||||
GstPad *pad = GST_AUDIO_DECODER_SRC_PAD (dec);
|
||||
gboolean res = FALSE;
|
||||
|
||||
dec = GST_AUDIO_DECODER (parent);
|
||||
|
||||
GST_LOG_OBJECT (dec, "handling query: %" GST_PTR_FORMAT, query);
|
||||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
@ -2658,7 +2679,7 @@ gst_audio_decoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||
GstFormat format;
|
||||
|
||||
/* upstream in any case */
|
||||
if ((res = gst_pad_query_default (pad, parent, query)))
|
||||
if ((res = gst_pad_query_default (pad, GST_OBJECT_CAST (dec), query)))
|
||||
break;
|
||||
|
||||
gst_query_parse_duration (query, &format, NULL);
|
||||
@ -2755,13 +2776,31 @@ gst_audio_decoder_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_CAST (dec), query);
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_audio_decoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||
{
|
||||
GstAudioDecoder *dec;
|
||||
GstAudioDecoderClass *dec_class;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
dec = GST_AUDIO_DECODER (parent);
|
||||
dec_class = GST_AUDIO_DECODER_GET_CLASS (dec);
|
||||
|
||||
GST_DEBUG_OBJECT (pad, "received query %" GST_PTR_FORMAT, query);
|
||||
|
||||
if (dec_class->src_query)
|
||||
ret = dec_class->src_query (dec, query);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_audio_decoder_stop (GstAudioDecoder * dec)
|
||||
{
|
||||
|
@ -231,6 +231,16 @@ struct _GstAudioDecoder
|
||||
* Propose buffer allocation parameters for upstream elements.
|
||||
* Subclasses should chain up to the parent implementation to
|
||||
* invoke the default handler.
|
||||
* @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
|
||||
* @getcaps: Optional.
|
||||
* Allows for a custom sink getcaps implementation.
|
||||
* If not implemented,
|
||||
@ -283,11 +293,15 @@ struct _GstAudioDecoderClass
|
||||
gboolean (*propose_allocation) (GstAudioDecoder *dec,
|
||||
GstQuery * query);
|
||||
|
||||
gboolean (*sink_query) (GstAudioDecoder *dec, GstQuery *query);
|
||||
|
||||
gboolean (*src_query) (GstAudioDecoder *dec, GstQuery *query);
|
||||
|
||||
GstCaps * (*getcaps) (GstAudioDecoder * dec,
|
||||
GstCaps * filter);
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE - 1];
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE - 3];
|
||||
};
|
||||
|
||||
GType gst_audio_decoder_get_type (void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user