1
0
mirror of https://github.com/danog/libtgvoip.git synced 2024-11-26 12:14:39 +01:00
Go to file
2020-03-30 19:14:51 +02:00
audio Mark more methods as override, fixes for android 2020-03-29 16:55:33 +02:00
client/android Various android bugfixes 2020-03-29 18:05:35 +02:00
controller Fix build 2020-03-30 19:14:51 +02:00
libtgvoip_osx.xcodeproj Fix 2020-01-22 13:15:22 +01:00
libtgvoip.xcodeproj Fix 2020-01-22 13:15:22 +01:00
os Various android bugfixes 2020-03-29 18:05:35 +02:00
tests Updated WebRTC APM 2018-11-23 04:02:53 +03:00
tools Misc fixes 2020-03-29 17:20:17 +02:00
video Fix bugs, now working 2020-03-26 20:37:25 +01:00
webrtc_dsp Merge multiple fixes 2020-03-10 19:36:27 +01:00
.clang-format Finish refactoring packet structure 2020-03-21 15:08:03 +01:00
.gitignore Cleanup classes a bit, preparing for my strategy 2020-01-23 16:45:53 +01:00
aclocal.m4 Finally compiling 2020-03-25 15:49:13 +01:00
Android.mk Various android bugfixes 2020-03-29 18:05:35 +02:00
compile 2.2 2018-07-17 19:48:21 +03:00
config.guess 2.2 2018-07-17 19:48:21 +03:00
config.h.in 2.2 2018-07-17 19:48:21 +03:00
config.h.in~ Misc improvements and refactorings 2020-01-22 12:43:51 +01:00
config.sub 2.2 2018-07-17 19:48:21 +03:00
configure Finally compiling 2020-03-25 15:49:13 +01:00
configure.ac Updated projects 2019-03-12 16:15:22 +03:00
depcomp 2.2 2018-07-17 19:48:21 +03:00
Info.plist updated to 0.3.1 2017-03-30 17:06:59 +03:00
install-sh 2.2 2018-07-17 19:48:21 +03:00
libtgvoip.gyp Mark more methods as override, fixes for android 2020-03-29 16:55:33 +02:00
libtgvoip.UWP.vcxproj Fix 2020-01-22 13:15:22 +01:00
libtgvoip.UWP.vcxproj.filters Fix 2020-01-22 13:15:22 +01:00
libtgvoip.WP81.vcxproj Refactoring 2020-01-22 12:51:17 +01:00
libtgvoip.WP81.vcxproj.filters Refactoring 2020-01-22 12:51:17 +01:00
ltmain.sh Fix ARM Linux builds 2019-02-10 14:04:22 +03:00
Makefile.am Mark more methods as override, fixes for android 2020-03-29 16:55:33 +02:00
Makefile.in Mark more methods as override, fixes for android 2020-03-29 16:55:33 +02:00
missing 2.2 2018-07-17 19:48:21 +03:00
README.md Re-enable tweaked congestion control 2020-03-30 19:10:20 +02:00
scheme.tlb Finish writing new parser 2020-03-18 19:54:56 +01:00
schemeNew.tlb Fix legaacy support 2020-03-28 17:05:24 +01:00
TgVoip.cpp Various android bugfixes 2020-03-29 18:05:35 +02:00
TgVoip.h Merge multiple fixes 2020-03-10 19:36:27 +01:00
UNLICENSE Initial public release 2017-02-02 19:24:40 +03:00
VoIPController.cpp Finally compiling 2020-03-25 15:49:13 +01:00
VoIPController.h Fix audio quality issues 2020-03-29 19:27:34 +02:00
VoIPGroupController.cpp Finish refactoring packet structure 2020-03-21 15:08:03 +01:00
VoIPGroupController.h Full RAII 2020-01-24 20:26:34 +01:00
VoIPServerConfig.cpp Cleanup 2020-01-23 18:06:11 +01:00
VoIPServerConfig.h Cleanup 2020-01-23 18:06:11 +01:00

Daniil Gentili's submission to the VoIP contest 3

In this submission, I created a new and improved protocol that unifies all flags, lengths that were previously sparsed around the protocol into one single data payload.

This allows saving around 6 bytes for each data packet, and enormously reduces complexity of existing code, splitting business logic and (legacy) presentation/transport details into separate classes. All signaling packets (including init and initAck) are now unified into extra signaling fields. A TL-B scheme for the new protocol can be viewed in schemeNew.tlb (compared to the old protocol in scheme.tlb).

