Giter Club home page Giter Club logo

libtgvoip's People

Contributors

3v1n0 avatar bakatrouble avatar cher-nov avatar frayxrulez avatar grishka avatar john-preston avatar johnnynator avatar mymedia2 avatar petertechstories avatar seven1240 avatar stek29 avatar xvitaly avatar zevlg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libtgvoip's Issues

Build failure against OpenSSL 1.1.0

Starting from OpenSSL 1.1.0, the AES_ctr128_encrypt function called in VoIPController.cpp file is removed. Changing the function to AES_cfg128_encrypt and coercively converting the argument type can fix the compilation error, but it may not work in practice.

utils.h not installed

Under linux I've done:

$ ./configure
$ make
$ make install

Everything goes nice, but when I've tried to compile file that includes <tgvoip/VoIPController.h> I've got next error:

c++ -std=c++11 -I/usr/local/include -Wall -g -pthread -DWITH_VOIP -o telega-voip.o telega-voip.cpp
In file included from /usr/local/include/tgvoip/video/VideoSource.h:12:0,
                 from /usr/local/include/tgvoip/VoIPController.h:24,
                 from telega-voip.cpp:1:
/usr/local/include/tgvoip/Buffers.h:20:19: fatal error: utils.h: No such file or directory
compilation terminated.
Makefile:14: recipe for target 'telega-voip.o' failed

I have to manually put utils.h into /usr/local/include/tgvoip to get rid of the error

Failed to build (windows), "no rule to make target"

process_begin: CreateProcess(NULL, "", ...) failed.
make: *** No rule to make target `C:/git/bettergram-android/TMessagesProj/jni/./libtgvoip/webrtc_dsp/webrtc/common_audio/ring_buffer.c', needed by `C:/git/bettergram-android/TMessagesProj/build/intermediates/ndkBuild/afat/debug/obj/local/armeabi-v7a/objs-debug/voip/./libtgvoip/webrtc_dsp/webrtc/common_audio/ring_buffer.o'.  Stop.

Full log here
https://gist.github.com/ArmeF97/66a13c1ff0f83229f6f30990da4de81d
direct link https://gist.githubusercontent.com/ArmeF97/66a13c1ff0f83229f6f30990da4de81d/raw/f5794e4640052c8e2260c3a4d095b95f36884769/Build%2520failed%2520libtgvoip

TGVOIP_ERROR_AUDIO_IO

I don't know if this is the right place for this but I'm getting an "Error initializing audio hardware" error in an LG-E610 running Android 4.1.2 which apparently maps to the constant above.

It's the first time I see an error of that kind on this terminal, in particular Telegram's audio messages work fine, and so do other telephony apps (the ones starting with Sk and Wh at least).

I can test custom APKs if needed, but only for a week or so since the phone is not mine.

Calls crash (Capture buffer is too big) on telegram desktop

telegram-desktop 
QEventLoop: Cannot be used without QApplication
QApplication: invalid style override passed, ignoring it.
D/tgvoip: === Updating voip config ===
V/tgvoip: adsp_good_impls -> (Qualcomm Fluence)
V/tgvoip: audio_bitrate_step_decr -> 1000.000000
V/tgvoip: audio_bitrate_step_incr -> 1000.000000
V/tgvoip: audio_congestion_window -> 1024.000000
V/tgvoip: audio_frame_size -> 60.000000
V/tgvoip: audio_init_bitrate -> 16000.000000
V/tgvoip: audio_init_bitrate_edge -> 8000.000000
V/tgvoip: audio_init_bitrate_gprs -> 8000.000000
V/tgvoip: audio_init_bitrate_saving -> 8000.000000
V/tgvoip: audio_max_bitrate -> 20000.000000
V/tgvoip: audio_max_bitrate_edge -> 16000.000000
V/tgvoip: audio_max_bitrate_gprs -> 8000.000000
V/tgvoip: audio_max_bitrate_saving -> 8000.000000
V/tgvoip: force_tcp -> false
V/tgvoip: jitter_initial_delay_60 -> 2.000000
V/tgvoip: jitter_losses_to_reset -> 20.000000
V/tgvoip: jitter_max_delay_60 -> 10.000000
V/tgvoip: jitter_max_slots_60 -> 20.000000
V/tgvoip: jitter_min_delay_60 -> 2.000000
V/tgvoip: jitter_resync_threshold -> 0.500000
V/tgvoip: use_system_aec -> true
V/tgvoip: use_system_ns -> true
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol                                                                                                                                                                        
Invalid return value 0 for stream protocol                                                                                                                                                                        
W/tgvoip: Set remote endpoints, allowP2P=0, connectionMaxLayer=65
V/tgvoip: Adding endpoint: 91.108.16.1:522, UDP
V/tgvoip: Adding endpoint: 91.108.16.2:536, UDP
V/tgvoip: Adding endpoint: 91.108.12.2:523, UDP
V/tgvoip: Adding endpoint: 91.108.12.3:534, UDP
V/tgvoip: Adding endpoint: 91.108.8.8:533, UDP
V/tgvoip: Adding endpoint: 91.108.8.4:527, UDP
I/tgvoip: update data saving mode, config 0, enabled 0, reqd by peer 0
W/tgvoip: Starting voip controller
V/tgvoip: trying bind to port 23918
D/tgvoip: Bound to local UDP port 23918
I/tgvoip: Receive thread starting
I/tgvoip: before create audio io
V/tgvoip: Socket 40 is ready to send
I/tgvoip: AEC: 1 NS: 1 AGC: 1
I/tgvoip: Audio initialization took 0.004538 seconds
V/tgvoip: Call state changed to 2
V/tgvoip: Sending UDP ping to 91.108.8.4:527, id 7429564131068570887
V/tgvoip: Sending UDP ping to 91.108.8.8:533, id -3714599649252290104
V/tgvoip: Sending UDP ping to 91.108.12.2:523, id 3932229395933083432
V/tgvoip: Sending UDP ping to 91.108.12.3:534, id 8940309287646375835
V/tgvoip: Sending UDP ping to 91.108.16.1:522, id 7305415550235190477
V/tgvoip: Sending UDP ping to 91.108.16.2:536, id 7118879853019769748
I/tgvoip: === send thread exiting ===
I/tgvoip: Detected IPv4 connectivity, will not try IPv6
V/tgvoip: Received UDP ping reply from 91.108.16.2:536: date=1544774617, queryID=7118879853019769748, my IP=124.121.195.2, my port=23918
V/tgvoip: Received UDP ping reply from 91.108.16.1:522: date=1544774617, queryID=7305415550235190477, my IP=124.121.195.2, my port=23918
V/tgvoip: Received UDP ping reply from 91.108.8.8:533: date=1544774617, queryID=-3714599649252290104, my IP=124.121.195.2, my port=23918
V/tgvoip: Received UDP ping reply from 91.108.8.4:527: date=1544774617, queryID=7429564131068570887, my IP=124.121.195.2, my port=23918
V/tgvoip: Received UDP ping reply from 91.108.12.2:523: date=1544774617, queryID=3932229395933083432, my IP=124.121.195.2, my port=23918
V/tgvoip: Received UDP ping reply from 91.108.12.3:534: date=1544774617, queryID=8940309287646375835, my IP=124.121.195.2, my port=23918
V/tgvoip: Sending UDP ping to 91.108.8.4:527, id -8360024936597700976
V/tgvoip: Sending UDP ping to 91.108.8.8:533, id 1418681432007352516
V/tgvoip: Sending UDP ping to 91.108.12.2:523, id -8146706013176485231
V/tgvoip: Sending UDP ping to 91.108.12.3:534, id 3282827147929495642
V/tgvoip: Sending UDP ping to 91.108.16.1:522, id -6266966635262632100
V/tgvoip: Sending UDP ping to 91.108.16.2:536, id -5337940464962887410
V/tgvoip: Received UDP ping reply from 91.108.16.2:536: date=1544774618, queryID=-5337940464962887410, my IP=124.121.195.2, my port=23918
V/tgvoip: Received UDP ping reply from 91.108.16.1:522: date=1544774618, queryID=-6266966635262632100, my IP=124.121.195.2, my port=23918
W/tgvoip: Received packet has wrong hash after decryption
D/tgvoip: Successfully decrypted packet in MTProto2.0 fallback, upgrading
D/tgvoip: Received init
I/tgvoip: Peer version is 6
I/tgvoip: Sending init ack
W/tgvoip: Received duplicated packet for seq 1
W/tgvoip: Received duplicated packet for seq 1
W/tgvoip: Received duplicated packet for seq 1
W/tgvoip: Received duplicated packet for seq 1
V/tgvoip: Received UDP ping reply from 91.108.8.8:533: date=1544774618, queryID=1418681432007352516, my IP=124.121.195.2, my port=23918
W/tgvoip: Received duplicated packet for seq 1
V/tgvoip: Received UDP ping reply from 91.108.8.4:527: date=1544774618, queryID=-8360024936597700976, my IP=124.121.195.2, my port=23918
V/tgvoip: Received UDP ping reply from 91.108.12.2:523: date=1544774618, queryID=-8146706013176485231, my IP=124.121.195.2, my port=23918
V/tgvoip: Received UDP ping reply from 91.108.12.3:534: date=1544774618, queryID=3282827147929495642, my IP=124.121.195.2, my port=23918
Invalid return value 0 for stream protocol
Invalid return value 0 for stream protocol                                                                                                                                                                        
V/tgvoip: Sending UDP ping to 91.108.8.4:527, id 8253367478718927017
V/tgvoip: Sending UDP ping to 91.108.8.8:533, id 4676351707000721239
V/tgvoip: Sending UDP ping to 91.108.12.2:523, id -7691665202932459463
V/tgvoip: Sending UDP ping to 91.108.12.3:534, id 4221351367275357709
V/tgvoip: Sending UDP ping to 91.108.16.1:522, id -5127233573755623357
V/tgvoip: Sending UDP ping to 91.108.16.2:536, id -2035872361814348440
W/tgvoip: received packet for unknown stream 1
V/tgvoip: Received UDP ping reply from 91.108.16.2:536: date=1544774618, queryID=-2035872361814348440, my IP=124.121.195.2, my port=23918
V/tgvoip: Received UDP ping reply from 91.108.16.1:522: date=1544774618, queryID=-5127233573755623357, my IP=124.121.195.2, my port=23918
W/tgvoip: received packet for unknown stream 1
W/tgvoip: received packet for unknown stream 1
W/tgvoip: received packet for unknown stream 1
D/tgvoip: Received init
I/tgvoip: Peer version is 6
I/tgvoip: Sending init ack
W/tgvoip: Received duplicated packet for seq 6
W/tgvoip: Received duplicated packet for seq 6
D/tgvoip: Received init ack
I/tgvoip: peer version from init ack 6
I/tgvoip: jitter: set min packet count 2
I/tgvoip: Audio I/O ready
I/tgvoip: decoder: packets per frame 3
V/tgvoip: jitter: found no packet for timestamp 0 (last put = 0, lost = 0)
V/tgvoip: jitter: found no packet for timestamp 60 (last put = 0, lost = 0)
V/tgvoip: starting encoder, packets per frame=3
I/tgvoip: jitter: resyncing, next timestamp = 120 (step=60, minDelay=2.000000)
W/tgvoip: Received duplicated packet for seq 6
W/tgvoip: Received duplicated packet for seq 6
V/tgvoip: Received UDP ping reply from 91.108.8.8:533: date=1544774618, queryID=4676351707000721239, my IP=124.121.195.2, my port=23918
W/tgvoip: Received duplicated packet for seq 6
V/tgvoip: Received UDP ping reply from 91.108.8.4:527: date=1544774618, queryID=8253367478718927017, my IP=124.121.195.2, my port=23918
V/tgvoip: opus_encoder: setting bitrate to 16000
V/tgvoip: Received UDP ping reply from 91.108.12.2:523: date=1544774618, queryID=-7691665202932459463, my IP=124.121.195.2, my port=23918
V/tgvoip: Received UDP ping reply from 91.108.12.3:534: date=1544774618, queryID=4221351367275357709, my IP=124.121.195.2, my port=23918
V/tgvoip: Sending UDP ping to 91.108.8.4:527, id -5401977422555754832
V/tgvoip: Sending UDP ping to 91.108.8.8:533, id 9052634242140961646
V/tgvoip: Sending UDP ping to 91.108.12.2:523, id -1292934664385299100
V/tgvoip: Sending UDP ping to 91.108.12.3:534, id 506481494673553725
V/tgvoip: Sending UDP ping to 91.108.16.1:522, id -178482456229748841
V/tgvoip: Sending UDP ping to 91.108.16.2:536, id -8683632577319455314
V/tgvoip: Received UDP ping reply from 91.108.16.2:536: date=1544774619, queryID=-8683632577319455314, my IP=124.121.195.2, my port=23918
V/tgvoip: Received UDP ping reply from 91.108.16.1:522: date=1544774619, queryID=-178482456229748841, my IP=124.121.195.2, my port=23918
D/tgvoip: Received init
I/tgvoip: Peer version is 6
I/tgvoip: Sending init ack
W/tgvoip: Received duplicated packet for seq 16
W/tgvoip: Received duplicated packet for seq 16
W/tgvoip: Received duplicated packet for seq 16
W/tgvoip: Received duplicated packet for seq 16
V/tgvoip: Received UDP ping reply from 91.108.8.8:533: date=1544774619, queryID=9052634242140961646, my IP=124.121.195.2, my port=23918
W/tgvoip: Received duplicated packet for seq 16
V/tgvoip: Received UDP ping reply from 91.108.8.4:527: date=1544774619, queryID=-5401977422555754832, my IP=124.121.195.2, my port=23918
V/tgvoip: Received UDP ping reply from 91.108.12.2:523: date=1544774619, queryID=-1292934664385299100, my IP=124.121.195.2, my port=23918
V/tgvoip: Received UDP ping reply from 91.108.12.3:534: date=1544774619, queryID=506481494673553725, my IP=124.121.195.2, my port=23918
E/tgvoip: Capture buffer is too big (16112)
[1]    5516 segmentation fault (core dumped)  telegram-desktop

