mirror of
https://github.com/danog/libtgvoip.git
synced 2024-11-26 20:24:38 +01:00
Updated UWP project to 2.4.4
This commit is contained in:
parent
b6cfcba80f
commit
028d86f599
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -206,23 +206,7 @@ void VoIPControllerWrapper::SetAudioOutputGainControlEnabled(bool enabled){
|
||||
}
|
||||
|
||||
void VoIPControllerWrapper::UpdateServerConfig(Platform::String^ json){
|
||||
JsonObject^ jconfig=JsonValue::Parse(json)->GetObject();
|
||||
std::map<std::string, std::string> config;
|
||||
|
||||
for each (auto item in jconfig){
|
||||
char _key[128];
|
||||
char _value[256];
|
||||
WideCharToMultiByte(CP_UTF8, 0, item->Key->Data(), -1, _key, sizeof(_key), NULL, NULL);
|
||||
if(item->Value->ValueType==Windows::Data::Json::JsonValueType::String)
|
||||
WideCharToMultiByte(CP_UTF8, 0, item->Value->GetString()->Data(), -1, _value, sizeof(_value), NULL, NULL);
|
||||
else
|
||||
WideCharToMultiByte(CP_UTF8, 0, item->Value->ToString()->Data(), -1, _value, sizeof(_value), NULL, NULL);
|
||||
std::string key(_key);
|
||||
std::string value(_value);
|
||||
|
||||
config[key]=value;
|
||||
}
|
||||
|
||||
std::string config=ToUtf8(json->Data(), json->Length());
|
||||
ServerConfig::GetSharedInstance()->Update(config);
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,26 @@
|
||||
#include "../../VoIPController.h"
|
||||
#include "../../VoIPServerConfig.h"
|
||||
|
||||
#define STACK_ARRAY(TYPE, LEN) \
|
||||
static_cast<TYPE*>(::alloca((LEN) * sizeof(TYPE)))
|
||||
|
||||
inline std::string ToUtf8(const wchar_t* wide, size_t len) {
|
||||
int len8 = ::WideCharToMultiByte(CP_UTF8, 0, wide, static_cast<int>(len),
|
||||
nullptr, 0, nullptr, nullptr);
|
||||
char* ns = STACK_ARRAY(char, len8);
|
||||
::WideCharToMultiByte(CP_UTF8, 0, wide, static_cast<int>(len), ns, len8,
|
||||
nullptr, nullptr);
|
||||
return std::string(ns, len8);
|
||||
}
|
||||
|
||||
inline std::string ToUtf8(const wchar_t* wide) {
|
||||
return ToUtf8(wide, wcslen(wide));
|
||||
}
|
||||
|
||||
inline std::string ToUtf8(const std::wstring& wstr) {
|
||||
return ToUtf8(wstr.data(), wstr.length());
|
||||
}
|
||||
|
||||
namespace libtgvoip{
|
||||
public ref class Endpoint sealed{
|
||||
public:
|
||||
|
@ -45,22 +45,38 @@ bool ClosePlatformFile(PlatformFile file) {
|
||||
}
|
||||
|
||||
bool RemoveFile(const std::string& path) {
|
||||
#if defined(WEBRTC_UWP)
|
||||
return kInvalidPlatformFileValue;
|
||||
#else // defined(WEBRTC_WIN)
|
||||
return ::DeleteFile(ToUtf16(path).c_str()) != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
PlatformFile OpenPlatformFile(const std::string& path) {
|
||||
#if defined(WEBRTC_UWP)
|
||||
return kInvalidPlatformFileValue;
|
||||
#else // defined(WEBRTC_WIN)
|
||||
return ::CreateFile(ToUtf16(path).c_str(), GENERIC_READ | GENERIC_WRITE, 0,
|
||||
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
#endif // defined(WEBRTC_WIN)
|
||||
}
|
||||
|
||||
PlatformFile OpenPlatformFileReadOnly(const std::string& path) {
|
||||
#if defined(WEBRTC_UWP)
|
||||
return kInvalidPlatformFileValue;
|
||||
#else // defined(WEBRTC_WIN)
|
||||
return ::CreateFile(ToUtf16(path).c_str(), GENERIC_READ, FILE_SHARE_READ,
|
||||
nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
#endif // defined(WEBRTC_WIN)
|
||||
}
|
||||
|
||||
PlatformFile CreatePlatformFile(const std::string& path) {
|
||||
#if defined(WEBRTC_UWP)
|
||||
return kInvalidPlatformFileValue;
|
||||
#else // defined(WEBRTC_WIN)
|
||||
return ::CreateFile(ToUtf16(path).c_str(), GENERIC_READ | GENERIC_WRITE, 0,
|
||||
nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
#endif // defined(WEBRTC_WIN)
|
||||
}
|
||||
|
||||
#else // defined(WEBRTC_WIN)
|
||||
|
@ -71,6 +71,25 @@ int64_t SystemTimeNanos() {
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
ticks = kNumNanosecsPerSec * static_cast<int64_t>(ts.tv_sec) +
|
||||
static_cast<int64_t>(ts.tv_nsec);
|
||||
#elif defined(WEBRTC_UWP)
|
||||
static volatile ULONGLONG last_timegettime = 0;
|
||||
static volatile int64_t num_wrap_timegettime = 0;
|
||||
volatile ULONGLONG* last_timegettime_ptr = &last_timegettime;
|
||||
ULONGLONG now = GetTickCount64();
|
||||
// Atomically update the last gotten time
|
||||
ULONGLONG old = InterlockedExchange(last_timegettime_ptr, now);
|
||||
if (now < old) {
|
||||
// If now is earlier than old, there may have been a race between threads.
|
||||
// 0x0fffffff ~3.1 days, the code will not take that long to execute
|
||||
// so it must have been a wrap around.
|
||||
if (old > 0xf0000000 && now < 0x0fffffff) {
|
||||
num_wrap_timegettime++;
|
||||
}
|
||||
}
|
||||
ticks = now + (num_wrap_timegettime << 32);
|
||||
// TODO(deadbeef): Calculate with nanosecond precision. Otherwise, we're
|
||||
// just wasting a multiply and divide when doing Time() on Windows.
|
||||
ticks = ticks * kNumNanosecsPerMillisec;
|
||||
#elif defined(WEBRTC_WIN)
|
||||
static volatile LONG last_timegettime = 0;
|
||||
static volatile int64_t num_wrap_timegettime = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user