From ac48c332867e773e0e0eb9ad0139b7b625e26851 Mon Sep 17 00:00:00 2001 From: Rohit Sutradhar Date: Fri, 14 Oct 2022 19:19:05 +0530 Subject: VoIP v1 implementation (#1161) * Initial commit for VoIP v1 implementation * Added draft of event handlers for voip methods * Added event handlers for VoIP events, added rejectCall, added version tracking for call version for V0 and V1 compatibility * Added call events to the general message pipeline. Modified Call Reject mechanism * Added message delegates for new events. Modified hidden events. Updated handle events. * Updated implementation to keep track of calls on other devices * Fixed linting * Fixed code warnings * Fixed minor bugs * fixed ci * Added acceptNegotiation method definition when missing gstreamer * Fixed warnings * Fixed linting --- src/Cache.cpp | 17 ++ src/ChatPage.cpp | 3 + src/PowerlevelsEditModels.cpp | 2 + src/Utils.cpp | 3 + src/Utils.h | 7 + src/timeline/TimelineModel.cpp | 65 +++++- src/timeline/TimelineModel.h | 6 + src/timeline/TimelineViewManager.cpp | 22 ++ src/timeline/TimelineViewManager.h | 3 + src/ui/HiddenEvents.cpp | 11 + src/voip/CallManager.cpp | 402 ++++++++++++++++++++++++++++++----- src/voip/CallManager.h | 37 +++- src/voip/WebRTCSession.cpp | 15 ++ src/voip/WebRTCSession.h | 1 + 14 files changed, 521 insertions(+), 73 deletions(-) (limited to 'src') diff --git a/src/Cache.cpp b/src/Cache.cpp index 863f0683..a83b73f7 100644 --- a/src/Cache.cpp +++ b/src/Cache.cpp @@ -184,8 +184,18 @@ Cache::isHiddenEvent(lmdb::txn &txn, hiddenEvents.hidden_event_types = std::vector{ EventType::Reaction, EventType::CallCandidates, + EventType::CallNegotiate, EventType::Unsupported, }; + // check if selected answer is from to local user + /* + * localUser accepts/rejects the call and it is selected by caller - No message + * Another User accepts/rejects the call and it is selected by caller - "Call answered/rejected + * elsewhere" + */ + bool callLocalUser_ = true; + if (callLocalUser_) + hiddenEvents.hidden_event_types->push_back(EventType::CallSelectAnswer); if (auto temp = getAccountData(txn, mtx::events::EventType::NhekoHiddenEvents, "")) { auto h = std::get< @@ -1661,11 +1671,18 @@ isMessage(const mtx::events::RoomEvent &) { return true; } + auto isMessage(const mtx::events::RoomEvent &) { return true; } + +// auto +// isMessage(const mtx::events::RoomEvent &) +// { +// return true; +// } } void diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index 3736ec6b..756ef425 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -363,6 +363,9 @@ ChatPage::ChatPage(QSharedPointer userSettings, QObject *parent) connectCallMessage(); connectCallMessage(); connectCallMessage(); + connectCallMessage(); + connectCallMessage(); + connectCallMessage(); } void diff --git a/src/PowerlevelsEditModels.cpp b/src/PowerlevelsEditModels.cpp index 8cc2dcc0..2c2d4a7f 100644 --- a/src/PowerlevelsEditModels.cpp +++ b/src/PowerlevelsEditModels.cpp @@ -222,6 +222,8 @@ PowerlevelsTypeListModel::data(const QModelIndex &index, int role) const return tr("Answer a call"); else if (type.type == "m.call.hangup") return tr("Hang up a call"); + else if (type.type == "m.call.reject") + return tr("Reject a call"); else if (type.type == "im.ponies.room_emotes") return tr("Change the room emotes"); return QString::fromStdString(type.type); diff --git a/src/Utils.cpp b/src/Utils.cpp index cedf537a..b92c6cce 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -219,6 +219,7 @@ utils::getMessageDescription(const TimelineEvent &event, using CallInvite = mtx::events::RoomEvent; using CallAnswer = mtx::events::RoomEvent; using CallHangUp = mtx::events::RoomEvent; + using CallReject = mtx::events::RoomEvent; using Encrypted = mtx::events::EncryptedEvent; if (std::holds_alternative