Linux, pulseaudio

Question about usage

Hey guys quick question,

Is it possible to integrate the lib like other VOIP lib like PJSIP. Do you think to add a wiki or a Readme to explain how to use the lib on Android ?

Calling client freeze when called client discarded the incoming call initiated by calling client

this is the log output when the problem occurred:

D/tgvoip: Packet with seq 108 was not acknowledged
V/tgvoip: Writing extra into header: type 1, length 5
V/tgvoip: jitter: found no packet for timestamp 7258 (last put = 0, lost = 0)
V/tgvoip: jitter: found no packet for timestamp 7318 (last put = 0, lost = 0)
V/tgvoip: Writing extra into header: type 1, length 5
D/tgvoip: Packet with seq 109 was not acknowledged
D/tgvoip: Packet with seq 110 was not acknowledged
V/tgvoip: jitter: found no packet for timestamp 7318 (last put = 0, lost = 0)
V/tgvoip: jitter: found no packet for timestamp 7378 (last put = 0, lost = 0)
V/tgvoip: Writing extra into header: type 1, length 5
D/tgvoip: Packet with seq 111 was not acknowledged
V/tgvoip: jitter: found no packet for timestamp 7378 (last put = 0, lost = 0)
V/tgvoip: jitter: found no packet for timestamp 7438 (last put = 0, lost = 0)
V/tgvoip: Writing extra into header: type 1, length 5
V/tgvoip: jitter: found no packet for timestamp 7438 (last put = 0, lost = 0)
V/tgvoip: jitter: found no packet for timestamp 7498 (last put = 0, lost = 0)
V/tgvoip: Writing extra into header: type 1, length 5
D/tgvoip: Packet with seq 112 was not acknowledged

video/VideoPacketSender.cpp is not compiled in, causing linking problems

I'm having problems linking against libtgvoip:

