Commit 513d4f7c authored by Sebastian Dröge's avatar Sebastian Dröge

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

The default implementation negotiates a buffer pool and allocator
with downstream.
parent e1702d62
......@@ -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;
......
......@@ -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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment