Commit bc4d9239 authored by Sebastian Dröge's avatar Sebastian Dröge

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

The default implementation negotiates a buffer pool and allocator
with downstream.
parent 93092723
......@@ -335,6 +335,7 @@ static gboolean gst_audio_encoder_decide_allocation_default (GstAudioEncoder *
enc, GstQuery * query);
static gboolean gst_audio_encoder_propose_allocation_default (GstAudioEncoder *
enc, GstQuery * query);
static gboolean gst_audio_encoder_negotiate_default (GstAudioEncoder * enc);
static void
gst_audio_encoder_class_init (GstAudioEncoderClass * klass)
......@@ -383,6 +384,7 @@ gst_audio_encoder_class_init (GstAudioEncoderClass * klass)
klass->src_event = gst_audio_encoder_src_event_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;
}
static void
......@@ -2510,16 +2512,8 @@ gst_audio_encoder_merge_tags (GstAudioEncoder * enc,
GST_OBJECT_UNLOCK (enc);
}
/**
* gst_audio_encoder_negotiate:
* @dec: a #GstAudioEncoder
*
* Negotiate with downstreame elements to currently configured #GstCaps.
*
* Returns: #TRUE if the negotiation succeeded, else #FALSE.
*/
gboolean
gst_audio_encoder_negotiate (GstAudioEncoder * enc)
static gboolean
gst_audio_encoder_negotiate_default (GstAudioEncoder * enc)
{
GstAudioEncoderClass *klass;
gboolean res = FALSE;
......@@ -2533,8 +2527,6 @@ gst_audio_encoder_negotiate (GstAudioEncoder * enc)
klass = GST_AUDIO_ENCODER_GET_CLASS (enc);
GST_AUDIO_ENCODER_STREAM_LOCK (enc);
caps = enc->priv->ctx.caps;
GST_DEBUG_OBJECT (enc, "Setting srcpad caps %" GST_PTR_FORMAT, caps);
......@@ -2576,8 +2568,6 @@ done:
if (query)
gst_query_unref (query);
GST_AUDIO_ENCODER_STREAM_UNLOCK (enc);
return res;
/* ERRORS */
......@@ -2588,6 +2578,32 @@ no_decide_allocation:
}
}
/**
* gst_audio_encoder_negotiate:
* @dec: a #GstAudioEncoder
*
* Negotiate with downstreame elements to currently configured #GstCaps.
*
* Returns: #TRUE if the negotiation succeeded, else #FALSE.
*/
gboolean
gst_audio_encoder_negotiate (GstAudioEncoder * enc)
{
GstAudioEncoderClass *klass;
gboolean ret = TRUE;
g_return_val_if_fail (GST_IS_AUDIO_ENCODER (enc), FALSE);
klass = GST_AUDIO_ENCODER_GET_CLASS (enc);
GST_AUDIO_ENCODER_STREAM_LOCK (enc);
if (klass->negotiate)
ret = klass->negotiate (enc);
GST_AUDIO_ENCODER_STREAM_UNLOCK (enc);
return ret;
}
/*
* gst_audio_encoder_set_output_format:
* @enc: a #GstAudioEncoder
......
......@@ -157,6 +157,8 @@ struct _GstAudioEncoder {
* @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
......@@ -200,6 +202,8 @@ struct _GstAudioEncoderClass {
gboolean (*close) (GstAudioEncoder *enc);
gboolean (*negotiate) (GstAudioEncoder *enc);
gboolean (*decide_allocation) (GstAudioEncoder *enc, GstQuery *query);
gboolean (*propose_allocation) (GstAudioEncoder * enc,
......
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