From b58ce4a2ab3ea9a7a42ded9a3f665d85a45ee3b8 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 25 Jan 2020 18:36:49 +0100 Subject: [PATCH] Finish moving around --- Makefile.am | 8 +- Makefile.in | 85 +++++++++++----------- VoIPController.cpp | 105 +++------------------------ VoIPController.h | 6 +- audio/AudioInput.h | 2 +- audio/AudioOutput.h | 2 +- controller/PrivateDefines.cpp | 66 +++++++++++++++++ controller/audio/EchoCanceller.h | 2 +- controller/audio/OpusDecoder.h | 2 +- controller/audio/OpusEncoder.h | 2 +- controller/controller/Crypto.cpp | 2 +- controller/controller/Init.cpp | 2 +- controller/controller/PublicAPI.cpp | 31 +++++++- controller/controller/Time.cpp | 2 +- controller/media/Audio.cpp | 2 +- controller/media/MediaStreamItf.cpp | 2 +- controller/media/Video.cpp | 2 +- controller/net/JitterBuffer.h | 2 +- controller/net/PacketReassembler.cpp | 2 +- controller/protocol/Bandwidth.cpp | 2 +- controller/protocol/Endpoints.cpp | 2 +- controller/protocol/Loop.cpp | 2 +- controller/protocol/NetworkAPI.cpp | 2 +- controller/protocol/Tick.cpp | 3 +- libtgvoip.gyp | 2 +- video/VideoPacketSender.h | 2 +- 26 files changed, 177 insertions(+), 165 deletions(-) create mode 100644 controller/PrivateDefines.cpp diff --git a/Makefile.am b/Makefile.am index e040574..07ab892 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,13 +11,13 @@ controller/net/CongestionControl.cpp \ controller/audio/EchoCanceller.cpp \ controller/net/JitterBuffer.cpp \ tools/logging.cpp \ -controller/MediaStreamItf.cpp \ +controller/media/MediaStreamItf.cpp \ tools/MessageThread.cpp \ controller/net/NetworkSocket.cpp \ controller/net/Endpoint.cpp \ controller/audio/OpusDecoder.cpp \ controller/audio/OpusEncoder.cpp \ -controller/PacketReassembler.cpp \ +controller/net/PacketReassembler.cpp \ VoIPGroupController.cpp \ VoIPServerConfig.cpp \ audio/AudioIO.cpp \ @@ -44,12 +44,12 @@ controller/audio/EchoCanceller.h \ controller/net/JitterBuffer.h \ tools/logging.h \ tools/threading.h \ -controller/MediaStreamItf.h \ +controller/media/MediaStreamItf.h \ tools/MessageThread.h \ controller/net/NetworkSocket.h \ controller/audio/OpusDecoder.h \ controller/audio/OpusEncoder.h \ -controller/PacketReassembler.h \ +controller/net/PacketReassembler.h \ VoIPServerConfig.h \ audio/AudioIO.h \ audio/AudioInput.h \ diff --git a/Makefile.in b/Makefile.in index fca5340..22d4505 100644 --- a/Makefile.in +++ b/Makefile.in @@ -812,11 +812,11 @@ am__libtgvoip_la_SOURCES_DIST = TgVoip.cpp VoIPController.cpp \ tools/Buffers.cpp controller/net/CongestionControl.cpp \ controller/audio/EchoCanceller.cpp \ controller/net/JitterBuffer.cpp tools/logging.cpp \ - controller/MediaStreamItf.cpp tools/MessageThread.cpp \ + controller/media/MediaStreamItf.cpp tools/MessageThread.cpp \ controller/net/NetworkSocket.cpp controller/net/Endpoint.cpp \ controller/audio/OpusDecoder.cpp \ controller/audio/OpusEncoder.cpp \ - controller/PacketReassembler.cpp VoIPGroupController.cpp \ + controller/net/PacketReassembler.cpp VoIPGroupController.cpp \ VoIPServerConfig.cpp audio/AudioIO.cpp audio/AudioInput.cpp \ audio/AudioOutput.cpp audio/Resampler.cpp \ audio/AudioInputTester.cpp os/posix/NetworkSocketPosix.cpp \ @@ -1432,10 +1432,11 @@ am__libtgvoip_la_SOURCES_DIST = TgVoip.cpp VoIPController.cpp \ VoIPController.h tools/Buffers.h tools/BlockingQueue.h \ controller/PrivateDefines.h controller/net/CongestionControl.h \ controller/audio/EchoCanceller.h controller/net/JitterBuffer.h \ - tools/logging.h tools/threading.h controller/MediaStreamItf.h \ - tools/MessageThread.h controller/net/NetworkSocket.h \ - controller/audio/OpusDecoder.h controller/audio/OpusEncoder.h \ - controller/PacketReassembler.h VoIPServerConfig.h \ + tools/logging.h tools/threading.h \ + controller/media/MediaStreamItf.h tools/MessageThread.h \ + controller/net/NetworkSocket.h controller/audio/OpusDecoder.h \ + controller/audio/OpusEncoder.h \ + controller/net/PacketReassembler.h VoIPServerConfig.h \ audio/AudioIO.h audio/AudioInput.h audio/AudioOutput.h \ audio/Resampler.h os/posix/NetworkSocketPosix.h \ video/VideoSource.h video/VideoPacketSender.h video/VideoFEC.h \ @@ -1750,11 +1751,11 @@ am__objects_12 = TgVoip.lo VoIPController.lo tools/Buffers.lo \ controller/net/CongestionControl.lo \ controller/audio/EchoCanceller.lo \ controller/net/JitterBuffer.lo tools/logging.lo \ - controller/MediaStreamItf.lo tools/MessageThread.lo \ + controller/media/MediaStreamItf.lo tools/MessageThread.lo \ controller/net/NetworkSocket.lo controller/net/Endpoint.lo \ controller/audio/OpusDecoder.lo \ controller/audio/OpusEncoder.lo \ - controller/PacketReassembler.lo VoIPGroupController.lo \ + controller/net/PacketReassembler.lo VoIPGroupController.lo \ VoIPServerConfig.lo audio/AudioIO.lo audio/AudioInput.lo \ audio/AudioOutput.lo audio/Resampler.lo \ audio/AudioInputTester.lo os/posix/NetworkSocketPosix.lo \ @@ -2060,15 +2061,15 @@ am__depfiles_remade = ./$(DEPDIR)/TgVoip.Plo \ audio/$(DEPDIR)/AudioInput.Plo \ audio/$(DEPDIR)/AudioInputTester.Plo \ audio/$(DEPDIR)/AudioOutput.Plo audio/$(DEPDIR)/Resampler.Plo \ - controller/$(DEPDIR)/MediaStreamItf.Plo \ - controller/$(DEPDIR)/PacketReassembler.Plo \ controller/audio/$(DEPDIR)/EchoCanceller.Plo \ controller/audio/$(DEPDIR)/OpusDecoder.Plo \ controller/audio/$(DEPDIR)/OpusEncoder.Plo \ + controller/media/$(DEPDIR)/MediaStreamItf.Plo \ controller/net/$(DEPDIR)/CongestionControl.Plo \ controller/net/$(DEPDIR)/Endpoint.Plo \ controller/net/$(DEPDIR)/JitterBuffer.Plo \ controller/net/$(DEPDIR)/NetworkSocket.Plo \ + controller/net/$(DEPDIR)/PacketReassembler.Plo \ os/darwin/$(DEPDIR)/AudioInputAudioUnit.Plo \ os/darwin/$(DEPDIR)/AudioInputAudioUnitOSX.Plo \ os/darwin/$(DEPDIR)/AudioOutputAudioUnit.Plo \ @@ -2182,10 +2183,11 @@ am__nobase_tgvoipinclude_HEADERS_DIST = TgVoip.h VoIPController.h \ tools/Buffers.h tools/BlockingQueue.h \ controller/PrivateDefines.h controller/net/CongestionControl.h \ controller/audio/EchoCanceller.h controller/net/JitterBuffer.h \ - tools/logging.h tools/threading.h controller/MediaStreamItf.h \ - tools/MessageThread.h controller/net/NetworkSocket.h \ - controller/audio/OpusDecoder.h controller/audio/OpusEncoder.h \ - controller/PacketReassembler.h VoIPServerConfig.h \ + tools/logging.h tools/threading.h \ + controller/media/MediaStreamItf.h tools/MessageThread.h \ + controller/net/NetworkSocket.h controller/audio/OpusDecoder.h \ + controller/audio/OpusEncoder.h \ + controller/net/PacketReassembler.h VoIPServerConfig.h \ audio/AudioIO.h audio/AudioInput.h audio/AudioOutput.h \ audio/Resampler.h os/posix/NetworkSocketPosix.h \ video/VideoSource.h video/VideoPacketSender.h video/VideoFEC.h \ @@ -2379,11 +2381,11 @@ SRC = TgVoip.cpp VoIPController.cpp tools/Buffers.cpp \ controller/net/CongestionControl.cpp \ controller/audio/EchoCanceller.cpp \ controller/net/JitterBuffer.cpp tools/logging.cpp \ - controller/MediaStreamItf.cpp tools/MessageThread.cpp \ + controller/media/MediaStreamItf.cpp tools/MessageThread.cpp \ controller/net/NetworkSocket.cpp controller/net/Endpoint.cpp \ controller/audio/OpusDecoder.cpp \ controller/audio/OpusEncoder.cpp \ - controller/PacketReassembler.cpp VoIPGroupController.cpp \ + controller/net/PacketReassembler.cpp VoIPGroupController.cpp \ VoIPServerConfig.cpp audio/AudioIO.cpp audio/AudioInput.cpp \ audio/AudioOutput.cpp audio/Resampler.cpp \ audio/AudioInputTester.cpp os/posix/NetworkSocketPosix.cpp \ @@ -2398,10 +2400,11 @@ TGVOIP_HDRS = TgVoip.h VoIPController.h tools/Buffers.h \ tools/BlockingQueue.h controller/PrivateDefines.h \ controller/net/CongestionControl.h \ controller/audio/EchoCanceller.h controller/net/JitterBuffer.h \ - tools/logging.h tools/threading.h controller/MediaStreamItf.h \ - tools/MessageThread.h controller/net/NetworkSocket.h \ - controller/audio/OpusDecoder.h controller/audio/OpusEncoder.h \ - controller/PacketReassembler.h VoIPServerConfig.h \ + tools/logging.h tools/threading.h \ + controller/media/MediaStreamItf.h tools/MessageThread.h \ + controller/net/NetworkSocket.h controller/audio/OpusDecoder.h \ + controller/audio/OpusEncoder.h \ + controller/net/PacketReassembler.h VoIPServerConfig.h \ audio/AudioIO.h audio/AudioInput.h audio/AudioOutput.h \ audio/Resampler.h os/posix/NetworkSocketPosix.h \ video/VideoSource.h video/VideoPacketSender.h video/VideoFEC.h \ @@ -2528,14 +2531,14 @@ controller/net/JitterBuffer.lo: controller/net/$(am__dirstamp) \ controller/net/$(DEPDIR)/$(am__dirstamp) tools/logging.lo: tools/$(am__dirstamp) \ tools/$(DEPDIR)/$(am__dirstamp) -controller/$(am__dirstamp): - @$(MKDIR_P) controller - @: > controller/$(am__dirstamp) -controller/$(DEPDIR)/$(am__dirstamp): - @$(MKDIR_P) controller/$(DEPDIR) - @: > controller/$(DEPDIR)/$(am__dirstamp) -controller/MediaStreamItf.lo: controller/$(am__dirstamp) \ - controller/$(DEPDIR)/$(am__dirstamp) +controller/media/$(am__dirstamp): + @$(MKDIR_P) controller/media + @: > controller/media/$(am__dirstamp) +controller/media/$(DEPDIR)/$(am__dirstamp): + @$(MKDIR_P) controller/media/$(DEPDIR) + @: > controller/media/$(DEPDIR)/$(am__dirstamp) +controller/media/MediaStreamItf.lo: controller/media/$(am__dirstamp) \ + controller/media/$(DEPDIR)/$(am__dirstamp) tools/MessageThread.lo: tools/$(am__dirstamp) \ tools/$(DEPDIR)/$(am__dirstamp) controller/net/NetworkSocket.lo: controller/net/$(am__dirstamp) \ @@ -2546,8 +2549,8 @@ controller/audio/OpusDecoder.lo: controller/audio/$(am__dirstamp) \ controller/audio/$(DEPDIR)/$(am__dirstamp) controller/audio/OpusEncoder.lo: controller/audio/$(am__dirstamp) \ controller/audio/$(DEPDIR)/$(am__dirstamp) -controller/PacketReassembler.lo: controller/$(am__dirstamp) \ - controller/$(DEPDIR)/$(am__dirstamp) +controller/net/PacketReassembler.lo: controller/net/$(am__dirstamp) \ + controller/net/$(DEPDIR)/$(am__dirstamp) audio/$(am__dirstamp): @$(MKDIR_P) audio @: > audio/$(am__dirstamp) @@ -3696,10 +3699,10 @@ mostlyclean-compile: -rm -f ./webrtc_dsp/third_party/rnnoise/src/*.lo -rm -f audio/*.$(OBJEXT) -rm -f audio/*.lo - -rm -f controller/*.$(OBJEXT) - -rm -f controller/*.lo -rm -f controller/audio/*.$(OBJEXT) -rm -f controller/audio/*.lo + -rm -f controller/media/*.$(OBJEXT) + -rm -f controller/media/*.lo -rm -f controller/net/*.$(OBJEXT) -rm -f controller/net/*.lo -rm -f os/darwin/*.$(OBJEXT) @@ -4003,15 +4006,15 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@audio/$(DEPDIR)/AudioInputTester.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@audio/$(DEPDIR)/AudioOutput.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@audio/$(DEPDIR)/Resampler.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@controller/$(DEPDIR)/MediaStreamItf.Plo@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@controller/$(DEPDIR)/PacketReassembler.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@controller/audio/$(DEPDIR)/EchoCanceller.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@controller/audio/$(DEPDIR)/OpusDecoder.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@controller/audio/$(DEPDIR)/OpusEncoder.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@controller/media/$(DEPDIR)/MediaStreamItf.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@controller/net/$(DEPDIR)/CongestionControl.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@controller/net/$(DEPDIR)/Endpoint.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@controller/net/$(DEPDIR)/JitterBuffer.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@controller/net/$(DEPDIR)/NetworkSocket.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@controller/net/$(DEPDIR)/PacketReassembler.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@os/darwin/$(DEPDIR)/AudioInputAudioUnit.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@os/darwin/$(DEPDIR)/AudioInputAudioUnitOSX.Plo@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@os/darwin/$(DEPDIR)/AudioOutputAudioUnit.Plo@am__quote@ # am--include-marker @@ -4217,8 +4220,8 @@ clean-libtool: -rm -rf ./webrtc_dsp/system_wrappers/source/.libs ./webrtc_dsp/system_wrappers/source/_libs -rm -rf ./webrtc_dsp/third_party/rnnoise/src/.libs ./webrtc_dsp/third_party/rnnoise/src/_libs -rm -rf audio/.libs audio/_libs - -rm -rf controller/.libs controller/_libs -rm -rf controller/audio/.libs controller/audio/_libs + -rm -rf controller/media/.libs controller/media/_libs -rm -rf controller/net/.libs controller/net/_libs -rm -rf os/darwin/.libs os/darwin/_libs -rm -rf os/linux/.libs os/linux/_libs @@ -4520,10 +4523,10 @@ distclean-generic: -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -rm -f audio/$(DEPDIR)/$(am__dirstamp) -rm -f audio/$(am__dirstamp) - -rm -f controller/$(DEPDIR)/$(am__dirstamp) - -rm -f controller/$(am__dirstamp) -rm -f controller/audio/$(DEPDIR)/$(am__dirstamp) -rm -f controller/audio/$(am__dirstamp) + -rm -f controller/media/$(DEPDIR)/$(am__dirstamp) + -rm -f controller/media/$(am__dirstamp) -rm -f controller/net/$(DEPDIR)/$(am__dirstamp) -rm -f controller/net/$(am__dirstamp) -rm -f os/darwin/$(DEPDIR)/$(am__dirstamp) @@ -4888,15 +4891,15 @@ distclean: distclean-am -rm -f audio/$(DEPDIR)/AudioInputTester.Plo -rm -f audio/$(DEPDIR)/AudioOutput.Plo -rm -f audio/$(DEPDIR)/Resampler.Plo - -rm -f controller/$(DEPDIR)/MediaStreamItf.Plo - -rm -f controller/$(DEPDIR)/PacketReassembler.Plo -rm -f controller/audio/$(DEPDIR)/EchoCanceller.Plo -rm -f controller/audio/$(DEPDIR)/OpusDecoder.Plo -rm -f controller/audio/$(DEPDIR)/OpusEncoder.Plo + -rm -f controller/media/$(DEPDIR)/MediaStreamItf.Plo -rm -f controller/net/$(DEPDIR)/CongestionControl.Plo -rm -f controller/net/$(DEPDIR)/Endpoint.Plo -rm -f controller/net/$(DEPDIR)/JitterBuffer.Plo -rm -f controller/net/$(DEPDIR)/NetworkSocket.Plo + -rm -f controller/net/$(DEPDIR)/PacketReassembler.Plo -rm -f os/darwin/$(DEPDIR)/AudioInputAudioUnit.Plo -rm -f os/darwin/$(DEPDIR)/AudioInputAudioUnitOSX.Plo -rm -f os/darwin/$(DEPDIR)/AudioOutputAudioUnit.Plo @@ -5256,15 +5259,15 @@ maintainer-clean: maintainer-clean-am -rm -f audio/$(DEPDIR)/AudioInputTester.Plo -rm -f audio/$(DEPDIR)/AudioOutput.Plo -rm -f audio/$(DEPDIR)/Resampler.Plo - -rm -f controller/$(DEPDIR)/MediaStreamItf.Plo - -rm -f controller/$(DEPDIR)/PacketReassembler.Plo -rm -f controller/audio/$(DEPDIR)/EchoCanceller.Plo -rm -f controller/audio/$(DEPDIR)/OpusDecoder.Plo -rm -f controller/audio/$(DEPDIR)/OpusEncoder.Plo + -rm -f controller/media/$(DEPDIR)/MediaStreamItf.Plo -rm -f controller/net/$(DEPDIR)/CongestionControl.Plo -rm -f controller/net/$(DEPDIR)/Endpoint.Plo -rm -f controller/net/$(DEPDIR)/JitterBuffer.Plo -rm -f controller/net/$(DEPDIR)/NetworkSocket.Plo + -rm -f controller/net/$(DEPDIR)/PacketReassembler.Plo -rm -f os/darwin/$(DEPDIR)/AudioInputAudioUnit.Plo -rm -f os/darwin/$(DEPDIR)/AudioInputAudioUnitOSX.Plo -rm -f os/darwin/$(DEPDIR)/AudioOutputAudioUnit.Plo diff --git a/VoIPController.cpp b/VoIPController.cpp index 5336706..93acd41 100644 --- a/VoIPController.cpp +++ b/VoIPController.cpp @@ -4,97 +4,14 @@ // you should have received with this source code distribution. // -#ifndef _WIN32 -#include -#include -#endif -#include -#include -#include -#include "VoIPController.h" -#include "tools/logging.h" -#include "tools/threading.h" -#include "tools/Buffers.h" -#include "controller/audio/OpusEncoder.h" -#include "controller/audio/OpusDecoder.h" -#include "VoIPServerConfig.h" -#include "controller/PrivateDefines.h" -#include "controller/net/Endpoint.h" -#include "tools/json11.hpp" -#include "controller/PacketSender.h" -#include "video/VideoPacketSender.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -inline int pad4(int x) -{ - int r = PAD4(x); - if (r == 4) - return 0; - return r; -} - -using namespace tgvoip; -using namespace std; - -#ifdef __APPLE__ -#include "os/darwin/AudioUnitIO.h" -#include -double VoIPController::machTimebase = 0; -uint64_t VoIPController::machTimestart = 0; -#endif - -#ifdef _WIN32 -int64_t VoIPController::win32TimeScale = 0; -bool VoIPController::didInitWin32TimeScale = false; -#endif - -#ifdef __ANDROID__ -#include "os/android/JNIUtilities.h" -#include "os/android/AudioInputAndroid.h" -#include "controller/net/NetworkSocket.h" - -extern jclass jniUtilitiesClass; -#endif - -#if defined(TGVOIP_USE_CALLBACK_AUDIO_IO) -#include "audio/AudioIOCallback.h" -#endif - - -#include "controller/voip/PublicAPI.cpp" -#include "controller/voip/Init.cpp" - - -#pragma mark - Miscellaneous - -void VoIPController::SetState(int state) -{ - this->state = state; - LOGV("Call state changed to %d", state); - stateChangeTime = GetCurrentTime(); - messageThread.Post([this, state] { - if (callbacks.connectionStateChanged) - callbacks.connectionStateChanged(this, state); - }); - if (state == STATE_ESTABLISHED) - { - SetMicMute(micMuted); - if (!wasEstablished) - { - wasEstablished = true; - messageThread.Post(std::bind(&VoIPController::UpdateRTT, this), 0.1, 0.5); - messageThread.Post(std::bind(&VoIPController::UpdateAudioBitrate, this), 0.0, 0.3); - messageThread.Post(std::bind(&VoIPController::UpdateCongestion, this), 0.0, 1.0); - messageThread.Post(std::bind(&VoIPController::UpdateSignalBars, this), 1.0, 1.0); - messageThread.Post(std::bind(&VoIPController::TickJitterBufferAndCongestionControl, this), 0.0, 0.1); - } - } -} +#include "controller/controller/PublicAPI.cpp" +#include "controller/controller/Init.cpp" +#include "controller/controller/Crypto.cpp" +#include "controller/controller/Time.cpp" +#include "controller/media/Audio.cpp" +#include "controller/media/Video.cpp" +#include "controller/protocol/Bandwidth.cpp" +#include "controller/protocol/Endpoints.cpp" +#include "controller/protocol/Loop.cpp" +#include "controller/protocol/NetworkAPI.cpp" +#include "controller/protocol/Tick.cpp" \ No newline at end of file diff --git a/VoIPController.h b/VoIPController.h index e8e2355..c6e9759 100755 --- a/VoIPController.h +++ b/VoIPController.h @@ -40,7 +40,7 @@ #include "controller/net/CongestionControl.h" #include "controller/net/NetworkSocket.h" #include "tools/Buffers.h" -#include "controller/PacketReassembler.h" +#include "controller/net/PacketReassembler.h" #include "tools/MessageThread.h" #include "tools/utils.h" #include "controller/PrivateDefines.h" @@ -581,7 +581,7 @@ private: void SendNopPacket(); void TickJitterBufferAndCongestionControl(); void ResetUdpAvailability(); - static std::string VoIPController::NetworkTypeToString(int type) + static std::string NetworkTypeToString(int type) { switch (type) { @@ -612,7 +612,7 @@ private: } } - static std::string VoIPController::GetPacketTypeString(unsigned char type) + static std::string GetPacketTypeString(unsigned char type) { switch (type) { diff --git a/audio/AudioInput.h b/audio/AudioInput.h index b6cb06f..2b3325c 100644 --- a/audio/AudioInput.h +++ b/audio/AudioInput.h @@ -10,7 +10,7 @@ #include #include #include -#include "../controller/MediaStreamItf.h" +#include "../controller/media/MediaStreamItf.h" namespace tgvoip { diff --git a/audio/AudioOutput.h b/audio/AudioOutput.h index 0f5beb9..c3f989e 100644 --- a/audio/AudioOutput.h +++ b/audio/AudioOutput.h @@ -11,7 +11,7 @@ #include #include #include -#include "../controller/MediaStreamItf.h" +#include "../controller/media/MediaStreamItf.h" namespace tgvoip { diff --git a/controller/PrivateDefines.cpp b/controller/PrivateDefines.cpp new file mode 100644 index 0000000..2fcc1c2 --- /dev/null +++ b/controller/PrivateDefines.cpp @@ -0,0 +1,66 @@ +#pragma once + +#ifndef _WIN32 +#include +#include +#endif +#include +#include +#include +#include "../VoIPController.h" +#include "../tools/logging.h" +#include "../tools/threading.h" +#include "../tools/Buffers.h" +#include "../controller/audio/OpusEncoder.h" +#include "../controller/audio/OpusDecoder.h" +#include "../VoIPServerConfig.h" +#include "../controller/PrivateDefines.h" +#include "../controller/net/Endpoint.h" +#include "../tools/json11.hpp" +#include "../controller/net/PacketSender.h" +#include "../video/VideoPacketSender.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +inline int pad4(int x) +{ + int r = PAD4(x); + if (r == 4) + return 0; + return r; +} + +using namespace tgvoip; +using namespace std; + +#ifdef __APPLE__ +#include "os/darwin/AudioUnitIO.h" +#include +double VoIPController::machTimebase = 0; +uint64_t VoIPController::machTimestart = 0; +#endif + +#ifdef _WIN32 +int64_t VoIPController::win32TimeScale = 0; +bool VoIPController::didInitWin32TimeScale = false; +#endif + +#ifdef __ANDROID__ +#include "os/android/JNIUtilities.h" +#include "os/android/AudioInputAndroid.h" +#include "controller/net/NetworkSocket.h" + +extern jclass jniUtilitiesClass; +#endif + +#if defined(TGVOIP_USE_CALLBACK_AUDIO_IO) +#include "audio/AudioIOCallback.h" +#endif + diff --git a/controller/audio/EchoCanceller.h b/controller/audio/EchoCanceller.h index bca64b5..7265036 100755 --- a/controller/audio/EchoCanceller.h +++ b/controller/audio/EchoCanceller.h @@ -10,7 +10,7 @@ #include "tools/threading.h" #include "tools/Buffers.h" #include "tools/BlockingQueue.h" -#include "controller/MediaStreamItf.h" +#include "controller/media/MediaStreamItf.h" #include "tools/utils.h" namespace webrtc diff --git a/controller/audio/OpusDecoder.h b/controller/audio/OpusDecoder.h index 9b92865..104d228 100755 --- a/controller/audio/OpusDecoder.h +++ b/controller/audio/OpusDecoder.h @@ -7,7 +7,7 @@ #ifndef LIBTGVOIP_OPUSDECODER_H #define LIBTGVOIP_OPUSDECODER_H -#include "controller/MediaStreamItf.h" +#include "controller/media/MediaStreamItf.h" #include "tools/threading.h" #include "tools/BlockingQueue.h" #include "tools/Buffers.h" diff --git a/controller/audio/OpusEncoder.h b/controller/audio/OpusEncoder.h index ea69d0d..f4a17e4 100755 --- a/controller/audio/OpusEncoder.h +++ b/controller/audio/OpusEncoder.h @@ -7,7 +7,7 @@ #ifndef LIBTGVOIP_OPUSENCODER_H #define LIBTGVOIP_OPUSENCODER_H -#include "controller/MediaStreamItf.h" +#include "controller/media/MediaStreamItf.h" #include "tools/threading.h" #include "tools/BlockingQueue.h" #include "tools/Buffers.h" diff --git a/controller/controller/Crypto.cpp b/controller/controller/Crypto.cpp index a001fcb..046e6e0 100644 --- a/controller/controller/Crypto.cpp +++ b/controller/controller/Crypto.cpp @@ -1,4 +1,4 @@ -#include "../../VoIPController.h" +#include "../PrivateDefines.cpp" using namespace tgvoip; using namespace std; diff --git a/controller/controller/Init.cpp b/controller/controller/Init.cpp index 04e433d..d5206d3 100644 --- a/controller/controller/Init.cpp +++ b/controller/controller/Init.cpp @@ -1,4 +1,4 @@ -#include "../../VoIPController.h" +#include "../PrivateDefines.cpp" using namespace tgvoip; using namespace std; diff --git a/controller/controller/PublicAPI.cpp b/controller/controller/PublicAPI.cpp index d95baf8..415e504 100644 --- a/controller/controller/PublicAPI.cpp +++ b/controller/controller/PublicAPI.cpp @@ -1,4 +1,4 @@ -#include "../../VoIPController.h" +#include "../PrivateDefines.cpp" using namespace tgvoip; @@ -734,4 +734,31 @@ CellularCarrierInfo VoIPController::GetCarrierInfo() #else return CellularCarrierInfo(); #endif -} \ No newline at end of file +} + + +#pragma mark - Miscellaneous + +void VoIPController::SetState(int state) +{ + this->state = state; + LOGV("Call state changed to %d", state); + stateChangeTime = GetCurrentTime(); + messageThread.Post([this, state] { + if (callbacks.connectionStateChanged) + callbacks.connectionStateChanged(this, state); + }); + if (state == STATE_ESTABLISHED) + { + SetMicMute(micMuted); + if (!wasEstablished) + { + wasEstablished = true; + messageThread.Post(std::bind(&VoIPController::UpdateRTT, this), 0.1, 0.5); + messageThread.Post(std::bind(&VoIPController::UpdateAudioBitrate, this), 0.0, 0.3); + messageThread.Post(std::bind(&VoIPController::UpdateCongestion, this), 0.0, 1.0); + messageThread.Post(std::bind(&VoIPController::UpdateSignalBars, this), 1.0, 1.0); + messageThread.Post(std::bind(&VoIPController::TickJitterBufferAndCongestionControl, this), 0.0, 0.1); + } + } +} diff --git a/controller/controller/Time.cpp b/controller/controller/Time.cpp index eb96491..abe476e 100644 --- a/controller/controller/Time.cpp +++ b/controller/controller/Time.cpp @@ -1,4 +1,4 @@ -#include "../../VoIPController.h" +#include "../PrivateDefines.cpp" using namespace tgvoip; using namespace std; diff --git a/controller/media/Audio.cpp b/controller/media/Audio.cpp index e5675ea..1dbc7a6 100644 --- a/controller/media/Audio.cpp +++ b/controller/media/Audio.cpp @@ -1,5 +1,5 @@ -#include "../../VoIPController.h" +#include "../PrivateDefines.cpp" using namespace tgvoip; using namespace std; diff --git a/controller/media/MediaStreamItf.cpp b/controller/media/MediaStreamItf.cpp index 91adc7c..295cabf 100644 --- a/controller/media/MediaStreamItf.cpp +++ b/controller/media/MediaStreamItf.cpp @@ -5,7 +5,7 @@ // #include "tools/logging.h" -#include "controller/MediaStreamItf.h" +#include "controller/media/MediaStreamItf.h" #include "controller/audio/EchoCanceller.h" #include #include diff --git a/controller/media/Video.cpp b/controller/media/Video.cpp index 233d862..345be6e 100644 --- a/controller/media/Video.cpp +++ b/controller/media/Video.cpp @@ -1,4 +1,4 @@ -#include "../../VoIPController.h" +#include "../PrivateDefines.cpp" using namespace tgvoip; using namespace std; diff --git a/controller/net/JitterBuffer.h b/controller/net/JitterBuffer.h index f4a387e..6b06255 100644 --- a/controller/net/JitterBuffer.h +++ b/controller/net/JitterBuffer.h @@ -10,7 +10,7 @@ #include #include #include -#include "controller/MediaStreamItf.h" +#include "controller/media/MediaStreamItf.h" #include "tools/BlockingQueue.h" #include "tools/Buffers.h" #include "tools/threading.h" diff --git a/controller/net/PacketReassembler.cpp b/controller/net/PacketReassembler.cpp index aaf797b..6ca6c2b 100644 --- a/controller/net/PacketReassembler.cpp +++ b/controller/net/PacketReassembler.cpp @@ -2,7 +2,7 @@ // Created by Grishka on 19.03.2018. // -#include "controller/PacketReassembler.h" +#include "PacketReassembler.h" #include "tools/logging.h" #include "controller/PrivateDefines.h" #include "video/VideoFEC.h" diff --git a/controller/protocol/Bandwidth.cpp b/controller/protocol/Bandwidth.cpp index c0fc1f8..d4b2061 100644 --- a/controller/protocol/Bandwidth.cpp +++ b/controller/protocol/Bandwidth.cpp @@ -1,4 +1,4 @@ -#include "../../VoIPController.h" +#include "../PrivateDefines.cpp" using namespace tgvoip; using namespace std; diff --git a/controller/protocol/Endpoints.cpp b/controller/protocol/Endpoints.cpp index 90de7fc..b814eda 100644 --- a/controller/protocol/Endpoints.cpp +++ b/controller/protocol/Endpoints.cpp @@ -1,4 +1,4 @@ -#include "../../VoIPController.h" +#include "../PrivateDefines.cpp" using namespace tgvoip; using namespace std; diff --git a/controller/protocol/Loop.cpp b/controller/protocol/Loop.cpp index 568c730..0b15bbf 100644 --- a/controller/protocol/Loop.cpp +++ b/controller/protocol/Loop.cpp @@ -1,4 +1,4 @@ -#include "../../VoIPController.h" +#include "../PrivateDefines.cpp" using namespace tgvoip; using namespace std; diff --git a/controller/protocol/NetworkAPI.cpp b/controller/protocol/NetworkAPI.cpp index 2bfad61..ba01a30 100644 --- a/controller/protocol/NetworkAPI.cpp +++ b/controller/protocol/NetworkAPI.cpp @@ -1,4 +1,4 @@ -#include "../../VoIPController.h" +#include "../PrivateDefines.cpp" using namespace tgvoip; using namespace std; diff --git a/controller/protocol/Tick.cpp b/controller/protocol/Tick.cpp index e95a9aa..689f197 100644 --- a/controller/protocol/Tick.cpp +++ b/controller/protocol/Tick.cpp @@ -1,5 +1,4 @@ - -#include "../../VoIPController.h" +#include "../PrivateDefines.cpp" using namespace tgvoip; using namespace std; diff --git a/libtgvoip.gyp b/libtgvoip.gyp index 132995e..cf75651 100644 --- a/libtgvoip.gyp +++ b/libtgvoip.gyp @@ -40,7 +40,7 @@ '<(tgvoip_src_loc)/tools/logging.cpp', '<(tgvoip_src_loc)/tools/logging.h', '<(tgvoip_src_loc)/controller/MediaStreamItf.cpp', - '<(tgvoip_src_loc)/controller/MediaStreamItf.h', + '<(tgvoip_src_loc)/controller/media/MediaStreamItf.h', '<(tgvoip_src_loc)/controller/audio/OpusDecoder.cpp', '<(tgvoip_src_loc)/controller/audio/OpusDecoder.h', '<(tgvoip_src_loc)/controller/audio/OpusEncoder.cpp', diff --git a/video/VideoPacketSender.h b/video/VideoPacketSender.h index 2768ace..6271288 100644 --- a/video/VideoPacketSender.h +++ b/video/VideoPacketSender.h @@ -5,7 +5,7 @@ #ifndef LIBTGVOIP_VIDEOPACKETSENDER_H #define LIBTGVOIP_VIDEOPACKETSENDER_H -#include "../controller/PacketSender.h" +#include "../controller/net/PacketSender.h" #include "../tools/Buffers.h" #include "../tools/threading.h" #include