msdk: add a helper function to get codename of the platform
authorHaihao Xiang <haihao.xiang@intel.com>
Fri, 20 Mar 2020 01:53:28 +0000 (09:53 +0800)
committerHaihao Xiang <haihao.xiang@intel.com>
Tue, 31 Mar 2020 01:27:03 +0000 (09:27 +0800)
The features supported in MSDK vary from platform to platform. We may
support some features based on the codename of the platform in future.

sys/msdk/msdk.c
sys/msdk/msdk.h

index bffdcda..bc560bc 100644 (file)
@@ -148,6 +148,24 @@ msdk_status_to_string (mfxStatus status)
   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
 msdk_close_session (mfxSession session)
 {
@@ -169,6 +187,7 @@ msdk_open_session (mfxIMPL impl)
   };
   mfxIMPL implementation;
   mfxStatus status;
+  mfxU16 codename;
 
   static const gchar *implementation_names[] = {
     "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));
     goto failed;
   }
-#if (MFX_VERSION >= 1019)
-  {
-    mfxPlatform platform = { 0 };
-    status = MFXVideoCORE_QueryPlatform (session, &platform);
-    if (MFX_ERR_NONE == status) {
-      GST_INFO ("Detected MFX platform with device code %d", platform.CodeName);
-    } else {
-      GST_WARNING ("Platform auto-detection failed with MFX status %d", status);
-    }
-  }
-#endif
+
+  codename = msdk_get_platform_codename (session);
+
+  if (codename != MFX_PLATFORM_UNKNOWN)
+    GST_INFO ("Detected MFX platform with device code %d", codename);
+  else
+    GST_WARNING ("Unknown MFX platform");
 
   GST_INFO ("MFX implementation: 0x%04x (%s)", implementation,
       implementation_names[MFX_IMPL_BASETYPE (implementation)]);
index 8483847..87867f6 100644 (file)
@@ -104,6 +104,9 @@ gboolean
 gst_msdk_load_plugin (mfxSession session, const mfxPluginUID * uid,
     mfxU32 version, const gchar * plugin);
 
+mfxU16
+msdk_get_platform_codename (mfxSession session);
+
 G_END_DECLS
 
 #endif /* __MSDK_H__ */