mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
SRT: Upgrade libsrt from 1.4.1 to 1.5.1. v6.0.12 (#3362)
Co-authored-by: winlin <winlin@vip.126.com>
This commit is contained in:
parent
7a56208f2f
commit
fe086dfc31
143 changed files with 38185 additions and 15108 deletions
69
trunk/3rdparty/srt-1-fit/srtcore/logging.h
vendored
69
trunk/3rdparty/srt-1-fit/srtcore/logging.h
vendored
|
@ -13,8 +13,8 @@ written by
|
|||
Haivision Systems Inc.
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef INC__SRT_LOGGING_H
|
||||
#define INC__SRT_LOGGING_H
|
||||
#ifndef INC_SRT_LOGGING_H
|
||||
#define INC_SRT_LOGGING_H
|
||||
|
||||
|
||||
#include <iostream>
|
||||
|
@ -28,16 +28,13 @@ written by
|
|||
#else
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
#if HAVE_CXX11
|
||||
#include <mutex>
|
||||
#endif
|
||||
|
||||
#include "srt.h"
|
||||
#include "utilities.h"
|
||||
#include "threadname.h"
|
||||
#include "logging_api.h"
|
||||
#include "srt_compat.h"
|
||||
#include "sync.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define PRINTF_LIKE __attribute__((format(printf,2,3)))
|
||||
|
@ -53,17 +50,24 @@ written by
|
|||
|
||||
// LOGC uses an iostream-like syntax, using the special 'log' symbol.
|
||||
// This symbol isn't visible outside the log macro parameters.
|
||||
// Usage: LOGC(mglog.Debug, log << param1 << param2 << param3);
|
||||
#define LOGC(logdes, args) if (logdes.CheckEnabled()) { srt_logging::LogDispatcher::Proxy log(logdes); log.setloc(__FILE__, __LINE__, __FUNCTION__); args; }
|
||||
// Usage: LOGC(gglog.Debug, log << param1 << param2 << param3);
|
||||
#define LOGC(logdes, args) if (logdes.CheckEnabled()) \
|
||||
{ \
|
||||
srt_logging::LogDispatcher::Proxy log(logdes); \
|
||||
log.setloc(__FILE__, __LINE__, __FUNCTION__); \
|
||||
const srt_logging::LogDispatcher::Proxy& log_prox SRT_ATR_UNUSED = args; \
|
||||
}
|
||||
|
||||
// LOGF uses printf-like style formatting.
|
||||
// Usage: LOGF(mglog.Debug, "%s: %d", param1.c_str(), int(param2));
|
||||
// Usage: LOGF(gglog.Debug, "%s: %d", param1.c_str(), int(param2));
|
||||
#define LOGF(logdes, ...) if (logdes.CheckEnabled()) logdes().setloc(__FILE__, __LINE__, __FUNCTION__).form(__VA_ARGS__)
|
||||
|
||||
// LOGP is C++11 only OR with only one string argument.
|
||||
// Usage: LOGP(mglog.Debug, param1, param2, param3);
|
||||
// Usage: LOGP(gglog.Debug, param1, param2, param3);
|
||||
#define LOGP(logdes, ...) if (logdes.CheckEnabled()) logdes.printloc(__FILE__, __LINE__, __FUNCTION__,##__VA_ARGS__)
|
||||
|
||||
#define IF_LOGGING(instr) instr
|
||||
|
||||
#if ENABLE_HEAVY_LOGGING
|
||||
|
||||
#define HLOGC LOGC
|
||||
|
@ -93,6 +97,7 @@ written by
|
|||
#define HLOGP(...)
|
||||
|
||||
#define IF_HEAVY_LOGGING(instr) (void)0
|
||||
#define IF_LOGGING(instr) (void)0
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -107,29 +112,30 @@ struct LogConfig
|
|||
std::ostream* log_stream;
|
||||
SRT_LOG_HANDLER_FN* loghandler_fn;
|
||||
void* loghandler_opaque;
|
||||
pthread_mutex_t mutex;
|
||||
srt::sync::Mutex mutex;
|
||||
int flags;
|
||||
|
||||
LogConfig(const fa_bitset_t& initial_fa):
|
||||
enabled_fa(initial_fa),
|
||||
max_level(LogLevel::warning),
|
||||
log_stream(&std::cerr)
|
||||
LogConfig(const fa_bitset_t& efa,
|
||||
LogLevel::type l = LogLevel::warning,
|
||||
std::ostream* ls = &std::cerr)
|
||||
: enabled_fa(efa)
|
||||
, max_level(l)
|
||||
, log_stream(ls)
|
||||
, loghandler_fn()
|
||||
, loghandler_opaque()
|
||||
, flags()
|
||||
{
|
||||
pthread_mutex_init(&mutex, 0);
|
||||
}
|
||||
LogConfig(const fa_bitset_t& efa, LogLevel::type l, std::ostream* ls):
|
||||
enabled_fa(efa), max_level(l), log_stream(ls)
|
||||
{
|
||||
pthread_mutex_init(&mutex, 0);
|
||||
}
|
||||
|
||||
~LogConfig()
|
||||
{
|
||||
pthread_mutex_destroy(&mutex);
|
||||
}
|
||||
|
||||
void lock() { pthread_mutex_lock(&mutex); }
|
||||
void unlock() { pthread_mutex_unlock(&mutex); }
|
||||
SRT_ATTR_ACQUIRE(mutex)
|
||||
void lock() { mutex.lock(); }
|
||||
|
||||
SRT_ATTR_RELEASE(mutex)
|
||||
void unlock() { mutex.unlock(); }
|
||||
};
|
||||
|
||||
// The LogDispatcher class represents the object that is responsible for
|
||||
|
@ -142,7 +148,6 @@ private:
|
|||
static const size_t MAX_PREFIX_SIZE = 32;
|
||||
char prefix[MAX_PREFIX_SIZE+1];
|
||||
LogConfig* src_config;
|
||||
pthread_mutex_t mutex;
|
||||
|
||||
bool isset(int flg) { return (src_config->flags & flg) != 0; }
|
||||
|
||||
|
@ -169,12 +174,10 @@ public:
|
|||
strcat(prefix, ":");
|
||||
strcat(prefix, logger_pfx);
|
||||
}
|
||||
pthread_mutex_init(&mutex, 0);
|
||||
}
|
||||
|
||||
~LogDispatcher()
|
||||
{
|
||||
pthread_mutex_destroy(&mutex);
|
||||
}
|
||||
|
||||
bool CheckEnabled();
|
||||
|
@ -244,6 +247,11 @@ public:
|
|||
return *this;
|
||||
}
|
||||
|
||||
DummyProxy& vform(const char*, va_list)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
DummyProxy& setloc(const char* , int , std::string)
|
||||
{
|
||||
return *this;
|
||||
|
@ -292,7 +300,7 @@ struct LogDispatcher::Proxy
|
|||
// or better __func__.
|
||||
std::string ExtractName(std::string pretty_function);
|
||||
|
||||
Proxy(LogDispatcher& guy);
|
||||
Proxy(LogDispatcher& guy);
|
||||
|
||||
// Copy constructor is needed due to noncopyable ostringstream.
|
||||
// This is used only in creation of the default object, so just
|
||||
|
@ -407,7 +415,6 @@ inline bool LogDispatcher::CheckEnabled()
|
|||
return configured_enabled_fa && level <= configured_maxlevel;
|
||||
}
|
||||
|
||||
SRT_API std::string FormatTime(uint64_t time);
|
||||
|
||||
#if HAVE_CXX11
|
||||
|
||||
|
@ -423,7 +430,7 @@ inline void PrintArgs(std::ostream& serr, Arg1&& arg1, Args&&... args)
|
|||
}
|
||||
|
||||
template <class... Args>
|
||||
inline void LogDispatcher::PrintLogLine(const char* file ATR_UNUSED, int line ATR_UNUSED, const std::string& area ATR_UNUSED, Args&&... args ATR_UNUSED)
|
||||
inline void LogDispatcher::PrintLogLine(const char* file SRT_ATR_UNUSED, int line SRT_ATR_UNUSED, const std::string& area SRT_ATR_UNUSED, Args&&... args SRT_ATR_UNUSED)
|
||||
{
|
||||
#ifdef ENABLE_LOGGING
|
||||
std::ostringstream serr;
|
||||
|
@ -441,7 +448,7 @@ inline void LogDispatcher::PrintLogLine(const char* file ATR_UNUSED, int line AT
|
|||
#else
|
||||
|
||||
template <class Arg>
|
||||
inline void LogDispatcher::PrintLogLine(const char* file ATR_UNUSED, int line ATR_UNUSED, const std::string& area ATR_UNUSED, const Arg& arg ATR_UNUSED)
|
||||
inline void LogDispatcher::PrintLogLine(const char* file SRT_ATR_UNUSED, int line SRT_ATR_UNUSED, const std::string& area SRT_ATR_UNUSED, const Arg& arg SRT_ATR_UNUSED)
|
||||
{
|
||||
#ifdef ENABLE_LOGGING
|
||||
std::ostringstream serr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue