mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
audiodecoder: add method to set output caps
Add a method to configure the output caps. Subclasses can't use gst_pad_set_caps() anymore because then we won't see the caps. Unbreak the padtemplate registration, the GTypeClass that is configured in the object during _init is not the right one, we need to use the klass passed as the argument to the init function..
This commit is contained in:
parent
19346c2c3b
commit
19626cf27a
2 changed files with 49 additions and 8 deletions
|
@ -287,9 +287,38 @@ static gboolean gst_audio_decoder_sink_query (GstPad * pad, GstQuery * query);
|
||||||
static const GstQueryType *gst_audio_decoder_get_query_types (GstPad * pad);
|
static const GstQueryType *gst_audio_decoder_get_query_types (GstPad * pad);
|
||||||
static void gst_audio_decoder_reset (GstAudioDecoder * dec, gboolean full);
|
static void gst_audio_decoder_reset (GstAudioDecoder * dec, gboolean full);
|
||||||
|
|
||||||
|
static GstElementClass *parent_class = NULL;
|
||||||
|
|
||||||
|
static void gst_audio_decoder_class_init (GstAudioDecoderClass * klass);
|
||||||
|
static void gst_audio_decoder_init (GstAudioDecoder * dec,
|
||||||
|
GstAudioDecoderClass * klass);
|
||||||
|
|
||||||
|
GType
|
||||||
|
gst_audio_decoder_get_type (void)
|
||||||
|
{
|
||||||
|
static volatile gsize audio_decoder_type = 0;
|
||||||
|
|
||||||
|
if (g_once_init_enter (&audio_decoder_type)) {
|
||||||
|
GType _type;
|
||||||
|
static const GTypeInfo audio_decoder_info = {
|
||||||
|
sizeof (GstAudioDecoderClass),
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
(GClassInitFunc) gst_audio_decoder_class_init,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
sizeof (GstAudioDecoder),
|
||||||
|
0,
|
||||||
|
(GInstanceInitFunc) gst_audio_decoder_init,
|
||||||
|
};
|
||||||
|
|
||||||
|
_type = g_type_register_static (GST_TYPE_ELEMENT,
|
||||||
|
"GstAudioDecoder", &audio_decoder_info, G_TYPE_FLAG_ABSTRACT);
|
||||||
|
g_once_init_leave (&audio_decoder_type, _type);
|
||||||
|
}
|
||||||
|
return audio_decoder_type;
|
||||||
|
}
|
||||||
|
|
||||||
#define gst_audio_decoder_parent_class parent_class
|
|
||||||
G_DEFINE_TYPE (GstAudioDecoder, gst_audio_decoder, GST_TYPE_ELEMENT);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_audio_decoder_class_init (GstAudioDecoderClass * klass)
|
gst_audio_decoder_class_init (GstAudioDecoderClass * klass)
|
||||||
|
@ -333,9 +362,8 @@ gst_audio_decoder_class_init (GstAudioDecoderClass * klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_audio_decoder_init (GstAudioDecoder * dec)
|
gst_audio_decoder_init (GstAudioDecoder * dec, GstAudioDecoderClass * klass)
|
||||||
{
|
{
|
||||||
GstAudioDecoderClass *klass = GST_AUDIO_DECODER_GET_CLASS (dec);
|
|
||||||
GstPadTemplate *pad_template;
|
GstPadTemplate *pad_template;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (dec, "gst_audio_decoder_init");
|
GST_DEBUG_OBJECT (dec, "gst_audio_decoder_init");
|
||||||
|
@ -455,10 +483,18 @@ gst_audio_decoder_finalize (GObject * object)
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* automagically perform sanity checking of src caps;
|
/**
|
||||||
* also extracts output data format */
|
* gst_audio_decoder_set_outcaps:
|
||||||
|
* @dec: a #GstAudioDecoder
|
||||||
|
* @caps: #GstCaps
|
||||||
|
*
|
||||||
|
* Configure output @caps on the srcpad of @dec. Also perform
|
||||||
|
* sanity checking of @caps and extracts output data format
|
||||||
|
*
|
||||||
|
* Returns: %TRUE on success.
|
||||||
|
* */
|
||||||
gboolean
|
gboolean
|
||||||
gst_audio_decoder_src_setcaps (GstAudioDecoder * dec, GstCaps * caps)
|
gst_audio_decoder_set_outcaps (GstAudioDecoder * dec, GstCaps * caps)
|
||||||
{
|
{
|
||||||
gboolean res = TRUE;
|
gboolean res = TRUE;
|
||||||
guint old_rate;
|
guint old_rate;
|
||||||
|
@ -486,6 +522,8 @@ gst_audio_decoder_src_setcaps (GstAudioDecoder * dec, GstCaps * caps)
|
||||||
done:
|
done:
|
||||||
GST_AUDIO_DECODER_STREAM_UNLOCK (dec);
|
GST_AUDIO_DECODER_STREAM_UNLOCK (dec);
|
||||||
|
|
||||||
|
res = gst_pad_set_caps (dec->srcpad, caps);
|
||||||
|
|
||||||
gst_object_unref (dec);
|
gst_object_unref (dec);
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
@ -543,7 +581,7 @@ gst_audio_decoder_setup (GstAudioDecoder * dec)
|
||||||
gst_query_unref (query);
|
gst_query_unref (query);
|
||||||
|
|
||||||
/* normalize to bool */
|
/* normalize to bool */
|
||||||
dec->priv->agg = ! !res;
|
dec->priv->agg = !!res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* mini aggregator combining output buffers into fewer larger ones,
|
/* mini aggregator combining output buffers into fewer larger ones,
|
||||||
|
|
|
@ -234,6 +234,9 @@ struct _GstAudioDecoderClass
|
||||||
|
|
||||||
GType gst_audio_decoder_get_type (void);
|
GType gst_audio_decoder_get_type (void);
|
||||||
|
|
||||||
|
gboolean gst_audio_decoder_set_outcaps (GstAudioDecoder * dec,
|
||||||
|
GstCaps * caps);
|
||||||
|
|
||||||
GstFlowReturn gst_audio_decoder_finish_frame (GstAudioDecoder * dec,
|
GstFlowReturn gst_audio_decoder_finish_frame (GstAudioDecoder * dec,
|
||||||
GstBuffer * buf, gint frames);
|
GstBuffer * buf, gint frames);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue