From 34fb3fda928661453a8392644129b67ac78bc5a9 Mon Sep 17 00:00:00 2001 From: dijunkun Date: Tue, 6 May 2025 18:32:52 +0800 Subject: [PATCH] [fix] use lowercase for nvcodec folder name --- src/common/any_invocable.h | 28 +- .../rtc_base/numerics/safe_conversions_impl.h | 1 + src/common/rtc_base/system_time.cc | 4 +- src/media/nvcodec/nvcodec_api.cpp | 364 ++++++------------ src/media/nvcodec/nvcodec_api.h | 4 +- src/statistics/io_statistics.h | 1 + .../{Interface => interface}/cuviddec.h | 0 .../{Interface => interface}/nvEncodeAPI.h | 0 .../{Interface => interface}/nvcuvid.h | 0 .../linux/stubs/aarch64/libnvcuvid.so | Bin .../linux/stubs/aarch64/libnvidia-encode.so | Bin .../linux/stubs/ppc64le/libnvcuvid.so | Bin .../linux/stubs/ppc64le/libnvidia-encode.so | Bin .../linux/stubs/x86_64/libnvcuvid.so | Bin .../linux/stubs/x86_64/libnvidia-encode.so | Bin .../{Lib/Win32 => lib/win32}/nvcuvid.lib | Bin .../{Lib/Win32 => lib/win32}/nvencodeapi.lib | Bin .../nvcodec/{Lib => lib}/x64/nvcuvid.lib | Bin .../nvcodec/{Lib => lib}/x64/nvencodeapi.lib | Bin xmake.lua | 8 +- 20 files changed, 157 insertions(+), 253 deletions(-) rename thirdparty/nvcodec/{Interface => interface}/cuviddec.h (100%) rename thirdparty/nvcodec/{Interface => interface}/nvEncodeAPI.h (100%) rename thirdparty/nvcodec/{Interface => interface}/nvcuvid.h (100%) rename thirdparty/nvcodec/{Lib => lib}/linux/stubs/aarch64/libnvcuvid.so (100%) rename thirdparty/nvcodec/{Lib => lib}/linux/stubs/aarch64/libnvidia-encode.so (100%) rename thirdparty/nvcodec/{Lib => lib}/linux/stubs/ppc64le/libnvcuvid.so (100%) rename thirdparty/nvcodec/{Lib => lib}/linux/stubs/ppc64le/libnvidia-encode.so (100%) rename thirdparty/nvcodec/{Lib => lib}/linux/stubs/x86_64/libnvcuvid.so (100%) rename thirdparty/nvcodec/{Lib => lib}/linux/stubs/x86_64/libnvidia-encode.so (100%) rename thirdparty/nvcodec/{Lib/Win32 => lib/win32}/nvcuvid.lib (100%) rename thirdparty/nvcodec/{Lib/Win32 => lib/win32}/nvencodeapi.lib (100%) rename thirdparty/nvcodec/{Lib => lib}/x64/nvcuvid.lib (100%) rename thirdparty/nvcodec/{Lib => lib}/x64/nvencodeapi.lib (100%) diff --git a/src/common/any_invocable.h b/src/common/any_invocable.h index 454c00b..f8932b5 100644 --- a/src/common/any_invocable.h +++ b/src/common/any_invocable.h @@ -10,6 +10,7 @@ #include #include #include +#include // 简化版的 AnyInvocable template @@ -21,15 +22,25 @@ class AnyInvocable { // 默认构造函数 AnyInvocable() = default; - // 构造函数:接受一个可以调用的对象 - template + AnyInvocable(std::nullptr_t) noexcept : callable_(nullptr) {} + + // 构造函数:接受一个可以调用的对象(排除 nullptr) + template , std::nullptr_t>>> AnyInvocable(Callable&& callable) : callable_(std::make_unique>( std::forward(callable))) {} - // 调用运算符 + // 调用运算符(支持 void 和非 void 返回类型) R operator()(Args... args) { - return callable_->Invoke(std::forward(args)...); + if (!callable_) { + throw std::bad_function_call(); + } + if constexpr (std::is_void_v) { + callable_->Invoke(std::forward(args)...); + } else { + return callable_->Invoke(std::forward(args)...); + } } // 移动构造函数 @@ -37,6 +48,7 @@ class AnyInvocable { // 移动赋值运算符 AnyInvocable& operator=(AnyInvocable&&) = default; + // 判断是否有效 explicit operator bool() const { return static_cast(callable_); } private: @@ -53,7 +65,11 @@ class AnyInvocable { : callable_(std::forward(callable)) {} R Invoke(Args&&... args) override { - return callable_(std::forward(args)...); + if constexpr (std::is_void_v) { + callable_(std::forward(args)...); + } else { + return callable_(std::forward(args)...); + } } Callable callable_; @@ -68,4 +84,4 @@ AnyInvocable MakeMoveOnlyFunction(std::function&& f) { return AnyInvocable(std::move(f)); } -#endif \ No newline at end of file +#endif // _ANY_INVOCABLE_H_ diff --git a/src/common/rtc_base/numerics/safe_conversions_impl.h b/src/common/rtc_base/numerics/safe_conversions_impl.h index e355ee4..0ecba85 100644 --- a/src/common/rtc_base/numerics/safe_conversions_impl.h +++ b/src/common/rtc_base/numerics/safe_conversions_impl.h @@ -13,6 +13,7 @@ #ifndef RTC_BASE_NUMERICS_SAFE_CONVERSIONS_IMPL_H_ #define RTC_BASE_NUMERICS_SAFE_CONVERSIONS_IMPL_H_ +#include #include #undef max #undef min diff --git a/src/common/rtc_base/system_time.cc b/src/common/rtc_base/system_time.cc index aae087b..dd6bf83 100644 --- a/src/common/rtc_base/system_time.cc +++ b/src/common/rtc_base/system_time.cc @@ -16,7 +16,7 @@ #include -#if defined(__POSIX__) +#if defined(__linux__) #include #endif #if defined(__APPLE__) @@ -54,7 +54,7 @@ int64_t SystemTimeNanos() { return rtc::dchecked_cast(a * b); }; ticks = mul(mach_absolute_time(), timebase.numer) / timebase.denom; -#elif defined(__POSIX__) +#elif defined(__linux__) struct timespec ts; // TODO(deadbeef): Do we need to handle the case when CLOCK_MONOTONIC is not // supported? diff --git a/src/media/nvcodec/nvcodec_api.cpp b/src/media/nvcodec/nvcodec_api.cpp index 3c3481c..029e76d 100644 --- a/src/media/nvcodec/nvcodec_api.cpp +++ b/src/media/nvcodec/nvcodec_api.cpp @@ -1,5 +1,10 @@ #include "nvcodec_api.h" +#ifdef _WIN32 +#else +#include +#endif + #include "log.h" TcuInit cuInit_ld = NULL; @@ -34,257 +39,141 @@ TcuvidDestroyVideoParser cuvidDestroyVideoParser_ld = NULL; TNvEncodeAPICreateInstance NvEncodeAPICreateInstance_ld = NULL; TNvEncodeAPIGetMaxSupportedVersion NvEncodeAPIGetMaxSupportedVersion_ld = NULL; -static HMODULE nvcuda_dll = NULL; -static HMODULE nvcuvid_dll = NULL; -static HMODULE nvEncodeAPI64_dll = NULL; +static void* nvcuda_dll = NULL; +static void* nvcuvid_dll = NULL; +static void* nvEncodeAPI64_dll = NULL; + +static int LoadLibraryHelper(void** library, const char* winLib, + const char* linuxLib) { +#ifdef _WIN32 + *library = LoadLibrary(TEXT(winLib)); +#else + *library = dlopen(linuxLib, RTLD_LAZY); +#endif + if (*library == NULL) { +#ifdef _WIN32 + LOG_ERROR("Unable to load library {}", winLib); +#else + LOG_ERROR("Unable to load library {}", linuxLib); +#endif + return -1; + } + return 0; +} + +static void FreeLibraryHelper(void** library) { + if (*library != NULL) { +#ifdef _WIN32 + FreeLibrary(*library); +#else + dlclose(*library); +#endif + *library = NULL; + } +} + +static int LoadFunctionHelper(void* library, void** func, + const char* funcName) { +#ifdef _WIN32 + *func = GetProcAddress(library, funcName); +#else + *func = dlsym(library, funcName); +#endif + if (*func == NULL) { + LOG_ERROR("Unable to find function {}", funcName); + return -1; + } + return 0; +} int LoadNvCodecDll() { - // Load library - nvcuda_dll = LoadLibrary(TEXT("nvcuda.dll")); - if (nvcuda_dll == NULL) { - LOG_ERROR("Unable to load nvcuda.dll"); + if (LoadLibraryHelper(&nvcuda_dll, "nvcuda.dll", "libcuda.so") != 0) { + FreeLibraryHelper(&nvcuda_dll); return -1; } - cuInit_ld = (TcuInit)GetProcAddress(nvcuda_dll, "cuInit"); - if (cuInit_ld == NULL) { - LOG_ERROR("Unable to find function cuInit()"); - FreeLibrary(nvcuda_dll); + if (LoadFunctionHelper(nvcuda_dll, (void**)&cuInit_ld, "cuInit") != 0 || + LoadFunctionHelper(nvcuda_dll, (void**)&cuDeviceGet_ld, "cuDeviceGet") != + 0 || + LoadFunctionHelper(nvcuda_dll, (void**)&cuDeviceGetCount_ld, + "cuDeviceGetCount") != 0 || + LoadFunctionHelper(nvcuda_dll, (void**)&cuCtxCreate_ld, + "cuCtxCreate_v2") != 0 || + LoadFunctionHelper(nvcuda_dll, (void**)&cuGetErrorName_ld, + "cuGetErrorName") != 0 || + LoadFunctionHelper(nvcuda_dll, (void**)&cuCtxPushCurrent_ld, + "cuCtxPushCurrent_v2") != 0 || + LoadFunctionHelper(nvcuda_dll, (void**)&cuCtxPopCurrent_ld, + "cuCtxPopCurrent_v2") != 0 || + LoadFunctionHelper(nvcuda_dll, (void**)&cuMemAlloc_ld, "cuMemAlloc_v2") != + 0 || + LoadFunctionHelper(nvcuda_dll, (void**)&cuMemAllocPitch_ld, + "cuMemAllocPitch_v2") != 0 || + LoadFunctionHelper(nvcuda_dll, (void**)&cuMemFree_ld, "cuMemFree_v2") != + 0 || + LoadFunctionHelper(nvcuda_dll, (void**)&cuMemcpy2DAsync_ld, + "cuMemcpy2DAsync_v2") != 0 || + LoadFunctionHelper(nvcuda_dll, (void**)&cuStreamSynchronize_ld, + "cuStreamSynchronize") != 0 || + LoadFunctionHelper(nvcuda_dll, (void**)&cuMemcpy2D_ld, "cuMemcpy2D_v2") != + 0 || + LoadFunctionHelper(nvcuda_dll, (void**)&cuMemcpy2DUnaligned_ld, + "cuMemcpy2DUnaligned_v2") != 0) { + FreeLibraryHelper(&nvcuda_dll); + } + + if (LoadLibraryHelper(&nvcuvid_dll, "nvcuvid.dll", "libnvcuvid.so") != 0) { + FreeLibraryHelper(&nvcuvid_dll); return -1; } - cuDeviceGet_ld = (TcuDeviceGet)GetProcAddress(nvcuda_dll, "cuDeviceGet"); - if (cuDeviceGet_ld == NULL) { - LOG_ERROR("Unable to find function cuDeviceGet()"); - FreeLibrary(nvcuda_dll); + if (LoadFunctionHelper(nvcuvid_dll, (void**)&cuvidCtxLockCreate_ld, + "cuvidCtxLockCreate") != 0 || + LoadFunctionHelper(nvcuvid_dll, (void**)&cuvidGetDecoderCaps_ld, + "cuvidGetDecoderCaps") != 0 || + LoadFunctionHelper(nvcuvid_dll, (void**)&cuvidCreateDecoder_ld, + "cuvidCreateDecoder") != 0 || + LoadFunctionHelper(nvcuvid_dll, (void**)&cuvidDestroyDecoder_ld, + "cuvidDestroyDecoder") != 0 || + LoadFunctionHelper(nvcuvid_dll, (void**)&cuvidDecodePicture_ld, + "cuvidDecodePicture") != 0 || + LoadFunctionHelper(nvcuvid_dll, (void**)&cuvidGetDecodeStatus_ld, + "cuvidGetDecodeStatus") != 0 || + LoadFunctionHelper(nvcuvid_dll, (void**)&cuvidReconfigureDecoder_ld, + "cuvidReconfigureDecoder") != 0 || + LoadFunctionHelper(nvcuvid_dll, (void**)&cuvidMapVideoFrame64_ld, + "cuvidMapVideoFrame64") != 0 || + LoadFunctionHelper(nvcuvid_dll, (void**)&cuvidUnmapVideoFrame64_ld, + "cuvidUnmapVideoFrame64") != 0 || + LoadFunctionHelper(nvcuvid_dll, (void**)&cuvidCtxLockDestroy_ld, + "cuvidCtxLockDestroy") != 0 || + LoadFunctionHelper(nvcuvid_dll, (void**)&cuvidCreateVideoParser_ld, + "cuvidCreateVideoParser") != 0 || + LoadFunctionHelper(nvcuvid_dll, (void**)&cuvidParseVideoData_ld, + "cuvidParseVideoData") != 0 || + LoadFunctionHelper(nvcuvid_dll, (void**)&cuvidDestroyVideoParser_ld, + "cuvidDestroyVideoParser") != 0) { + FreeLibraryHelper(&nvcuvid_dll); return -1; } - cuDeviceGetCount_ld = - (TcuDeviceGetCount)GetProcAddress(nvcuda_dll, "cuDeviceGetCount"); - if (cuDeviceGetCount_ld == NULL) { - LOG_ERROR("Unable to find function cuDeviceGetCount()"); - FreeLibrary(nvcuda_dll); - return -1; - } - - cuCtxCreate_ld = (TcuCtxCreate)GetProcAddress(nvcuda_dll, "cuCtxCreate_v2"); - if (cuCtxCreate_ld == NULL) { - LOG_ERROR("Unable to find function cuCtxCreate()"); - FreeLibrary(nvcuda_dll); - return -1; - } - - cuGetErrorName_ld = - (TcuGetErrorName)GetProcAddress(nvcuda_dll, "cuGetErrorName"); - if (cuGetErrorName_ld == NULL) { - LOG_ERROR("Unable to find function cuGetErrorName()"); - FreeLibrary(nvcuda_dll); - return -1; - } - - cuCtxPushCurrent_ld = - (TcuCtxPushCurrent)GetProcAddress(nvcuda_dll, "cuCtxPushCurrent_v2"); - if (cuCtxPushCurrent_ld == NULL) { - LOG_ERROR("Unable to find function cuCtxPushCurrent()"); - FreeLibrary(nvcuda_dll); - return -1; - } - - cuCtxPopCurrent_ld = - (TcuCtxPopCurrent)GetProcAddress(nvcuda_dll, "cuCtxPopCurrent_v2"); - if (cuCtxPopCurrent_ld == NULL) { - LOG_ERROR("Unable to find function cuCtxPopCurrent()"); - FreeLibrary(nvcuda_dll); - return -1; - } - cuMemAlloc_ld = (TcuMemAlloc)GetProcAddress(nvcuda_dll, "cuMemAlloc_v2"); - if (cuMemAlloc_ld == NULL) { - LOG_ERROR("Unable to find function cuMemAlloc()"); - FreeLibrary(nvcuda_dll); - return -1; - } - - cuMemAllocPitch_ld = - (TcuMemAllocPitch)GetProcAddress(nvcuda_dll, "cuMemAllocPitch_v2"); - if (cuMemAllocPitch_ld == NULL) { - LOG_ERROR("Unable to find function cuMemAllocPitch()"); - FreeLibrary(nvcuda_dll); - return -1; - } - - cuMemFree_ld = (TcuMemFree)GetProcAddress(nvcuda_dll, "cuMemFree_v2"); - if (cuMemFree_ld == NULL) { - LOG_ERROR("Unable to find function cuMemFree()"); - FreeLibrary(nvcuda_dll); - return -1; - } - - cuMemcpy2DAsync_ld = - (TcuMemcpy2DAsync)GetProcAddress(nvcuda_dll, "cuMemcpy2DAsync_v2"); - if (cuMemcpy2DAsync_ld == NULL) { - LOG_ERROR("Unable to find function cuMemcpy2DAsync()"); - FreeLibrary(nvcuda_dll); - return -1; - } - - cuStreamSynchronize_ld = - (TcuStreamSynchronize)GetProcAddress(nvcuda_dll, "cuStreamSynchronize"); - if (cuStreamSynchronize_ld == NULL) { - LOG_ERROR("Unable to find function cuStreamSynchronize()"); - FreeLibrary(nvcuda_dll); - return -1; - } - - cuMemcpy2D_ld = (TcuMemcpy2D)GetProcAddress(nvcuda_dll, "cuMemcpy2D_v2"); - if (cuMemcpy2D_ld == NULL) { - LOG_ERROR("Unable to find function cuMemcpy2D()"); - FreeLibrary(nvcuda_dll); - return -1; - } - - cuMemcpy2DUnaligned_ld = (TcuMemcpy2DUnaligned)GetProcAddress( - nvcuda_dll, "cuMemcpy2DUnaligned_v2"); - if (cuMemcpy2DUnaligned_ld == NULL) { - LOG_ERROR("Unable to find function cuMemcpy2DUnaligned()"); - FreeLibrary(nvcuda_dll); - return -1; - } - - // - nvcuvid_dll = LoadLibrary(TEXT("nvcuvid.dll")); - if (nvcuvid_dll == NULL) { - LOG_ERROR("Unable to load nvcuvid.dll"); - return -1; - } - - cuvidCtxLockCreate_ld = - (TcuvidCtxLockCreate)GetProcAddress(nvcuvid_dll, "cuvidCtxLockCreate"); - if (cuvidCtxLockCreate_ld == NULL) { - LOG_ERROR("Unable to find function cuvidCtxLockCreate()"); - FreeLibrary(nvcuvid_dll); - return -1; - } - - cuvidGetDecoderCaps_ld = - (TcuvidGetDecoderCaps)GetProcAddress(nvcuvid_dll, "cuvidGetDecoderCaps"); - if (cuvidGetDecoderCaps_ld == NULL) { - LOG_ERROR("Unable to find function cuvidGetDecoderCaps()"); - FreeLibrary(nvcuvid_dll); - return -1; - } - - cuvidCreateDecoder_ld = - (TcuvidCreateDecoder)GetProcAddress(nvcuvid_dll, "cuvidCreateDecoder"); - if (cuvidCreateDecoder_ld == NULL) { - LOG_ERROR("Unable to find function cuvidCreateDecoder()"); - FreeLibrary(nvcuvid_dll); - return -1; - } - - cuvidDestroyDecoder_ld = - (TcuvidDestroyDecoder)GetProcAddress(nvcuvid_dll, "cuvidDestroyDecoder"); - if (cuvidDestroyDecoder_ld == NULL) { - LOG_ERROR("Unable to find function cuvidDestroyDecoder()"); - FreeLibrary(nvcuvid_dll); - return -1; - } - - cuvidDecodePicture_ld = - (TcuvidDecodePicture)GetProcAddress(nvcuvid_dll, "cuvidDecodePicture"); - if (cuvidDecodePicture_ld == NULL) { - LOG_ERROR("Unable to find function cuvidDecodePicture()"); - FreeLibrary(nvcuvid_dll); - return -1; - } - - cuvidGetDecodeStatus_ld = (TcuvidGetDecodeStatus)GetProcAddress( - nvcuvid_dll, "cuvidGetDecodeStatus"); - if (cuvidGetDecodeStatus_ld == NULL) { - LOG_ERROR("Unable to find function cuvidGetDecodeStatus()"); - FreeLibrary(nvcuvid_dll); - return -1; - } - - cuvidReconfigureDecoder_ld = (TcuvidReconfigureDecoder)GetProcAddress( - nvcuvid_dll, "cuvidReconfigureDecoder"); - if (cuvidReconfigureDecoder_ld == NULL) { - LOG_ERROR("Unable to find function cuvidReconfigureDecoder()"); - FreeLibrary(nvcuvid_dll); - return -1; - } - - cuvidMapVideoFrame64_ld = (TcuvidMapVideoFrame64)GetProcAddress( - nvcuvid_dll, "cuvidMapVideoFrame64"); - if (cuvidMapVideoFrame64_ld == NULL) { - LOG_ERROR("Unable to find function cuvidMapVideoFrame64()"); - FreeLibrary(nvcuvid_dll); - return -1; - } - - cuvidUnmapVideoFrame64_ld = (TcuvidUnmapVideoFrame64)GetProcAddress( - nvcuvid_dll, "cuvidUnmapVideoFrame64"); - if (cuvidUnmapVideoFrame64_ld == NULL) { - LOG_ERROR("Unable to find function cuvidUnmapVideoFrame64()"); - FreeLibrary(nvcuvid_dll); - return -1; - } - - cuvidCtxLockDestroy_ld = - (TcuvidCtxLockDestroy)GetProcAddress(nvcuvid_dll, "cuvidCtxLockDestroy"); - if (cuvidCtxLockDestroy_ld == NULL) { - LOG_ERROR("Unable to find function cuvidCtxLockDestroy()"); - FreeLibrary(nvcuvid_dll); - return -1; - } - - cuvidCreateVideoParser_ld = (TcuvidCreateVideoParser)GetProcAddress( - nvcuvid_dll, "cuvidCreateVideoParser"); - if (cuvidCreateVideoParser_ld == NULL) { - LOG_ERROR("Unable to find function cuvidCreateVideoParser()"); - FreeLibrary(nvcuvid_dll); - return -1; - } - - cuvidParseVideoData_ld = - (TcuvidParseVideoData)GetProcAddress(nvcuvid_dll, "cuvidParseVideoData"); - if (cuvidParseVideoData_ld == NULL) { - LOG_ERROR("Unable to find function cuvidParseVideoData()"); - FreeLibrary(nvcuvid_dll); - return -1; - } - - cuvidDestroyVideoParser_ld = (TcuvidDestroyVideoParser)GetProcAddress( - nvcuvid_dll, "cuvidDestroyVideoParser"); - if (cuvidDestroyVideoParser_ld == NULL) { - LOG_ERROR("Unable to find function cuvidDestroyVideoParser()"); - FreeLibrary(nvcuvid_dll); - return -1; - } - - // +#ifdef _WIN32 nvEncodeAPI64_dll = LoadLibrary(TEXT("nvEncodeAPI64.dll")); if (nvEncodeAPI64_dll == NULL) { - LOG_ERROR("Unable to load nvEncodeAPI64.dll"); + LOG_ERROR("Unable to load library nvEncodeAPI64.dll"); return -1; } - NvEncodeAPICreateInstance_ld = (TNvEncodeAPICreateInstance)GetProcAddress( - nvEncodeAPI64_dll, "NvEncodeAPICreateInstance"); - if (NvEncodeAPICreateInstance_ld == NULL) { - LOG_ERROR("Unable to find function NvEncodeAPICreateInstance()"); - FreeLibrary(nvEncodeAPI64_dll); - return -1; - } - - NvEncodeAPIGetMaxSupportedVersion_ld = - (TNvEncodeAPIGetMaxSupportedVersion)GetProcAddress( - nvEncodeAPI64_dll, "NvEncodeAPIGetMaxSupportedVersion"); - if (NvEncodeAPIGetMaxSupportedVersion_ld == NULL) { - LOG_ERROR("Unable to find function NvEncodeAPIGetMaxSupportedVersion()"); - FreeLibrary(nvEncodeAPI64_dll); + if (LoadFunctionHelper(nvEncodeAPI64_dll, + (void**)&NvEncodeAPICreateInstance_ld, + "NvEncodeAPICreateInstance") != 0 || + LoadFunctionHelper(nvEncodeAPI64_dll, + (void**)&NvEncodeAPIGetMaxSupportedVersion_ld, + "NvEncodeAPIGetMaxSupportedVersion") != 0) { + FreeLibraryHelper(&nvEncodeAPI64_dll); return -1; } +#endif LOG_INFO("Load NvCodec API success"); @@ -293,18 +182,15 @@ int LoadNvCodecDll() { int ReleaseNvCodecDll() { if (nvcuda_dll != NULL) { - FreeLibrary(nvcuda_dll); - nvcuda_dll = NULL; + FreeLibraryHelper(&nvcuda_dll); } if (nvcuvid_dll != NULL) { - FreeLibrary(nvcuvid_dll); - nvcuvid_dll = NULL; + FreeLibraryHelper(&nvcuvid_dll); } if (nvEncodeAPI64_dll != NULL) { - FreeLibrary(nvEncodeAPI64_dll); - nvEncodeAPI64_dll = NULL; + FreeLibraryHelper(&nvEncodeAPI64_dll); } LOG_INFO("Release NvCodec API success"); diff --git a/src/media/nvcodec/nvcodec_api.h b/src/media/nvcodec/nvcodec_api.h index 5506235..5506242 100644 --- a/src/media/nvcodec/nvcodec_api.h +++ b/src/media/nvcodec/nvcodec_api.h @@ -7,7 +7,9 @@ #ifndef _NVCODEC_API_H_ #define _NVCODEC_API_H_ +#if __WIN32__ #include +#endif #include @@ -115,4 +117,4 @@ int LoadNvCodecDll(); int ReleaseNvCodecDll(); -#endif \ No newline at end of file +#endif diff --git a/src/statistics/io_statistics.h b/src/statistics/io_statistics.h index 5470600..4028a33 100644 --- a/src/statistics/io_statistics.h +++ b/src/statistics/io_statistics.h @@ -7,6 +7,7 @@ #ifndef _STATISTICS_H_ #define _STATISTICS_H_ +#include #include #include #include diff --git a/thirdparty/nvcodec/Interface/cuviddec.h b/thirdparty/nvcodec/interface/cuviddec.h similarity index 100% rename from thirdparty/nvcodec/Interface/cuviddec.h rename to thirdparty/nvcodec/interface/cuviddec.h diff --git a/thirdparty/nvcodec/Interface/nvEncodeAPI.h b/thirdparty/nvcodec/interface/nvEncodeAPI.h similarity index 100% rename from thirdparty/nvcodec/Interface/nvEncodeAPI.h rename to thirdparty/nvcodec/interface/nvEncodeAPI.h diff --git a/thirdparty/nvcodec/Interface/nvcuvid.h b/thirdparty/nvcodec/interface/nvcuvid.h similarity index 100% rename from thirdparty/nvcodec/Interface/nvcuvid.h rename to thirdparty/nvcodec/interface/nvcuvid.h diff --git a/thirdparty/nvcodec/Lib/linux/stubs/aarch64/libnvcuvid.so b/thirdparty/nvcodec/lib/linux/stubs/aarch64/libnvcuvid.so similarity index 100% rename from thirdparty/nvcodec/Lib/linux/stubs/aarch64/libnvcuvid.so rename to thirdparty/nvcodec/lib/linux/stubs/aarch64/libnvcuvid.so diff --git a/thirdparty/nvcodec/Lib/linux/stubs/aarch64/libnvidia-encode.so b/thirdparty/nvcodec/lib/linux/stubs/aarch64/libnvidia-encode.so similarity index 100% rename from thirdparty/nvcodec/Lib/linux/stubs/aarch64/libnvidia-encode.so rename to thirdparty/nvcodec/lib/linux/stubs/aarch64/libnvidia-encode.so diff --git a/thirdparty/nvcodec/Lib/linux/stubs/ppc64le/libnvcuvid.so b/thirdparty/nvcodec/lib/linux/stubs/ppc64le/libnvcuvid.so similarity index 100% rename from thirdparty/nvcodec/Lib/linux/stubs/ppc64le/libnvcuvid.so rename to thirdparty/nvcodec/lib/linux/stubs/ppc64le/libnvcuvid.so diff --git a/thirdparty/nvcodec/Lib/linux/stubs/ppc64le/libnvidia-encode.so b/thirdparty/nvcodec/lib/linux/stubs/ppc64le/libnvidia-encode.so similarity index 100% rename from thirdparty/nvcodec/Lib/linux/stubs/ppc64le/libnvidia-encode.so rename to thirdparty/nvcodec/lib/linux/stubs/ppc64le/libnvidia-encode.so diff --git a/thirdparty/nvcodec/Lib/linux/stubs/x86_64/libnvcuvid.so b/thirdparty/nvcodec/lib/linux/stubs/x86_64/libnvcuvid.so similarity index 100% rename from thirdparty/nvcodec/Lib/linux/stubs/x86_64/libnvcuvid.so rename to thirdparty/nvcodec/lib/linux/stubs/x86_64/libnvcuvid.so diff --git a/thirdparty/nvcodec/Lib/linux/stubs/x86_64/libnvidia-encode.so b/thirdparty/nvcodec/lib/linux/stubs/x86_64/libnvidia-encode.so similarity index 100% rename from thirdparty/nvcodec/Lib/linux/stubs/x86_64/libnvidia-encode.so rename to thirdparty/nvcodec/lib/linux/stubs/x86_64/libnvidia-encode.so diff --git a/thirdparty/nvcodec/Lib/Win32/nvcuvid.lib b/thirdparty/nvcodec/lib/win32/nvcuvid.lib similarity index 100% rename from thirdparty/nvcodec/Lib/Win32/nvcuvid.lib rename to thirdparty/nvcodec/lib/win32/nvcuvid.lib diff --git a/thirdparty/nvcodec/Lib/Win32/nvencodeapi.lib b/thirdparty/nvcodec/lib/win32/nvencodeapi.lib similarity index 100% rename from thirdparty/nvcodec/Lib/Win32/nvencodeapi.lib rename to thirdparty/nvcodec/lib/win32/nvencodeapi.lib diff --git a/thirdparty/nvcodec/Lib/x64/nvcuvid.lib b/thirdparty/nvcodec/lib/x64/nvcuvid.lib similarity index 100% rename from thirdparty/nvcodec/Lib/x64/nvcuvid.lib rename to thirdparty/nvcodec/lib/x64/nvcuvid.lib diff --git a/thirdparty/nvcodec/Lib/x64/nvencodeapi.lib b/thirdparty/nvcodec/lib/x64/nvencodeapi.lib similarity index 100% rename from thirdparty/nvcodec/Lib/x64/nvencodeapi.lib rename to thirdparty/nvcodec/lib/x64/nvencodeapi.lib diff --git a/xmake.lua b/xmake.lua index 733b570..fa688ea 100644 --- a/xmake.lua +++ b/xmake.lua @@ -25,8 +25,6 @@ if is_os("windows") then add_defines("_WEBSOCKETPP_CPP11_INTERNAL_") add_cxflags("/WX") elseif is_os("linux") then - add_requires("glib", {system = true}) - add_packages("glib") add_cxflags("-fPIC", "-Wno-unused-variable") add_syslinks("pthread") elseif is_os("macosx") then @@ -173,7 +171,7 @@ target("media") "src/media/nvcodec", "thirdparty/nvcodec/interface", {public = true}) add_includedirs(path.join(os.getenv("CUDA_PATH"), "include"), {public = true}) - elseif is_os(("linux")) then + elseif is_os("linux") then add_files("src/media/video/encode/*.cpp", "src/media/video/decode/*.cpp", "src/media/video/encode/nvcodec/*.cpp", @@ -244,7 +242,7 @@ target("projectx") "ws2_32", "Bcrypt", "windowsapp", "User32", "Strmiids", "Mfuuid", "Secur32", "Bcrypt") add_links("cuda", "nvencodeapi", "nvcuvid") - elseif is_os(("linux")) then + elseif is_os("linux") then add_linkdirs("thirdparty/nvcodec/lib/x64") add_linkdirs(path.join(os.getenv("CUDA_PATH"), "lib/x64")) add_links("cuda", "nvidia-encode", "nvcuvid") @@ -310,4 +308,4 @@ target("projectx") -- add_files("tests/opus/OpusEncoderImpl.cpp", -- "tests/opus/OpusDecoderImpl.cpp", -- "tests/opus/main.cpp") --- add_includedirs("tests/opus") \ No newline at end of file +-- add_includedirs("tests/opus")