mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 12:15:34 +08:00
[fix] use lowercase for nvcodec folder name
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
// 简化版的 AnyInvocable
|
// 简化版的 AnyInvocable
|
||||||
template <typename Signature>
|
template <typename Signature>
|
||||||
@@ -21,15 +22,25 @@ class AnyInvocable<R(Args...)> {
|
|||||||
// 默认构造函数
|
// 默认构造函数
|
||||||
AnyInvocable() = default;
|
AnyInvocable() = default;
|
||||||
|
|
||||||
// 构造函数:接受一个可以调用的对象
|
AnyInvocable(std::nullptr_t) noexcept : callable_(nullptr) {}
|
||||||
template <typename Callable>
|
|
||||||
|
// 构造函数:接受一个可以调用的对象(排除 nullptr)
|
||||||
|
template <typename Callable, typename = std::enable_if_t<!std::is_same_v<
|
||||||
|
std::decay_t<Callable>, std::nullptr_t>>>
|
||||||
AnyInvocable(Callable&& callable)
|
AnyInvocable(Callable&& callable)
|
||||||
: callable_(std::make_unique<CallableWrapper<Callable>>(
|
: callable_(std::make_unique<CallableWrapper<Callable>>(
|
||||||
std::forward<Callable>(callable))) {}
|
std::forward<Callable>(callable))) {}
|
||||||
|
|
||||||
// 调用运算符
|
// 调用运算符(支持 void 和非 void 返回类型)
|
||||||
R operator()(Args... args) {
|
R operator()(Args... args) {
|
||||||
return callable_->Invoke(std::forward<Args>(args)...);
|
if (!callable_) {
|
||||||
|
throw std::bad_function_call();
|
||||||
|
}
|
||||||
|
if constexpr (std::is_void_v<R>) {
|
||||||
|
callable_->Invoke(std::forward<Args>(args)...);
|
||||||
|
} else {
|
||||||
|
return callable_->Invoke(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 移动构造函数
|
// 移动构造函数
|
||||||
@@ -37,6 +48,7 @@ class AnyInvocable<R(Args...)> {
|
|||||||
// 移动赋值运算符
|
// 移动赋值运算符
|
||||||
AnyInvocable& operator=(AnyInvocable&&) = default;
|
AnyInvocable& operator=(AnyInvocable&&) = default;
|
||||||
|
|
||||||
|
// 判断是否有效
|
||||||
explicit operator bool() const { return static_cast<bool>(callable_); }
|
explicit operator bool() const { return static_cast<bool>(callable_); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -53,7 +65,11 @@ class AnyInvocable<R(Args...)> {
|
|||||||
: callable_(std::forward<Callable>(callable)) {}
|
: callable_(std::forward<Callable>(callable)) {}
|
||||||
|
|
||||||
R Invoke(Args&&... args) override {
|
R Invoke(Args&&... args) override {
|
||||||
return callable_(std::forward<Args>(args)...);
|
if constexpr (std::is_void_v<R>) {
|
||||||
|
callable_(std::forward<Args>(args)...);
|
||||||
|
} else {
|
||||||
|
return callable_(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Callable callable_;
|
Callable callable_;
|
||||||
@@ -68,4 +84,4 @@ AnyInvocable<R(Args...)> MakeMoveOnlyFunction(std::function<R(Args...)>&& f) {
|
|||||||
return AnyInvocable<R(Args...)>(std::move(f));
|
return AnyInvocable<R(Args...)>(std::move(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif // _ANY_INVOCABLE_H_
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#ifndef RTC_BASE_NUMERICS_SAFE_CONVERSIONS_IMPL_H_
|
#ifndef RTC_BASE_NUMERICS_SAFE_CONVERSIONS_IMPL_H_
|
||||||
#define RTC_BASE_NUMERICS_SAFE_CONVERSIONS_IMPL_H_
|
#define RTC_BASE_NUMERICS_SAFE_CONVERSIONS_IMPL_H_
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#undef max
|
#undef max
|
||||||
#undef min
|
#undef min
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#if defined(__POSIX__)
|
#if defined(__linux__)
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
@@ -54,7 +54,7 @@ int64_t SystemTimeNanos() {
|
|||||||
return rtc::dchecked_cast<int64_t>(a * b);
|
return rtc::dchecked_cast<int64_t>(a * b);
|
||||||
};
|
};
|
||||||
ticks = mul(mach_absolute_time(), timebase.numer) / timebase.denom;
|
ticks = mul(mach_absolute_time(), timebase.numer) / timebase.denom;
|
||||||
#elif defined(__POSIX__)
|
#elif defined(__linux__)
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
// TODO(deadbeef): Do we need to handle the case when CLOCK_MONOTONIC is not
|
// TODO(deadbeef): Do we need to handle the case when CLOCK_MONOTONIC is not
|
||||||
// supported?
|
// supported?
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
#include "nvcodec_api.h"
|
#include "nvcodec_api.h"
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#else
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
TcuInit cuInit_ld = NULL;
|
TcuInit cuInit_ld = NULL;
|
||||||
@@ -34,257 +39,141 @@ TcuvidDestroyVideoParser cuvidDestroyVideoParser_ld = NULL;
|
|||||||
TNvEncodeAPICreateInstance NvEncodeAPICreateInstance_ld = NULL;
|
TNvEncodeAPICreateInstance NvEncodeAPICreateInstance_ld = NULL;
|
||||||
TNvEncodeAPIGetMaxSupportedVersion NvEncodeAPIGetMaxSupportedVersion_ld = NULL;
|
TNvEncodeAPIGetMaxSupportedVersion NvEncodeAPIGetMaxSupportedVersion_ld = NULL;
|
||||||
|
|
||||||
static HMODULE nvcuda_dll = NULL;
|
static void* nvcuda_dll = NULL;
|
||||||
static HMODULE nvcuvid_dll = NULL;
|
static void* nvcuvid_dll = NULL;
|
||||||
static HMODULE nvEncodeAPI64_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() {
|
int LoadNvCodecDll() {
|
||||||
// Load library
|
if (LoadLibraryHelper(&nvcuda_dll, "nvcuda.dll", "libcuda.so") != 0) {
|
||||||
nvcuda_dll = LoadLibrary(TEXT("nvcuda.dll"));
|
FreeLibraryHelper(&nvcuda_dll);
|
||||||
if (nvcuda_dll == NULL) {
|
|
||||||
LOG_ERROR("Unable to load nvcuda.dll");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cuInit_ld = (TcuInit)GetProcAddress(nvcuda_dll, "cuInit");
|
if (LoadFunctionHelper(nvcuda_dll, (void**)&cuInit_ld, "cuInit") != 0 ||
|
||||||
if (cuInit_ld == NULL) {
|
LoadFunctionHelper(nvcuda_dll, (void**)&cuDeviceGet_ld, "cuDeviceGet") !=
|
||||||
LOG_ERROR("Unable to find function cuInit()");
|
0 ||
|
||||||
FreeLibrary(nvcuda_dll);
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cuDeviceGet_ld = (TcuDeviceGet)GetProcAddress(nvcuda_dll, "cuDeviceGet");
|
if (LoadFunctionHelper(nvcuvid_dll, (void**)&cuvidCtxLockCreate_ld,
|
||||||
if (cuDeviceGet_ld == NULL) {
|
"cuvidCtxLockCreate") != 0 ||
|
||||||
LOG_ERROR("Unable to find function cuDeviceGet()");
|
LoadFunctionHelper(nvcuvid_dll, (void**)&cuvidGetDecoderCaps_ld,
|
||||||
FreeLibrary(nvcuda_dll);
|
"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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cuDeviceGetCount_ld =
|
#ifdef _WIN32
|
||||||
(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
nvEncodeAPI64_dll = LoadLibrary(TEXT("nvEncodeAPI64.dll"));
|
nvEncodeAPI64_dll = LoadLibrary(TEXT("nvEncodeAPI64.dll"));
|
||||||
if (nvEncodeAPI64_dll == NULL) {
|
if (nvEncodeAPI64_dll == NULL) {
|
||||||
LOG_ERROR("Unable to load nvEncodeAPI64.dll");
|
LOG_ERROR("Unable to load library nvEncodeAPI64.dll");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
NvEncodeAPICreateInstance_ld = (TNvEncodeAPICreateInstance)GetProcAddress(
|
if (LoadFunctionHelper(nvEncodeAPI64_dll,
|
||||||
nvEncodeAPI64_dll, "NvEncodeAPICreateInstance");
|
(void**)&NvEncodeAPICreateInstance_ld,
|
||||||
if (NvEncodeAPICreateInstance_ld == NULL) {
|
"NvEncodeAPICreateInstance") != 0 ||
|
||||||
LOG_ERROR("Unable to find function NvEncodeAPICreateInstance()");
|
LoadFunctionHelper(nvEncodeAPI64_dll,
|
||||||
FreeLibrary(nvEncodeAPI64_dll);
|
(void**)&NvEncodeAPIGetMaxSupportedVersion_ld,
|
||||||
return -1;
|
"NvEncodeAPIGetMaxSupportedVersion") != 0) {
|
||||||
}
|
FreeLibraryHelper(&nvEncodeAPI64_dll);
|
||||||
|
|
||||||
NvEncodeAPIGetMaxSupportedVersion_ld =
|
|
||||||
(TNvEncodeAPIGetMaxSupportedVersion)GetProcAddress(
|
|
||||||
nvEncodeAPI64_dll, "NvEncodeAPIGetMaxSupportedVersion");
|
|
||||||
if (NvEncodeAPIGetMaxSupportedVersion_ld == NULL) {
|
|
||||||
LOG_ERROR("Unable to find function NvEncodeAPIGetMaxSupportedVersion()");
|
|
||||||
FreeLibrary(nvEncodeAPI64_dll);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
LOG_INFO("Load NvCodec API success");
|
LOG_INFO("Load NvCodec API success");
|
||||||
|
|
||||||
@@ -293,18 +182,15 @@ int LoadNvCodecDll() {
|
|||||||
|
|
||||||
int ReleaseNvCodecDll() {
|
int ReleaseNvCodecDll() {
|
||||||
if (nvcuda_dll != NULL) {
|
if (nvcuda_dll != NULL) {
|
||||||
FreeLibrary(nvcuda_dll);
|
FreeLibraryHelper(&nvcuda_dll);
|
||||||
nvcuda_dll = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nvcuvid_dll != NULL) {
|
if (nvcuvid_dll != NULL) {
|
||||||
FreeLibrary(nvcuvid_dll);
|
FreeLibraryHelper(&nvcuvid_dll);
|
||||||
nvcuvid_dll = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nvEncodeAPI64_dll != NULL) {
|
if (nvEncodeAPI64_dll != NULL) {
|
||||||
FreeLibrary(nvEncodeAPI64_dll);
|
FreeLibraryHelper(&nvEncodeAPI64_dll);
|
||||||
nvEncodeAPI64_dll = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("Release NvCodec API success");
|
LOG_INFO("Release NvCodec API success");
|
||||||
|
|||||||
@@ -7,7 +7,9 @@
|
|||||||
#ifndef _NVCODEC_API_H_
|
#ifndef _NVCODEC_API_H_
|
||||||
#define _NVCODEC_API_H_
|
#define _NVCODEC_API_H_
|
||||||
|
|
||||||
|
#if __WIN32__
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@@ -115,4 +117,4 @@ int LoadNvCodecDll();
|
|||||||
|
|
||||||
int ReleaseNvCodecDll();
|
int ReleaseNvCodecDll();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#ifndef _STATISTICS_H_
|
#ifndef _STATISTICS_H_
|
||||||
#define _STATISTICS_H_
|
#define _STATISTICS_H_
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ if is_os("windows") then
|
|||||||
add_defines("_WEBSOCKETPP_CPP11_INTERNAL_")
|
add_defines("_WEBSOCKETPP_CPP11_INTERNAL_")
|
||||||
add_cxflags("/WX")
|
add_cxflags("/WX")
|
||||||
elseif is_os("linux") then
|
elseif is_os("linux") then
|
||||||
add_requires("glib", {system = true})
|
|
||||||
add_packages("glib")
|
|
||||||
add_cxflags("-fPIC", "-Wno-unused-variable")
|
add_cxflags("-fPIC", "-Wno-unused-variable")
|
||||||
add_syslinks("pthread")
|
add_syslinks("pthread")
|
||||||
elseif is_os("macosx") then
|
elseif is_os("macosx") then
|
||||||
@@ -173,7 +171,7 @@ target("media")
|
|||||||
"src/media/nvcodec",
|
"src/media/nvcodec",
|
||||||
"thirdparty/nvcodec/interface", {public = true})
|
"thirdparty/nvcodec/interface", {public = true})
|
||||||
add_includedirs(path.join(os.getenv("CUDA_PATH"), "include"), {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",
|
add_files("src/media/video/encode/*.cpp",
|
||||||
"src/media/video/decode/*.cpp",
|
"src/media/video/decode/*.cpp",
|
||||||
"src/media/video/encode/nvcodec/*.cpp",
|
"src/media/video/encode/nvcodec/*.cpp",
|
||||||
@@ -244,7 +242,7 @@ target("projectx")
|
|||||||
"ws2_32", "Bcrypt", "windowsapp", "User32", "Strmiids", "Mfuuid",
|
"ws2_32", "Bcrypt", "windowsapp", "User32", "Strmiids", "Mfuuid",
|
||||||
"Secur32", "Bcrypt")
|
"Secur32", "Bcrypt")
|
||||||
add_links("cuda", "nvencodeapi", "nvcuvid")
|
add_links("cuda", "nvencodeapi", "nvcuvid")
|
||||||
elseif is_os(("linux")) then
|
elseif is_os("linux") then
|
||||||
add_linkdirs("thirdparty/nvcodec/lib/x64")
|
add_linkdirs("thirdparty/nvcodec/lib/x64")
|
||||||
add_linkdirs(path.join(os.getenv("CUDA_PATH"), "lib/x64"))
|
add_linkdirs(path.join(os.getenv("CUDA_PATH"), "lib/x64"))
|
||||||
add_links("cuda", "nvidia-encode", "nvcuvid")
|
add_links("cuda", "nvidia-encode", "nvcuvid")
|
||||||
@@ -310,4 +308,4 @@ target("projectx")
|
|||||||
-- add_files("tests/opus/OpusEncoderImpl.cpp",
|
-- add_files("tests/opus/OpusEncoderImpl.cpp",
|
||||||
-- "tests/opus/OpusDecoderImpl.cpp",
|
-- "tests/opus/OpusDecoderImpl.cpp",
|
||||||
-- "tests/opus/main.cpp")
|
-- "tests/opus/main.cpp")
|
||||||
-- add_includedirs("tests/opus")
|
-- add_includedirs("tests/opus")
|
||||||
|
|||||||
Reference in New Issue
Block a user