From: Haihao Xiang Date: Mon, 1 Mar 2021 04:09:43 +0000 (+0800) Subject: msdk: use MFXJoinSession() to join the parent and child sessions X-Git-Tag: 1.19.3~507^2~403 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bda11a3e735141b5b2740cc93abfcf0b934c7143;p=platform%2Fupstream%2Fgstreamer.git msdk: use MFXJoinSession() to join the parent and child sessions Part-of: --- diff --git a/sys/msdk/gstmsdkcontext.c b/sys/msdk/gstmsdkcontext.c index c46a67a..1938f38 100644 --- a/sys/msdk/gstmsdkcontext.c +++ b/sys/msdk/gstmsdkcontext.c @@ -315,17 +315,80 @@ gst_msdk_context_new_with_parent (GstMsdkContext * parent) GstMsdkContext *obj = g_object_new (GST_TYPE_MSDK_CONTEXT, NULL); GstMsdkContextPrivate *priv = obj->priv; GstMsdkContextPrivate *parent_priv = parent->priv; + mfxVersion version; + mfxIMPL impl; + MsdkSession child_msdk_session; + mfxHandleType handle_type = 0; + mfxHDL handle = NULL; + status = MFXQueryIMPL (parent_priv->session.session, &impl); + + if (status == MFX_ERR_NONE) + status = MFXQueryVersion (parent_priv->session.session, &version); + + if (status != MFX_ERR_NONE) { + GST_ERROR ("Failed to query the session attributes (%s)", + msdk_status_to_string (status)); + g_object_unref (obj); + return NULL; + } + + if (MFX_IMPL_VIA_VAAPI == (0x0f00 & (impl))) + handle_type = MFX_HANDLE_VA_DISPLAY; + + if (handle_type) { + status = + MFXVideoCORE_GetHandle (parent_priv->session.session, handle_type, + &handle); + + if (status != MFX_ERR_NONE || !handle) { + GST_ERROR ("Failed to get session handle (%s)", + msdk_status_to_string (status)); + g_object_unref (obj); + return NULL; + } + } + + child_msdk_session.loader = parent_priv->session.loader; + child_msdk_session.session = NULL; + status = msdk_init_msdk_session (impl, &version, &child_msdk_session); + + if (status != MFX_ERR_NONE) { + GST_ERROR ("Failed to create a child mfx session (%s)", + msdk_status_to_string (status)); + g_object_unref (obj); + return NULL; + } + + if (handle) { + status = + MFXVideoCORE_SetHandle (child_msdk_session.session, handle_type, + handle); + + if (status != MFX_ERR_NONE) { + GST_ERROR ("Failed to set a HW handle (%s)", + msdk_status_to_string (status)); + MFXClose (child_msdk_session.session); + g_object_unref (obj); + return NULL; + } + } +#if (MFX_VERSION >= 1025) status = - MFXCloneSession (parent_priv->session.session, &priv->session.session); + MFXJoinSession (parent_priv->session.session, child_msdk_session.session); + if (status != MFX_ERR_NONE) { - GST_ERROR ("Failed to clone mfx session"); + GST_ERROR ("Failed to join two sessions (%s)", + msdk_status_to_string (status)); + MFXClose (child_msdk_session.session); g_object_unref (obj); return NULL; } +#endif /* Set loader to NULL for child session */ priv->session.loader = NULL; + priv->session.session = child_msdk_session.session; priv->is_joined = TRUE; priv->hardware = parent_priv->hardware; priv->job_type = parent_priv->job_type; @@ -334,20 +397,6 @@ gst_msdk_context_new_with_parent (GstMsdkContext * parent) #ifndef _WIN32 priv->dpy = parent_priv->dpy; priv->fd = parent_priv->fd; - - if (priv->hardware) { - status = - MFXVideoCORE_SetHandle (priv->session.session, MFX_HANDLE_VA_DISPLAY, - (mfxHDL) parent_priv->dpy); - - if (status != MFX_ERR_NONE) { - GST_ERROR ("Setting VA handle failed (%s)", - msdk_status_to_string (status)); - g_object_unref (obj); - return NULL; - } - - } #endif return obj;