/usr/local/lib/libtgvoip.so: undefined reference to `tgvoip::video::VideoPacketSender::SetSource(tgvoip::video::VideoSource*)'
/usr/local/lib/libtgvoip.so: undefined reference to `tgvoip::video::VideoPacketSender::VideoPacketSender(tgvoip::VoIPController*, tgvoip::video::VideoSource*, std::shared_ptr<tgvoip::VoIPController::Stream>)'
/usr/local/lib/libtgvoip.so: undefined reference to `tgvoip::video::ParityFEC::Decode(std::vector<tgvoip::Buffer, std::allocator<tgvoip::Buffer> >&, tgvoip::Buffer&)'
collect2: error: ld returned 1 exit status

If I add video/VideoPacketSender.cpp to SRC list in Makefile.am, then everything is ok

Thanks

How to use the library to convert wav to opus

This is more a question than an issue, but since I don't see any documentation I'm gonna ask here. Is it possible, and if so how, to use this library to convert PCM audio coming from a file to opus? This seems the only library able to output opus files that Telegram likes on all platforms. I tried without success by using ffmpeg, opusenc and oggenc.

Group Call Feature

Hey, It seems that the group call feature exists in the native code for couple of months.
Whatsapp already has it for a long time.
Why doesn't telegram releases the feature and when is the release planned?

AudioIO.h is missing

Hi, can u hell me? When i try to make, seems like my Ubuntu can't find AudoIO.h file

Audio callbacks are compiled in by default

I've noticed that audio callbacks compiles in even if --enable-audio-callback is not specified. Might be a typo error for action-if-not-given in configure.ac. I use next patch:

index f5f5dc0..c21f162 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,7 +44,7 @@ AS_CASE([$host_os],
 )
 AM_CONDITIONAL(TARGET_OS_OSX, test "x$os_osx" == xyes)
 
-AC_ARG_ENABLE([audio-callback], [AS_HELP_STRING([--enable-audio-callback], [enable callback-based audio I/O])], [], [enable_audio_callback=yes])
+AC_ARG_ENABLE([audio-callback], [AS_HELP_STRING([--enable-audio-callback], [enable callback-based audio I/O])], [], [enable_audio_callback=no])
 AM_CONDITIONAL(ENABLE_AUDIO_CALLBACK, test "x$enable_audio_callback" == xyes)
 
 AS_IF([test "x$os_osx" != xyes && test "x$enable_audio_callback" != xyes], [ # Linux

Enabling audio callbacks by default gives a problem, program that uses libtgvoip must also define TGVOIP_USE_CALLBACK_AUDIO_IO, because this macro is used to define VoIPController class members. I've got multiple random crashes before figured out that TGVOIP_USE_CALLBACK_AUDIO_IO was defined on libtgvoip compilation.

2.2.3 build failure

Build failure under GCC 8.2.1 on Fedora 28+:

[ 57%] Building CXX object CMakeFiles/libtgvoip.dir/builddir/build/BUILD/libtgvoip-2.2.3/VoIPController.o
/usr/bin/c++  -DTGVOIP_USE_DESKTOP_DSP -DWEBRTC_APM_DEBUG_DUMP=0 -DWEBRTC_POSIX -Dlibtgvoip_EXPORTS -I/builddir/build/BUILD/libtgvoip-2.2.3/out/Release/../../webrtc_dsp -I/usr/include/opus  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC   -o CMakeFiles/libtgvoip.dir/builddir/build/BUILD/libtgvoip-2.2.3/VoIPController.o -c /builddir/build/BUILD/libtgvoip-2.2.3/VoIPController.cpp
make[2]: Leaving directory '/builddir/build/BUILD/libtgvoip-2.2.3/out/Release'
/builddir/build/BUILD/libtgvoip-2.2.3/VoIPController.cpp:2776: warning: ignoring #pragma mark  [-Wunknown-pragmas]
 #pragma mark - Timer methods
 
/builddir/build/BUILD/libtgvoip-2.2.3/VoIPController.cpp:3150: warning: ignoring #pragma mark  [-Wunknown-pragmas]
 #pragma mark - Endpoint
 
/builddir/build/BUILD/libtgvoip-2.2.3/VoIPController.cpp: In member function 'void tgvoip::VoIPController::RunRecvThread(void*)':
/builddir/build/BUILD/libtgvoip-2.2.3/VoIPController.cpp:876:24: warning: catching polymorphic type 'class std::out_of_range' by value [-Wcatch-value=]
    }catch(out_of_range x){
                        ^
/builddir/build/BUILD/libtgvoip-2.2.3/VoIPController.cpp: In member function 'virtual void tgvoip::VoIPController::SendRelayPings()':
/builddir/build/BUILD/libtgvoip-2.2.3/VoIPController.cpp:2841:12: error: 'DBL_MAX' was not declared in this scope
    minPing=DBL_MAX;
            ^~~~~~~
/builddir/build/BUILD/libtgvoip-2.2.3/VoIPController.cpp:2841:12: note: suggested alternative: 'AF_MAX'
    minPing=DBL_MAX;
            ^~~~~~~
            AF_MAX
make[2]: *** [CMakeFiles/libtgvoip.dir/build.make:742: CMakeFiles/libtgvoip.dir/builddir/build/BUILD/libtgvoip-2.2.3/VoIPController.o] Error 1
make[2]: *** Waiting for unfinished jobs....

Incorrect pulseaudio availability check/device enumeration

Problem: Telegram Desktop hangs after key exchange in accepted call.

I have libpulse installed on my system, but I'm not using pulseaudio, hence pulseaudio daemon is not running.

So, AudioOutputPulse::IsAvailable() returns true. Then, here AudioOutputPulse::EnumerateDevices is being called, which calls pa_mainloop_iterate(ml, 1, NULL).

Looks like this call blocks thread if pulseaudio daemon is not running.

sources for static libraries

Hello!
The Telegram-FOSS project, the FOSS friendly fork of the Android app available on F-Droid, needs the sources for the included static libraries, as it can't be using the prebuilts.
In the issue #1 you have showed intention to release those sources, could you please do it now, since the version with call support is already in production?
Thank you in advance!

Logs are written into stdout

I've noticed that under linux logs are written into stdout. If some program links to libtgvoip and uses stdout for its own purpose, there is no way to separate ordinary output from the program and logging output made by libtgvoip.

Is not it a good practice for libraries to write logs/diagnostics to stderr instead of stdout ?

Voice calls stuck on connecting status

Linux Mageia 6.0 64 bits on Lenovo T530. Telegram Desktop 1.5.8

Telegram is working fine except for voice calls. After ringing the call remains in 'connecying status.
The libtgvoip seems unable to connect a socket.

Here is the debug log:
W/tgvoip: Set remote endpoints, allowP2P=1, connectionMaxLayer=92
V/tgvoip: Adding endpoint: 91.108.8.4:536, UDP
V/tgvoip: Adding endpoint: 91.108.8.8:526, UDP
V/tgvoip: Adding endpoint: 91.108.12.3:539, UDP
V/tgvoip: Adding endpoint: 91.108.12.1:533, UDP
V/tgvoip: Adding endpoint: 91.108.16.1:531, UDP
V/tgvoip: Adding endpoint: 91.108.16.3:540, UDP
I/tgvoip: update data saving mode, config 0, enabled 0, reqd by peer 0
W/tgvoip: Starting voip controller
E/tgvoip: error creating socket: 97 / Famiglia di indirizzi non supportata dal protocollo
V/tgvoip: Call state changed to 4
I/tgvoip: before create audio io
I/tgvoip: AEC: 1 NS: 1 AGC: 1
(audio_processing_impl.cc:394): Capture analyzer activated: 0
Capture post processor activated: 0
Render pre processor activated: 0
(audio_processing_impl.cc:658): Highpass filter activated: 1
(audio_processing_impl.cc:672): Gain Controller 2 activated: 1
(audio_processing_impl.cc:674): Pre-amplifier activated: 0
I/tgvoip: Audio initialization took 0,003698 seconds
W/tgvoip: Not ready to send - enqueueing
W/tgvoip: Not ready to send - enqueueing
W/tgvoip: Not ready to send - enqueueing
W/tgvoip: Not ready to send - enqueueing
W/tgvoip: Not ready to send - enqueueing
W/tgvoip: Not ready to send - enqueueing
I/tgvoip: === send thread exiting ===
D/tgvoip: Entered VoIPController::Stop
D/tgvoip: before shutdown socket

The same Telegram Desktop 1.5.8 works perfectly on a Mageia 5 Linux box Lenovo T410, as like as the previous Telegram versions.
The trivk enable/disable IPv6 changes nothing.

Assertion `requestedBytes<=sizeof(remainingData)' failed

Hi,

The following crash occurs at the beginning of a call. What can cause this error?

