summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorHaihao Xiang <haihao.xiang@intel.com>2021-03-01 12:09:43 +0800
committerHaihao Xiang <haihao.xiang@intel.com>2021-05-17 01:58:24 +0000
commitbda11a3e735141b5b2740cc93abfcf0b934c7143 (patch)
tree726b31b71414baa41b3e728ad768134915fcd731 /sys
parentcd3a3534c4a44ea90e1e410479b0d8ee451173d5 (diff)
downloadgstreamer-plugins-bad-bda11a3e735141b5b2740cc93abfcf0b934c7143.tar.gz
msdk: use MFXJoinSession() to join the parent and child sessions
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1503>
Diffstat (limited to 'sys')
-rw-r--r--sys/msdk/gstmsdkcontext.c81
1 files changed, 65 insertions, 16 deletions
diff --git a/sys/msdk/gstmsdkcontext.c b/sys/msdk/gstmsdkcontext.c
index c46a67ae9..1938f3825 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;