mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-29 14:18:49 +03:00
Merge pull request #1110 from r0hit05/msc2746
Update namespace for call events
This commit is contained in:
commit
4b68fc9271
14 changed files with 98 additions and 79 deletions
|
@ -581,7 +581,7 @@ if(USE_BUNDLED_MTXCLIENT)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
MatrixClient
|
MatrixClient
|
||||||
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
|
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
|
||||||
GIT_TAG 6f908f379c6d7afb6117baee3a59c6f5e3adfdda
|
GIT_TAG c2824dae5050882872a6c3f5677f3309a60511be
|
||||||
)
|
)
|
||||||
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
|
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
|
||||||
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
|
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
|
||||||
|
|
|
@ -203,7 +203,7 @@ modules:
|
||||||
buildsystem: cmake-ninja
|
buildsystem: cmake-ninja
|
||||||
name: mtxclient
|
name: mtxclient
|
||||||
sources:
|
sources:
|
||||||
- commit: 6f908f379c6d7afb6117baee3a59c6f5e3adfdda
|
- commit: c2824dae5050882872a6c3f5677f3309a60511be
|
||||||
#tag: v0.7.0
|
#tag: v0.7.0
|
||||||
type: git
|
type: git
|
||||||
url: https://github.com/Nheko-Reborn/mtxclient.git
|
url: https://github.com/Nheko-Reborn/mtxclient.git
|
||||||
|
|
|
@ -1639,18 +1639,18 @@ isMessage(const mtx::events::EncryptedEvent<T> &)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto
|
auto
|
||||||
isMessage(const mtx::events::RoomEvent<mtx::events::msg::CallInvite> &)
|
isMessage(const mtx::events::RoomEvent<mtx::events::voip::CallInvite> &)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto
|
auto
|
||||||
isMessage(const mtx::events::RoomEvent<mtx::events::msg::CallAnswer> &)
|
isMessage(const mtx::events::RoomEvent<mtx::events::voip::CallAnswer> &)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
auto
|
auto
|
||||||
isMessage(const mtx::events::RoomEvent<mtx::events::msg::CallHangUp> &)
|
isMessage(const mtx::events::RoomEvent<mtx::events::voip::CallHangUp> &)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,10 +247,10 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QObject *parent)
|
||||||
},
|
},
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
connectCallMessage<mtx::events::msg::CallInvite>();
|
connectCallMessage<mtx::events::voip::CallInvite>();
|
||||||
connectCallMessage<mtx::events::msg::CallCandidates>();
|
connectCallMessage<mtx::events::voip::CallCandidates>();
|
||||||
connectCallMessage<mtx::events::msg::CallAnswer>();
|
connectCallMessage<mtx::events::voip::CallAnswer>();
|
||||||
connectCallMessage<mtx::events::msg::CallHangUp>();
|
connectCallMessage<mtx::events::voip::CallHangUp>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -75,9 +75,9 @@ struct CallType
|
||||||
template<class T>
|
template<class T>
|
||||||
std::string operator()(const T &e)
|
std::string operator()(const T &e)
|
||||||
{
|
{
|
||||||
if constexpr (std::is_same_v<mtx::events::RoomEvent<mtx::events::msg::CallInvite>, T>) {
|
if constexpr (std::is_same_v<mtx::events::RoomEvent<mtx::events::voip::CallInvite>, T>) {
|
||||||
const char video[] = "m=video";
|
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(),
|
return std::search(sdp.cbegin(),
|
||||||
sdp.cend(),
|
sdp.cend(),
|
||||||
std::cbegin(video),
|
std::cbegin(video),
|
||||||
|
|
|
@ -209,9 +209,9 @@ utils::getMessageDescription(const TimelineEvent &event,
|
||||||
using Notice = mtx::events::RoomEvent<mtx::events::msg::Notice>;
|
using Notice = mtx::events::RoomEvent<mtx::events::msg::Notice>;
|
||||||
using Text = mtx::events::RoomEvent<mtx::events::msg::Text>;
|
using Text = mtx::events::RoomEvent<mtx::events::msg::Text>;
|
||||||
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
||||||
using CallInvite = mtx::events::RoomEvent<mtx::events::msg::CallInvite>;
|
using CallInvite = mtx::events::RoomEvent<mtx::events::voip::CallInvite>;
|
||||||
using CallAnswer = mtx::events::RoomEvent<mtx::events::msg::CallAnswer>;
|
using CallAnswer = mtx::events::RoomEvent<mtx::events::voip::CallAnswer>;
|
||||||
using CallHangUp = mtx::events::RoomEvent<mtx::events::msg::CallHangUp>;
|
using CallHangUp = mtx::events::RoomEvent<mtx::events::voip::CallHangUp>;
|
||||||
using Encrypted = mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>;
|
using Encrypted = mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>;
|
||||||
|
|
||||||
if (std::holds_alternative<Audio>(event)) {
|
if (std::holds_alternative<Audio>(event)) {
|
||||||
|
|
|
@ -107,9 +107,9 @@ messageDescription(const QString &username = QString(),
|
||||||
using Sticker = mtx::events::Sticker;
|
using Sticker = mtx::events::Sticker;
|
||||||
using Text = mtx::events::RoomEvent<mtx::events::msg::Text>;
|
using Text = mtx::events::RoomEvent<mtx::events::msg::Text>;
|
||||||
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
||||||
using CallInvite = mtx::events::RoomEvent<mtx::events::msg::CallInvite>;
|
using CallInvite = mtx::events::RoomEvent<mtx::events::voip::CallInvite>;
|
||||||
using CallAnswer = mtx::events::RoomEvent<mtx::events::msg::CallAnswer>;
|
using CallAnswer = mtx::events::RoomEvent<mtx::events::voip::CallAnswer>;
|
||||||
using CallHangUp = mtx::events::RoomEvent<mtx::events::msg::CallHangUp>;
|
using CallHangUp = mtx::events::RoomEvent<mtx::events::voip::CallHangUp>;
|
||||||
using Encrypted = mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>;
|
using Encrypted = mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>;
|
||||||
|
|
||||||
if (std::is_same<T, Audio>::value) {
|
if (std::is_same<T, Audio>::value) {
|
||||||
|
|
|
@ -121,20 +121,20 @@ struct RoomEventType
|
||||||
{
|
{
|
||||||
return qml_mtx_events::EventType::Redacted;
|
return qml_mtx_events::EventType::Redacted;
|
||||||
}
|
}
|
||||||
qml_mtx_events::EventType operator()(const mtx::events::Event<mtx::events::msg::CallInvite> &)
|
qml_mtx_events::EventType operator()(const mtx::events::Event<mtx::events::voip::CallInvite> &)
|
||||||
{
|
{
|
||||||
return qml_mtx_events::EventType::CallInvite;
|
return qml_mtx_events::EventType::CallInvite;
|
||||||
}
|
}
|
||||||
qml_mtx_events::EventType operator()(const mtx::events::Event<mtx::events::msg::CallAnswer> &)
|
qml_mtx_events::EventType operator()(const mtx::events::Event<mtx::events::voip::CallAnswer> &)
|
||||||
{
|
{
|
||||||
return qml_mtx_events::EventType::CallAnswer;
|
return qml_mtx_events::EventType::CallAnswer;
|
||||||
}
|
}
|
||||||
qml_mtx_events::EventType operator()(const mtx::events::Event<mtx::events::msg::CallHangUp> &)
|
qml_mtx_events::EventType operator()(const mtx::events::Event<mtx::events::voip::CallHangUp> &)
|
||||||
{
|
{
|
||||||
return qml_mtx_events::EventType::CallHangUp;
|
return qml_mtx_events::EventType::CallHangUp;
|
||||||
}
|
}
|
||||||
qml_mtx_events::EventType
|
qml_mtx_events::EventType
|
||||||
operator()(const mtx::events::Event<mtx::events::msg::CallCandidates> &)
|
operator()(const mtx::events::Event<mtx::events::voip::CallCandidates> &)
|
||||||
{
|
{
|
||||||
return qml_mtx_events::EventType::CallCandidates;
|
return qml_mtx_events::EventType::CallCandidates;
|
||||||
}
|
}
|
||||||
|
@ -941,17 +941,17 @@ TimelineModel::addEvents(const mtx::responses::Timeline &timeline)
|
||||||
e = result.event.value();
|
e = result.event.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (std::holds_alternative<RoomEvent<msg::CallCandidates>>(e) ||
|
if (std::holds_alternative<RoomEvent<voip::CallCandidates>>(e) ||
|
||||||
std::holds_alternative<RoomEvent<msg::CallInvite>>(e) ||
|
std::holds_alternative<RoomEvent<voip::CallInvite>>(e) ||
|
||||||
std::holds_alternative<RoomEvent<msg::CallAnswer>>(e) ||
|
std::holds_alternative<RoomEvent<voip::CallAnswer>>(e) ||
|
||||||
std::holds_alternative<RoomEvent<msg::CallHangUp>>(e))
|
std::holds_alternative<RoomEvent<voip::CallHangUp>>(e))
|
||||||
std::visit(
|
std::visit(
|
||||||
[this](auto &event) {
|
[this](auto &event) {
|
||||||
event.room_id = room_id_.toStdString();
|
event.room_id = room_id_.toStdString();
|
||||||
if constexpr (std::is_same_v<std::decay_t<decltype(event)>,
|
if constexpr (std::is_same_v<std::decay_t<decltype(event)>,
|
||||||
RoomEvent<msg::CallAnswer>> ||
|
RoomEvent<voip::CallAnswer>> ||
|
||||||
std::is_same_v<std::decay_t<decltype(event)>,
|
std::is_same_v<std::decay_t<decltype(event)>,
|
||||||
RoomEvent<msg::CallHangUp>>)
|
RoomEvent<voip::CallHangUp>>)
|
||||||
emit newCallEvent(event);
|
emit newCallEvent(event);
|
||||||
else {
|
else {
|
||||||
if (event.sender != http::client()->user_id().to_string())
|
if (event.sender != http::client()->user_id().to_string())
|
||||||
|
@ -1007,18 +1007,18 @@ isMessage(const mtx::events::EncryptedEvent<T> &)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto
|
auto
|
||||||
isMessage(const mtx::events::RoomEvent<mtx::events::msg::CallInvite> &)
|
isMessage(const mtx::events::RoomEvent<mtx::events::voip::CallInvite> &)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto
|
auto
|
||||||
isMessage(const mtx::events::RoomEvent<mtx::events::msg::CallAnswer> &)
|
isMessage(const mtx::events::RoomEvent<mtx::events::voip::CallAnswer> &)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
auto
|
auto
|
||||||
isMessage(const mtx::events::RoomEvent<mtx::events::msg::CallHangUp> &)
|
isMessage(const mtx::events::RoomEvent<mtx::events::voip::CallHangUp> &)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1460,25 +1460,25 @@ struct SendMessageVisitor
|
||||||
emit model_->addPendingMessageToStore(msg);
|
emit model_->addPendingMessageToStore(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(const mtx::events::RoomEvent<mtx::events::msg::CallInvite> &event)
|
void operator()(const mtx::events::RoomEvent<mtx::events::voip::CallInvite> &event)
|
||||||
{
|
{
|
||||||
sendRoomEvent<mtx::events::msg::CallInvite, mtx::events::EventType::CallInvite>(event);
|
sendRoomEvent<mtx::events::voip::CallInvite, mtx::events::EventType::CallInvite>(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(const mtx::events::RoomEvent<mtx::events::msg::CallCandidates> &event)
|
void operator()(const mtx::events::RoomEvent<mtx::events::voip::CallCandidates> &event)
|
||||||
{
|
{
|
||||||
sendRoomEvent<mtx::events::msg::CallCandidates, mtx::events::EventType::CallCandidates>(
|
sendRoomEvent<mtx::events::voip::CallCandidates, mtx::events::EventType::CallCandidates>(
|
||||||
event);
|
event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(const mtx::events::RoomEvent<mtx::events::msg::CallAnswer> &event)
|
void operator()(const mtx::events::RoomEvent<mtx::events::voip::CallAnswer> &event)
|
||||||
{
|
{
|
||||||
sendRoomEvent<mtx::events::msg::CallAnswer, mtx::events::EventType::CallAnswer>(event);
|
sendRoomEvent<mtx::events::voip::CallAnswer, mtx::events::EventType::CallAnswer>(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(const mtx::events::RoomEvent<mtx::events::msg::CallHangUp> &event)
|
void operator()(const mtx::events::RoomEvent<mtx::events::voip::CallHangUp> &event)
|
||||||
{
|
{
|
||||||
sendRoomEvent<mtx::events::msg::CallHangUp, mtx::events::EventType::CallHangUp>(event);
|
sendRoomEvent<mtx::events::voip::CallHangUp, mtx::events::EventType::CallHangUp>(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationRequest> &msg)
|
void operator()(const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationRequest> &msg)
|
||||||
|
|
|
@ -347,7 +347,7 @@ TimelineViewManager::queueReply(const QString &roomid,
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelineViewManager::queueCallMessage(const QString &roomid,
|
TimelineViewManager::queueCallMessage(const QString &roomid,
|
||||||
const mtx::events::msg::CallInvite &callInvite)
|
const mtx::events::voip::CallInvite &callInvite)
|
||||||
{
|
{
|
||||||
if (auto room = rooms_->getRoomById(roomid))
|
if (auto room = rooms_->getRoomById(roomid))
|
||||||
room->sendMessageEvent(callInvite, mtx::events::EventType::CallInvite);
|
room->sendMessageEvent(callInvite, mtx::events::EventType::CallInvite);
|
||||||
|
@ -355,7 +355,7 @@ TimelineViewManager::queueCallMessage(const QString &roomid,
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelineViewManager::queueCallMessage(const QString &roomid,
|
TimelineViewManager::queueCallMessage(const QString &roomid,
|
||||||
const mtx::events::msg::CallCandidates &callCandidates)
|
const mtx::events::voip::CallCandidates &callCandidates)
|
||||||
{
|
{
|
||||||
if (auto room = rooms_->getRoomById(roomid))
|
if (auto room = rooms_->getRoomById(roomid))
|
||||||
room->sendMessageEvent(callCandidates, mtx::events::EventType::CallCandidates);
|
room->sendMessageEvent(callCandidates, mtx::events::EventType::CallCandidates);
|
||||||
|
@ -363,7 +363,7 @@ TimelineViewManager::queueCallMessage(const QString &roomid,
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelineViewManager::queueCallMessage(const QString &roomid,
|
TimelineViewManager::queueCallMessage(const QString &roomid,
|
||||||
const mtx::events::msg::CallAnswer &callAnswer)
|
const mtx::events::voip::CallAnswer &callAnswer)
|
||||||
{
|
{
|
||||||
if (auto room = rooms_->getRoomById(roomid))
|
if (auto room = rooms_->getRoomById(roomid))
|
||||||
room->sendMessageEvent(callAnswer, mtx::events::EventType::CallAnswer);
|
room->sendMessageEvent(callAnswer, mtx::events::EventType::CallAnswer);
|
||||||
|
@ -371,7 +371,7 @@ TimelineViewManager::queueCallMessage(const QString &roomid,
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelineViewManager::queueCallMessage(const QString &roomid,
|
TimelineViewManager::queueCallMessage(const QString &roomid,
|
||||||
const mtx::events::msg::CallHangUp &callHangUp)
|
const mtx::events::voip::CallHangUp &callHangUp)
|
||||||
{
|
{
|
||||||
if (auto room = rooms_->getRoomById(roomid))
|
if (auto room = rooms_->getRoomById(roomid))
|
||||||
room->sendMessageEvent(callHangUp, mtx::events::EventType::CallHangUp);
|
room->sendMessageEvent(callHangUp, mtx::events::EventType::CallHangUp);
|
||||||
|
|
|
@ -105,10 +105,10 @@ public slots:
|
||||||
|
|
||||||
void updateColorPalette();
|
void updateColorPalette();
|
||||||
void queueReply(const QString &roomid, const QString &repliedToEvent, const QString &replyBody);
|
void queueReply(const QString &roomid, const QString &repliedToEvent, const QString &replyBody);
|
||||||
void queueCallMessage(const QString &roomid, const mtx::events::msg::CallInvite &);
|
void queueCallMessage(const QString &roomid, const mtx::events::voip::CallInvite &);
|
||||||
void queueCallMessage(const QString &roomid, const mtx::events::msg::CallCandidates &);
|
void queueCallMessage(const QString &roomid, const mtx::events::voip::CallCandidates &);
|
||||||
void queueCallMessage(const QString &roomid, const mtx::events::msg::CallAnswer &);
|
void queueCallMessage(const QString &roomid, const mtx::events::voip::CallAnswer &);
|
||||||
void queueCallMessage(const QString &roomid, const mtx::events::msg::CallHangUp &);
|
void queueCallMessage(const QString &roomid, const mtx::events::voip::CallHangUp &);
|
||||||
|
|
||||||
void setVideoCallItem();
|
void setVideoCallItem();
|
||||||
|
|
||||||
|
|
|
@ -36,14 +36,16 @@ extern "C"
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(std::vector<mtx::events::msg::CallCandidates::Candidate>)
|
Q_DECLARE_METATYPE(std::vector<mtx::events::voip::CallCandidates::Candidate>)
|
||||||
Q_DECLARE_METATYPE(mtx::events::msg::CallCandidates::Candidate)
|
Q_DECLARE_METATYPE(mtx::events::voip::CallCandidates::Candidate)
|
||||||
Q_DECLARE_METATYPE(mtx::responses::TurnServer)
|
Q_DECLARE_METATYPE(mtx::responses::TurnServer)
|
||||||
|
|
||||||
using namespace mtx::events;
|
using namespace mtx::events;
|
||||||
using namespace mtx::events::msg;
|
using namespace mtx::events::voip;
|
||||||
|
|
||||||
using webrtc::CallType;
|
using webrtc::CallType;
|
||||||
|
//! Session Description Object
|
||||||
|
typedef RTCSessionDescriptionInit SDO;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
std::vector<std::string>
|
std::vector<std::string>
|
||||||
|
@ -55,8 +57,8 @@ CallManager::CallManager(QObject *parent)
|
||||||
, session_(WebRTCSession::instance())
|
, session_(WebRTCSession::instance())
|
||||||
, turnServerTimer_(this)
|
, turnServerTimer_(this)
|
||||||
{
|
{
|
||||||
qRegisterMetaType<std::vector<mtx::events::msg::CallCandidates::Candidate>>();
|
qRegisterMetaType<std::vector<mtx::events::voip::CallCandidates::Candidate>>();
|
||||||
qRegisterMetaType<mtx::events::msg::CallCandidates::Candidate>();
|
qRegisterMetaType<mtx::events::voip::CallCandidates::Candidate>();
|
||||||
qRegisterMetaType<mtx::responses::TurnServer>();
|
qRegisterMetaType<mtx::responses::TurnServer>();
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
|
@ -65,8 +67,10 @@ CallManager::CallManager(QObject *parent)
|
||||||
this,
|
this,
|
||||||
[this](const std::string &sdp, const std::vector<CallCandidates::Candidate> &candidates) {
|
[this](const std::string &sdp, const std::vector<CallCandidates::Candidate> &candidates) {
|
||||||
nhlog::ui()->debug("WebRTC: call id: {} - sending offer", callid_);
|
nhlog::ui()->debug("WebRTC: call id: {} - sending offer", callid_);
|
||||||
emit newMessage(roomid_, CallInvite{callid_, sdp, "0", timeoutms_});
|
emit newMessage(
|
||||||
emit newMessage(roomid_, CallCandidates{callid_, candidates, "0"});
|
roomid_,
|
||||||
|
CallInvite{callid_, partyid_, SDO{sdp, SDO::Type::Offer}, "0", timeoutms_, invitee_});
|
||||||
|
emit newMessage(roomid_, CallCandidates{callid_, partyid_, candidates, "0"});
|
||||||
std::string callid(callid_);
|
std::string callid(callid_);
|
||||||
QTimer::singleShot(timeoutms_, this, [this, callid]() {
|
QTimer::singleShot(timeoutms_, this, [this, callid]() {
|
||||||
if (session_.state() == webrtc::State::OFFERSENT && callid == callid_) {
|
if (session_.state() == webrtc::State::OFFERSENT && callid == callid_) {
|
||||||
|
@ -83,8 +87,8 @@ CallManager::CallManager(QObject *parent)
|
||||||
this,
|
this,
|
||||||
[this](const std::string &sdp, const std::vector<CallCandidates::Candidate> &candidates) {
|
[this](const std::string &sdp, const std::vector<CallCandidates::Candidate> &candidates) {
|
||||||
nhlog::ui()->debug("WebRTC: call id: {} - sending answer", callid_);
|
nhlog::ui()->debug("WebRTC: call id: {} - sending answer", callid_);
|
||||||
emit newMessage(roomid_, CallAnswer{callid_, sdp, "0"});
|
emit newMessage(roomid_, CallAnswer{callid_, partyid_, "0", SDO{sdp, SDO::Type::Answer}});
|
||||||
emit newMessage(roomid_, CallCandidates{callid_, candidates, "0"});
|
emit newMessage(roomid_, CallCandidates{callid_, partyid_, candidates, "0"});
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(&session_,
|
connect(&session_,
|
||||||
|
@ -92,7 +96,7 @@ CallManager::CallManager(QObject *parent)
|
||||||
this,
|
this,
|
||||||
[this](const CallCandidates::Candidate &candidate) {
|
[this](const CallCandidates::Candidate &candidate) {
|
||||||
nhlog::ui()->debug("WebRTC: call id: {} - sending ice candidate", callid_);
|
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);
|
connect(&turnServerTimer_, &QTimer::timeout, this, &CallManager::retrieveTurnServer);
|
||||||
|
@ -223,6 +227,16 @@ callHangUpReasonString(CallHangUp::Reason reason)
|
||||||
return "ICE failed";
|
return "ICE failed";
|
||||||
case CallHangUp::Reason::InviteTimeOut:
|
case CallHangUp::Reason::InviteTimeOut:
|
||||||
return "Invite time out";
|
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:
|
default:
|
||||||
return "User";
|
return "User";
|
||||||
}
|
}
|
||||||
|
@ -235,7 +249,7 @@ CallManager::hangUp(CallHangUp::Reason reason)
|
||||||
if (!callid_.empty()) {
|
if (!callid_.empty()) {
|
||||||
nhlog::ui()->debug(
|
nhlog::ui()->debug(
|
||||||
"WebRTC: call id: {} - hanging up ({})", callid_, callHangUpReasonString(reason));
|
"WebRTC: call id: {} - hanging up ({})", callid_, callHangUpReasonString(reason));
|
||||||
emit newMessage(roomid_, CallHangUp{callid_, "0", reason});
|
emit newMessage(roomid_, CallHangUp{callid_, partyid_, "0", reason});
|
||||||
endCall();
|
endCall();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,7 +281,7 @@ void
|
||||||
CallManager::handleEvent(const RoomEvent<CallInvite> &callInviteEvent)
|
CallManager::handleEvent(const RoomEvent<CallInvite> &callInviteEvent)
|
||||||
{
|
{
|
||||||
const char video[] = "m=video";
|
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(),
|
bool isVideo = std::search(sdp.cbegin(),
|
||||||
sdp.cend(),
|
sdp.cend(),
|
||||||
std::cbegin(video),
|
std::cbegin(video),
|
||||||
|
@ -288,7 +302,8 @@ CallManager::handleEvent(const RoomEvent<CallInvite> &callInviteEvent)
|
||||||
if (isOnCall() || roomInfo.member_count != 2) {
|
if (isOnCall() || roomInfo.member_count != 2) {
|
||||||
emit newMessage(
|
emit newMessage(
|
||||||
QString::fromStdString(callInviteEvent.room_id),
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,7 +326,7 @@ CallManager::handleEvent(const RoomEvent<CallInvite> &callInviteEvent)
|
||||||
|
|
||||||
haveCallInvite_ = true;
|
haveCallInvite_ = true;
|
||||||
callType_ = isVideo ? CallType::VIDEO : CallType::VOICE;
|
callType_ = isVideo ? CallType::VIDEO : CallType::VOICE;
|
||||||
inviteSDP_ = callInviteEvent.content.sdp;
|
inviteSDP_ = callInviteEvent.content.offer.sdp;
|
||||||
emit newInviteState();
|
emit newInviteState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,7 +400,7 @@ CallManager::handleEvent(const RoomEvent<CallAnswer> &callAnswerEvent)
|
||||||
|
|
||||||
if (isOnCall() && callid_ == callAnswerEvent.content.call_id) {
|
if (isOnCall() && callid_ == callAnswerEvent.content.call_id) {
|
||||||
stopRingtone();
|
stopRingtone();
|
||||||
if (!session_.acceptAnswer(callAnswerEvent.content.sdp)) {
|
if (!session_.acceptAnswer(callAnswerEvent.content.answer.sdp)) {
|
||||||
emit ChatPage::instance()->showNotification(QStringLiteral("Problem setting up call."));
|
emit ChatPage::instance()->showNotification(QStringLiteral("Problem setting up call."));
|
||||||
hangUp();
|
hangUp();
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,15 +67,16 @@ public slots:
|
||||||
void toggleMicMute();
|
void toggleMicMute();
|
||||||
void toggleLocalPiP() { session_.toggleLocalPiP(); }
|
void toggleLocalPiP() { session_.toggleLocalPiP(); }
|
||||||
void acceptInvite();
|
void acceptInvite();
|
||||||
void hangUp(mtx::events::msg::CallHangUp::Reason = mtx::events::msg::CallHangUp::Reason::User);
|
void
|
||||||
|
hangUp(mtx::events::voip::CallHangUp::Reason = mtx::events::voip::CallHangUp::Reason::User);
|
||||||
QStringList windowList();
|
QStringList windowList();
|
||||||
void previewWindow(unsigned int windowIndex) const;
|
void previewWindow(unsigned int windowIndex) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void newMessage(const QString &roomid, const mtx::events::msg::CallInvite &);
|
void newMessage(const QString &roomid, const mtx::events::voip::CallInvite &);
|
||||||
void newMessage(const QString &roomid, const mtx::events::msg::CallCandidates &);
|
void newMessage(const QString &roomid, const mtx::events::voip::CallCandidates &);
|
||||||
void newMessage(const QString &roomid, const mtx::events::msg::CallAnswer &);
|
void newMessage(const QString &roomid, const mtx::events::voip::CallAnswer &);
|
||||||
void newMessage(const QString &roomid, const mtx::events::msg::CallHangUp &);
|
void newMessage(const QString &roomid, const mtx::events::voip::CallHangUp &);
|
||||||
void newInviteState();
|
void newInviteState();
|
||||||
void newCallState();
|
void newCallState();
|
||||||
void micMuteChanged();
|
void micMuteChanged();
|
||||||
|
@ -92,11 +93,13 @@ private:
|
||||||
QString callPartyDisplayName_;
|
QString callPartyDisplayName_;
|
||||||
QString callPartyAvatarUrl_;
|
QString callPartyAvatarUrl_;
|
||||||
std::string callid_;
|
std::string callid_;
|
||||||
|
std::string partyid_ = "";
|
||||||
|
std::string invitee_ = "";
|
||||||
const uint32_t timeoutms_ = 120000;
|
const uint32_t timeoutms_ = 120000;
|
||||||
webrtc::CallType callType_ = webrtc::CallType::VOICE;
|
webrtc::CallType callType_ = webrtc::CallType::VOICE;
|
||||||
bool haveCallInvite_ = false;
|
bool haveCallInvite_ = false;
|
||||||
std::string inviteSDP_;
|
std::string inviteSDP_;
|
||||||
std::vector<mtx::events::msg::CallCandidates::Candidate> remoteICECandidates_;
|
std::vector<mtx::events::voip::CallCandidates::Candidate> remoteICECandidates_;
|
||||||
std::vector<std::string> turnURIs_;
|
std::vector<std::string> turnURIs_;
|
||||||
QTimer turnServerTimer_;
|
QTimer turnServerTimer_;
|
||||||
QMediaPlayer player_;
|
QMediaPlayer player_;
|
||||||
|
@ -104,11 +107,11 @@ private:
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool handleEvent(const mtx::events::collections::TimelineEvents &event);
|
bool handleEvent(const mtx::events::collections::TimelineEvents &event);
|
||||||
void handleEvent(const mtx::events::RoomEvent<mtx::events::msg::CallInvite> &);
|
void handleEvent(const mtx::events::RoomEvent<mtx::events::voip::CallInvite> &);
|
||||||
void handleEvent(const mtx::events::RoomEvent<mtx::events::msg::CallCandidates> &);
|
void handleEvent(const mtx::events::RoomEvent<mtx::events::voip::CallCandidates> &);
|
||||||
void handleEvent(const mtx::events::RoomEvent<mtx::events::msg::CallAnswer> &);
|
void handleEvent(const mtx::events::RoomEvent<mtx::events::voip::CallAnswer> &);
|
||||||
void handleEvent(const mtx::events::RoomEvent<mtx::events::msg::CallHangUp> &);
|
void handleEvent(const mtx::events::RoomEvent<mtx::events::voip::CallHangUp> &);
|
||||||
void answerInvite(const mtx::events::msg::CallInvite &, bool isVideo);
|
void answerInvite(const mtx::events::voip::CallInvite &, bool isVideo);
|
||||||
void generateCallID();
|
void generateCallID();
|
||||||
QStringList devices(bool isVideo) const;
|
QStringList devices(bool isVideo) const;
|
||||||
void clear();
|
void clear();
|
||||||
|
|
|
@ -105,7 +105,7 @@ WebRTCSession::init(std::string *errorMessage)
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
std::string localsdp_;
|
std::string localsdp_;
|
||||||
std::vector<mtx::events::msg::CallCandidates::Candidate> localcandidates_;
|
std::vector<mtx::events::voip::CallCandidates::Candidate> localcandidates_;
|
||||||
bool haveAudioStream_ = false;
|
bool haveAudioStream_ = false;
|
||||||
bool haveVideoStream_ = false;
|
bool haveVideoStream_ = false;
|
||||||
GstPad *localPiPSinkPad_ = nullptr;
|
GstPad *localPiPSinkPad_ = nullptr;
|
||||||
|
@ -726,7 +726,7 @@ WebRTCSession::acceptAnswer(const std::string &sdp)
|
||||||
|
|
||||||
void
|
void
|
||||||
WebRTCSession::acceptICECandidates(
|
WebRTCSession::acceptICECandidates(
|
||||||
const std::vector<mtx::events::msg::CallCandidates::Candidate> &candidates)
|
const std::vector<mtx::events::voip::CallCandidates::Candidate> &candidates)
|
||||||
{
|
{
|
||||||
if (state_ >= State::INITIATED) {
|
if (state_ >= State::INITIATED) {
|
||||||
for (const auto &c : candidates) {
|
for (const auto &c : candidates) {
|
||||||
|
@ -1151,7 +1151,8 @@ WebRTCSession::acceptAnswer(const std::string &)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
WebRTCSession::acceptICECandidates(const std::vector<mtx::events::msg::CallCandidates::Candidate> &)
|
WebRTCSession::acceptICECandidates(
|
||||||
|
const std::vector<mtx::events::voip::CallCandidates::Candidate> &)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
@ -64,7 +64,7 @@ public:
|
||||||
bool createOffer(webrtc::CallType, uint32_t shareWindowId);
|
bool createOffer(webrtc::CallType, uint32_t shareWindowId);
|
||||||
bool acceptOffer(const std::string &sdp);
|
bool acceptOffer(const std::string &sdp);
|
||||||
bool acceptAnswer(const std::string &sdp);
|
bool acceptAnswer(const std::string &sdp);
|
||||||
void acceptICECandidates(const std::vector<mtx::events::msg::CallCandidates::Candidate> &);
|
void acceptICECandidates(const std::vector<mtx::events::voip::CallCandidates::Candidate> &);
|
||||||
|
|
||||||
bool isMicMuted() const;
|
bool isMicMuted() const;
|
||||||
bool toggleMicMute();
|
bool toggleMicMute();
|
||||||
|
@ -78,10 +78,10 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void offerCreated(const std::string &sdp,
|
void offerCreated(const std::string &sdp,
|
||||||
const std::vector<mtx::events::msg::CallCandidates::Candidate> &);
|
const std::vector<mtx::events::voip::CallCandidates::Candidate> &);
|
||||||
void answerCreated(const std::string &sdp,
|
void answerCreated(const std::string &sdp,
|
||||||
const std::vector<mtx::events::msg::CallCandidates::Candidate> &);
|
const std::vector<mtx::events::voip::CallCandidates::Candidate> &);
|
||||||
void newICECandidate(const mtx::events::msg::CallCandidates::Candidate &);
|
void newICECandidate(const mtx::events::voip::CallCandidates::Candidate &);
|
||||||
void stateChanged(webrtc::State);
|
void stateChanged(webrtc::State);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
Loading…
Reference in a new issue