MSDK: Handle context query into the encoder's query function.

The MSDK encoder's query function is not set and it just forwards
all query to its base class. We now need to answer the context
query correctly. Other VA plugins need to query the VA display.

By the way, the current query of "gst.msdk.Context" is also missing.
The other MSDK elements must depend on the bin's context message(
sent in context_propagate()) to set their MsdkContext correctly.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1087>
This commit is contained in:
He Junyan 2021-05-08 15:51:11 +08:00 committed by GStreamer Marge Bot
parent 2928b14b69
commit 26172123e5

View file

@ -2016,6 +2016,50 @@ gst_msdkenc_propose_allocation (GstVideoEncoder * encoder, GstQuery * query)
query);
}
static gboolean
gst_msdkenc_query (GstVideoEncoder * encoder, GstQuery * query,
GstPadDirection dir)
{
GstMsdkEnc *thiz = GST_MSDKENC (encoder);
gboolean ret = FALSE;
switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_CONTEXT:{
GstMsdkContext *msdk_context = NULL;
gst_object_replace ((GstObject **) & msdk_context,
(GstObject *) thiz->context);
ret = gst_msdk_handle_context_query (GST_ELEMENT_CAST (encoder),
query, msdk_context);
gst_clear_object (&msdk_context);
break;
}
default:
if (dir == GST_PAD_SRC) {
ret =
GST_VIDEO_ENCODER_CLASS (parent_class)->src_query (encoder, query);
} else {
ret =
GST_VIDEO_ENCODER_CLASS (parent_class)->sink_query (encoder, query);
}
break;
}
return ret;
}
static gboolean
gst_msdkenc_src_query (GstVideoEncoder * encoder, GstQuery * query)
{
return gst_msdkenc_query (encoder, query, GST_PAD_SRC);
}
static gboolean
gst_msdkenc_sink_query (GstVideoEncoder * encoder, GstQuery * query)
{
return gst_msdkenc_query (encoder, query, GST_PAD_SINK);
}
static void
gst_msdkenc_dispose (GObject * object)
{
@ -2098,6 +2142,8 @@ gst_msdkenc_class_init (GstMsdkEncClass * klass)
gstencoder_class->finish = GST_DEBUG_FUNCPTR (gst_msdkenc_finish);
gstencoder_class->propose_allocation =
GST_DEBUG_FUNCPTR (gst_msdkenc_propose_allocation);
gstencoder_class->src_query = GST_DEBUG_FUNCPTR (gst_msdkenc_src_query);
gstencoder_class->sink_query = GST_DEBUG_FUNCPTR (gst_msdkenc_sink_query);
gst_element_class_add_static_pad_template (element_class, &sink_factory);
}