mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-22 14:06:23 +00:00
videoencoder: Add sink_query() src_query() virtual functions
Based on the videodecoder change by Nicolas Dufresne and applied here for consistency. https://bugzilla.gnome.org/show_bug.cgi?id=720103
This commit is contained in:
parent
09a6ca97d2
commit
729e3c8a10
2 changed files with 69 additions and 10 deletions
|
@ -235,6 +235,11 @@ static gboolean gst_video_encoder_negotiate_default (GstVideoEncoder * encoder);
|
|||
static gboolean gst_video_encoder_negotiate_unlocked (GstVideoEncoder *
|
||||
encoder);
|
||||
|
||||
static gboolean gst_video_encoder_sink_query_default (GstVideoEncoder * encoder,
|
||||
GstQuery * query);
|
||||
static gboolean gst_video_encoder_src_query_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 */
|
||||
GType
|
||||
|
@ -296,6 +301,8 @@ gst_video_encoder_class_init (GstVideoEncoderClass * klass)
|
|||
klass->propose_allocation = gst_video_encoder_propose_allocation_default;
|
||||
klass->decide_allocation = gst_video_encoder_decide_allocation_default;
|
||||
klass->negotiate = gst_video_encoder_negotiate_default;
|
||||
klass->sink_query = gst_video_encoder_sink_query_default;
|
||||
klass->src_query = gst_video_encoder_src_query_default;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -812,14 +819,12 @@ config_failed:
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_video_encoder_sink_query (GstPad * pad, GstObject * parent,
|
||||
gst_video_encoder_sink_query_default (GstVideoEncoder * encoder,
|
||||
GstQuery * query)
|
||||
{
|
||||
GstVideoEncoder *encoder;
|
||||
GstPad *pad = GST_VIDEO_ENCODER_SINK_PAD (encoder);
|
||||
gboolean res = FALSE;
|
||||
|
||||
encoder = GST_VIDEO_ENCODER (parent);
|
||||
|
||||
switch (GST_QUERY_TYPE (query)) {
|
||||
case GST_QUERY_CAPS:
|
||||
{
|
||||
|
@ -841,12 +846,32 @@ gst_video_encoder_sink_query (GstPad * pad, GstObject * parent,
|
|||
break;
|
||||
}
|
||||
default:
|
||||
res = gst_pad_query_default (pad, parent, query);
|
||||
res = gst_pad_query_default (pad, GST_OBJECT (encoder), query);
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_video_encoder_sink_query (GstPad * pad, GstObject * parent,
|
||||
GstQuery * query)
|
||||
{
|
||||
GstVideoEncoder *encoder;
|
||||
GstVideoEncoderClass *encoder_class;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
encoder = GST_VIDEO_ENCODER (parent);
|
||||
encoder_class = GST_VIDEO_ENCODER_GET_CLASS (encoder);
|
||||
|
||||
GST_DEBUG_OBJECT (encoder, "received query %d, %s", GST_QUERY_TYPE (query),
|
||||
GST_QUERY_TYPE_NAME (query));
|
||||
|
||||
if (encoder_class->sink_query)
|
||||
ret = encoder_class->sink_query (encoder, query);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_video_encoder_finalize (GObject * object)
|
||||
{
|
||||
|
@ -1141,13 +1166,12 @@ gst_video_encoder_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gst_video_encoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||
gst_video_encoder_src_query_default (GstVideoEncoder * enc, GstQuery * query)
|
||||
{
|
||||
GstPad *pad = GST_VIDEO_ENCODER_SRC_PAD (enc);
|
||||
GstVideoEncoderPrivate *priv;
|
||||
GstVideoEncoder *enc;
|
||||
gboolean res;
|
||||
|
||||
enc = GST_VIDEO_ENCODER (parent);
|
||||
priv = enc->priv;
|
||||
|
||||
GST_LOG_OBJECT (enc, "handling query: %" GST_PTR_FORMAT, query);
|
||||
|
@ -1193,7 +1217,7 @@ gst_video_encoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
res = gst_pad_query_default (pad, parent, query);
|
||||
res = gst_pad_query_default (pad, GST_OBJECT (enc), query);
|
||||
}
|
||||
return res;
|
||||
|
||||
|
@ -1202,6 +1226,25 @@ error:
|
|||
return res;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_video_encoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||
{
|
||||
GstVideoEncoder *encoder;
|
||||
GstVideoEncoderClass *encoder_class;
|
||||
gboolean ret = FALSE;
|
||||
|
||||
encoder = GST_VIDEO_ENCODER (parent);
|
||||
encoder_class = GST_VIDEO_ENCODER_GET_CLASS (encoder);
|
||||
|
||||
GST_DEBUG_OBJECT (encoder, "received query %d, %s", GST_QUERY_TYPE (query),
|
||||
GST_QUERY_TYPE_NAME (query));
|
||||
|
||||
if (encoder_class->src_query)
|
||||
ret = encoder_class->src_query (encoder, query);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static GstVideoCodecFrame *
|
||||
gst_video_encoder_new_frame (GstVideoEncoder * encoder, GstBuffer * buf,
|
||||
GstClockTime pts, GstClockTime dts, GstClockTime duration)
|
||||
|
|
|
@ -214,6 +214,16 @@ struct _GstVideoEncoder
|
|||
* @flush: Optional.
|
||||
* Flush all remaining data from the encoder without
|
||||
* pushing it downstream. Since: 1.2
|
||||
* @sink_query: Optional.
|
||||
* Query handler on the sink pad. This function should
|
||||
* return TRUE if the query could be performed. Subclasses
|
||||
* should chain up to the parent implementation to invoke the
|
||||
* default handler. Since 1.4
|
||||
* @src_query: Optional.
|
||||
* Query handler on the source pad. This function should
|
||||
* return TRUE if the query could be performed. Subclasses
|
||||
* should chain up to the parent implementation to invoke the
|
||||
* default handler. Since 1.4
|
||||
*
|
||||
* Subclasses can override any of the available virtual methods or not, as
|
||||
* needed. At minimum @handle_frame needs to be overridden, and @set_format
|
||||
|
@ -265,8 +275,14 @@ struct _GstVideoEncoderClass
|
|||
GstQuery * query);
|
||||
gboolean (*flush) (GstVideoEncoder *encoder);
|
||||
|
||||
gboolean (*sink_query) (GstVideoEncoder *encoder,
|
||||
GstQuery *query);
|
||||
|
||||
gboolean (*src_query) (GstVideoEncoder *encoder,
|
||||
GstQuery *query);
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE-1];
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE-3];
|
||||
};
|
||||
|
||||
GType gst_video_encoder_get_type (void);
|
||||
|
|
Loading…
Reference in a new issue