From: Sebastian Dröge Date: Tue, 24 Apr 2012 20:42:59 +0000 (+0200) Subject: videoencoder: Add support for subclasses to propose allocation parameters X-Git-Tag: 1.19.3~511^2~6544 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3de8d58c4e8cdf2bb8dec3905608d134d7206732;p=platform%2Fupstream%2Fgstreamer.git videoencoder: Add support for subclasses to propose allocation parameters --- diff --git a/gst-libs/gst/video/gstvideoencoder.c b/gst-libs/gst/video/gstvideoencoder.c index 2106d20..d1e0eec 100644 --- a/gst-libs/gst/video/gstvideoencoder.c +++ b/gst-libs/gst/video/gstvideoencoder.c @@ -122,6 +122,8 @@ #include "gstvideoencoder.h" #include "gstvideoutils.h" +#include + #include GST_DEBUG_CATEGORY (videoencoder_debug); @@ -219,6 +221,8 @@ static gboolean gst_video_encoder_sink_event_default (GstVideoEncoder * encoder, GstEvent * event); static gboolean gst_video_encoder_src_event_default (GstVideoEncoder * encoder, GstEvent * event); +static gboolean gst_video_encoder_propose_allocation_default (GstVideoEncoder * + encoder, GstQuery * query); /* we can't use G_DEFINE_ABSTRACT_TYPE because we need the klass in the _init * method to get to the padtemplates */ @@ -278,6 +282,7 @@ gst_video_encoder_class_init (GstVideoEncoderClass * klass) klass->sink_event = gst_video_encoder_sink_event_default; klass->src_event = gst_video_encoder_src_event_default; + klass->propose_allocation = gst_video_encoder_propose_allocation_default; } static void @@ -702,6 +707,14 @@ gst_video_encoder_sink_getcaps (GstVideoEncoder * encoder, GstCaps * filter) return caps; } +static gboolean +gst_video_encoder_propose_allocation_default (GstVideoEncoder * encoder, + GstQuery * query) +{ + gst_query_add_allocation_meta (query, GST_VIDEO_META_API_TYPE); + + return TRUE; +} static gboolean gst_video_encoder_sink_query (GstPad * pad, GstObject * parent, @@ -724,6 +737,14 @@ gst_video_encoder_sink_query (GstPad * pad, GstObject * parent, res = TRUE; break; } + case GST_QUERY_ALLOCATION: + { + GstVideoEncoderClass *klass = GST_VIDEO_ENCODER_GET_CLASS (encoder); + + if (klass->propose_allocation) + res = klass->propose_allocation (encoder, query); + break; + } default: res = gst_pad_query_default (pad, parent, query); break; diff --git a/gst-libs/gst/video/gstvideoencoder.h b/gst-libs/gst/video/gstvideoencoder.h index 4b066b1..f73c07e 100644 --- a/gst-libs/gst/video/gstvideoencoder.h +++ b/gst-libs/gst/video/gstvideoencoder.h @@ -213,6 +213,9 @@ struct _GstVideoEncoder * 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). + * @propose_allocation: Optional. + * Propose buffer allocation parameters for upstream elements. + * The default implementation proposes the VIDEO_META. * * Subclasses can override any of the available virtual methods or not, as * needed. At minimum @handle_frame needs to be overridden, and @set_format @@ -258,6 +261,9 @@ struct _GstVideoEncoderClass gboolean (*src_event) (GstVideoEncoder *encoder, GstEvent *event); + gboolean (*propose_allocation) (GstVideoEncoder * encoder, + GstQuery * query); + /*< private >*/ /* FIXME before moving to base */ gpointer _gst_reserved[GST_PADDING_LARGE];