mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
videoencoder: Add support for subclasses to propose allocation parameters
This commit is contained in:
parent
894875d705
commit
3de8d58c4e
2 changed files with 27 additions and 0 deletions
|
@ -122,6 +122,8 @@
|
|||
#include "gstvideoencoder.h"
|
||||
#include "gstvideoutils.h"
|
||||
|
||||
#include <gst/video/gstvideometa.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
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;
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Reference in a new issue