mirror of
https://github.com/danog/libtgvoip.git
synced 2024-12-02 09:37:52 +01:00
Merge branch 'public' of https://github.com/grishka/libtgvoip into public
This commit is contained in:
commit
2b8659140b
@ -292,7 +292,7 @@ void NetworkSocketTCPObfuscated::Receive(NetworkPacket *packet){
|
||||
}
|
||||
|
||||
if(packetLen>packet->length){
|
||||
LOGW("packet too big to fit into buffer (%u vs %u)", packetLen, packet->length);
|
||||
LOGW("packet too big to fit into buffer (%u vs %u)", (unsigned int)packetLen, (unsigned int)packet->length);
|
||||
packet->length=0;
|
||||
return;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ namespace tgvoip {
|
||||
virtual std::string ToString()=0;
|
||||
bool operator==(const NetworkAddress& other);
|
||||
bool operator!=(const NetworkAddress& other);
|
||||
virtual ~NetworkAddress()=default;
|
||||
};
|
||||
|
||||
class IPv4Address : public NetworkAddress{
|
||||
|
@ -16,10 +16,6 @@
|
||||
void tgvoip_log_file_printf(char level, const char* msg, ...);
|
||||
void tgvoip_log_file_write_header();
|
||||
|
||||
#if !defined(snprintf) && defined(_WIN32) && defined(__cplusplus_winrt)
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
|
||||
#include <android/log.h>
|
||||
@ -48,6 +44,10 @@ void tgvoip_log_file_write_header();
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if !defined(snprintf) && defined(_WIN32) && defined(__cplusplus_winrt)
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#define _TGVOIP_W32_LOG_PRINT(verb, msg, ...){ char __log_buf[1024]; snprintf(__log_buf, 1024, "%c/tgvoip: " msg "\n", verb, ##__VA_ARGS__); OutputDebugStringA(__log_buf); tgvoip_log_file_printf((char)verb, msg, __VA_ARGS__);}
|
||||
|
||||
#define LOGV(msg, ...) _TGVOIP_W32_LOG_PRINT('V', msg, ##__VA_ARGS__)
|
||||
|
@ -149,15 +149,27 @@ void VoIPControllerWrapper::SetConfig(double initTimeout, double recvTimeout, Da
|
||||
config.enableAEC=enableAEC;
|
||||
config.enableAGC=enableAGC;
|
||||
config.enableNS=enableNS;
|
||||
if(logFilePath!=nullptr){
|
||||
if(logFilePath!=nullptr&&!logFilePath->IsEmpty()){
|
||||
WideCharToMultiByte(CP_UTF8, 0, logFilePath->Data(), -1, config.logFilePath, sizeof(config.logFilePath), NULL, NULL);
|
||||
}
|
||||
if(statsDumpFilePath!=nullptr){
|
||||
if(statsDumpFilePath!=nullptr&&!statsDumpFilePath->IsEmpty()){
|
||||
WideCharToMultiByte(CP_UTF8, 0, statsDumpFilePath->Data(), -1, config.statsDumpFilePath, sizeof(config.statsDumpFilePath), NULL, NULL);
|
||||
}
|
||||
controller->SetConfig(&config);
|
||||
}
|
||||
|
||||
void VoIPControllerWrapper::SetProxy(ProxyProtocol protocol, Platform::String^ address, uint16_t port, Platform::String^ username, Platform::String^ password){
|
||||
char _address[2000];
|
||||
char _username[256];
|
||||
char _password[256];
|
||||
|
||||
WideCharToMultiByte(CP_UTF8, 0, address->Data(), -1, _address, sizeof(_address), NULL, NULL);
|
||||
WideCharToMultiByte(CP_UTF8, 0, username->Data(), -1, _username, sizeof(_username), NULL, NULL);
|
||||
WideCharToMultiByte(CP_UTF8, 0, password->Data(), -1, _password, sizeof(_password), NULL, NULL);
|
||||
|
||||
controller->SetProxy((int)protocol, _address, port, _username, _password);
|
||||
}
|
||||
|
||||
void VoIPControllerWrapper::UpdateServerConfig(Platform::String^ json){
|
||||
JsonObject^ jconfig=JsonValue::Parse(json)->GetObject();
|
||||
std::map<std::string, std::string> config;
|
||||
|
@ -53,6 +53,11 @@ namespace libtgvoip{
|
||||
Always
|
||||
};
|
||||
|
||||
public enum class ProxyProtocol{
|
||||
None=0,
|
||||
SOCKS5
|
||||
};
|
||||
|
||||
public interface class IStateCallback{
|
||||
void OnCallStateChanged(CallState newState);
|
||||
};
|
||||
@ -69,6 +74,7 @@ namespace libtgvoip{
|
||||
void SetMicMute(bool mute);
|
||||
void SetEncryptionKey(const Platform::Array<uint8>^ key, bool isOutgoing);
|
||||
void SetConfig(double initTimeout, double recvTimeout, DataSavingMode dataSavingMode, bool enableAEC, bool enableNS, bool enableAGC, Platform::String^ logFilePath, Platform::String^ statsDumpFilePath);
|
||||
void SetProxy(ProxyProtocol protocol, Platform::String^ address, uint16_t port, Platform::String^ username, Platform::String^ password);
|
||||
Platform::String^ GetDebugString();
|
||||
Platform::String^ GetDebugLog();
|
||||
Error GetLastError();
|
||||
|
Loading…
Reference in New Issue
Block a user