diff --git a/gst-libs/gst/video/gstvideoencoder.c b/gst-libs/gst/video/gstvideoencoder.c index 2106d20ed9..d1e0eec8b2 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 4b066b1a6e..f73c07ecf0 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];