diff --git a/src/sip/sdp.cpp b/src/sip/sdp.cpp index f0da2995f5884014459f6c4d07cd492e2b8c31dd..7457b2cfc1fd07a148f5f4adc1f804f814690326 100644 --- a/src/sip/sdp.cpp +++ b/src/sip/sdp.cpp @@ -123,7 +123,11 @@ Sdp::findCodecByPayload(const unsigned payloadType) static void randomFill(std::vector<uint8_t>& dest) { + #ifdef WIN32_NATIVE + std::uniform_int_distribution<int> rand_byte{ 0, std::numeric_limits<uint8_t>::max() }; +#else std::uniform_int_distribution<uint8_t> rand_byte(0, 255); +#endif /* WIN32_NATIVE */ random_device rdev; std::generate(dest.begin(), dest.end(), std::bind(rand_byte, std::ref(rdev))); } diff --git a/src/sip/sipaccount.cpp b/src/sip/sipaccount.cpp index 6a429a752cce2484a19821f15dbe41753e147b12..ed0b582eee2dfcbc5be6428238e466b92fae177b 100644 --- a/src/sip/sipaccount.cpp +++ b/src/sip/sipaccount.cpp @@ -166,9 +166,8 @@ SIPAccount::newIncomingCall(const std::string& from UNUSED) return manager.callFactory.newCall<SIPCall, SIPAccount>(*this, manager.getNewCallID(), Call::CallType::INCOMING); } -template <> std::shared_ptr<SIPCall> -SIPAccount::newOutgoingCall(const std::string& toUrl) +SIPAccount::newOutgoingSIPCall(const std::string& toUrl) { std::string to; int family; @@ -317,7 +316,7 @@ SIPAccount::getTransportSelector() { std::shared_ptr<Call> SIPAccount::newOutgoingCall(const std::string& toUrl) { - return newOutgoingCall<SIPCall>(toUrl); + return newOutgoingSIPCall(toUrl); } bool @@ -735,7 +734,7 @@ void SIPAccount::doRegister() std::thread{ [shared] { /* We have to register the external thread so it could access the pjsip frameworks */ if (!pj_thread_is_registered()) { -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || defined WIN32_NATIVE static thread_local pj_thread_desc desc; static thread_local pj_thread_t *this_thread; #else @@ -1313,6 +1312,14 @@ std::string SIPAccount::getLoginName() #ifndef _WIN32 struct passwd * user_info = getpwuid(getuid()); return user_info ? user_info->pw_name : ""; +#elif defined (WIN32_NATIVE) + TCHAR username[UNLEN + 1]; + DWORD size = UNLEN + 1; + std::string uname; + if (GetUserName((TCHAR*)username, &size)) { + uname = username; + } + return uname; #else TCHAR username[UNLEN + 1]; DWORD size = UNLEN + 1; @@ -1624,16 +1631,16 @@ void SIPAccount::setCredentials(const std::vector<std::map<std::string, std::str c.computePasswordHash(); cred_.emplace_back(pjsip_cred_info { - .realm = pj_str((char*) c.realm.c_str()), - .scheme = pj_str((char*) "digest"), - .username = pj_str((char*) c.username.c_str()), - .data_type = (c.password_h.empty() + /*.realm = */pj_str((char*) c.realm.c_str()), + /*.scheme = */pj_str((char*) "digest"), + /*.username = */pj_str((char*) c.username.c_str()), + /*.data_type = */(c.password_h.empty() ? PJSIP_CRED_DATA_PLAIN_PASSWD : PJSIP_CRED_DATA_DIGEST), - .data = pj_str((char*) (c.password_h.empty() + /*.data = */pj_str((char*) (c.password_h.empty() ? c.password.c_str() : c.password_h.c_str())), - .ext = {} + /*.ext = */{} }); } } diff --git a/src/sip/sipaccount.h b/src/sip/sipaccount.h index efc4d1c45a7a899005783617f24ca2b0ac676e57..81707849c1030d087d644e0269d68cba1879967d 100644 --- a/src/sip/sipaccount.h +++ b/src/sip/sipaccount.h @@ -475,9 +475,8 @@ class SIPAccount : public SIPAccountBase { * The type of this instance is given in template argument. * This type can be any base class of SIPCall class (included). */ - template <class T=SIPCall> - std::shared_ptr<enable_if_base_of<T, SIPCall> > - newOutgoingCall(const std::string& toUrl); + std::shared_ptr<SIPCall> + newOutgoingSIPCall(const std::string& toUrl); /** * Create incoming SIPCall. diff --git a/src/sip/siptransport.cpp b/src/sip/siptransport.cpp index 410716d53f995f10ed9b255f2a33303e6c7af965..d81714011bbab29214d88b262a22f7aff6b0e369 100644 --- a/src/sip/siptransport.cpp +++ b/src/sip/siptransport.cpp @@ -389,9 +389,9 @@ SipTransportBroker::getTlsTransport(const std::shared_ptr<TlsListener>& l, const remoteAddr.setPort(pjsip_transport_get_default_port_for_type(l->get()->type)); RING_DBG("Get new TLS transport to %s", remoteAddr.toString(true).c_str()); - pjsip_tpselector sel {PJSIP_TPSELECTOR_LISTENER, { - .listener = l->get() - }}; + pjsip_tpselector sel; + sel.type = PJSIP_TPSELECTOR_LISTENER; + sel.u.listener = l->get(); pjsip_tx_data tx_data; tx_data.dest_info.name = pj_str_t{(char*)remote_name.data(), (pj_ssize_t)remote_name.size()}; diff --git a/src/sip/sipvoiplink.cpp b/src/sip/sipvoiplink.cpp index 12c011030af20165d0b59a2c591e1ce0249c2531..59dbc517028c5b88734e2c61fcb0f4874125aef1 100644 --- a/src/sip/sipvoiplink.cpp +++ b/src/sip/sipvoiplink.cpp @@ -605,7 +605,7 @@ SIPVoIPLink::~SIPVoIPLink() for (int timeout = 0; pjsip_tsx_layer_get_tsx_count() and timeout < MAX_TIMEOUT_ON_LEAVING; timeout++) - sleep(1); + std::this_thread::sleep_for(std::chrono::seconds(1)); pjsip_tpmgr_set_state_cb(pjsip_endpt_get_tpmgr(endpt_), nullptr); Manager::instance().unregisterEventHandler((uintptr_t)this); @@ -674,7 +674,7 @@ SIPVoIPLink::handleEvents() { // We have to register the external thread so it could access the pjsip frameworks if (!pj_thread_is_registered()) { -#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || defined WIN32_NATIVE static thread_local pj_thread_desc desc; static thread_local pj_thread_t *this_thread; #else @@ -1235,9 +1235,9 @@ SIPVoIPLink::resolveSrvName(const std::string &name, pjsip_transport_type_e type RING_DBG("try to resolve '%s' (port: %u)", name.c_str(), port); pjsip_host_info host_info { - .flag = 0, - .type = type, - .addr = {{(char*)name.c_str(), name_size}, port}, + /*.flag = */0, + /*.type = */type, + /*.addr = */{{(char*)name.c_str(), name_size}, port}, }; const auto token = std::hash<std::string>()(name + to_string(type));