videodecoder: Add negotiate vfunc that is used to negotiate with downstream
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 9 Aug 2012 12:35:22 +0000 (14:35 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Thu, 9 Aug 2012 12:47:46 +0000 (14:47 +0200)
The default implementation negotiates a buffer pool and allocator
with downstream.

gst-libs/gst/video/gstvideodecoder.c
gst-libs/gst/video/gstvideodecoder.h

index 7df04d4..cd4a092 100644 (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 */
@@ -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
  *
index b451981..1d5be4e 100644 (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);