From: He Junyan Date: Sat, 8 May 2021 07:51:11 +0000 (+0800) Subject: MSDK: Handle context query into the encoder's query function. X-Git-Tag: 1.22.0~2452 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=26172123e52c458176c9c3c8a6ae4b6b7b1c07f7;p=platform%2Fupstream%2Fgstreamer.git 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: --- diff --git a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkenc.c b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkenc.c index d7546a4..5ead853 100644 --- a/subprojects/gst-plugins-bad/sys/msdk/gstmsdkenc.c +++ b/subprojects/gst-plugins-bad/sys/msdk/gstmsdkenc.c @@ -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); }