mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
audioencoder: 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:
parent
9309272309
commit
bc4d923982
2 changed files with 34 additions and 14 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue