Fix MacOS compile error

This commit is contained in:
dijunkun
2023-10-07 10:07:45 +08:00
parent 36305eef46
commit 0a7dd291f1
5 changed files with 36 additions and 8 deletions

View File

@@ -1,8 +1,13 @@
#include "video_decoder_factory.h"
#if __APPLE__
#include "ffmpeg/ffmpeg_video_decoder.h"
#else
#include "ffmpeg/ffmpeg_video_decoder.h"
#include "log.h"
#include "nvcodec/nvidia_video_decoder.h"
#endif
#include "log.h"
VideoDecoderFactory::VideoDecoderFactory() {}
@@ -10,6 +15,9 @@ VideoDecoderFactory::~VideoDecoderFactory() {}
std::unique_ptr<VideoDecoder> VideoDecoderFactory::CreateVideoDecoder(
bool hardware_acceleration) {
#if __APPLE__
return std::make_unique<FfmpegVideoDecoder>(FfmpegVideoDecoder());
#else
if (hardware_acceleration) {
if (CheckIsHardwareAccerlerationSupported()) {
return std::make_unique<NvidiaVideoDecoder>(NvidiaVideoDecoder());
@@ -19,9 +27,13 @@ std::unique_ptr<VideoDecoder> VideoDecoderFactory::CreateVideoDecoder(
} else {
return std::make_unique<FfmpegVideoDecoder>(FfmpegVideoDecoder());
}
#endif
}
bool VideoDecoderFactory::CheckIsHardwareAccerlerationSupported() {
#if __APPLE__
return false;
#else
CUresult cuResult;
CUvideoctxlock cudaCtxLock;
@@ -34,4 +46,5 @@ bool VideoDecoderFactory::CheckIsHardwareAccerlerationSupported() {
}
return true;
#endif
}