msdk: add a helper function to get codename of the platform

The features supported in MSDK vary from platform to platform. We may
support some features based on the codename of the platform in future.
This commit is contained in:
Haihao Xiang 2020-03-20 09:53:28 +08:00
parent afb042cbb9
commit fbd1d0cecb
2 changed files with 29 additions and 11 deletions

View file

@ -148,6 +148,24 @@ msdk_status_to_string (mfxStatus status)
return "undefined error"; return "undefined error";
} }
mfxU16
msdk_get_platform_codename (mfxSession session)
{
mfxU16 codename = MFX_PLATFORM_UNKNOWN;
#if (MFX_VERSION >= 1019)
{
mfxStatus status;
mfxPlatform platform = { 0 };
status = MFXVideoCORE_QueryPlatform (session, &platform);
if (MFX_ERR_NONE == status)
codename = platform.CodeName;
}
#endif
return codename;
}
void void
msdk_close_session (mfxSession session) msdk_close_session (mfxSession session)
{ {
@ -169,6 +187,7 @@ msdk_open_session (mfxIMPL impl)
}; };
mfxIMPL implementation; mfxIMPL implementation;
mfxStatus status; mfxStatus status;
mfxU16 codename;
static const gchar *implementation_names[] = { static const gchar *implementation_names[] = {
"AUTO", "SOFTWARE", "HARDWARE", "AUTO_ANY", "HARDWARE_ANY", "HARDWARE2", "AUTO", "SOFTWARE", "HARDWARE", "AUTO_ANY", "HARDWARE_ANY", "HARDWARE2",
@ -194,17 +213,13 @@ msdk_open_session (mfxIMPL impl)
GST_ERROR ("Query version failed (%s)", msdk_status_to_string (status)); GST_ERROR ("Query version failed (%s)", msdk_status_to_string (status));
goto failed; goto failed;
} }
#if (MFX_VERSION >= 1019)
{ codename = msdk_get_platform_codename (session);
mfxPlatform platform = { 0 };
status = MFXVideoCORE_QueryPlatform (session, &platform); if (codename != MFX_PLATFORM_UNKNOWN)
if (MFX_ERR_NONE == status) { GST_INFO ("Detected MFX platform with device code %d", codename);
GST_INFO ("Detected MFX platform with device code %d", platform.CodeName); else
} else { GST_WARNING ("Unknown MFX platform");
GST_WARNING ("Platform auto-detection failed with MFX status %d", status);
}
}
#endif
GST_INFO ("MFX implementation: 0x%04x (%s)", implementation, GST_INFO ("MFX implementation: 0x%04x (%s)", implementation,
implementation_names[MFX_IMPL_BASETYPE (implementation)]); implementation_names[MFX_IMPL_BASETYPE (implementation)]);

View file

@ -104,6 +104,9 @@ gboolean
gst_msdk_load_plugin (mfxSession session, const mfxPluginUID * uid, gst_msdk_load_plugin (mfxSession session, const mfxPluginUID * uid,
mfxU32 version, const gchar * plugin); mfxU32 version, const gchar * plugin);
mfxU16
msdk_get_platform_codename (mfxSession session);
G_END_DECLS G_END_DECLS
#endif /* __MSDK_H__ */ #endif /* __MSDK_H__ */