commit cfade1b77bde7a76dbac877c3097d71f35ab5d4e
Author: Vitaly Zaitsev <vitaly(a)easycoding.org>
Date: Mon Jul 30 11:28:45 2018 +0200
Updated to 2.2 (regular release).
.gitignore | 1 +
libtgvoip-addidional-fixes.patch | 142 +++++++++++++++++++++++++++++++++++++++
libtgvoip-build-fixes.patch | 4 +-
libtgvoip-crash-fix.patch | 48 +++++++++++++
libtgvoip.spec | 15 +++--
sources | 2 +-
6 files changed, 202 insertions(+), 10 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 5bd95a2..65f436e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@
/libtgvoip-83ac2c6.tar.gz
/libtgvoip-6a8f543.tar.gz
/libtgvoip-2.1.1.tar.gz
+/libtgvoip-2.2.tar.gz
diff --git a/libtgvoip-addidional-fixes.patch b/libtgvoip-addidional-fixes.patch
new file mode 100644
index 0000000..7f97a48
--- /dev/null
+++ b/libtgvoip-addidional-fixes.patch
@@ -0,0 +1,142 @@
+From 8faf6f670037a8049ede4b85a004c40bdd359c6a Mon Sep 17 00:00:00 2001
+From: Grishka <grishka93(a)gmail.com>
+Date: Sun, 29 Jul 2018 21:21:34 +0300
+Subject: [PATCH] Fixes
+
+---
+ VoIPController.cpp | 34 ++++++++++++++++++++++++++--------
+ VoIPController.h | 3 +++
+ 2 files changed, 29 insertions(+), 8 deletions(-)
+
+diff --git a/VoIPController.cpp b/VoIPController.cpp
+index f60c6c5..e361dcb 100644
+--- a/VoIPController.cpp
++++ b/VoIPController.cpp
+@@ -526,7 +526,8 @@ void VoIPController::InitializeTimers(){
+ }, 0.1, 0.1);
+ }
+
+- messageThread.Post(std::bind(&VoIPController::SendUdpPings, this), 0.0, 0.5);
++ udpConnectivityState=UDP_PING_PENDING;
++ udpPingTimeoutID=messageThread.Post(std::bind(&VoIPController::SendUdpPings, this),
0.0, 0.5);
+ messageThread.Post(std::bind(&VoIPController::SendRelayPings, this), 0.0, 2.0);
+ }
+
+@@ -1891,7 +1892,7 @@ void VoIPController::SetNetworkType(int type){
+ if(itfName!=activeNetItfName){
+ udpSocket->OnActiveInterfaceChanged();
+ LOGI("Active network interface changed: %s -> %s",
activeNetItfName.c_str(), itfName.c_str());
+- bool isFirstChange=activeNetItfName.length()==0;
++ bool isFirstChange=activeNetItfName.length()==0 && state!=STATE_ESTABLISHED
&& state!=STATE_RECONNECTING;
+ activeNetItfName=itfName;
+ if(isFirstChange)
+ return;
+@@ -1921,8 +1922,6 @@ void VoIPController::SetNetworkType(int type){
+ }
+ }
+ }
+- udpConnectivityState=UDP_UNKNOWN;
+- udpPingCount=0;
+ lastUdpPingTime=0;
+ if(proxyProtocol==PROXY_SOCKS5)
+ InitUDPProxy();
+@@ -1939,9 +1938,9 @@ void VoIPController::SetNetworkType(int type){
+ }
+ selectCanceller->CancelSelect();
+ didSendIPv6Endpoint=false;
+- udpPingCount=0;
+
+ AddIPv6Relays();
++ ResetUdpAvailability();
+ }
+ LOGI("set network type: %d, active interface %s", type,
activeNetItfName.c_str());
+ }
+@@ -2747,6 +2746,22 @@ void VoIPController::SetEchoCancellationStrength(int strength){
+ echoCanceller->SetAECStrength(strength);
+ }
+
++void VoIPController::ResetUdpAvailability(){
++ LOGI("Resetting UDP availability");
++ if(udpPingTimeoutID!=MessageThread::INVALID_ID){
++ messageThread.Cancel(udpPingTimeoutID);
++ }
++ {
++ MutexGuard m(endpointsMutex);
++ for(shared_ptr<Endpoint>& e:endpoints){
++ e->udpPongCount=0;
++ }
++ }
++ udpPingCount=0;
++ udpConnectivityState=UDP_PING_PENDING;
++ udpPingTimeoutID=messageThread.Post(std::bind(&VoIPController::SendUdpPings, this),
0.0, 0.5);
++}
++
+ #pragma mark - Timer methods
+
+ void VoIPController::SendUdpPings(){
+@@ -2755,12 +2770,12 @@ void VoIPController::SendUdpPings(){
+ SendUdpPing(e);
+ }
+ }
+- if(udpConnectivityState==UDP_UNKNOWN)
++ if(udpConnectivityState==UDP_UNKNOWN || udpConnectivityState==UDP_PING_PENDING)
+ udpConnectivityState=UDP_PING_SENT;
+ udpPingCount++;
+ if(udpPingCount==4 || udpPingCount==10){
+ messageThread.CancelSelf();
+- messageThread.Post(std::bind(&VoIPController::EvaluateUdpPingResults, this),
1.0);
++ udpPingTimeoutID=messageThread.Post(std::bind(&VoIPController::EvaluateUdpPingResults,
this), 1.0);
+ }
+ }
+
+@@ -2795,11 +2810,13 @@ void VoIPController::EvaluateUdpPingResults(){
+ useTCP=true;
+ AddTCPRelays();
+ setCurrentEndpointToTCP=true;
+- messageThread.Post(std::bind(&VoIPController::SendUdpPings, this), 0.5, 0.5);
++ udpPingTimeoutID=messageThread.Post(std::bind(&VoIPController::SendUdpPings,
this), 0.5, 0.5);
+ }else{
++ udpPingTimeoutID=MessageThread::INVALID_ID;
+ udpConnectivityState=UDP_AVAILABLE;
+ }
+ }else{
++ udpPingTimeoutID=MessageThread::INVALID_ID;
+ udpConnectivityState=UDP_NOT_AVAILABLE;
+ }
+ }
+@@ -2966,6 +2983,7 @@ void VoIPController::UpdateAudioBitrate(){
+
+ if(state==STATE_ESTABLISHED &&
time-lastRecvPacketTime>=reconnectingTimeout){
+ SetState(STATE_RECONNECTING);
++ ResetUdpAvailability();
+ }
+
+ if(state==STATE_ESTABLISHED || state==STATE_RECONNECTING){
+diff --git a/VoIPController.h b/VoIPController.h
+index c7f0232..a8a64f8 100644
+--- a/VoIPController.h
++++ b/VoIPController.h
+@@ -436,6 +436,7 @@ namespace tgvoip{
+ };
+ enum{
+ UDP_UNKNOWN=0,
++ UDP_PING_PENDING,
+ UDP_PING_SENT,
+ UDP_AVAILABLE,
+ UDP_NOT_AVAILABLE,
+@@ -475,6 +476,7 @@ namespace tgvoip{
+ void UpdateQueuedPackets();
+ void SendNopPacket();
+ void TickJitterBufferAngCongestionControl();
++ void ResetUdpAvailability();
+
+ int state;
+ std::vector<std::shared_ptr<Endpoint>> endpoints;
+@@ -594,6 +596,7 @@ namespace tgvoip{
+
+ uint32_t initTimeoutID=MessageThread::INVALID_ID;
+ uint32_t noStreamsNopID=MessageThread::INVALID_ID;
++ uint32_t udpPingTimeoutID=MessageThread::INVALID_ID;
+
+ /*** server config values ***/
+ uint32_t maxAudioBitrate;
diff --git a/libtgvoip-build-fixes.patch b/libtgvoip-build-fixes.patch
index bba8031..942a6e7 100644
--- a/libtgvoip-build-fixes.patch
+++ b/libtgvoip-build-fixes.patch
@@ -1,4 +1,4 @@
-From a21e490ded152c915a8f2cd793fb0daa3d78592f Mon Sep 17 00:00:00 2001
+From 4b4b5ea525c2f061c7e7ba62563e8cfd1c2b01ff Mon Sep 17 00:00:00 2001
From: Vitaly Zaitsev <vitaly(a)easycoding.org>
Date: Thu, 6 Jul 2017 17:27:01 +0200
Subject: [PATCH] Fixed build of libtgvoip under Fedora as shared library.
@@ -11,7 +11,7 @@ Subject: [PATCH] Fixed build of libtgvoip under Fedora as shared
library.
4 files changed, 65 insertions(+), 10 deletions(-)
diff --git a/libtgvoip.gyp b/libtgvoip.gyp
-index f236987..a86317f 100644
+index 0cf04ea..88a98cd 100644
--- a/libtgvoip.gyp
+++ b/libtgvoip.gyp
@@ -4,7 +4,8 @@
diff --git a/libtgvoip-crash-fix.patch b/libtgvoip-crash-fix.patch
new file mode 100644
index 0000000..7b1b648
--- /dev/null
+++ b/libtgvoip-crash-fix.patch
@@ -0,0 +1,48 @@
+From 100f7ecbd889a94742c378b726dc46bfbc27ad96 Mon Sep 17 00:00:00 2001
+From: Grishka <grishka93(a)gmail.com>
+Date: Thu, 19 Jul 2018 14:52:38 +0300
+Subject: [PATCH] Fixed crash
+
+---
+ threading.h | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/threading.h b/threading.h
+index dbba1f9..cef6d3c 100644
+--- a/threading.h
++++ b/threading.h
+@@ -75,6 +75,7 @@ namespace tgvoip{
+ public:
+ Thread(MethodPointerBase* entry, void* arg) : entry(entry), arg(arg){
+ name=NULL;
++ thread=NULL;
+ }
+
+ virtual ~Thread(){
+@@ -86,7 +87,8 @@ namespace tgvoip{
+ }
+
+ void Join(){
+- pthread_join(thread, NULL);
++ if(thread)
++ pthread_join(thread, NULL);
+ }
+
+ void SetName(const char* name){
+@@ -242,6 +244,7 @@ namespace tgvoip{
+ public:
+ Thread(MethodPointerBase* entry, void* arg) : entry(entry), arg(arg){
+ name=NULL;
++ thread=NULL;
+ }
+
+ ~Thread(){
+@@ -253,6 +256,8 @@ namespace tgvoip{
+ }
+
+ void Join(){
++ if(!thread)
++ return;
+ #if !defined(WINAPI_FAMILY) || WINAPI_FAMILY!=WINAPI_FAMILY_PHONE_APP
+ WaitForSingleObject(thread, INFINITE);
+ #else
diff --git a/libtgvoip.spec b/libtgvoip.spec
index 9cb5c35..8043a47 100644
--- a/libtgvoip.spec
+++ b/libtgvoip.spec
@@ -1,6 +1,6 @@
Name: libtgvoip
-Version: 2.1.1
-Release: 2%{?dist}
+Version: 2.2
+Release: 1%{?dist}
Summary: VoIP library for Telegram clients
# Libtgvoip shared library - Public Domain.
@@ -11,6 +11,10 @@ URL:
https://github.com/grishka/%{name}
Source0: %{url}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Patch0: %{name}-build-fixes.patch
+# Temporary backported from upstream patches.
+Patch100: %{name}-crash-fix.patch
+Patch101: %{name}-addidional-fixes.patch
+
Provides: bundled(webrtc-audio-processing) = 0.3
BuildRequires: pulseaudio-libs-devel
BuildRequires: alsa-lib-devel
@@ -47,7 +51,6 @@ popd
# Installing shared library...
mkdir -p "%{buildroot}%{_libdir}"
install -m 0755 -p out/Release/lib.target/%{name}.so.%{version}
"%{buildroot}%{_libdir}/%{name}.so.%{version}"
-ln -s %{name}.so.%{version} "%{buildroot}%{_libdir}/%{name}.so.2.1"
ln -s %{name}.so.%{version} "%{buildroot}%{_libdir}/%{name}.so.2"
ln -s %{name}.so.%{version} "%{buildroot}%{_libdir}/%{name}.so"
@@ -56,8 +59,6 @@ mkdir -p "%{buildroot}%{_includedir}/%{name}/audio"
find . -maxdepth 1 -type f -name "*.h" -exec install -m 0644 -p '{}'
%{buildroot}%{_includedir}/%{name} \;
find audio -maxdepth 1 -type f -name "*.h" -exec install -m 0644 -p
'{}' %{buildroot}%{_includedir}/%{name}/audio \;
-%ldconfig_scriptlets
-
%files
%license UNLICENSE
%{_libdir}/%{name}.so.*
@@ -67,8 +68,8 @@ find audio -maxdepth 1 -type f -name "*.h" -exec install -m
0644 -p '{}' %{build
%{_libdir}/%{name}.so
%changelog
-* Thu Jul 26 2018 RPM Fusion Release Engineering <leigh123linux(a)gmail.com> -
2.1.1-2
-- Rebuilt for
https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
+* Fri Jul 20 2018 Vitaly Zaitsev <vitaly(a)easycoding.org> - 2.2-1
+- Updated to 2.2 (regular release).
* Mon Jul 02 2018 Vitaly Zaitsev <vitaly(a)easycoding.org> - 2.1.1-1
- Updated to 2.1.1 (regular release).
diff --git a/sources b/sources
index 565b5eb..116d4e3 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-45cb22177aa588c37f3c8185ad20363b libtgvoip-2.1.1.tar.gz
+29ad32f3ad855b6838a15d798ad28d1f libtgvoip-2.2.tar.gz