Skip to content

Commit

Permalink
Updated UWP project to 2.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
FrayxRulez committed Mar 11, 2019
1 parent b6cfcba commit 028d86f
Show file tree
Hide file tree
Showing 6 changed files with 2,395 additions and 412 deletions.
815 changes: 678 additions & 137 deletions libtgvoip.UWP.vcxproj

Large diffs are not rendered by default.

1,919 changes: 1,661 additions & 258 deletions libtgvoip.UWP.vcxproj.filters

Large diffs are not rendered by default.

18 changes: 1 addition & 17 deletions os/windows/CXWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
20 changes: 20 additions & 0 deletions os/windows/CXWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 16 additions & 0 deletions webrtc_dsp/rtc_base/platform_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions webrtc_dsp/rtc_base/timeutils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 028d86f

Please sign in to comment.