videodecoder: 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 14:35:22 +02:00
parent 5adc87c6bd
commit 7cb22ef241
2 changed files with 34 additions and 14 deletions

View file

@ -443,6 +443,7 @@ static gboolean gst_video_decoder_decide_allocation_default (GstVideoDecoder *
decoder, GstQuery * query);
static gboolean gst_video_decoder_propose_allocation_default (GstVideoDecoder *
decoder, GstQuery * query);
static gboolean gst_video_decoder_negotiate_default (GstVideoDecoder * decoder);
/* we can't use G_DEFINE_ABSTRACT_TYPE because we need the klass in the _init
* method to get to the padtemplates */
@ -496,6 +497,7 @@ gst_video_decoder_class_init (GstVideoDecoderClass * klass)
klass->src_event = gst_video_decoder_src_event_default;
klass->decide_allocation = gst_video_decoder_decide_allocation_default;
klass->propose_allocation = gst_video_decoder_propose_allocation_default;
klass->negotiate = gst_video_decoder_negotiate_default;
}
static void
@ -2693,16 +2695,8 @@ gst_video_decoder_propose_allocation_default (GstVideoDecoder * decoder,
return TRUE;
}
/**
* gst_video_decoder_negotiate:
* @decoder: a #GstVideoDecoder
*
* Negotiate with downstreame elements to currently configured #GstVideoCodecState.
*
* Returns: #TRUE if the negotiation succeeded, else #FALSE.
*/
gboolean
gst_video_decoder_negotiate (GstVideoDecoder * decoder)
static gboolean
gst_video_decoder_negotiate_default (GstVideoDecoder * decoder)
{
GstVideoCodecState *state = decoder->priv->output_state;
GstVideoDecoderClass *klass;
@ -2715,8 +2709,6 @@ gst_video_decoder_negotiate (GstVideoDecoder * decoder)
g_return_val_if_fail (GST_VIDEO_INFO_WIDTH (&state->info) != 0, FALSE);
g_return_val_if_fail (GST_VIDEO_INFO_HEIGHT (&state->info) != 0, FALSE);
GST_VIDEO_DECODER_STREAM_LOCK (decoder);
klass = GST_VIDEO_DECODER_GET_CLASS (decoder);
GST_DEBUG_OBJECT (decoder, "output_state par %d/%d fps %d/%d",
@ -2785,8 +2777,6 @@ done:
if (query)
gst_query_unref (query);
GST_VIDEO_DECODER_STREAM_UNLOCK (decoder);
return ret;
/* Errors */
@ -2797,6 +2787,32 @@ no_decide_allocation:
}
}
/**
* gst_video_decoder_negotiate:
* @decoder: a #GstVideoDecoder
*
* Negotiate with downstreame elements to currently configured #GstVideoCodecState.
*
* Returns: #TRUE if the negotiation succeeded, else #FALSE.
*/
gboolean
gst_video_decoder_negotiate (GstVideoDecoder * decoder)
{
GstVideoDecoderClass *klass;
gboolean ret = TRUE;
g_return_val_if_fail (GST_IS_VIDEO_DECODER (decoder), FALSE);
klass = GST_VIDEO_DECODER_GET_CLASS (decoder);
GST_VIDEO_DECODER_STREAM_LOCK (decoder);
if (klass->negotiate)
ret = klass->negotiate (decoder);
GST_VIDEO_DECODER_STREAM_UNLOCK (decoder);
return ret;
}
/**
* gst_video_decoder_allocate_output_buffer:
* @decoder: a #GstVideoDecoder

View file

@ -223,6 +223,8 @@ struct _GstVideoDecoder
* Event handler on the source pad. This function should return
* TRUE if the event was handled and should be discarded
* (i.e. not unref'ed).
* @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
@ -271,6 +273,8 @@ struct _GstVideoDecoderClass
gboolean (*src_event) (GstVideoDecoder *decoder,
GstEvent *event);
gboolean (*negotiate) (GstVideoDecoder *decoder);
gboolean (*decide_allocation) (GstVideoDecoder *decoder, GstQuery *query);
gboolean (*propose_allocation) (GstVideoDecoder *decoder, GstQuery * query);