- now build without uuid library is possible

This commit is contained in:
Dmytro Bogovych 2019-02-04 11:08:42 +03:00
parent 0a54d7f7db
commit c34bcdc058
3 changed files with 72 additions and 65 deletions

View File

@ -3,6 +3,7 @@ project (helper_lib)
# Rely on C++ 11 # Rely on C++ 11
set (CMAKE_CXX_STANDARD 11) set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD_REQUIRED ON) set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (USE_NULL_UUID OFF CACHE BOOL "When enabled linking to libuuid is avoided")
file(GLOB HELPER_LIB_SOURCES "*.cpp" "*.h") file(GLOB HELPER_LIB_SOURCES "*.cpp" "*.h")

View File

@ -17,69 +17,68 @@
template<class T> template<class T>
struct RtpPair struct RtpPair
{ {
T mRtp; T mRtp;
T mRtcp; T mRtcp;
RtpPair() RtpPair()
{} {}
RtpPair(const T& rtp, const T& rtcp) RtpPair(const T& rtp, const T& rtcp)
:mRtp(rtp), mRtcp(rtcp) :mRtp(rtp), mRtcp(rtcp)
{} {}
bool multiplexed() { return mRtp == mRtcp; } bool multiplexed() { return mRtp == mRtcp; }
}; };
class RtpHelper class RtpHelper
{ {
public: public:
static bool isRtp(const void* buffer, int length); static bool isRtp(const void* buffer, int length);
static int findPtype(const void* buffer, int length); static int findPtype(const void* buffer, int length);
static bool isRtpOrRtcp(const void* buffer, int length); static bool isRtpOrRtcp(const void* buffer, int length);
static bool isRtcp(const void* buffer, int length); static bool isRtcp(const void* buffer, int length);
static unsigned findSsrc(const void* buffer, int length); static unsigned findSsrc(const void* buffer, int length);
static int findPayloadLength(const void* buffer, int length); static int findPayloadLength(const void* buffer, int length);
}; };
class RtpDump class RtpDump
{ {
protected: protected:
struct RtpData struct RtpData
{ {
jrtplib::RTPPacket* mPacket; jrtplib::RTPPacket* mPacket;
void* mData; void* mData;
unsigned mLength; unsigned mLength;
}; };
typedef std::vector<RtpData> PacketList; typedef std::vector<RtpData> PacketList;
PacketList mPacketList; PacketList mPacketList;
std::string mFilename; std::string mFilename;
public: public:
RtpDump(const char* filename); RtpDump(const char* filename);
~RtpDump(); ~RtpDump();
void load(); void load();
int count() const; int count() const;
jrtplib::RTPPacket& packetAt(int index); jrtplib::RTPPacket& packetAt(int index);
void add(const void* data, int len); void add(const void* data, int len);
void flush(); void flush();
}; };
struct MediaStreamId struct MediaStreamId
{ {
InternetAddress mSource; InternetAddress mSource;
InternetAddress mDestination; InternetAddress mDestination;
uint32_t mSSRC = 0; uint32_t mSSRC = 0;
bool mSsrcIsId = true; bool mSsrcIsId = true;
Uuid mLinkId; Uuid mLinkId;
bool operator < (const MediaStreamId& s2) const;
bool operator == (const MediaStreamId& right) const;
bool operator < (const MediaStreamId& s2) const; std::string toString() const;
bool operator == (const MediaStreamId& right) const; std::string getDetectDescription() const;
std::string getFinishDescription() const;
std::string toString() const;
std::string getDetectDescription() const;
std::string getFinishDescription() const;
}; };
#endif #endif

View File

@ -4,64 +4,71 @@
Uuid::Uuid() Uuid::Uuid()
{ {
#if defined(TARGET_WIN) || defined(TARGET_LINUX) || defined(TARGET_OSX) #if defined(TARGET_WIN) || defined(TARGET_LINUX) || defined(TARGET_OSX)
memset(&mUuid, 0, sizeof mUuid); memset(&mUuid, 0, sizeof mUuid);
#endif #endif
} }
Uuid Uuid::generateOne() Uuid Uuid::generateOne()
{ {
Uuid result; Uuid result;
#if !defined(USE_NULL_UUID)
#if defined(TARGET_LINUX) || defined(TARGET_OSX) #if defined(TARGET_LINUX) || defined(TARGET_OSX)
uuid_generate(result.mUuid); uuid_generate(result.mUuid);
#endif #endif
#if defined(TARGET_WIN) #if defined(TARGET_WIN)
UuidCreate(&result.mUuid); UuidCreate(&result.mUuid);
#endif #endif
#endif
return result; return result;
} }
Uuid Uuid::parse(const std::string &s) Uuid Uuid::parse(const std::string &s)
{ {
Uuid result; Uuid result;
#if !defined(USE_NULL_UUID)
#if defined(TARGET_LINUX) || defined(TARGET_OSX) #if defined(TARGET_LINUX) || defined(TARGET_OSX)
uuid_parse(s.c_str(), result.mUuid); uuid_parse(s.c_str(), result.mUuid);
#endif #endif
#if defined(TARGET_WIN) #if defined(TARGET_WIN)
UuidFromStringA((RPC_CSTR)s.c_str(), &result.mUuid); UuidFromStringA((RPC_CSTR)s.c_str(), &result.mUuid);
#endif #endif
return result; #endif
return result;
} }
std::string Uuid::toString() const std::string Uuid::toString() const
{ {
char buf[64]; char buf[64];
#if defined(USE_NULL_UUID)
return "UUID_disabled";
#else
#if defined(TARGET_LINUX) || defined(TARGET_OSX) #if defined(TARGET_LINUX) || defined(TARGET_OSX)
uuid_unparse_lower(mUuid, buf); uuid_unparse_lower(mUuid, buf);
#endif #endif
#if defined(TARGET_WIN) #if defined(TARGET_WIN)
RPC_CSTR s = nullptr; RPC_CSTR s = nullptr;
UuidToStringA(&mUuid, &s); UuidToStringA(&mUuid, &s);
if (s) if (s)
{ {
strcpy(buf, (const char*)s); strcpy(buf, (const char*)s);
RpcStringFreeA(&s); RpcStringFreeA(&s);
s = nullptr; s = nullptr;
} }
#endif #endif
return buf; return buf;
#endif
} }
bool Uuid::operator < (const Uuid& right) const bool Uuid::operator < (const Uuid& right) const
{ {
#if defined(TARGET_LINUX) || defined(TARGET_OSX) #if defined(TARGET_LINUX) || defined(TARGET_OSX)
return memcmp(mUuid, right.mUuid, sizeof(mUuid)) < 0; return memcmp(mUuid, right.mUuid, sizeof(mUuid)) < 0;
#endif #endif
#if defined(TARGET_WIN) #if defined(TARGET_WIN)
return memcmp(&mUuid, &right.mUuid, sizeof(mUuid)) < 0; return memcmp(&mUuid, &right.mUuid, sizeof(mUuid)) < 0;
#endif #endif
} }