2021-01-31 20:46:55 +08:00
|
|
|
|
/*
|
2021-01-31 19:18:17 +08:00
|
|
|
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by MIT license that can be found in the
|
|
|
|
|
* LICENSE file in the root of the source tree. All contributing project authors
|
|
|
|
|
* may be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef ZLMEDIAKIT_MACROS_H
|
|
|
|
|
#define ZLMEDIAKIT_MACROS_H
|
|
|
|
|
|
2022-06-11 21:37:41 +08:00
|
|
|
|
#include "Util/logger.h"
|
2021-10-16 16:24:40 +08:00
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <sstream>
|
2021-01-31 19:18:17 +08:00
|
|
|
|
#if defined(__MACH__)
|
|
|
|
|
#include <arpa/inet.h>
|
2022-06-11 21:37:41 +08:00
|
|
|
|
#include <machine/endian.h>
|
|
|
|
|
#define __BYTE_ORDER BYTE_ORDER
|
|
|
|
|
#define __BIG_ENDIAN BIG_ENDIAN
|
|
|
|
|
#define __LITTLE_ENDIAN LITTLE_ENDIAN
|
2021-01-31 19:18:17 +08:00
|
|
|
|
#elif defined(__linux__)
|
2022-06-11 21:37:41 +08:00
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
#include <endian.h>
|
2021-01-31 19:18:17 +08:00
|
|
|
|
#elif defined(_WIN32)
|
2022-06-11 21:37:41 +08:00
|
|
|
|
#define BIG_ENDIAN 1
|
|
|
|
|
#define LITTLE_ENDIAN 0
|
|
|
|
|
#define BYTE_ORDER LITTLE_ENDIAN
|
|
|
|
|
#define __BYTE_ORDER BYTE_ORDER
|
|
|
|
|
#define __BIG_ENDIAN BIG_ENDIAN
|
|
|
|
|
#define __LITTLE_ENDIAN LITTLE_ENDIAN
|
2021-01-31 19:18:17 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef PACKED
|
2022-06-11 21:37:41 +08:00
|
|
|
|
#if !defined(_WIN32)
|
|
|
|
|
#define PACKED __attribute__((packed))
|
|
|
|
|
#else
|
|
|
|
|
#define PACKED
|
|
|
|
|
#endif //! defined(_WIN32)
|
2021-01-31 19:18:17 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
2021-06-28 20:29:56 +08:00
|
|
|
|
#ifndef CHECK
|
2022-11-12 21:59:48 +08:00
|
|
|
|
#define CHECK(exp, ...) ::mediakit::Assert_ThrowCpp(!(exp), #exp, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__)
|
2022-06-11 21:37:41 +08:00
|
|
|
|
#endif // CHECK
|
2021-06-28 20:29:56 +08:00
|
|
|
|
|
|
|
|
|
#ifndef MAX
|
2022-06-11 21:37:41 +08:00
|
|
|
|
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
|
|
|
|
#endif // MAX
|
2021-06-28 20:29:56 +08:00
|
|
|
|
|
|
|
|
|
#ifndef MIN
|
2022-06-11 21:37:41 +08:00
|
|
|
|
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
|
|
|
|
#endif // MIN
|
2021-06-28 20:29:56 +08:00
|
|
|
|
|
|
|
|
|
#ifndef CLEAR_ARR
|
2022-06-11 21:37:41 +08:00
|
|
|
|
#define CLEAR_ARR(arr) \
|
|
|
|
|
for (auto &item : arr) { \
|
|
|
|
|
item = 0; \
|
|
|
|
|
}
|
|
|
|
|
#endif // CLEAR_ARR
|
2021-06-28 20:29:56 +08:00
|
|
|
|
|
|
|
|
|
#define VHOST_KEY "vhost"
|
|
|
|
|
#define HTTP_SCHEMA "http"
|
|
|
|
|
#define RTSP_SCHEMA "rtsp"
|
2021-10-19 15:22:48 +08:00
|
|
|
|
#define RTC_SCHEMA "rtc"
|
2021-06-28 20:29:56 +08:00
|
|
|
|
#define RTMP_SCHEMA "rtmp"
|
|
|
|
|
#define HLS_SCHEMA "hls"
|
|
|
|
|
#define TS_SCHEMA "ts"
|
|
|
|
|
#define FMP4_SCHEMA "fmp4"
|
2022-06-11 21:37:41 +08:00
|
|
|
|
#define SRT_SCHEMA "srt"
|
2021-06-28 20:29:56 +08:00
|
|
|
|
#define DEFAULT_VHOST "__defaultVhost__"
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
2021-10-16 16:24:40 +08:00
|
|
|
|
extern void Assert_Throw(int failed, const char *exp, const char *func, const char *file, int line, const char *str);
|
2021-06-28 20:29:56 +08:00
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2021-01-31 19:18:17 +08:00
|
|
|
|
|
2021-10-16 16:24:40 +08:00
|
|
|
|
namespace mediakit {
|
|
|
|
|
|
2021-10-16 16:58:03 +08:00
|
|
|
|
extern const char kServerName[];
|
2021-10-16 16:24:40 +08:00
|
|
|
|
|
2022-06-11 21:37:41 +08:00
|
|
|
|
template <typename... ARGS>
|
2021-10-16 16:24:40 +08:00
|
|
|
|
void Assert_ThrowCpp(int failed, const char *exp, const char *func, const char *file, int line, ARGS &&...args) {
|
|
|
|
|
if (failed) {
|
|
|
|
|
std::stringstream ss;
|
2021-11-13 00:24:38 +08:00
|
|
|
|
toolkit::LoggerWrapper::appendLog(ss, std::forward<ARGS>(args)...);
|
2021-10-16 16:24:40 +08:00
|
|
|
|
Assert_Throw(failed, exp, func, file, line, ss.str().data());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-11 21:37:41 +08:00
|
|
|
|
} // namespace mediakit
|
|
|
|
|
#endif // ZLMEDIAKIT_MACROS_H
|