diff options
Diffstat (limited to 'lib/room.cpp')
-rw-r--r-- | lib/room.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/lib/room.cpp b/lib/room.cpp index 07c39498..ea1386ad 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -33,6 +33,10 @@ #include "events/roommemberevent.h" #include "events/typingevent.h" #include "events/receiptevent.h" +#include "events/callinviteevent.h" +#include "events/callcandidatesevent.h" +#include "events/callanswerevent.h" +#include "events/callhangupevent.h" #include "events/redactionevent.h" #include "jobs/mediathumbnailjob.h" #include "jobs/downloadfilejob.h" @@ -1289,6 +1293,60 @@ bool isEchoEvent(const RoomEventPtr& le, const PendingEventItem& re) return le->contentJson() == re->contentJson(); } +bool Room::processCall(Room* room, const RoomEvent* event) +{ + if (!room->isCallSupported()) { + qCDebug(MAIN) << "Got call event in room with more then two" + << "members, Ignoring this event!"; + return true; + } + emit callEvent(room, event); + return false; +} + +bool Room::isCallSupported() const +{ + return d->membersMap.size() == 2; +} + +void Room::inviteCall(const QString& callId, const int lifetime, + const QString& sdp) +{ + Q_ASSERT(isCallSupported()); + auto *evt = new CallInviteEvent(callId, lifetime, sdp); + postEvent(evt); +} + +void Room::callCandidates(const QString& callId, + const QJsonArray& candidates) +{ + Q_ASSERT(isCallSupported()); + auto *evt = new CallCandidatesEvent(callId, candidates); + postEvent(evt); +} + +void Room::answerCall(const QString& callId, const int lifetime, + const QString& sdp) +{ + Q_ASSERT(isCallSupported()); + auto *evt = new CallAnswerEvent(callId, lifetime, sdp); + postEvent(evt); +} + +void Room::answerCall(const QString& callId, const QString& sdp) +{ + Q_ASSERT(isCallSupported()); + auto *evt = new CallAnswerEvent(callId, sdp); + postEvent(evt); +} + +void Room::hangupCall(const QString& callId) +{ + Q_ASSERT(isCallSupported()); + auto *evt = new CallHangupEvent(callId); + postEvent(evt); +} + void Room::getPreviousContent(int limit) { d->getPreviousContent(limit); @@ -1764,6 +1822,18 @@ bool Room::processStateEvent(const RoomEvent& e) } return false; } + , [this] (const CallAnswerEvent& evt) { + return processCall(this, &evt); + } + , [this] (const CallCandidatesEvent& evt) { + return processCall(this, &evt); + } + , [this] (const CallHangupEvent& evt) { + return processCall(this, &evt); + } + , [this] (const CallInviteEvent& evt) { + return processCall(this, &evt); + } , [this] (const EncryptionEvent& evt) { d->encryptionAlgorithm = evt.algorithm(); qCDebug(MAIN) << "Encryption switched on in room" << id() |