mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
Fix MacOS compile error
This commit is contained in:
@@ -231,7 +231,7 @@ std::string GetMac(char *mac_addr) {
|
|||||||
(const struct sockaddr_dl *)cursor->ifa_addr;
|
(const struct sockaddr_dl *)cursor->ifa_addr;
|
||||||
if ((cursor->ifa_addr->sa_family == AF_LINK) &&
|
if ((cursor->ifa_addr->sa_family == AF_LINK) &&
|
||||||
(socAddr->sdl_type == IFT_ETHER) &&
|
(socAddr->sdl_type == IFT_ETHER) &&
|
||||||
strcmp(if_name, cursor->ifa_name) == 0) {
|
strcmp(if_name.c_str(), cursor->ifa_name) == 0) {
|
||||||
dlAddr = (const struct sockaddr_dl *)cursor->ifa_addr;
|
dlAddr = (const struct sockaddr_dl *)cursor->ifa_addr;
|
||||||
const unsigned char *base =
|
const unsigned char *base =
|
||||||
(const unsigned char *)&dlAddr->sdl_data[dlAddr->sdl_nlen];
|
(const unsigned char *)&dlAddr->sdl_data[dlAddr->sdl_nlen];
|
||||||
|
|||||||
@@ -101,10 +101,8 @@ int FfmpegVideoDecoder::Decode(
|
|||||||
std::function<void(VideoFrame)> on_receive_decoded_frame) {
|
std::function<void(VideoFrame)> on_receive_decoded_frame) {
|
||||||
if (!first_) {
|
if (!first_) {
|
||||||
if ((*(data + 4) & 0x1f) != 0x07) {
|
if ((*(data + 4) & 0x1f) != 0x07) {
|
||||||
LOG_ERROR("1");
|
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR("2");
|
|
||||||
first_ = true;
|
first_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,7 +147,7 @@ int FfmpegVideoDecoder::Decode(
|
|||||||
std::chrono::high_resolution_clock::now().time_since_epoch())
|
std::chrono::high_resolution_clock::now().time_since_epoch())
|
||||||
.count());
|
.count());
|
||||||
|
|
||||||
LOG_ERROR("cost {}", now_ts - start_ts);
|
// LOG_ERROR("cost {}", now_ts - start_ts);
|
||||||
|
|
||||||
on_receive_decoded_frame(*decoded_frame_);
|
on_receive_decoded_frame(*decoded_frame_);
|
||||||
if (SAVE_DECODER_STREAM) {
|
if (SAVE_DECODER_STREAM) {
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
#include "video_decoder_factory.h"
|
#include "video_decoder_factory.h"
|
||||||
|
|
||||||
|
#if __APPLE__
|
||||||
|
#include "ffmpeg/ffmpeg_video_decoder.h"
|
||||||
|
#else
|
||||||
#include "ffmpeg/ffmpeg_video_decoder.h"
|
#include "ffmpeg/ffmpeg_video_decoder.h"
|
||||||
#include "log.h"
|
|
||||||
#include "nvcodec/nvidia_video_decoder.h"
|
#include "nvcodec/nvidia_video_decoder.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
VideoDecoderFactory::VideoDecoderFactory() {}
|
VideoDecoderFactory::VideoDecoderFactory() {}
|
||||||
|
|
||||||
@@ -10,6 +15,9 @@ VideoDecoderFactory::~VideoDecoderFactory() {}
|
|||||||
|
|
||||||
std::unique_ptr<VideoDecoder> VideoDecoderFactory::CreateVideoDecoder(
|
std::unique_ptr<VideoDecoder> VideoDecoderFactory::CreateVideoDecoder(
|
||||||
bool hardware_acceleration) {
|
bool hardware_acceleration) {
|
||||||
|
#if __APPLE__
|
||||||
|
return std::make_unique<FfmpegVideoDecoder>(FfmpegVideoDecoder());
|
||||||
|
#else
|
||||||
if (hardware_acceleration) {
|
if (hardware_acceleration) {
|
||||||
if (CheckIsHardwareAccerlerationSupported()) {
|
if (CheckIsHardwareAccerlerationSupported()) {
|
||||||
return std::make_unique<NvidiaVideoDecoder>(NvidiaVideoDecoder());
|
return std::make_unique<NvidiaVideoDecoder>(NvidiaVideoDecoder());
|
||||||
@@ -19,9 +27,13 @@ std::unique_ptr<VideoDecoder> VideoDecoderFactory::CreateVideoDecoder(
|
|||||||
} else {
|
} else {
|
||||||
return std::make_unique<FfmpegVideoDecoder>(FfmpegVideoDecoder());
|
return std::make_unique<FfmpegVideoDecoder>(FfmpegVideoDecoder());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VideoDecoderFactory::CheckIsHardwareAccerlerationSupported() {
|
bool VideoDecoderFactory::CheckIsHardwareAccerlerationSupported() {
|
||||||
|
#if __APPLE__
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
CUresult cuResult;
|
CUresult cuResult;
|
||||||
|
|
||||||
CUvideoctxlock cudaCtxLock;
|
CUvideoctxlock cudaCtxLock;
|
||||||
@@ -34,4 +46,5 @@ bool VideoDecoderFactory::CheckIsHardwareAccerlerationSupported() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,13 @@
|
|||||||
#include "video_encoder_factory.h"
|
#include "video_encoder_factory.h"
|
||||||
|
|
||||||
|
#if __APPLE__
|
||||||
|
#include "ffmpeg/ffmpeg_video_encoder.h"
|
||||||
|
#else
|
||||||
#include "ffmpeg/ffmpeg_video_encoder.h"
|
#include "ffmpeg/ffmpeg_video_encoder.h"
|
||||||
#include "log.h"
|
|
||||||
#include "nvcodec/nvidia_video_encoder.h"
|
#include "nvcodec/nvidia_video_encoder.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
VideoEncoderFactory::VideoEncoderFactory() {}
|
VideoEncoderFactory::VideoEncoderFactory() {}
|
||||||
|
|
||||||
@@ -10,6 +15,9 @@ VideoEncoderFactory::~VideoEncoderFactory() {}
|
|||||||
|
|
||||||
std::unique_ptr<VideoEncoder> VideoEncoderFactory::CreateVideoEncoder(
|
std::unique_ptr<VideoEncoder> VideoEncoderFactory::CreateVideoEncoder(
|
||||||
bool hardware_acceleration) {
|
bool hardware_acceleration) {
|
||||||
|
#if __APPLE__
|
||||||
|
return std::make_unique<FFmpegVideoEncoder>(FFmpegVideoEncoder());
|
||||||
|
#else
|
||||||
if (hardware_acceleration) {
|
if (hardware_acceleration) {
|
||||||
if (CheckIsHardwareAccerlerationSupported()) {
|
if (CheckIsHardwareAccerlerationSupported()) {
|
||||||
return std::make_unique<NvidiaVideoEncoder>(NvidiaVideoEncoder());
|
return std::make_unique<NvidiaVideoEncoder>(NvidiaVideoEncoder());
|
||||||
@@ -19,9 +27,13 @@ std::unique_ptr<VideoEncoder> VideoEncoderFactory::CreateVideoEncoder(
|
|||||||
} else {
|
} else {
|
||||||
return std::make_unique<FFmpegVideoEncoder>(FFmpegVideoEncoder());
|
return std::make_unique<FFmpegVideoEncoder>(FFmpegVideoEncoder());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VideoEncoderFactory::CheckIsHardwareAccerlerationSupported() {
|
bool VideoEncoderFactory::CheckIsHardwareAccerlerationSupported() {
|
||||||
|
#if __APPLE__
|
||||||
|
return false;
|
||||||
|
#else
|
||||||
CUresult cuResult;
|
CUresult cuResult;
|
||||||
NV_ENCODE_API_FUNCTION_LIST functionList = {NV_ENCODE_API_FUNCTION_LIST_VER};
|
NV_ENCODE_API_FUNCTION_LIST functionList = {NV_ENCODE_API_FUNCTION_LIST_VER};
|
||||||
|
|
||||||
@@ -42,4 +54,5 @@ bool VideoEncoderFactory::CheckIsHardwareAccerlerationSupported() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
@@ -139,9 +139,13 @@ target("media")
|
|||||||
add_linkdirs("thirdparty/nvcodec/Lib/x64")
|
add_linkdirs("thirdparty/nvcodec/Lib/x64")
|
||||||
add_links("cuda", "nvidia-encode", "nvcuvid")
|
add_links("cuda", "nvidia-encode", "nvcuvid")
|
||||||
elseif is_os("macosx") then
|
elseif is_os("macosx") then
|
||||||
add_files("src/media/video/encode/ffmpeg/*.cpp",
|
add_files("src/media/video/encode/*.cpp",
|
||||||
|
"src/media/video/decode/*.cpp",
|
||||||
|
"src/media/video/encode/ffmpeg/*.cpp",
|
||||||
"src/media/video/decode/ffmpeg/*.cpp")
|
"src/media/video/decode/ffmpeg/*.cpp")
|
||||||
add_includedirs("src/media/video/encode/ffmpeg",
|
add_includedirs("src/media/video/encode",
|
||||||
|
"src/media/video/decode",
|
||||||
|
"src/media/video/encode/ffmpeg",
|
||||||
"src/media/video/decode/ffmpeg", {public = true})
|
"src/media/video/decode/ffmpeg", {public = true})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user