/* This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once #include "mtproto/sender.h" #include "calls/calls_call.h" #include "calls/calls_group_call.h" namespace Platform { enum class PermissionType; } // namespace Platform namespace Media { namespace Audio { class Track; } // namespace Audio } // namespace Media namespace Main { class Session; } // namespace Main namespace Calls { class Panel; class GroupPanel; class Instance : private Call::Delegate , private GroupCall::Delegate , private base::Subscriber , public base::has_weak_ptr { public: Instance(); ~Instance(); void startOutgoingCall(not_null user, bool video); void startOrJoinGroupCall(not_null channel); void handleUpdate( not_null session, const MTPUpdate &update); void showInfoPanel(not_null call); void showInfoPanel(not_null call); [[nodiscard]] Call *currentCall() const; [[nodiscard]] rpl::producer currentCallValue() const; [[nodiscard]] GroupCall *currentGroupCall() const; [[nodiscard]] rpl::producer currentGroupCallValue() const; [[nodiscard]] bool inCall() const; [[nodiscard]] bool inGroupCall() const; bool activateCurrentCall(); std::shared_ptr getVideoCapture() override; void setCurrentAudioDevice(bool input, const QString &deviceId); [[nodiscard]] bool isQuitPrevent(); private: [[nodiscard]] not_null getCallDelegate() { return static_cast(this); } [[nodiscard]] not_null getGroupCallDelegate() { return static_cast(this); } [[nodiscard]] DhConfig getDhConfig() const override { return _dhConfig; } void callFinished(not_null call) override; void callFailed(not_null call) override; void callRedial(not_null call) override; void callRequestPermissionsOrFail( Fn onSuccess, bool video) override { requestPermissionsOrFail(std::move(onSuccess), video); } void groupCallFinished(not_null call) override; void groupCallFailed(not_null call) override; using Sound = Call::Delegate::Sound; void playSound(Sound sound) override; void createCall(not_null user, Call::Type type, bool video); void destroyCall(not_null call); void createGroupCall( not_null channel, const MTPInputGroupCall &inputCall); void destroyGroupCall(not_null call); void requestPermissionsOrFail(Fn onSuccess, bool video = true); void requestPermissionOrFail(Platform::PermissionType type, Fn onSuccess); void refreshDhConfig(); void refreshServerConfig(not_null session); bytes::const_span updateDhConfig(const MTPmessages_DhConfig &data); void destroyCurrentCall(); void handleCallUpdate( not_null session, const MTPPhoneCall &call); void handleSignalingData( not_null session, const MTPDupdatePhoneCallSignalingData &data); void handleGroupCallUpdate( not_null session, const MTPGroupCall &call); void handleGroupCallUpdate( not_null session, const MTPDupdateGroupCallParticipants &update); DhConfig _dhConfig; crl::time _lastServerConfigUpdateTime = 0; base::weak_ptr _serverConfigRequestSession; std::weak_ptr _videoCapture; std::unique_ptr _currentCall; rpl::event_stream _currentCallChanges; std::unique_ptr _currentCallPanel; std::unique_ptr _currentGroupCall; rpl::event_stream _currentGroupCallChanges; std::unique_ptr _currentGroupCallPanel; std::unique_ptr _callConnectingTrack; std::unique_ptr _callEndedTrack; std::unique_ptr _callBusyTrack; }; } // namespace Calls