From 6663e5683db083ab2def8766e87a5822dd9adbdb Mon Sep 17 00:00:00 2001 From: r0hit05 Date: Mon, 27 Jun 2022 21:39:31 +0530 Subject: Updated call event namespaces to voip --- src/voip/CallManager.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/voip/CallManager.cpp') diff --git a/src/voip/CallManager.cpp b/src/voip/CallManager.cpp index 54d86620..617f687c 100644 --- a/src/voip/CallManager.cpp +++ b/src/voip/CallManager.cpp @@ -36,12 +36,12 @@ extern "C" } #endif -Q_DECLARE_METATYPE(std::vector) -Q_DECLARE_METATYPE(mtx::events::msg::CallCandidates::Candidate) +Q_DECLARE_METATYPE(std::vector) +Q_DECLARE_METATYPE(mtx::events::voip::CallCandidates::Candidate) Q_DECLARE_METATYPE(mtx::responses::TurnServer) using namespace mtx::events; -using namespace mtx::events::msg; +using namespace mtx::events::voip; using webrtc::CallType; @@ -55,8 +55,8 @@ CallManager::CallManager(QObject *parent) , session_(WebRTCSession::instance()) , turnServerTimer_(this) { - qRegisterMetaType>(); - qRegisterMetaType(); + qRegisterMetaType>(); + qRegisterMetaType(); qRegisterMetaType(); connect( -- cgit 1.5.1 From a7bfaa4ef68a599ccaf09491c59b98959d5ae8cd Mon Sep 17 00:00:00 2001 From: r0hit05 Date: Mon, 27 Jun 2022 22:08:02 +0530 Subject: Updated call struct definitions --- src/EventAccessors.cpp | 2 +- src/voip/CallManager.cpp | 31 +++++++++++++++++++++---------- src/voip/CallManager.h | 2 ++ 3 files changed, 24 insertions(+), 11 deletions(-) (limited to 'src/voip/CallManager.cpp') diff --git a/src/EventAccessors.cpp b/src/EventAccessors.cpp index f3cb4f99..659338a0 100644 --- a/src/EventAccessors.cpp +++ b/src/EventAccessors.cpp @@ -77,7 +77,7 @@ struct CallType { if constexpr (std::is_same_v, T>) { const char video[] = "m=video"; - const std::string &sdp = e.content.sdp; + const std::string &sdp = e.content.offer.sdp; return std::search(sdp.cbegin(), sdp.cend(), std::cbegin(video), diff --git a/src/voip/CallManager.cpp b/src/voip/CallManager.cpp index 617f687c..d479a937 100644 --- a/src/voip/CallManager.cpp +++ b/src/voip/CallManager.cpp @@ -44,6 +44,7 @@ using namespace mtx::events; using namespace mtx::events::voip; using webrtc::CallType; +typedef RTCSessionDescriptionInit SDO; namespace { std::vector @@ -65,8 +66,8 @@ CallManager::CallManager(QObject *parent) this, [this](const std::string &sdp, const std::vector &candidates) { nhlog::ui()->debug("WebRTC: call id: {} - sending offer", callid_); - emit newMessage(roomid_, CallInvite{callid_, sdp, "0", timeoutms_}); - emit newMessage(roomid_, CallCandidates{callid_, candidates, "0"}); + emit newMessage(roomid_, CallInvite{callid_, partyid_, SDO{sdp, SDO::Type::Offer}, "0", timeoutms_, invitee_}); + emit newMessage(roomid_, CallCandidates{callid_, partyid_, candidates, "0"}); std::string callid(callid_); QTimer::singleShot(timeoutms_, this, [this, callid]() { if (session_.state() == webrtc::State::OFFERSENT && callid == callid_) { @@ -83,8 +84,8 @@ CallManager::CallManager(QObject *parent) this, [this](const std::string &sdp, const std::vector &candidates) { nhlog::ui()->debug("WebRTC: call id: {} - sending answer", callid_); - emit newMessage(roomid_, CallAnswer{callid_, sdp, "0"}); - emit newMessage(roomid_, CallCandidates{callid_, candidates, "0"}); + emit newMessage(roomid_, CallAnswer{callid_, partyid_, "0", SDO{sdp, SDO::Type::Answer}}); + emit newMessage(roomid_, CallCandidates{callid_, partyid_, candidates, "0"}); }); connect(&session_, @@ -92,7 +93,7 @@ CallManager::CallManager(QObject *parent) this, [this](const CallCandidates::Candidate &candidate) { nhlog::ui()->debug("WebRTC: call id: {} - sending ice candidate", callid_); - emit newMessage(roomid_, CallCandidates{callid_, {candidate}, "0"}); + emit newMessage(roomid_, CallCandidates{callid_, partyid_, {candidate}, "0"}); }); connect(&turnServerTimer_, &QTimer::timeout, this, &CallManager::retrieveTurnServer); @@ -223,6 +224,16 @@ callHangUpReasonString(CallHangUp::Reason reason) return "ICE failed"; case CallHangUp::Reason::InviteTimeOut: return "Invite time out"; + case CallHangUp::Reason::ICETimeOut: + return "ICE time out"; + case CallHangUp::Reason::UserHangUp: + return "User hung up"; + case CallHangUp::Reason::UserMediaFailed: + return "User media failed"; + case CallHangUp::Reason::UserBusy: + return "User busy"; + case CallHangUp::Reason::UnknownError: + return "Unknown error"; default: return "User"; } @@ -235,7 +246,7 @@ CallManager::hangUp(CallHangUp::Reason reason) if (!callid_.empty()) { nhlog::ui()->debug( "WebRTC: call id: {} - hanging up ({})", callid_, callHangUpReasonString(reason)); - emit newMessage(roomid_, CallHangUp{callid_, "0", reason}); + emit newMessage(roomid_, CallHangUp{callid_, partyid_, "0", reason}); endCall(); } } @@ -267,7 +278,7 @@ void CallManager::handleEvent(const RoomEvent &callInviteEvent) { const char video[] = "m=video"; - const std::string &sdp = callInviteEvent.content.sdp; + const std::string &sdp = callInviteEvent.content.offer.sdp; bool isVideo = std::search(sdp.cbegin(), sdp.cend(), std::cbegin(video), @@ -288,7 +299,7 @@ CallManager::handleEvent(const RoomEvent &callInviteEvent) if (isOnCall() || roomInfo.member_count != 2) { emit newMessage( QString::fromStdString(callInviteEvent.room_id), - CallHangUp{callInviteEvent.content.call_id, "0", CallHangUp::Reason::InviteTimeOut}); + CallHangUp{callInviteEvent.content.call_id, partyid_, "0", CallHangUp::Reason::InviteTimeOut}); return; } @@ -311,7 +322,7 @@ CallManager::handleEvent(const RoomEvent &callInviteEvent) haveCallInvite_ = true; callType_ = isVideo ? CallType::VIDEO : CallType::VOICE; - inviteSDP_ = callInviteEvent.content.sdp; + inviteSDP_ = callInviteEvent.content.offer.sdp; emit newInviteState(); } @@ -385,7 +396,7 @@ CallManager::handleEvent(const RoomEvent &callAnswerEvent) if (isOnCall() && callid_ == callAnswerEvent.content.call_id) { stopRingtone(); - if (!session_.acceptAnswer(callAnswerEvent.content.sdp)) { + if (!session_.acceptAnswer(callAnswerEvent.content.answer.sdp)) { emit ChatPage::instance()->showNotification(QStringLiteral("Problem setting up call.")); hangUp(); } diff --git a/src/voip/CallManager.h b/src/voip/CallManager.h index c17182f0..52d33739 100644 --- a/src/voip/CallManager.h +++ b/src/voip/CallManager.h @@ -92,6 +92,8 @@ private: QString callPartyDisplayName_; QString callPartyAvatarUrl_; std::string callid_; + std::string partyid_ = ""; + std::string invitee_ = ""; const uint32_t timeoutms_ = 120000; webrtc::CallType callType_ = webrtc::CallType::VOICE; bool haveCallInvite_ = false; -- cgit 1.5.1 From 4c8ce911bd5c00187740b7d77d20db37faece0be Mon Sep 17 00:00:00 2001 From: r0hit05 Date: Thu, 30 Jun 2022 16:03:44 +0530 Subject: Fixed formatting --- CMakeLists.txt | 4 ++-- io.github.NhekoReborn.Nheko.yaml | 4 ++-- src/voip/CallManager.cpp | 8 ++++++-- src/voip/CallManager.h | 7 ++++--- src/voip/WebRTCSession.cpp | 3 ++- 5 files changed, 16 insertions(+), 10 deletions(-) (limited to 'src/voip/CallManager.cpp') diff --git a/CMakeLists.txt b/CMakeLists.txt index 368843e7..026e3c4b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -580,8 +580,8 @@ if(USE_BUNDLED_MTXCLIENT) include(FetchContent) FetchContent_Declare( MatrixClient - GIT_REPOSITORY https://github.com/r0hit05/mtxclient.git - GIT_TAG 9743ddde60151c2d0e3fd622d5e3fe469813f5d9 + GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git + GIT_TAG c2824dae5050882872a6c3f5677f3309a60511be ) set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "") set(BUILD_LIB_TESTS OFF CACHE INTERNAL "") diff --git a/io.github.NhekoReborn.Nheko.yaml b/io.github.NhekoReborn.Nheko.yaml index 9fbf53da..879043b2 100644 --- a/io.github.NhekoReborn.Nheko.yaml +++ b/io.github.NhekoReborn.Nheko.yaml @@ -203,10 +203,10 @@ modules: buildsystem: cmake-ninja name: mtxclient sources: - - commit: 9743ddde60151c2d0e3fd622d5e3fe469813f5d9 + - commit: c2824dae5050882872a6c3f5677f3309a60511be #tag: v0.7.0 type: git - url: https://github.com/r0hit05/mtxclient.git + url: https://github.com/Nheko-Reborn/mtxclient.git - config-opts: - -DCMAKE_BUILD_TYPE=Release - -DLMDBXX_INCLUDE_DIR=.deps/lmdbxx diff --git a/src/voip/CallManager.cpp b/src/voip/CallManager.cpp index d479a937..14f3adf8 100644 --- a/src/voip/CallManager.cpp +++ b/src/voip/CallManager.cpp @@ -44,6 +44,7 @@ using namespace mtx::events; using namespace mtx::events::voip; using webrtc::CallType; +//! Session Description Object typedef RTCSessionDescriptionInit SDO; namespace { @@ -66,7 +67,9 @@ CallManager::CallManager(QObject *parent) this, [this](const std::string &sdp, const std::vector &candidates) { nhlog::ui()->debug("WebRTC: call id: {} - sending offer", callid_); - emit newMessage(roomid_, CallInvite{callid_, partyid_, SDO{sdp, SDO::Type::Offer}, "0", timeoutms_, invitee_}); + emit newMessage( + roomid_, + CallInvite{callid_, partyid_, SDO{sdp, SDO::Type::Offer}, "0", timeoutms_, invitee_}); emit newMessage(roomid_, CallCandidates{callid_, partyid_, candidates, "0"}); std::string callid(callid_); QTimer::singleShot(timeoutms_, this, [this, callid]() { @@ -299,7 +302,8 @@ CallManager::handleEvent(const RoomEvent &callInviteEvent) if (isOnCall() || roomInfo.member_count != 2) { emit newMessage( QString::fromStdString(callInviteEvent.room_id), - CallHangUp{callInviteEvent.content.call_id, partyid_, "0", CallHangUp::Reason::InviteTimeOut}); + CallHangUp{ + callInviteEvent.content.call_id, partyid_, "0", CallHangUp::Reason::InviteTimeOut}); return; } diff --git a/src/voip/CallManager.h b/src/voip/CallManager.h index 52d33739..16bd9a37 100644 --- a/src/voip/CallManager.h +++ b/src/voip/CallManager.h @@ -67,7 +67,8 @@ public slots: void toggleMicMute(); void toggleLocalPiP() { session_.toggleLocalPiP(); } void acceptInvite(); - void hangUp(mtx::events::voip::CallHangUp::Reason = mtx::events::voip::CallHangUp::Reason::User); + void + hangUp(mtx::events::voip::CallHangUp::Reason = mtx::events::voip::CallHangUp::Reason::User); QStringList windowList(); void previewWindow(unsigned int windowIndex) const; @@ -92,8 +93,8 @@ private: QString callPartyDisplayName_; QString callPartyAvatarUrl_; std::string callid_; - std::string partyid_ = ""; - std::string invitee_ = ""; + std::string partyid_ = ""; + std::string invitee_ = ""; const uint32_t timeoutms_ = 120000; webrtc::CallType callType_ = webrtc::CallType::VOICE; bool haveCallInvite_ = false; diff --git a/src/voip/WebRTCSession.cpp b/src/voip/WebRTCSession.cpp index a99ff5b8..48e878e8 100644 --- a/src/voip/WebRTCSession.cpp +++ b/src/voip/WebRTCSession.cpp @@ -1151,7 +1151,8 @@ WebRTCSession::acceptAnswer(const std::string &) } void -WebRTCSession::acceptICECandidates(const std::vector &) +WebRTCSession::acceptICECandidates( + const std::vector &) {} bool -- cgit 1.5.1