Constructor serialization and parsing is implemented using a manually-written polymorphic approach, inspired by Telegram's C++ applications (tdesktop, tdlib).
My implementation of polymorphic TL serialization and parsing can be viewed in controller/protocol/protocol/* and controller/protocol/packets/PacketStructs.*.

The new libtgvoip is 100% backwards compatibile with previous versions, keeping compatibility even with layer 8 and below, while enormously reducing complexity, encapsulating all legacy behaviour implementation details into a single Legacy.cpp file.

Among other features, all packet data buffers are moved around as unique_ptrs instead of being copied: previously, feeding a packet to the OPUS decoder through the jitter required two copies, and allocation of a slot in a buffer pool; now, a single unique_ptr (generated when initially parsing the packet) is moved around, instead (protocol/Protocol.cpp).
Similarly efficient move-logic is used for outgoing audio buffers (EC & main), network socket payloads, and reliable packet resending (see below).

The new protocol also allows for (backwards-compatible) transport multiplexing for streams, simply by making use of the packet seq (in newer protocols) or the audio PTS (in older protocols), without using additional fields.

This allows AudioPacketSender.cpp to reliably determine whether a certain packet was received by the other end or not, and resend only the missing audio pieces, especially in the case of Error Correction (EC) packets generated by the secondary low-bitrate opus encoder: only packets that are known to be lost (as of now) are re-sent, by using a Mask array type instead of a basic Array, skipping audio pieces that were already acknowledged for the current stream by the other endpoint.

I've also kept the reliable packet resending for the main audio stream, by further building onto and refactoring the reliable packet logic, which was now merged with the extraSignaling reliability logic (Reliable.cpp).

I've fixed a few nasty jitter buffer bugs:

  • Fixed a bug where the jitter buffer would wrongly reset in presence of EC packets (5ba6e99882bdc045ae64a3b4f65039910677edf0; for latest commit JitterBuffer.cpp line 142-151, wrongly interpreted EC packets as late main packets)
  • Fixed a minor bug where the jitter buffer would backtrack to an invalid timestamp when trying to fill gaps in transmission (457576e93faf8e99c49f936685d5c1582ca221bc; for latest commit JitterBuffer.cpp line 314, delay not multiplied by OPUS step)

Among other changes, the data structure representing incoming and outgoing streams was split into several polymorphic data structures and classes (protocol/packets/PacketStructs.h, protocol/Stream.h) to save memory and properly separate business logic from datastructures.

The commit history will be available @ https://gitlab.com/danog/libtgvoip as usual.

Please note that commit 2252eb1a20 contains an initial final version that suitably fixes one specific issues with audio quality: in case of sudden but short packet loss bursts (like when switching from WiFi to mobile network), libtgvoip would usually enable redundant EC, and most importantly decrease the bitrate of both main OPUS stream to the absolute minimum.
This causes hearable and persistent audio quality issues even if packet loss is reduced right afterwards (since it takes a while for the congestion controller to raise the audio quality again).
In that commit, I completely disable manual OPUS bandwidth regulation, instead relying on EC packets to fill in the gap during the short period of downtime: this yielded excellent results in my tests (I used a real-life device, switching constantly from wifi to weak 4g, with only very brief switches to EC hearable in the audio stream, automatically switching back to the high-quality 20kbps stream right afterwards).
The same results were confirmed by the tgvoip-test-suite: after re-enabling congestion control in the next commit, albeit with some fixes to account for packet resending: this also yielded good results even in low-bandwidth conditions.

If I have time until the end of the submissions, I'll refactor the jitter buffer to avoid excessive switching between the main and EC audio streams in case of packet loss in low-bandwidth conditions.

In the meantime, just wanted to say that I really enjoyed working on this contest: as usual, I have many more ideas for improvements, but for now, I'm pretty satisfied of the result.

Thank you.


Daniil Gentili's submission to the VoIP contest 2

My submission consists of a major refactor (to C++) of the existing libtgvoip library.

The existing code was somewhat readable, even if extremely bulky, all in one single controller class, and had way too many C-isms, assertions, unmanaged pointers and then unoptimized C++ code progressively added into the library at later stages.

I've removed many C-isms within the main controller, switching entirely to smart pointers for the management of internal objects, reducing to 0 the number of deletes in the destructor; with multiple refactoring passes I've optimized many places of the network loop with modern C++ data structures and general logical optimizations. I've also applied several optimizations to the code of the controller and helper utilities especially in the MessageThread, buffers and main network threads, switching to the C++ STL for many otherwise highly unefficient and unsafe operations (like throwing assertions if the deletion order of objects using buffers from bufferpool isn't exactly right, easily fixed with smart pointers and a lambda).