- 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

@ -73,7 +73,6 @@ struct MediaStreamId
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& s2) const;
bool operator == (const MediaStreamId& right) const; bool operator == (const MediaStreamId& right) const;

View File

@ -11,25 +11,28 @@ Uuid::Uuid()
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 #endif
return result; return result;
} }
@ -37,6 +40,9 @@ Uuid Uuid::parse(const std::string &s)
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
@ -53,6 +59,7 @@ std::string Uuid::toString() const
#endif #endif
return buf; return buf;
#endif
} }
bool Uuid::operator < (const Uuid& right) const bool Uuid::operator < (const Uuid& right) const