#ifndef TGCALLS_MANAGER_H #define TGCALLS_MANAGER_H #include "ThreadLocalObject.h" #include "EncryptedConnection.h" #include "NetworkManager.h" #include "MediaManager.h" #include "Instance.h" namespace tgcalls { class Manager final : public std::enable_shared_from_this { public: static rtc::Thread *getMediaThread(); Manager(rtc::Thread *thread, Descriptor &&descriptor); ~Manager(); void start(); void receiveSignalingData(const std::vector &data); void setVideoCapture(std::shared_ptr videoCapture); void setMuteOutgoingAudio(bool mute); void setIncomingVideoOutput(std::shared_ptr> sink); void setIsLowBatteryLevel(bool isLowBatteryLevel); void setIsLocalNetworkLowCost(bool isLocalNetworkLowCost); void getNetworkStats(std::function completion); private: void sendSignalingAsync(int delayMs, int cause); void receiveMessage(DecryptedMessage &&message); bool calculateIsCurrentNetworkLowCost() const; void updateIsCurrentNetworkLowCost(bool wasLowCost); void sendInitialSignalingMessages(); rtc::Thread *_thread; EncryptionKey _encryptionKey; EncryptedConnection _signaling; bool _enableP2P = false; ProtocolVersion _protocolVersion = ProtocolVersion::V0; std::vector _rtcServers; std::shared_ptr _videoCapture; std::function _stateUpdated; std::function _remoteMediaStateUpdated; std::function _remoteBatteryLevelIsLowUpdated; std::function _remotePrefferedAspectRatioUpdated; std::function &)> _signalingDataEmitted; std::function _signalBarsUpdated; std::function _sendSignalingMessage; std::function _sendTransportMessage; std::unique_ptr> _networkManager; std::unique_ptr> _mediaManager; State _state = State::Reconnecting; bool _didConnectOnce = false; float _localPreferredVideoAspectRatio = 0.0f; bool _enableHighBitrateVideo = false; std::vector _preferredCodecs; bool _localNetworkIsLowCost = false; bool _remoteNetworkIsLowCost = false; std::shared_ptr _platformContext; }; } // namespace tgcalls #endif