From da704ab2f1184c3c87be64fe18c9f413de101d0f Mon Sep 17 00:00:00 2001
From: xia-chu <771730766@qq.com>
Date: Sun, 4 Aug 2024 20:46:05 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=B9=B6=E9=80=82=E9=85=8DZL?=
 =?UTF-8?q?ToolKit?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 3rdpart/ZLToolKit         |  2 +-
 src/Common/macros.cpp     | 15 ---------------
 src/Common/macros.h       | 21 ++++-----------------
 src/Rtp/PSDecoder.cpp     |  2 +-
 src/Rtsp/RtspSplitter.cpp |  2 +-
 5 files changed, 7 insertions(+), 35 deletions(-)

diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit
index fb695d2034..abf61efe35 160000
--- a/3rdpart/ZLToolKit
+++ b/3rdpart/ZLToolKit
@@ -1 +1 @@
-Subproject commit fb695d203421d906c473018022a736fa4a7a47e4
+Subproject commit abf61efe35d99a775669d417f0c3e8f8d0992f0e
diff --git a/src/Common/macros.cpp b/src/Common/macros.cpp
index 5e403b6a87..f6529ce4ab 100644
--- a/src/Common/macros.cpp
+++ b/src/Common/macros.cpp
@@ -9,7 +9,6 @@
  */
 
 #include "macros.h"
-#include "Util/util.h"
 
 using namespace toolkit;
 
@@ -17,20 +16,6 @@ using namespace toolkit;
 #include "ZLMVersion.h"
 #endif
 
-extern "C" {
-void Assert_Throw(int failed, const char *exp, const char *func, const char *file, int line, const char *str) {
-    if (failed) {
-        _StrPrinter printer;
-        printer << "Assertion failed: (" << exp ;
-        if(str && *str){
-            printer << ", " << str;
-        }
-        printer << "), function " << func << ", file " << file << ", line " << line << ".";
-        throw mediakit::AssertFailedException(printer);
-    }
-}
-}
-
 namespace mediakit {
 
 /**
diff --git a/src/Common/macros.h b/src/Common/macros.h
index b1187810cc..e9f87826fb 100644
--- a/src/Common/macros.h
+++ b/src/Common/macros.h
@@ -11,9 +11,10 @@
 #ifndef ZLMEDIAKIT_MACROS_H
 #define ZLMEDIAKIT_MACROS_H
 
-#include "Util/logger.h"
-#include <iostream>
 #include <sstream>
+#include <iostream>
+#include "Util/util.h"
+#include "Util/logger.h"
 #if defined(__MACH__)
 #include <arpa/inet.h>
 #include <machine/endian.h>
@@ -40,7 +41,7 @@
 #define CHECK_RET(...)                                                         \
     try {                                                                      \
         CHECK(__VA_ARGS__);                                                    \
-    } catch (AssertFailedException & ex) {                                     \
+    } catch (toolkit::AssertFailedException & ex) {                                     \
         WarnL << ex.what();                                                    \
         return;                                                                \
     }
@@ -71,22 +72,8 @@
 #define VHOST_KEY "vhost"
 #define DEFAULT_VHOST "__defaultVhost__"
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-extern void Assert_Throw(int failed, const char *exp, const char *func, const char *file, int line, const char *str);
-#ifdef __cplusplus
-}
-#endif
-
 namespace mediakit {
 
-class AssertFailedException : public std::runtime_error {
-public:
-    template<typename ...T>
-    AssertFailedException(T && ...args) : std::runtime_error(std::forward<T>(args)...) {}
-};
-
 extern const char kServerName[];
 
 template <typename... ARGS>
diff --git a/src/Rtp/PSDecoder.cpp b/src/Rtp/PSDecoder.cpp
index f176670ab2..4949e2369a 100644
--- a/src/Rtp/PSDecoder.cpp
+++ b/src/Rtp/PSDecoder.cpp
@@ -63,7 +63,7 @@ const char *PSDecoder::onSearchPacketTail(const char *data, size_t len) {
 
         //解析失败,丢弃所有数据
         return data + len;
-    } catch (AssertFailedException &ex) {
+    } catch (toolkit::AssertFailedException &ex) {
         InfoL << "解析 ps 异常: bytes=" << len
               << ", exception=" << ex.what()
               << ", hex=" << hexdump(data, MIN(len, 32));
diff --git a/src/Rtsp/RtspSplitter.cpp b/src/Rtsp/RtspSplitter.cpp
index 837728f2d3..aaf8bfe701 100644
--- a/src/Rtsp/RtspSplitter.cpp
+++ b/src/Rtsp/RtspSplitter.cpp
@@ -72,7 +72,7 @@ ssize_t RtspSplitter::onRecvHeader(const char *data, size_t len) {
     }
     try {
         _parser.parse(data, len);
-    } catch (mediakit::AssertFailedException &ex){
+    } catch (toolkit::AssertFailedException &ex){
         if (!_enableRecvRtp) {
             // 还在握手中,直接中断握手
             throw;