From 5d62f408f2221cec14b679c6a54c9f3618d8377a Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Wed, 21 Feb 2024 01:13:02 +0900 Subject: [PATCH] nvcodec: Add plugin status message Part-of: --- .../gst-plugins-bad/sys/nvcodec/plugin.c | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/nvcodec/plugin.c b/subprojects/gst-plugins-bad/sys/nvcodec/plugin.c index 7d7c9a2b89..08cac8f34c 100644 --- a/subprojects/gst-plugins-bad/sys/nvcodec/plugin.c +++ b/subprojects/gst-plugins-bad/sys/nvcodec/plugin.c @@ -54,6 +54,8 @@ #include "gstnvcodecutils.h" #include "gstnvjpegenc.h" +#include + GST_DEBUG_CATEGORY (gst_nvcodec_debug); GST_DEBUG_CATEGORY (gst_nvdec_debug); GST_DEBUG_CATEGORY (gst_nvenc_debug); @@ -65,6 +67,22 @@ GST_DEBUG_CATEGORY (gst_cuda_nvmm_debug); #define GST_CAT_DEFAULT gst_nvcodec_debug +#ifdef G_OS_WIN32 +#define CUDA_LIBNAME "nvcuda.dll" +#define NVCUVID_LIBNAME "nvcuvid.dll" +#ifdef _WIN64 +#define NVENC_LIBNAME "nvEncodeAPI64.dll" +#else +#define NVENC_LIBNAME "nvEncodeAPI.dll" +#endif +#define NVRTC_LIBNAME "nvrtc64_*_0.dll" +#else /* G_OS_WIN32 */ +#define CUDA_LIBNAME "libcuda.so.1" +#define NVCUVID_LIBNAME "libnvcuvid.so.1" +#define NVENC_LIBNAME "libnvidia-encode.so.1" +#define NVRTC_LIBNAME "libnvrtc.so" +#endif /* G_OS_WIN32 */ + static void plugin_deinit (gpointer data) { @@ -120,20 +138,24 @@ plugin_init (GstPlugin * plugin) #endif if (!gst_cuda_load_library ()) { - GST_WARNING ("Failed to load cuda library"); + gst_plugin_add_status_warning (plugin, + "CUDA library \"" CUDA_LIBNAME "\" was not found."); return TRUE; } /* get available API version from nvenc and it will be passed to * nvdec */ if (!gst_nvenc_load_library (&api_major_ver, &api_minor_ver)) { - GST_WARNING ("Failed to load nvenc library"); + gst_plugin_add_status_warning (plugin, + "NVENC library \"" NVENC_LIBNAME "\" was not found."); nvenc_available = FALSE; } if (!gst_cuvid_load_library (api_major_ver, api_minor_ver)) { GST_WARNING ("Failed to load nvdec library version %u.%u", api_major_ver, api_minor_ver); + gst_plugin_add_status_warning (plugin, + "NVDEC library \"" NVCUVID_LIBNAME "\" was not found."); nvdec_available = FALSE; } @@ -149,6 +171,10 @@ plugin_init (GstPlugin * plugin) /* to abort if GST_CUDA_CRITICAL_ERRORS is configured */ gst_cuda_result (CUDA_ERROR_NO_DEVICE); + + gst_plugin_add_status_error (plugin, + N_("Unable to initialize CUDA library.")); + return TRUE; } @@ -158,10 +184,19 @@ plugin_init (GstPlugin * plugin) CuGetErrorString (cuda_ret, &err_desc); GST_ERROR ("No available device, cuDeviceGetCount ret: 0x%x: %s %s", (int) cuda_ret, err_name, err_desc); + + gst_plugin_add_status_warning (plugin, + N_("No NVIDIA graphics cards detected!")); + return TRUE; } have_nvrtc = check_runtime_compiler (); + if (!have_nvrtc) { + gst_plugin_add_status_info (plugin, + "CUDA runtime compilation library \"" NVRTC_LIBNAME "\" was not found, " + "check CUDA toolkit package installation"); + } for (i = 0; i < dev_count; i++) { GstCudaContext *context = gst_cuda_context_new (i);