telegram-desktop: /build/libtgvoip/os/linux/AudioOutputPulse.cpp:282: void tgvoip::audio::AudioOutputPulse::StreamWriteCallback(pa_stream*, size_t): Assertion `requestedBytes<=sizeof(remainingData)' failed.

Stacktrace:

#0  0x00007f9c017a4e7b in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
        set = {__val = {18446744067266838239, 140305709940016, 2, 140308016686727, 140307919110144, 140305709940016, 140305709940117, 140305709940016, 140305709940016, 140305709940223, 140305709940316, 140305709940016, 140305709940316, 0, 0, 0}}
        pid = <optimized out>
        tid = <optimized out>
#1  0x00007f9c017a6231 in __GI_abort () at abort.c:79
        save_stage = 1
        act = {__sigaction_handler = {sa_handler = 0x7f9b78003d30, sa_sigaction = 0x7f9b78003d30}, sa_mask = {__val = {0, 140305709924384, 0, 0, 0, 140306448110776, 0, 140306448110608, 140308017792896, 21474836480, 140308017777992, 0, 5361793661716653056, 140308017762964, 0, 140308017777992}}, sa_flags = -1759447064, sa_restorer = 0x55819720f818}
        sigs = {__val = {32, 0 <repeats 15 times>}}
#2  0x00007f9c0179d9da in __assert_fail_base (fmt=0x7f9c018f0d48 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x55819720f818 "requestedBytes<=sizeof(remainingData)", file=file@entry=0x55819720f7e8 "/build/libtgvoip/os/linux/AudioOutputPulse.cpp", line=line@entry=282, function=function@entry=0x55819720f920 <tgvoip::audio::AudioOutputPulse::StreamWriteCallback(pa_stream*, unsigned long)::__PRETTY_FUNCTION__> "void tgvoip::audio::AudioOutputPulse::StreamWriteCallback(pa_stream*, size_t)") at assert.c:92
        str = 0x7f9b78003d30 ""
        total = 4096
#3  0x00007f9c0179da52 in __GI___assert_fail (assertion=0x55819720f818 "requestedBytes<=sizeof(remainingData)", file=0x55819720f7e8 "/build/libtgvoip/os/linux/AudioOutputPulse.cpp", line=282, function=0x55819720f920 <tgvoip::audio::AudioOutputPulse::StreamWriteCallback(pa_stream*, unsigned long)::__PRETTY_FUNCTION__> "void tgvoip::audio::AudioOutputPulse::StreamWriteCallback(pa_stream*, size_t)") at assert.c:101
#4  0x0000558196f5c95b in  ()
#5  0x00007f9be3139567 in create_stream_complete (s=0x7f9b9401eaa0) at pulse/stream.c:970
        s = 0x7f9b9401eaa0
        requested_bytes = 16896
        __func__ = "pa_create_stream_callback"
        __PRETTY_FUNCTION__ = "pa_create_stream_callback"
#6  0x00007f9be3139567 in pa_create_stream_callback (pd=pd@entry=0x7f9b780017f0, command=command@entry=2, tag=tag@entry=2, t=t@entry=0x7f9bd80028d0, userdata=userdata@entry=0x7f9b9401eaa0) at pulse/stream.c:1176
        s = 0x7f9b9401eaa0
        requested_bytes = 16896
        __func__ = "pa_create_stream_callback"
        __PRETTY_FUNCTION__ = "pa_create_stream_callback"
#7  0x00007f9be2ec65d1 in run_action (pd=0x7f9b780017f0, r=0x7f9b9c000ee0, command=2, ts=0x7f9bd80028d0) at pulsecore/pdispatch.c:288
        callback = 0x7f9be31391b0 <pa_create_stream_callback>
        userdata = 0x7f9b9401eaa0
        tag = 2
#8  0x00007f9be2ec694b in pa_pdispatch_run (pd=0x7f9b780017f0, packet=packet@entry=0x7f9b9c000db0, ancil_data=ancil_data@entry=0x7f9b78000e58, userdata=userdata@entry=0x7f9b9401d470) at pulsecore/pdispatch.c:341
        r = <optimized out>
        tag = 2
        command = 2
        ts = 0x7f9bd80028d0
        ret = -1
        pdata = <optimized out>
        plen = 254
        __func__ = "pa_pdispatch_run"
        __PRETTY_FUNCTION__ = "pa_pdispatch_run"
#9  0x00007f9be311a38e in pstream_packet_callback (p=<optimized out>, packet=0x7f9b9c000db0, ancil_data=0x7f9b78000e58, userdata=0x7f9b9401d470) at pulse/context.c:349
        c = 0x7f9b9401d470
        __func__ = "pstream_packet_callback"
        __PRETTY_FUNCTION__ = "pstream_packet_callback"
#10 0x00007f9be2ec959f in do_read (p=p@entry=0x7f9b78000bc0, re=re@entry=0x7f9b78000d88) at pulsecore/pstream.c:1012
        d = <optimized out>
        l = <optimized out>
        r = <optimized out>
        release_memblock = 0x0
        __func__ = "do_read"
        __PRETTY_FUNCTION__ = "do_read"
#11 0x00007f9be2ecc05b in do_pstream_read_write (p=0x7f9b78000bc0) at pulsecore/pstream.c:248
        __func__ = "do_pstream_read_write"
        __PRETTY_FUNCTION__ = "do_pstream_read_write"
#12 0x00007f9be2ecc3f9 in srb_callback (srb=<optimized out>, userdata=0x7f9b78000bc0) at pulsecore/pstream.c:287
        p = 0x7f9b78000bc0
        __func__ = "srb_callback"
        __PRETTY_FUNCTION__ = "srb_callback"
#13 0x00007f9be2eccc7f in srbchannel_rwloop (sr=0x7f9b78003520) at pulsecore/srbchannel.c:190
#14 0x00007f9be312f358 in dispatch_pollfds (m=0x7f9b94018420) at pulse/mainloop.c:655
        e = 0x7f9b780035f0
        r = 0
        k = 1
        dispatched = 0
        __func__ = "pa_mainloop_dispatch"
        __PRETTY_FUNCTION__ = "pa_mainloop_dispatch"
#15 0x00007f9be312f358 in pa_mainloop_dispatch (m=m@entry=0x7f9b94018420) at pulse/mainloop.c:898
        dispatched = 0
        __func__ = "pa_mainloop_dispatch"
        __PRETTY_FUNCTION__ = "pa_mainloop_dispatch"
#16 0x00007f9be312f72e in pa_mainloop_iterate (m=0x7f9b94018420, block=<optimized out>, retval=0x0) at pulse/mainloop.c:929
        r = 1
#17 0x00007f9be312f7b0 in pa_mainloop_run (m=0x7f9b94018420, retval=retval@entry=0x0) at pulse/mainloop.c:944
        r = <optimized out>
#18 0x00007f9be313d619 in thread (userdata=0x7f9b940183e0) at pulse/thread-mainloop.c:100
        m = 0x7f9b940183e0
        mask = {__val = {18446744067267100671, 18446744073709551615 <repeats 15 times>}}
        prev_mask = {__val = {0 <repeats 16 times>}}
        sa = {__sigaction_handler = {sa_handler = 0x0, sa_sigaction = 0x0}, sa_mask = {__val = {0 <repeats 16 times>}}, sa_flags = 0, sa_restorer = 0x0}
#19 0x00007f9be2edcc08 in internal_thread_func (userdata=0x7f9b9401dd40) at pulsecore/thread-posix.c:81
        t = 0x7f9b9401dd40
#20 0x00007f9c0245d5aa in start_thread (arg=0x7f9ba3ffe700) at pthread_create.c:463
        pd = 0x7f9ba3ffe700
        now = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140306448115456, -2014747426996165198, 140306892341150, 140306892341151, 140306892341152, 0, 1962841682978465202, 1959674316377744818}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
#21 0x00007f9c01866cbf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

libtgvoip version: 2.1.1
Telegram Desktop version: 1.3.10

make pulseaudio dependency optional

I was tweaking telegram desktop to compile on a musl-libc based distro with no pulseaudio and I noticed that your library unconditionally pulls in pulse, which was making it impossible to build it.

Since you also implement ALSA output, why not make pulse optional?

I'm not really familiar with gyp builds so I really can't help with integrating it into the build system, but at the moment I'm using this patch https://gist.github.com/Francesco149/9232b755f06bd45662d44a8b4cb0cf64 and adding -DLIBTGVOIP_WITHOUT_PULSE and it works fine, although it's not the nicest thing ever.

Lots of warnings under GCC 6+

[ 12%] Building CXX object CMakeFiles/libtgvoip.dir/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/BufferPool.o
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/BufferPool.cpp: In constructor 'tgvoip::BufferPool::BufferPool(unsigned int, unsigned int)':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/BufferPool.cpp:20:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=1;i<count;i++){
          ~^~~~~~
[ 12%] Building CXX object CMakeFiles/libtgvoip.dir/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/logging.o
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/logging.cpp: In function 'void tgvoip_log_file_write_header()':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/logging.cpp:42:6: warning: '%s' directive output may be truncated writing up to 64 bytes into a region of size between 63 and 127 [-Wformat-truncation=]
 void tgvoip_log_file_write_header(){
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:939:0,
                 from /builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/logging.cpp:8:
/usr/include/bits/stdio2.h:65:44: note: '__builtin___snprintf_chk' output between 5 and 197 bytes into a destination of size 128
        __bos (__s), __fmt, __va_arg_pack ());
                                            ^
[ 12%] Building CXX object CMakeFiles/libtgvoip.dir/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/JitterBuffer.o
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/JitterBuffer.cpp: In member function 'int tgvoip::JitterBuffer::GetInternal(jitter_packet_t*, int)':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/JitterBuffer.cpp:167:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(lostCount>=lossesToReset || (gotSinceReset>minDelay*25 && lostSinceReset>gotSinceReset/2)){
      ~~~~~~~~~^~~~~~~~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/JitterBuffer.cpp:167:48: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(lostCount>=lossesToReset || (gotSinceReset>minDelay*25 && lostSinceReset>gotSinceReset/2)){
                                   ~~~~~~~~~~~~~^~~~~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/JitterBuffer.cpp:172:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(GetCurrentDelay()<minDelay)
       ~~~~~~~~~~~~~~~~~^~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/JitterBuffer.cpp: In member function 'void tgvoip::JitterBuffer::PutInternal(jitter_packet_t*)':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/JitterBuffer.cpp:241:46: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  if(i==JITTER_SLOT_COUNT || GetCurrentDelay()>=maxUsedSlots){
                             ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/JitterBuffer.cpp: In member function 'void tgvoip::JitterBuffer::Tick()':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/JitterBuffer.cpp:392:48: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (((minDelay==1 ? (avgDelay>=3) : (avgDelay>=minDelay/2)) && delayHistory[0]>minDelay && avgLate16<=0.1 && absolutelyNoLatePackets && dontDecMinDelay<32 && min>minDelay) /*|| (avgRecvTimeDiff>0 && delayHistory[0]>minDelay/2 && avgRecvTimeDiff*1000<step/2)*/) {
                                        ~~~~~~~~^~~~~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/JitterBuffer.cpp:392:81: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (((minDelay==1 ? (avgDelay>=3) : (avgDelay>=minDelay/2)) && delayHistory[0]>minDelay && avgLate16<=0.1 && absolutelyNoLatePackets && dontDecMinDelay<32 && min>minDelay) /*|| (avgRecvTimeDiff>0 && delayHistory[0]>minDelay/2 && avgRecvTimeDiff*1000<step/2)*/) {
                                                                  ~~~~~~~~~~~~~~~^~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/JitterBuffer.cpp:392:164: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (((minDelay==1 ? (avgDelay>=3) : (avgDelay>=minDelay/2)) && delayHistory[0]>minDelay && avgLate16<=0.1 && absolutelyNoLatePackets && dontDecMinDelay<32 && min>minDelay) /*|| (avgRecvTimeDiff>0 && delayHistory[0]>minDelay/2 && avgRecvTimeDiff*1000<step/2)*/) {
                                                                                                                                                                 ~~~^~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/JitterBuffer.cpp:404:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(GetCurrentDelay()<=minDelay || min<=minDelay){
       ~~~~~~~~~~~~~~~~~^~~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/JitterBuffer.cpp:404:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(GetCurrentDelay()<=minDelay || min<=minDelay){
                                      ~~~^~~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/JitterBuffer.cpp:286:6: warning: unused variable 'count' [-Wunused-variable]
  int count=0;
      ^~~~~
[ 14%] Building CXX object CMakeFiles/libtgvoip.dir/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/NetworkSocket.o
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/NetworkSocket.cpp:22:0: warning: ignoring #pragma mark  [-Wunknown-pragmas]
 #pragma mark - NetworkSocket
 
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/NetworkSocket.cpp:57:0: warning: ignoring #pragma mark  [-Wunknown-pragmas]
 #pragma mark - NetworkAddress
 
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/NetworkSocket.cpp:77:0: warning: ignoring #pragma mark  [-Wunknown-pragmas]
 #pragma mark - IPv4Address
 
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/NetworkSocket.cpp:112:0: warning: ignoring #pragma mark  [-Wunknown-pragmas]
 #pragma mark - IPv6Address
[ 14%] Building CXX object CMakeFiles/libtgvoip.dir/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/os/linux/AudioInputALSA.o
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/os/linux/AudioInputALSA.cpp: In static member function 'static void* tgvoip::audio::AudioInputALSA::StartThread(void*)':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/os/linux/AudioInputALSA.cpp:74:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
[ 14%] Building CXX object CMakeFiles/libtgvoip.dir/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/os/posix/NetworkSocketPosix.o
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/os/posix/NetworkSocketPosix.cpp: In member function 'virtual void tgvoip::NetworkSocketPosix::Send(tgvoip::NetworkPacket*)':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/os/posix/NetworkSocketPosix.cpp:72:74: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
       uint32_t v4part=*((uint32_t*)&translatedAddr->sin6_addr.s6_addr[12]);
                                                                          ^
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/os/posix/NetworkSocketPosix.cpp:97:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   *((uint32_t*)&addr.sin6_addr.s6_addr[12])=v4addr->GetAddress();
                                           ^
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/os/posix/NetworkSocketPosix.cpp: In member function 'virtual void tgvoip::NetworkSocketPosix::Receive(tgvoip::NetworkPacket*)':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/os/posix/NetworkSocketPosix.cpp:137:62: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
   in_addr v4addr=*((in_addr *) &srcAddr.sin6_addr.s6_addr[12]);
                                                              ^
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/os/posix/NetworkSocketPosix.cpp:137:62: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/os/posix/NetworkSocketPosix.cpp: In member function 'virtual void tgvoip::NetworkSocketPosix::Open()':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/os/posix/NetworkSocketPosix.cpp:186:11: warning: unused variable 'localUdpPort' [-Wunused-variable]
  uint16_t localUdpPort=ntohs(addr.sin6_port);
           ^~~~~~~~~~~~
[ 14%] Building CXX object CMakeFiles/libtgvoip.dir/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/os/linux/AudioOutputALSA.o
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/os/linux/AudioOutputALSA.cpp: In static member function 'static void* tgvoip::audio::AudioOutputALSA::StartThread(void*)':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/os/linux/AudioOutputALSA.cpp:77:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
[ 13%] Building CXX object CMakeFiles/libtgvoip.dir/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.o
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp: In member function 'void tgvoip::VoIPController::SetRemoteEndpoints(std::vector<tgvoip::Endpoint>, bool)':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp:278:9: warning: unused variable 'i' [-Wunused-variable]
  size_t i;
         ^
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp: In member function 'void tgvoip::VoIPController::Start()':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp:308:6: warning: unused variable 'res' [-Wunused-variable]
  int res;
      ^~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp: In member function 'void tgvoip::VoIPController::RunRecvThread()':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp:808:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(i=0;i<queuedPackets.size();i++){
            ~^~~~~~~~~~~~~~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp:891:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(i=0; i<outgoingStreams.size(); i++){
             ~^~~~~~~~~~~~~~~~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp:1097:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(i=0;i<incomingStreams.size();i++){
            ~^~~~~~~~~~~~~~~~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp: In member function 'void tgvoip::VoIPController::RunTickThread()':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp:1287:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(i=0;i<outgoingStreams.size();i++){
           ~^~~~~~~~~~~~~~~~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp:1326:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(i=0;i<queuedPackets.size();i++){
           ~^~~~~~~~~~~~~~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp:1194:7: warning: variable 'wasWaitingForAcks' set but not used [-Wunused-but-set-variable]
  bool wasWaitingForAcks=false;
       ^~~~~~~~~~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp: In member function 'void tgvoip::VoIPController::SetMicMute(bool)':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp:1664:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0;i<outgoingStreams.size();i++){
          ~^~~~~~~~~~~~~~~~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp: In member function 'void tgvoip::VoIPController::UpdateAudioOutputState()':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp:1679:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0;i<incomingStreams.size();i++){
          ~^~~~~~~~~~~~~~~~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp: In member function 'void tgvoip::VoIPController::GetDebugString(char*, size_t)':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp:1749:6: warning: unused variable 'i' [-Wunused-variable]
  int i;
      ^
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp: In member function 'void tgvoip::VoIPController::RunRecvThread()':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/VoIPController.cpp:1071:4: warning: 'packetInnerLen' may be used uninitialized in this function [-Wmaybe-uninitialized]
    if(packetInnerLen>=4){
    ^~
[ 16%] Building CXX object CMakeFiles/libtgvoip.dir/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/aecm/echo_control_mobile.o
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/aecm/echo_control_mobile.cc: In function 'int32_t WebRtcAecm_GetBufferFarendError(void*, const int16_t*, size_t)':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/aecm/echo_control_mobile.cc:212:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (nrOfSamples != 80*aecm->aecmCore->mult && nrOfSamples != 160*aecm->aecmCore->mult)
       ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/aecm/echo_control_mobile.cc:212:61: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (nrOfSamples != 80*aecm->aecmCore->mult && nrOfSamples != 160*aecm->aecmCore->mult)
                                                 ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/aecm/echo_control_mobile.cc: In function 'int32_t WebRtcAecm_Process(void*, const int16_t*, const int16_t*, int16_t*, size_t, int16_t)':
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/aecm/echo_control_mobile.cc:274:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (nrOfSamples != 80*aecm->aecmCore->mult && nrOfSamples != 160*aecm->aecmCore->mult)
         ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/builddir/build/BUILD/tdesktop-1.0.37/Telegram/ThirdParty/libtgvoip/webrtc_dsp/webrtc/modules/audio_processing/aecm/echo_control_mobile.cc:274:63: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (nrOfSamples != 80*aecm->aecmCore->mult && nrOfSamples != 160*aecm->aecmCore->mult)
                                                   ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~

Some of them are critical and can cause vulnerabilities. Full build log: http://koji.russianfedora.pro/kojifiles/work/tasks/5923/45923/build.log

libtgvoip.gyp: non-portable compiler flag

At line 379 of libtgvoip.gyp, here, it appears that the compiler flag -msse2 is added unconditionally to the build configuration - this has led to build failure on all non-x86 architectures as the compiler simply won't support it (not to mention all i686 and below processors which will not be able to run the compiled code for unsupported instructions).

Will it be at all possible to make this flag optional? To be honest I was going to yell this issue out here, but I did find many SSE2 related code branches so...

ifaddrs.h: No such file or directory #include <ifaddrs.h>

i cloned the telegram for android and used your repo to put into the jni folder. on odk build i am getting this error-

[armeabi] Compile++ thumb: voip <= BufferInputStream.cpp
[armeabi] Compile++ thumb: voip <= BufferOutputStream.cpp
[armeabi] Compile++ thumb: voip <= BlockingQueue.cpp
[armeabi] Compile++ thumb: voip <= AudioInput.cpp
[armeabi] Compile++ thumb: voip <= AudioInputOpenSLES.cpp
[armeabi] Compile++ thumb: voip <= MediaStreamItf.cpp
[armeabi] Compile++ thumb: voip <= AudioOutput.cpp
[armeabi] Compile++ thumb: voip <= OpusEncoder.cpp
[armeabi] Compile++ thumb: voip <= AudioOutputOpenSLES.cpp
[armeabi] Compile++ thumb: voip <= JitterBuffer.cpp
[armeabi] Compile++ thumb: voip <= OpusDecoder.cpp
[armeabi] Compile++ thumb: voip <= BufferPool.cpp
[armeabi] Compile++ thumb: voip <= OpenSLEngineWrapper.cpp
[armeabi] Compile++ thumb: voip <= AudioInputAndroid.cpp
[armeabi] Compile++ thumb: voip <= AudioOutputAndroid.cpp
[armeabi] Compile++ thumb: voip <= EchoCanceller.cpp
[armeabi] Compile++ thumb: voip <= CongestionControl.cpp
[armeabi] Compile++ thumb: voip <= VoIPServerConfig.cpp
[armeabi] Compile++ thumb: voip <= Resampler.cpp
[armeabi] Compile++ thumb: voip <= NetworkSocket.cpp
[armeabi] Compile++ thumb: voip <= NetworkSocketPosix.cpp
jni/./libtgvoip/os/posix/NetworkSocketPosix.cpp:16:21: fatal error: ifaddrs.h: No such file or directory
 #include <ifaddrs.h>
                     ^
compilation terminated.
make: *** [obj/local/armeabi/objs/voip/./libtgvoip/os/posix/NetworkSocketPosix.o] Error 1

Can you please suggest a fix ?

Feature request: Support push-to-talk in voice chat

(repost of my original request on telegramdesktop/tdesktop#4175)

It'd be cool if Telegram supported a push-to-talk function for its voice chat: Instead of always transmitting audio, Telegram would only transmit while I'm holding a (configurable) key on my keyboard, and/or a button on the interface. Ideally, the key would still work even if the Telegram client doesn't currently have focus.

Push-to-talk is most commonly associated with voice chat applications geared toward gamers, but I actually find apps like Mumble useful for any sort of voice-chat context, because its push-to-talk feature minimizes any possible background noises or side talk the other person has to listen to.

Missing tag

Telegram Desktop 1.5.7 beta require latest version of libtgvoip. Can you create Git tag for it?

Is Server Needed ?

Hello ,

does this lib need a server to start making and receiving calls ? if yes what type of server is required ?

if defined(WEBRTC_ARCH_ARM_FAMILY) && defined(WEBRTC_ARCH_X86_FAMILY)

diff --git a/webrtc_dsp/modules/audio_processing/aec3/adaptive_fir_filter.cc b/webrtc_dsp/modules/audio_processing/aec3/adaptive_fir_filter.cc
index 7449fdc..727b74a 100644
--- a/webrtc_dsp/modules/audio_processing/aec3/adaptive_fir_filter.cc
+++ b/webrtc_dsp/modules/audio_processing/aec3/adaptive_fir_filter.cc
@@ -353,7 +353,7 @@ void ApplyFilter_NEON(const RenderBuffer& render_buffer,
}
#endif

-#if defined(WEBRTC_ARCH_ARM_FAMILY) && defined(WEBRTC_ARCH_X86_FAMILY)
+#if defined(WEBRTC_ARCH_ARM_FAMILY) || defined(WEBRTC_ARCH_X86_FAMILY)

Build Error on Windows and Linux

I forked the Telegram Android app as well as the libtgvoip repositories to a Windows 7 and a Linux Ubuntu 14.04 machine (64 bits). (I also tried cloning and downloading).
The android NDK-BUILD tool does not build the libtgvoip complaining about missing functions references. See bellow. I checked and the files in the "include" folder are there and there is a header file containing the complained functions in the /libtgvoip/external/include/webrtc/gain_control.h.
I have read this article and applied the suggested changes into the root mk files under /TMessagesProj/jni but I could not figure out where is the problem.

[armeabi] SharedLibrary : libtmessages.26.so
jni/./libtgvoip/EchoCanceller.cpp:82: error: undefined reference to 'WebRtcAgc_Free'
jni/./libtgvoip/EchoCanceller.cpp:54: error: undefined reference to 'WebRtcAgc_Create'
jni/./libtgvoip/EchoCanceller.cpp:59: error: undefined reference to 'WebRtcAgc_Init'
jni/./libtgvoip/EchoCanceller.cpp:60: error: undefined reference to 'WebRtcAgc_set_config'
jni/./libtgvoip/EchoCanceller.cpp:167: error: undefined reference to 'WebRtcAgc_AddMic'
jni/./libtgvoip/EchoCanceller.cpp:168: error: undefined reference to 'WebRtcAgc_Process'
jni/./libtgvoip/EchoCanceller.cpp:173: error: undefined reference to 'WebRtcAgc_AddMic'
jni/./libtgvoip/EchoCanceller.cpp:174: error: undefined reference to 'WebRtcAgc_Process'
collect2: error: ld returned 1 exit status
make: *** [obj/local/armeabi/libtmessages.26.so] Error 1

Can't connect to the peer

I'm having problems connecting to official telegram client using libtgvoip

here is the log:

I/tgvoip: update data saving mode, config 0, enabled 0, reqd by peer 0
D/tgvoip: === Updating voip config ===
D/tgvoip: {"audio_frame_size":60,"jitter_min_delay_60":2,"jitter_max_delay_60":10,"jitter_max_slots_60":20,"jitter_losses_to_reset":20,"jitter_resync_threshold":0.5,"audio_congestion_window":1024,"audio_max_bitrate":20000,"audio_max_bitrate_edge":16000,"audio_max_bitrate_gprs":8000,"audio_max_bitrate_saving":8000,"audio_init_bitrate":16000,"audio_init_bitrate_edge":8000,"audio_init_bitrate_gprs":8000,"audio_init_bitrate_saving":8000,"audio_bitrate_step_incr":1000,"audio_bitrate_step_decr":1000,"use_system_ns":true,"use_system_aec":true,"force_tcp":false,"jitter_initial_delay_60":2,"adsp_good_impls":"(Qualcomm Fluence)","bad_call_rating":true,"use_ios_vpio_agc":false,"use_tcp":false,"audio_medium_fec_bitrate":20000,"audio_medium_fec_multiplier":0.1,"audio_strong_fec_bitrate":7000}
W/tgvoip: Set remote endpoints, allowP2P=1, connectionMaxLayer=65
V/tgvoip: Adding endpoint: 134.209.182.236:559, UDP
V/tgvoip: Adding endpoint: 91.108.8.2:531, UDP
V/tgvoip: Adding endpoint: 91.108.8.5:526, UDP
V/tgvoip: Adding endpoint: 134.209.176.124:557, UDP
V/tgvoip: Adding endpoint: 134.209.186.207:556, UDP
W/tgvoip: Starting voip controller
V/tgvoip: trying bind to port 25773
D/tgvoip: Bound to local UDP port 25773
I/tgvoip: Receive thread starting
I/tgvoip: before create audio io
I/tgvoip: successfully connected to 23.105.225.206:1488
V/tgvoip: Socket 27 is ready to send
V/tgvoip: UDP proxy control socket ready to send
I/tgvoip: AEC: 1 NS: 1 AGC: 1
I/tgvoip: Audio initialization took 0.036406 seconds
W/tgvoip: Not ready to send - enqueueing
W/tgvoip: Not ready to send - enqueueing
W/tgvoip: Not ready to send - enqueueing
W/tgvoip: Not ready to send - enqueueing
W/tgvoip: Not ready to send - enqueueing
V/tgvoip: Call state changed to 2
I/tgvoip: === send thread exiting ===
V/tgvoip: socks5: VER=05, METHOD=02
V/tgvoip: socks5: auth response VER=01, STATUS=00
V/tgvoip: socks5: authentication succeeded
V/tgvoip: Sending udp associate
V/tgvoip: socks5: udp associate successful, given endpoint 23.108.217.198:57894
V/tgvoip: UDP proxy initialized
I/tgvoip: Resetting UDP availability
V/tgvoip: Socket 26 is ready to send
I/tgvoip: Sending queued packet
W/tgvoip: Send udp pings
I/tgvoip: Sending queued packet
V/tgvoip: Sending UDP ping to 91.108.8.5:526, id 4441475266705789262
I/tgvoip: Sending queued packet
V/tgvoip: Sending UDP ping to 91.108.8.2:531, id -7703959618806324945
I/tgvoip: Sending queued packet
V/tgvoip: Sending UDP ping to 134.209.186.207:556, id -8935923022641102571
V/tgvoip: Sending UDP ping to 134.209.176.124:557, id 4729247778523452789
I/tgvoip: Sending queued packet
V/tgvoip: Sending UDP ping to 134.209.182.236:559, id -5074907828049057263
W/tgvoip: Send udp pings
V/tgvoip: Sending UDP ping to 91.108.8.5:526, id 9060876288895160672
V/tgvoip: Sending UDP ping to 91.108.8.2:531, id 5488553117056903403
V/tgvoip: Sending UDP ping to 134.209.186.207:556, id 7968411937965077521
V/tgvoip: Sending UDP ping to 134.209.176.124:557, id -7449512232857068192
V/tgvoip: Sending UDP ping to 134.209.182.236:559, id 6099319604174485090
W/tgvoip: Send udp pings
V/tgvoip: Sending UDP ping to 91.108.8.5:526, id 6220455090801080952
V/tgvoip: Sending UDP ping to 91.108.8.2:531, id 492313030131660914
V/tgvoip: Sending UDP ping to 134.209.186.207:556, id 9145240022446986028
V/tgvoip: Sending UDP ping to 134.209.176.124:557, id 2406939392765307096
V/tgvoip: Sending UDP ping to 134.209.182.236:559, id -5394891798602119865
W/tgvoip: Send udp pings
V/tgvoip: Sending UDP ping to 91.108.8.5:526, id -6302722642300240301
V/tgvoip: Sending UDP ping to 91.108.8.2:531, id 8721768830081396553
V/tgvoip: Sending UDP ping to 134.209.186.207:556, id 8274791091726808735
V/tgvoip: Sending UDP ping to 134.209.176.124:557, id -3581150452088765552
V/tgvoip: Sending UDP ping to 134.209.182.236:559, id 4089437349257006681
I/tgvoip: UDP ping reply count: 0.00
I/tgvoip: Proxy does not let UDP through, closing proxy connection and using UDP directly
I/tgvoip: Resetting UDP availability
W/tgvoip: Send udp pings
V/tgvoip: Select canceled
V/tgvoip: Sending UDP ping to 91.108.8.5:526, id 4328686965824189298
V/tgvoip: Sending UDP ping to 91.108.8.2:531, id 4680094731392781299
V/tgvoip: Sending UDP ping to 134.209.186.207:556, id -7332011875088371450
V/tgvoip: Sending UDP ping to 134.209.176.124:557, id 4376966863906813296
V/tgvoip: Sending UDP ping to 134.209.182.236:559, id -7745502994920056446
I/tgvoip: Detected IPv4 connectivity, will not try IPv6
V/tgvoip: Received UDP ping reply from 134.209.186.207:556: date=1562409529, queryID=-7332011875088371450, my IP=37.145.127.46, my port=25773
V/tgvoip: Received UDP ping reply from 134.209.176.124:557: date=1562409534, queryID=4376966863906813296, my IP=37.145.127.46, my port=25773
V/tgvoip: Received UDP ping reply from 134.209.182.236:559: date=1562409533, queryID=-7745502994920056446, my IP=37.145.127.46, my port=25773
D/tgvoip: Received init
I/tgvoip: Peer version is 8
I/tgvoip: Sending init ack
I/tgvoip: Peer network address probably changed, switching to relay
I/tgvoip: Sending public endpoints request
D/tgvoip: Sending public endpoints request to 91.108.8.5:526
D/tgvoip: Sending public endpoints request to 91.108.8.2:531
D/tgvoip: Sending public endpoints request to 134.209.186.207:556
D/tgvoip: Sending public endpoints request to 134.209.176.124:557
D/tgvoip: Sending public endpoints request to 134.209.182.236:559
E/tgvoip: ProcessExtraData
W/tgvoip: Error parsing packet: Not enough bytes in buffer
W/tgvoip: Send udp pings
V/tgvoip: Sending UDP ping to 91.108.8.5:526, id 3507588293281162409
V/tgvoip: Sending UDP ping to 91.108.8.2:531, id -2277774931710466565
V/tgvoip: Sending UDP ping to 134.209.186.207:556, id 1015772244107978060
V/tgvoip: Sending UDP ping to 134.209.176.124:557, id 5720722344648352682
V/tgvoip: Sending UDP ping to 134.209.182.236:559, id -2055082073813076129
V/tgvoip: Received UDP ping reply from 134.209.186.207:556: date=1562409530, queryID=1015772244107978060, my IP=37.145.127.46, my port=25773
V/tgvoip: Received UDP ping reply from 134.209.176.124:557: date=1562409535, queryID=5720722344648352682, my IP=37.145.127.46, my port=25773
V/tgvoip: Received UDP ping reply from 134.209.182.236:559: date=1562409534, queryID=-2055082073813076129, my IP=37.145.127.46, my port=25773
W/tgvoip: Packet 2240156407 is out of order and too late
I/tgvoip: Peer network address probably changed, switching to relay
I/tgvoip: Sending public endpoints request
D/tgvoip: Sending public endpoints request to 91.108.8.5:526
D/tgvoip: Sending public endpoints request to 91.108.8.2:531
D/tgvoip: Sending public endpoints request to 134.209.186.207:556
D/tgvoip: Sending public endpoints request to 134.209.176.124:557
D/tgvoip: Sending public endpoints request to 134.209.182.236:559
W/tgvoip: Packet 2481759104 is out of order and too late
W/tgvoip: Send udp pings
V/tgvoip: Sending UDP ping to 91.108.8.5:526, id 582785621057503917
V/tgvoip: Sending UDP ping to 91.108.8.2:531, id 4992978033090699519
V/tgvoip: Sending UDP ping to 134.209.186.207:556, id -8873938423238788053
V/tgvoip: Sending UDP ping to 134.209.176.124:557, id -1161816140600476397
V/tgvoip: Sending UDP ping to 134.209.182.236:559, id -2330911144159093905
V/tgvoip: Received UDP ping reply from 134.209.186.207:556: date=1562409530, queryID=-8873938423238788053, my IP=37.145.127.46, my port=25773
V/tgvoip: Received UDP ping reply from 134.209.176.124:557: date=1562409535, queryID=-1161816140600476397, my IP=37.145.127.46, my port=25773
V/tgvoip: Received UDP ping reply from 134.209.182.236:559: date=1562409534, queryID=-2330911144159093905, my IP=37.145.127.46, my port=25773
W/tgvoip: Error parsing packet: Not enough bytes in buffer
W/tgvoip: Packet 3942843007 is out of order and too late
W/tgvoip: Packet 4014795878 is out of order and too late
W/tgvoip: Send udp pings
V/tgvoip: Sending UDP ping to 91.108.8.5:526, id 2230981910017526811
V/tgvoip: Sending UDP ping to 91.108.8.2:531, id 638186632623607967
V/tgvoip: Sending UDP ping to 134.209.186.207:556, id 2914682005968446342
V/tgvoip: Sending UDP ping to 134.209.176.124:557, id 1512108124789789105
V/tgvoip: Sending UDP ping to 134.209.182.236:559, id 5812105261843838642
V/tgvoip: Received UDP ping reply from 134.209.186.207:556: date=1562409531, queryID=2914682005968446342, my IP=37.145.127.46, my port=25773
V/tgvoip: Received UDP ping reply from 134.209.176.124:557: date=1562409536, queryID=1512108124789789105, my IP=37.145.127.46, my port=25773
V/tgvoip: Received UDP ping reply from 134.209.182.236:559: date=1562409535, queryID=5812105261843838642, my IP=37.145.127.46, my port=25773
W/tgvoip: Packet 893259920 is out of order and too late
W/tgvoip: Error parsing packet: Not enough bytes in buffer
I/tgvoip: Peer network address probably changed, switching to relay
I/tgvoip: Sending public endpoints request
D/tgvoip: Sending public endpoints request to 91.108.8.5:526
D/tgvoip: Sending public endpoints request to 91.108.8.2:531
D/tgvoip: Sending public endpoints request to 134.209.186.207:556
D/tgvoip: Sending public endpoints request to 134.209.176.124:557
D/tgvoip: Sending public endpoints request to 134.209.182.236:559
W/tgvoip: Error parsing packet: Not enough bytes in buffer
W/tgvoip: Packet 3938690194 is out of order and too late
I/tgvoip: UDP ping reply count: 4.00
W/tgvoip: Packet 3032711617 is out of order and too late
I/tgvoip: Peer network address probably changed, switching to relay
I/tgvoip: Sending public endpoints request
D/tgvoip: Sending public endpoints request to 91.108.8.5:526
D/tgvoip: Sending public endpoints request to 91.108.8.2:531
D/tgvoip: Sending public endpoints request to 134.209.186.207:556
D/tgvoip: Sending public endpoints request to 134.209.176.124:557
D/tgvoip: Sending public endpoints request to 134.209.182.236:559
E/tgvoip: ProcessExtraData
W/tgvoip: Error parsing packet: Not enough bytes in buffer
I/tgvoip: Peer network address probably changed, switching to relay
I/tgvoip: Sending public endpoints request
D/tgvoip: Sending public endpoints request to 91.108.8.5:526
D/tgvoip: Sending public endpoints request to 91.108.8.2:531
D/tgvoip: Sending public endpoints request to 134.209.186.207:556
D/tgvoip: Sending public endpoints request to 134.209.176.124:557
D/tgvoip: Sending public endpoints request to 134.209.182.236:559
E/tgvoip: ProcessExtraData
W/tgvoip: Error parsing packet: Not enough bytes in buffer
W/tgvoip: Packet 1409277214 is out of order and too late
W/tgvoip: Error parsing packet: Not enough bytes in buffer
W/tgvoip: Packet 2952143796 is out of order and too late
W/tgvoip: Packet 2526917132 is out of order and too late
W/tgvoip: Packet 3031755732 is out of order and too late
I/tgvoip: Peer network address probably changed, switching to relay
I/tgvoip: Sending public endpoints request
D/tgvoip: Sending public endpoints request to 91.108.8.5:526
D/tgvoip: Sending public endpoints request to 91.108.8.2:531
D/tgvoip: Sending public endpoints request to 134.209.186.207:556
D/tgvoip: Sending public endpoints request to 134.209.176.124:557
D/tgvoip: Sending public endpoints request to 134.209.182.236:559
I/tgvoip: Peer network address probably changed, switching to relay
I/tgvoip: Sending public endpoints request
D/tgvoip: Sending public endpoints request to 91.108.8.5:526
D/tgvoip: Sending public endpoints request to 91.108.8.2:531
D/tgvoip: Sending public endpoints request to 134.209.186.207:556
D/tgvoip: Sending public endpoints request to 134.209.176.124:557
D/tgvoip: Sending public endpoints request to 134.209.182.236:559
I/tgvoip: Peer network address probably changed, switching to relay
I/tgvoip: Sending public endpoints request
D/tgvoip: Sending public endpoints request to 91.108.8.5:526
D/tgvoip: Sending public endpoints request to 91.108.8.2:531
D/tgvoip: Sending public endpoints request to 134.209.186.207:556
D/tgvoip: Sending public endpoints request to 134.209.176.124:557
D/tgvoip: Sending public endpoints request to 134.209.182.236:559
E/tgvoip: ProcessExtraData
W/tgvoip: Error parsing packet: Not enough bytes in buffer
W/tgvoip: Packet 3239556762 is out of order and too late

The code using libtgvoip is pretty simple.

What am I doing wrong?

Thanks

Probably error in ping-pong logic

I see disconnect timeout in this log. Sending 21 ping, got 20 response.
Doubled ping on 555 port was sended at 2020-01-11_16:10:32 and after that connection was closed.

2020-01-11_16:10:32.239446 : 'V/tgvoip: Sending UDP ping to 134.209.178.131:555, id -3602320821221394583'
2020-01-11_16:10:32.239446 : 'V/tgvoip: Sending UDP ping to 134.209.178.131:555, id -3602320821221394583'

At first - doubled ping - looks strange. I see one reply on it.
At second - no 10 sec timeout in this case.
Full log:

2020-01-11_16:10:22.237224 : 'W/tgvoip: Set remote endpoints, allowP2P=1, connectionMaxLayer=92'
2020-01-11_16:10:22.237884 : 'V/tgvoip: Adding endpoint: 134.209.178.88:558, UDP'
2020-01-11_16:10:22.237973 : 'V/tgvoip: Adding endpoint: 91.108.8.2:524, UDP'
2020-01-11_16:10:22.238036 : 'V/tgvoip: Adding endpoint: 91.108.8.5:523, UDP'
2020-01-11_16:10:22.238083 : 'V/tgvoip: Adding endpoint: 134.209.178.131:555, UDP'
2020-01-11_16:10:22.238129 : 'V/tgvoip: Adding endpoint: 134.209.176.124:552, UDP'
2020-01-11_16:10:22.238175 : 'I/tgvoip: update data saving mode, config 0, enabled 0, reqd by peer 0'
2020-01-11_16:10:22.238221 : 'I/tgvoip: update data saving mode, config 0, enabled 0, reqd by peer 0'
2020-01-11_16:10:22.238269 : 'I/tgvoip: set network type: ethernet, active interface eth0'
2020-01-11_16:10:22.238321 : 'I/tgvoip: Local IPv6 address: 2a03:a140:10:891::1'
2020-01-11_16:10:22.238369 : 'I/tgvoip: Active network interface changed:  -> eth0'
2020-01-11_16:10:22.238417 : 'W/tgvoip: Starting voip controller'
2020-01-11_16:10:22.238817 : 'V/tgvoip: trying bind to port 26531'
2020-01-11_16:10:22.238872 : 'D/tgvoip: Bound to local UDP port 26531'
2020-01-11_16:10:22.238949 : 'I/tgvoip: before create audio io'
2020-01-11_16:10:22.239228 : 'I/tgvoip: AEC: 0 NS: 0 AGC: 0'
2020-01-11_16:10:22.240041 : 'I/tgvoip: Audio initialization took 0.000230 seconds'
2020-01-11_16:10:22.240073 : 'W/tgvoip: Not ready to send - enqueueing'
2020-01-11_16:10:22.240123 : 'W/tgvoip: Not ready to send - enqueueing'
2020-01-11_16:10:22.240490 : 'W/tgvoip: Not ready to send - enqueueing'
2020-01-11_16:10:22.240546 : 'W/tgvoip: Not ready to send - enqueueing'
2020-01-11_16:10:22.240591 : 'W/tgvoip: Not ready to send - enqueueing'
2020-01-11_16:10:22.240637 : 'V/tgvoip: Call state changed to 2'
2020-01-11_16:10:22.240681 : 'I/tgvoip: === send thread exiting ==='
2020-01-11_16:10:22.240724 : 'I/tgvoip: Receive thread starting'
2020-01-11_16:10:22.240976 : 'V/tgvoip: Socket 9 is ready to send'
2020-01-11_16:10:22.241029 : 'I/tgvoip: Sending queued packet'
2020-01-11_16:10:22.241079 : 'I/tgvoip: Sending queued packet'
2020-01-11_16:10:22.241137 : 'I/tgvoip: Sending queued packet'
2020-01-11_16:10:22.241181 : 'I/tgvoip: Sending queued packet'
2020-01-11_16:10:22.241410 : 'I/tgvoip: Sending queued packet'
2020-01-11_16:10:22.241463 : 'W/tgvoip: Send udp pings'
2020-01-11_16:10:22.241506 : 'V/tgvoip: Sending UDP ping to 91.108.8.5:523, id -3817415755165323969'
2020-01-11_16:10:22.241550 : 'V/tgvoip: Sending UDP ping to 91.108.8.2:524, id 6901368930608868445'
2020-01-11_16:10:22.241713 : 'V/tgvoip: Sending UDP ping to 134.209.176.124:552, id 1755996362657760226'
2020-01-11_16:10:22.241770 : 'V/tgvoip: Sending UDP ping to 134.209.178.131:555, id 2645042903637372986'
2020-01-11_16:10:22.241819 : 'V/tgvoip: Sending UDP ping to 134.209.178.88:558, id -4869043572370612716'
2020-01-11_16:10:32.236691 : 'I/tgvoip: Detected IPv4 connectivity, will not try IPv6'
2020-01-11_16:10:32.239234 : 'V/tgvoip: Received UDP ping reply from 91.108.8.5:523: date=1578755422, queryID=-3817415755165323969, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.239264 : 'V/tgvoip: Received UDP ping reply from 91.108.8.2:524: date=1578755422, queryID=6901368930608868445, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.239282 : 'V/tgvoip: Received UDP ping reply from 134.209.178.131:555: date=1578755333, queryID=2645042903637372986, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.239344 : 'V/tgvoip: Received UDP ping reply from 134.209.178.88:558: date=1578755025, queryID=-4869043572370612716, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.239362 : 'V/tgvoip: Received UDP ping reply from 134.209.176.124:552: date=1578754712, queryID=1755996362657760226, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.239380 : 'W/tgvoip: Send udp pings'
2020-01-11_16:10:32.239396 : 'V/tgvoip: Sending UDP ping to 91.108.8.5:523, id -6427060238848443264'
2020-01-11_16:10:32.239413 : 'V/tgvoip: Sending UDP ping to 91.108.8.2:524, id -694658261907644342'
2020-01-11_16:10:32.239429 : 'V/tgvoip: Sending UDP ping to 134.209.176.124:552, id -9190746633918223979'
2020-01-11_16:10:32.239446 : 'V/tgvoip: Sending UDP ping to 134.209.178.131:555, id -3602320821221394583'
2020-01-11_16:10:32.239446 : 'V/tgvoip: Sending UDP ping to 134.209.178.131:555, id -3602320821221394583'
2020-01-11_16:10:32.239462 : 'V/tgvoip: Sending UDP ping to 134.209.178.88:558, id -1557779231005966908'
2020-01-11_16:10:32.239479 : 'V/tgvoip: Received UDP ping reply from 91.108.8.5:523: date=1578755422, queryID=-6427060238848443264, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.239515 : 'V/tgvoip: Received UDP ping reply from 91.108.8.2:524: date=1578755422, queryID=-694658261907644342, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.239556 : 'V/tgvoip: Received UDP ping reply from 134.209.176.124:552: date=1578754713, queryID=-9190746633918223979, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.239962 : 'V/tgvoip: Received UDP ping reply from 134.209.178.131:555: date=1578755333, queryID=-3602320821221394583, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.239983 : 'V/tgvoip: Received UDP ping reply from 134.209.178.88:558: date=1578755026, queryID=-1557779231005966908, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.240000 : 'W/tgvoip: Send udp pings'
2020-01-11_16:10:32.240016 : 'V/tgvoip: Sending UDP ping to 91.108.8.5:523, id -8736267458746041368'
2020-01-11_16:10:32.240032 : 'V/tgvoip: Sending UDP ping to 91.108.8.2:524, id 8608741114975086036'
2020-01-11_16:10:32.240069 : 'V/tgvoip: Sending UDP ping to 134.209.176.124:552, id -2114693216985638656'
2020-01-11_16:10:32.240089 : 'V/tgvoip: Sending UDP ping to 134.209.178.131:555, id -4128303154435647207'
2020-01-11_16:10:32.240105 : 'V/tgvoip: Sending UDP ping to 134.209.178.88:558, id 7747231581407896919'
2020-01-11_16:10:32.240121 : 'V/tgvoip: Received UDP ping reply from 91.108.8.5:523: date=1578755423, queryID=-8736267458746041368, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.240138 : 'V/tgvoip: Received UDP ping reply from 91.108.8.2:524: date=1578755423, queryID=8608741114975086036, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.240155 : 'V/tgvoip: Received UDP ping reply from 134.209.178.88:558: date=1578755026, queryID=7747231581407896919, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.240172 : 'V/tgvoip: Received UDP ping reply from 134.209.176.124:552: date=1578754713, queryID=-2114693216985638656, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.240188 : 'V/tgvoip: Received UDP ping reply from 134.209.178.131:555: date=1578755334, queryID=-4128303154435647207, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.240205 : 'W/tgvoip: Send udp pings'
2020-01-11_16:10:32.240221 : 'V/tgvoip: Sending UDP ping to 91.108.8.5:523, id 7012775788596422607'
2020-01-11_16:10:32.240237 : 'V/tgvoip: Sending UDP ping to 91.108.8.2:524, id 1131485709082541546'
2020-01-11_16:10:32.240637 : 'V/tgvoip: Sending UDP ping to 134.209.176.124:552, id 5533250358792255060'
2020-01-11_16:10:32.240664 : 'V/tgvoip: Sending UDP ping to 134.209.178.131:555, id -8262545997127981128'
2020-01-11_16:10:32.240686 : 'V/tgvoip: Sending UDP ping to 134.209.178.88:558, id -1935282131501892829'
2020-01-11_16:10:32.240708 : 'V/tgvoip: Received UDP ping reply from 91.108.8.5:523: date=1578755423, queryID=7012775788596422607, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.240751 : 'V/tgvoip: Received UDP ping reply from 91.108.8.2:524: date=1578755423, queryID=1131485709082541546, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.240772 : 'V/tgvoip: Received UDP ping reply from 134.209.176.124:552: date=1578754714, queryID=5533250358792255060, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.240789 : 'V/tgvoip: Received UDP ping reply from 134.209.178.131:555: date=1578755334, queryID=-8262545997127981128, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.240807 : 'V/tgvoip: Received UDP ping reply from 134.209.178.88:558: date=1578755027, queryID=-1935282131501892829, my IP=86.105.52.145, my port=26531'
2020-01-11_16:10:32.240824 : 'I/tgvoip: UDP ping reply count: 4.00'
2020-01-11_16:10:32.241204 : 'W/tgvoip: Init timeout, disconnecting'
2020-01-11_16:10:32.241230 : 'V/tgvoip: Call state changed to 4'
2020-01-11_16:10:32.241247 : 'D/tgvoip: Entered VoIPController::Stop'
2020-01-11_16:10:32.241285 : 'D/tgvoip: before shutdown socket'
2020-01-11_16:10:32.241302 : 'D/tgvoip: before join sendThread'
2020-01-11_16:10:32.241318 : 'D/tgvoip: before join recvThread'
2020-01-11_16:10:32.241334 : 'V/tgvoip: Select canceled'
2020-01-11_16:10:32.241350 : 'I/tgvoip: === recv thread exiting ==='
2020-01-11_16:10:32.241611 : 'D/tgvoip: before stop messageThread'
2020-01-11_16:10:32.241630 : 'D/tgvoip: Before stop audio I/O'
2020-01-11_16:10:32.241646 : 'D/tgvoip: Left VoIPController::Stop [need rate = 0]'
2020-01-11_16:10:32.241662 : 'D/tgvoip: Entered VoIPController::~VoIPController'
2020-01-11_16:10:32.241678 : 'D/tgvoip: before close socket'
2020-01-11_16:10:32.241904 : 'D/tgvoip: before delete audioIO'
2020-01-11_16:10:32.241922 : 'D/tgvoip: before delete encoder'
2020-01-11_16:10:32.241945 : 'D/tgvoip: before delete echo canceller'
2020-01-11_16:10:32.242122 : 'D/tgvoip: Left VoIPController::~VoIPController'

This log was published by @@avegorov at https://t.me/contests_ru
Link on message https://t.me/contests_ru/28424

Provide a readme.

Could you please provide a readme about what is it? I just came across this GitHub and I really wanna know what is the relationship between VoIP and telegram.
I read this issue #6 and providing a readme file make it better to understand your git.
Thanks.

New release

Can you bump version and create a new release tag for last changes? GNU/Linux maintainers need this to push new version to repositories and build tdesktop.

Missing tag 2.2.4

Please create Git tag for 2.2.4 release. Linux maintainers need it to package this library.

libtgvoip as layer for custom P2P communication

Is it possible somehow to use libtgvoip for custom P2P communication?

I'd like to use it not only for phone/video calls, but also for collaborative editing and teledildonics using custom telegram client.

Thanks

Don't work handle of changing default audio device for VoIP in Windows.

Steps to reproduce in Telegram Desktop

  1. Change audio device from default;
  2. Call somebody and talk.

Expected behaviour

VoIP must to use default audio device.

Actual behaviour

VoIP use last installed audio device always. O

Configuration

Operating system:
Windows 10 x64

Audio Devices:
asus xonar essence stx
m.stage HPA-3Uāŗ

Version of Telegram Desktop:
1.2.17

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.