summary refs log tree commit diff
path: root/src/CallManager.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/CallManager.h')
-rw-r--r--src/CallManager.h32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/CallManager.h b/src/CallManager.h
index d59a6249..e5571c88 100644
--- a/src/CallManager.h
+++ b/src/CallManager.h
@@ -16,48 +16,56 @@ namespace mtx::responses {
 struct TurnServer;
 }
 
+class QStringList;
 class QUrl;
 
 class CallManager : public QObject
 {
         Q_OBJECT
+        Q_PROPERTY(bool haveCallInvite READ haveCallInvite NOTIFY newInviteState)
         Q_PROPERTY(bool isOnCall READ isOnCall NOTIFY newCallState)
-        Q_PROPERTY(bool isOnVideoCall READ isOnVideoCall NOTIFY newVideoCallState)
+        Q_PROPERTY(bool isVideo READ isVideo NOTIFY newInviteState)
         Q_PROPERTY(webrtc::State callState READ callState NOTIFY newCallState)
-        Q_PROPERTY(QString callPartyName READ callPartyName NOTIFY newCallParty)
-        Q_PROPERTY(QString callPartyAvatarUrl READ callPartyAvatarUrl NOTIFY newCallParty)
+        Q_PROPERTY(QString callParty READ callParty NOTIFY newInviteState)
+        Q_PROPERTY(QString callPartyAvatarUrl READ callPartyAvatarUrl NOTIFY newInviteState)
         Q_PROPERTY(bool isMicMuted READ isMicMuted NOTIFY micMuteChanged)
         Q_PROPERTY(bool callsSupported READ callsSupported CONSTANT)
+        Q_PROPERTY(QStringList mics READ mics NOTIFY devicesChanged)
+        Q_PROPERTY(QStringList cameras READ cameras NOTIFY devicesChanged)
 
 public:
         CallManager(QObject *);
 
         void sendInvite(const QString &roomid, bool isVideo);
-        void hangUp(
-          mtx::events::msg::CallHangUp::Reason = mtx::events::msg::CallHangUp::Reason::User);
+        bool haveCallInvite() const { return haveCallInvite_; }
         bool isOnCall() const { return session_.state() != webrtc::State::DISCONNECTED; }
-        bool isOnVideoCall() const { return session_.isVideo(); }
+        bool isVideo() const { return isVideo_; }
         webrtc::State callState() const { return session_.state(); }
-        QString callPartyName() const { return callPartyName_; }
+        QString callParty() const { return callParty_; }
         QString callPartyAvatarUrl() const { return callPartyAvatarUrl_; }
         bool isMicMuted() const { return session_.isMicMuted(); }
         bool callsSupported() const;
+        QStringList mics() const { return devices(false); }
+        QStringList cameras() const { return devices(true); }
         void refreshTurnServer();
 
 public slots:
         void syncEvent(const mtx::events::collections::TimelineEvents &event);
         void toggleMicMute();
         void toggleCameraView() { session_.toggleCameraView(); }
+        void acceptInvite();
+        void hangUp(
+          mtx::events::msg::CallHangUp::Reason = mtx::events::msg::CallHangUp::Reason::User);
 
 signals:
         void newMessage(const QString &roomid, const mtx::events::msg::CallInvite &);
         void newMessage(const QString &roomid, const mtx::events::msg::CallCandidates &);
         void newMessage(const QString &roomid, const mtx::events::msg::CallAnswer &);
         void newMessage(const QString &roomid, const mtx::events::msg::CallHangUp &);
+        void newInviteState();
         void newCallState();
-        void newVideoCallState();
-        void newCallParty();
         void micMuteChanged();
+        void devicesChanged();
         void turnServerRetrieved(const mtx::responses::TurnServer &);
 
 private slots:
@@ -66,10 +74,13 @@ private slots:
 private:
         WebRTCSession &session_;
         QString roomid_;
-        QString callPartyName_;
+        QString callParty_;
         QString callPartyAvatarUrl_;
         std::string callid_;
         const uint32_t timeoutms_ = 120000;
+        bool isVideo_             = false;
+        bool haveCallInvite_      = false;
+        std::string inviteSDP_;
         std::vector<mtx::events::msg::CallCandidates::Candidate> remoteICECandidates_;
         std::vector<std::string> turnURIs_;
         QTimer turnServerTimer_;
@@ -83,6 +94,7 @@ private:
         void handleEvent(const mtx::events::RoomEvent<mtx::events::msg::CallHangUp> &);
         void answerInvite(const mtx::events::msg::CallInvite &, bool isVideo);
         void generateCallID();
+        QStringList devices(bool isVideo) const;
         void clear();
         void endCall();
         void playRingtone(const QUrl &ringtone, bool repeat);