amfcodec: Add plugin status message

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6167>
This commit is contained in:
Seungha Yang 2024-02-21 00:57:32 +09:00 committed by GStreamer Marge Bot
parent 301e281777
commit fa477a4a25

View file

@ -37,6 +37,8 @@
#include "gstamfh265enc.h" #include "gstamfh265enc.h"
#include "gstamfav1enc.h" #include "gstamfav1enc.h"
#include <glib/gi18n-lib.h>
/* *INDENT-OFF* */ /* *INDENT-OFF* */
using namespace Microsoft::WRL; using namespace Microsoft::WRL;
using namespace amf; using namespace amf;
@ -48,20 +50,28 @@ plugin_init (GstPlugin * plugin)
AMFFactory *amf_factory; AMFFactory *amf_factory;
ComPtr < IDXGIFactory1 > factory; ComPtr < IDXGIFactory1 > factory;
HRESULT hr; HRESULT hr;
bool have_amd_gpu = false;
if (!IsWindows8OrGreater ()) if (!IsWindows8OrGreater ()) {
gst_plugin_add_status_warning (plugin,
N_("This plugin requires at least Windows 8 or newer."));
return TRUE; return TRUE;
}
if (!gst_amf_init_once ()) if (!gst_amf_init_once () || !gst_amf_get_factory ()) {
gst_plugin_add_status_warning (plugin,
"AMF runtime library \"" AMF_DLL_NAMEA "\" was not found.");
return TRUE; return TRUE;
}
amf_factory = (AMFFactory *) gst_amf_get_factory (); amf_factory = (AMFFactory *) gst_amf_get_factory ();
if (!amf_factory)
return TRUE;
hr = CreateDXGIFactory1 (IID_PPV_ARGS (&factory)); hr = CreateDXGIFactory1 (IID_PPV_ARGS (&factory));
if (FAILED (hr)) if (FAILED (hr)) {
/* Shouldn't happen, this means all DirectX bits would not be functional */
gst_plugin_add_status_error (plugin, N_("Unable to enumerate GPUs."));
return TRUE; return TRUE;
}
/* Enumerate AMD GPUs */ /* Enumerate AMD GPUs */
for (guint idx = 0;; idx++) { for (guint idx = 0;; idx++) {
@ -86,6 +96,7 @@ plugin_init (GstPlugin * plugin)
if (desc.VendorId != 0x1002 && desc.VendorId != 0x1022) if (desc.VendorId != 0x1002 && desc.VendorId != 0x1022)
continue; continue;
have_amd_gpu = true;
luid = gst_d3d11_luid_to_int64 (&desc.AdapterLuid); luid = gst_d3d11_luid_to_int64 (&desc.AdapterLuid);
device = gst_d3d11_device_new_for_adapter_luid (luid, device = gst_d3d11_device_new_for_adapter_luid (luid,
D3D11_CREATE_DEVICE_BGRA_SUPPORT); D3D11_CREATE_DEVICE_BGRA_SUPPORT);
@ -116,6 +127,13 @@ plugin_init (GstPlugin * plugin)
gst_clear_object (&device); gst_clear_object (&device);
} }
if (!have_amd_gpu) {
/* A little unexpected case. AMF runtime (part of driver) is installed
* but AMD GPU is not detected */
gst_plugin_add_status_warning (plugin,
N_("No AMD graphics cards detected!"));
}
return TRUE; return TRUE;
} }