audiodecoder: Add negotiate vfunc that is used to negotiate with downstream

The default implementation negotiates a buffer pool and allocator
with downstream.
This commit is contained in:
Sebastian Dröge 2012-08-09 15:07:18 +02:00
parent e1702d62a0
commit 513d4f7cd1
2 changed files with 37 additions and 14 deletions

View file

@ -308,6 +308,7 @@ static gboolean gst_audio_decoder_decide_allocation_default (GstAudioDecoder *
dec, GstQuery * query);
static gboolean gst_audio_decoder_propose_allocation_default (GstAudioDecoder *
dec, GstQuery * query);
static gboolean gst_audio_decoder_negotiate_default (GstAudioDecoder * dec);
static GstElementClass *parent_class = NULL;
@ -393,6 +394,8 @@ gst_audio_decoder_class_init (GstAudioDecoderClass * klass)
GST_DEBUG_FUNCPTR (gst_audio_decoder_propose_allocation_default);
audiodecoder_class->decide_allocation =
GST_DEBUG_FUNCPTR (gst_audio_decoder_decide_allocation_default);
audiodecoder_class->negotiate =
GST_DEBUG_FUNCPTR (gst_audio_decoder_negotiate_default);
}
static void
@ -524,16 +527,8 @@ gst_audio_decoder_finalize (GObject * object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
/**
* gst_audio_decoder_negotiate:
* @dec: a #GstAudioDecoder
*
* Negotiate with downstreame elements to currently configured #GstAudioInfo.
*
* Returns: #TRUE if the negotiation succeeded, else #FALSE.
*/
gboolean
gst_audio_decoder_negotiate (GstAudioDecoder * dec)
static gboolean
gst_audio_decoder_negotiate_default (GstAudioDecoder * dec)
{
GstAudioDecoderClass *klass;
gboolean res = TRUE;
@ -547,8 +542,6 @@ gst_audio_decoder_negotiate (GstAudioDecoder * dec)
klass = GST_AUDIO_DECODER_GET_CLASS (dec);
GST_AUDIO_DECODER_STREAM_LOCK (dec);
GST_DEBUG_OBJECT (dec, "setting src caps %" GST_PTR_FORMAT, caps);
caps = gst_audio_info_to_caps (&dec->priv->ctx.info);
@ -587,7 +580,6 @@ gst_audio_decoder_negotiate (GstAudioDecoder * dec)
dec->priv->ctx.params = params;
done:
GST_AUDIO_DECODER_STREAM_UNLOCK (dec);
if (query)
gst_query_unref (query);
@ -603,6 +595,32 @@ no_decide_allocation:
}
}
/**
* gst_audio_decoder_negotiate:
* @dec: a #GstAudioDecoder
*
* Negotiate with downstreame elements to currently configured #GstAudioInfo.
*
* Returns: #TRUE if the negotiation succeeded, else #FALSE.
*/
gboolean
gst_audio_decoder_negotiate (GstAudioDecoder * dec)
{
GstAudioDecoderClass *klass;
gboolean res = TRUE;
g_return_val_if_fail (GST_IS_AUDIO_DECODER (dec), FALSE);
klass = GST_AUDIO_DECODER_GET_CLASS (dec);
GST_AUDIO_DECODER_STREAM_LOCK (dec);
if (klass->negotiate)
res = klass->negotiate (dec);
GST_AUDIO_DECODER_STREAM_UNLOCK (dec);
return res;
}
/**
* gst_audio_decoder_set_output_format:
* @dec: a #GstAudioDecoder
@ -660,7 +678,8 @@ gst_audio_decoder_set_output_format (GstAudioDecoder * dec,
done:
GST_AUDIO_DECODER_STREAM_UNLOCK (dec);
gst_caps_unref (caps);
if (caps)
gst_caps_unref (caps);
return res;

View file

@ -213,6 +213,8 @@ struct _GstAudioDecoder
* @close: Optional.
* Called when the element changes to GST_STATE_NULL.
* Allows closing external resources.
* @negotiate: Optional.
* Negotiate with downstream and configure buffer pools, etc.
* @decide_allocation: Optional.
* Setup the allocation parameters for allocating output
* buffers. The passed in query contains the result of the
@ -259,6 +261,8 @@ struct _GstAudioDecoderClass
gboolean (*close) (GstAudioDecoder *dec);
gboolean (*negotiate) (GstAudioDecoder *dec);
gboolean (*decide_allocation) (GstAudioDecoder *dec, GstQuery *query);
gboolean (*propose_allocation) (GstAudioDecoder *dec,