From 49ddde28c014dcde6b8c1259612e3d6e802ed136 Mon Sep 17 00:00:00 2001 From: xia-chu <771730766@qq.com> Date: Fri, 22 Mar 2024 20:36:09 +0800 Subject: [PATCH] Refactor code --- ext-codec/H264Rtmp.cpp | 8 -------- ext-codec/H265Rtmp.cpp | 8 -------- src/Common/macros.h | 10 ++++++++++ 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/ext-codec/H264Rtmp.cpp b/ext-codec/H264Rtmp.cpp index 30bf10eb..6dd50807 100644 --- a/ext-codec/H264Rtmp.cpp +++ b/ext-codec/H264Rtmp.cpp @@ -14,14 +14,6 @@ using namespace std; using namespace toolkit; -#define CHECK_RET(...) \ - try { \ - CHECK(__VA_ARGS__); \ - } catch (AssertFailedException & ex) { \ - WarnL << ex.what(); \ - return; \ - } - namespace mediakit { void H264RtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) { diff --git a/ext-codec/H265Rtmp.cpp b/ext-codec/H265Rtmp.cpp index 2b88795d..69a27390 100644 --- a/ext-codec/H265Rtmp.cpp +++ b/ext-codec/H265Rtmp.cpp @@ -18,14 +18,6 @@ using namespace std; using namespace toolkit; -#define CHECK_RET(...) \ - try { \ - CHECK(__VA_ARGS__); \ - } catch (AssertFailedException & ex) { \ - WarnL << ex.what(); \ - return; \ - } - namespace mediakit { void H265RtmpDecoder::inputRtmp(const RtmpPacket::Ptr &pkt) { diff --git a/src/Common/macros.h b/src/Common/macros.h index 796bd326..b1187810 100644 --- a/src/Common/macros.h +++ b/src/Common/macros.h @@ -36,6 +36,16 @@ #define CHECK(exp, ...) ::mediakit::Assert_ThrowCpp(!(exp), #exp, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__) #endif // CHECK +#ifndef CHECK_RET +#define CHECK_RET(...) \ + try { \ + CHECK(__VA_ARGS__); \ + } catch (AssertFailedException & ex) { \ + WarnL << ex.what(); \ + return; \ + } +#endif + #ifndef MAX #define MAX(a, b) ((a) > (b) ? (a) : (b)) #endif // MAX