#ifndef TGCALLS_MANAGER_H #define TGCALLS_MANAGER_H #include "ThreadLocalObject.h" #include "EncryptedConnection.h" #include "NetworkManager.h" #include "MediaManager.h" #include "Instance.h" #include "Stats.h" namespace tgcalls { class Manager final : public std::enable_shared_from_this { private: struct ResolvedNetworkStatus { bool isLowCost = false; bool isLowDataRequested = false; bool operator==(const ResolvedNetworkStatus &rhs); bool operator!=(const ResolvedNetworkStatus &rhs); }; 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 setRequestedVideoAspect(float aspect); void setMuteOutgoingAudio(bool mute); void setIncomingVideoOutput(std::shared_ptr> sink); void setIsLowBatteryLevel(bool isLowBatteryLevel); void setIsLocalNetworkLowCost(bool isLocalNetworkLowCost); void getNetworkStats(std::function completion); void setAudioInputDevice(std::string id); void setAudioOutputDevice(std::string id); void setInputVolume(float level); void setOutputVolume(float level); private: void sendSignalingAsync(int delayMs, int cause); void receiveMessage(DecryptedMessage &&message); void updateCurrentResolvedNetworkStatus(); void sendInitialSignalingMessages(); rtc::Thread *_thread; EncryptionKey _encryptionKey; EncryptedConnection _signaling; bool _enableP2P = false; bool _enableTCP = false; bool _enableStunMarking = false; ProtocolVersion _protocolVersion = ProtocolVersion::V0; FilePath _statsLogPath; std::vector _rtcServers; std::unique_ptr _proxy; MediaDevicesConfig _mediaDevicesConfig; std::shared_ptr _videoCapture; std::function _stateUpdated; std::function _remoteMediaStateUpdated; std::function _remoteBatteryLevelIsLowUpdated; std::function _remotePrefferedAspectRatioUpdated; std::function &)> _signalingDataEmitted; std::function _signalBarsUpdated; std::function _audioLevelUpdated; std::function _sendSignalingMessage; std::function _sendTransportMessage; std::unique_ptr> _networkManager; std::unique_ptr> _mediaManager; State _state = State::Reconnecting; bool _didConnectOnce = false; bool _enableHighBitrateVideo = false; DataSaving _dataSaving = DataSaving::Never; std::vector _preferredCodecs; bool _localNetworkIsLowCost = false; bool _remoteNetworkIsLowCost = false; bool _remoteIsLowDataRequested = false; absl::optional _currentResolvedLocalNetworkStatus; absl::optional _currentResolvedNetworkStatus; std::shared_ptr _platformContext; }; } // namespace tgcalls #endif