Skip to content

Commit

Permalink
更新并适配ZLToolKit
Browse files Browse the repository at this point in the history
  • Loading branch information
xia-chu committed Aug 4, 2024
1 parent 47b8435 commit da704ab
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 35 deletions.
2 changes: 1 addition & 1 deletion 3rdpart/ZLToolKit
Submodule ZLToolKit updated from fb695d to abf61e
15 changes: 0 additions & 15 deletions src/Common/macros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,13 @@
*/

#include "macros.h"
#include "Util/util.h"

using namespace toolkit;

#if defined(ENABLE_VERSION)
#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 {

/**
Expand Down
21 changes: 4 additions & 17 deletions src/Common/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -40,7 +41,7 @@
#define CHECK_RET(...) \
try { \
CHECK(__VA_ARGS__); \
} catch (AssertFailedException & ex) { \
} catch (toolkit::AssertFailedException & ex) { \
WarnL << ex.what(); \
return; \
}
Expand Down Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion src/Rtp/PSDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion src/Rtsp/RtspSplitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit da704ab

Please sign in to comment.