- fixes to handle codec configs properly
This commit is contained in:
parent
62f2d996c6
commit
7aadde3a09
|
|
@ -1,23 +1,20 @@
|
||||||
#include "HL_Uuid.h"
|
#include "HL_Uuid.h"
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
#include <random>
|
||||||
|
#include "uuid_v4.h"
|
||||||
|
|
||||||
Uuid::Uuid()
|
Uuid::Uuid()
|
||||||
{
|
{
|
||||||
#if defined(TARGET_WIN) || defined(TARGET_LINUX) || defined(TARGET_OSX)
|
|
||||||
memset(&mUuid, 0, sizeof mUuid);
|
memset(&mUuid, 0, sizeof mUuid);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Uuid Uuid::generateOne()
|
Uuid Uuid::generateOne()
|
||||||
{
|
{
|
||||||
Uuid result;
|
Uuid result;
|
||||||
#if !defined(USE_NULL_UUID)
|
#if !defined(USE_NULL_UUID)
|
||||||
#if defined(TARGET_LINUX) || defined(TARGET_OSX)
|
UUIDv4::UUIDGenerator<std::mt19937_64> generatorUUID;
|
||||||
uuid_generate(result.mUuid);
|
auto r = generatorUUID.getUUID();
|
||||||
#endif
|
r.bytes((char*)result.mUuid);
|
||||||
#if defined(TARGET_WIN)
|
|
||||||
UuidCreate(&result.mUuid);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -25,53 +22,20 @@ Uuid Uuid::generateOne()
|
||||||
Uuid Uuid::parse(const std::string &s)
|
Uuid Uuid::parse(const std::string &s)
|
||||||
{
|
{
|
||||||
Uuid result;
|
Uuid result;
|
||||||
#if !defined(USE_NULL_UUID)
|
UUIDv4::UUID load;
|
||||||
#if defined(TARGET_LINUX) || defined(TARGET_OSX)
|
load.fromStr(s.c_str());
|
||||||
uuid_parse(s.c_str(), result.mUuid);
|
load.bytes((char*)result.mUuid);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(TARGET_WIN)
|
|
||||||
UuidFromStringA((RPC_CSTR)s.c_str(), &result.mUuid);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Uuid::toString() const
|
std::string Uuid::toString() const
|
||||||
{
|
{
|
||||||
#if defined(USE_NULL_UUID)
|
UUIDv4::UUID load((const uint8_t*)mUuid);
|
||||||
return "UUID_disabled";
|
return load.str();
|
||||||
#else
|
|
||||||
char buf[64];
|
|
||||||
|
|
||||||
#if defined(TARGET_LINUX) || defined(TARGET_OSX)
|
|
||||||
uuid_unparse_lower(mUuid, buf);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(TARGET_WIN)
|
|
||||||
RPC_CSTR s = nullptr;
|
|
||||||
UuidToStringA(&mUuid, &s);
|
|
||||||
if (s)
|
|
||||||
{
|
|
||||||
strcpy(buf, (const char*)s);
|
|
||||||
RpcStringFreeA(&s);
|
|
||||||
s = nullptr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Uuid::operator < (const Uuid& right) const
|
bool Uuid::operator < (const Uuid& right) const
|
||||||
{
|
{
|
||||||
#if defined(TARGET_LINUX) || defined(TARGET_OSX)
|
|
||||||
return memcmp(mUuid, right.mUuid, sizeof(mUuid)) < 0;
|
return memcmp(mUuid, right.mUuid, sizeof(mUuid)) < 0;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(TARGET_WIN)
|
|
||||||
return memcmp(&mUuid, &right.mUuid, sizeof(mUuid)) < 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,39 +2,19 @@
|
||||||
#define __HL_UUID_H
|
#define __HL_UUID_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <stdint.h>
|
||||||
#if (defined(TARGET_LINUX) || defined(TARGET_OSX)) && !defined(USE_NULL_UUID)
|
|
||||||
// Please do not forget "sudo apt install uuid-dev" on Ubuntu
|
|
||||||
# include <uuid/uuid.h>
|
|
||||||
#endif
|
|
||||||
#if defined(TARGET_WIN)
|
|
||||||
# include <rpc.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
class Uuid
|
class Uuid
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Uuid();
|
Uuid();
|
||||||
static Uuid generateOne();
|
static Uuid generateOne();
|
||||||
static Uuid parse(const std::string& s);
|
static Uuid parse(const std::string& s);
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
bool operator < (const Uuid& right) const;
|
bool operator < (const Uuid& right) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
#if defined(USE_NULL_UUID)
|
uint8_t mUuid[16];
|
||||||
unsigned char mUuid[16];
|
|
||||||
#else
|
|
||||||
|
|
||||||
#if defined(TARGET_LINUX) || defined(TARGET_OSX)
|
|
||||||
uuid_t mUuid;
|
|
||||||
#endif
|
|
||||||
#if defined(TARGET_WIN)
|
|
||||||
UUID mUuid;
|
|
||||||
#endif
|
|
||||||
#if defined(TARGET_ANDROID)
|
|
||||||
// Stub only
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,10 @@ public:
|
||||||
bool mSkipDecode = false;
|
bool mSkipDecode = false;
|
||||||
|
|
||||||
// AMR payload types
|
// AMR payload types
|
||||||
std::set<int> mAmrWbPayloadType = { MT_AMRWB_PAYLOADTYPE };
|
std::set<int64_t> mAmrWbPayloadType = { MT_AMRWB_PAYLOADTYPE };
|
||||||
std::set<int> mAmrNbPayloadType = { MT_AMRNB_PAYLOADTYPE };
|
std::set<int64_t> mAmrNbPayloadType = { MT_AMRNB_PAYLOADTYPE };
|
||||||
std::set<int> mAmrWbOctetPayloadType = { MT_AMRWB_OCTET_PAYLOADTYPE };
|
std::set<int64_t> mAmrWbOctetPayloadType = { MT_AMRWB_OCTET_PAYLOADTYPE };
|
||||||
std::set<int> mAmrNbOctetPayloadType = { MT_AMRNB_OCTET_PAYLOADTYPE };
|
std::set<int64_t> mAmrNbOctetPayloadType = { MT_AMRNB_OCTET_PAYLOADTYPE };
|
||||||
|
|
||||||
bool isAmrWb(int ptype) const { return mAmrWbOctetPayloadType.count(ptype) > 0 || mAmrWbPayloadType.count(ptype) > 0; }
|
bool isAmrWb(int ptype) const { return mAmrWbOctetPayloadType.count(ptype) > 0 || mAmrWbPayloadType.count(ptype) > 0; }
|
||||||
bool isAmrNb(int ptype) const { return mAmrNbOctetPayloadType.count(ptype) > 0 || mAmrNbPayloadType.count(ptype) > 0; }
|
bool isAmrNb(int ptype) const { return mAmrNbOctetPayloadType.count(ptype) > 0 || mAmrNbPayloadType.count(ptype) > 0; }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue