From 7cb22ef24110ab894a09b6137b75a2ef0e3939ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 9 Aug 2012 14:35:22 +0200 Subject: [PATCH] videodecoder: Add negotiate vfunc that is used to negotiate with downstream The default implementation negotiates a buffer pool and allocator with downstream. --- gst-libs/gst/video/gstvideodecoder.c | 44 ++++++++++++++++++++++++------------ gst-libs/gst/video/gstvideodecoder.h | 4 ++++ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/gst-libs/gst/video/gstvideodecoder.c b/gst-libs/gst/video/gstvideodecoder.c index 7df04d4..cd4a092 100644 --- a/gst-libs/gst/video/gstvideodecoder.c +++ b/gst-libs/gst/video/gstvideodecoder.c @@ -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 */ @@ -2798,6 +2788,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 * diff --git a/gst-libs/gst/video/gstvideodecoder.h b/gst-libs/gst/video/gstvideodecoder.h index b451981..1d5be4e 100644 --- a/gst-libs/gst/video/gstvideodecoder.h +++ b/gst-libs/gst/video/gstvideodecoder.h @@ -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); -- 2.7.4