diff options
author | trilene <trilene@runbox.com> | 2020-09-25 10:26:36 -0400 |
---|---|---|
committer | trilene <trilene@runbox.com> | 2020-09-25 10:26:36 -0400 |
commit | 3f73853e4b71b67ab6c8ced2dd4eb1e7f473025e (patch) | |
tree | 634c964effe292a5f1e093e5179a341e5f10df09 /src | |
parent | clang-format (diff) | |
download | nheko-3f73853e4b71b67ab6c8ced2dd4eb1e7f473025e.tar.xz |
Move ActiveCallBar Qml to separate file
Diffstat (limited to 'src')
-rw-r--r-- | src/CallManager.cpp | 13 | ||||
-rw-r--r-- | src/CallManager.h | 7 | ||||
-rw-r--r-- | src/WebRTCSession.cpp | 15 | ||||
-rw-r--r-- | src/WebRTCSession.h | 3 | ||||
-rw-r--r-- | src/timeline/TimelineViewManager.cpp | 10 | ||||
-rw-r--r-- | src/timeline/TimelineViewManager.h | 15 |
6 files changed, 53 insertions, 10 deletions
diff --git a/src/CallManager.cpp b/src/CallManager.cpp index 2c0f9d5a..b1d1a75a 100644 --- a/src/CallManager.cpp +++ b/src/CallManager.cpp @@ -152,6 +152,12 @@ CallManager::sendInvite(const QString &roomid) generateCallID(); nhlog::ui()->debug("WebRTC: call id: {} - creating invite", callid_); + std::vector<RoomMember> members(cache::getMembers(roomid.toStdString())); + const RoomMember &callee = + members.front().user_id == utils::localUser() ? members.back() : members.front(); + callPartyName_ = callee.display_name.isEmpty() ? callee.user_id : callee.display_name; + callPartyAvatarUrl_ = QString::fromStdString(roomInfo.avatar_url); + emit newCallParty(); playRingtone("qrc:/media/media/ringback.ogg", true); if (!session_.createOffer()) { emit ChatPage::instance()->showNotification("Problem setting up call."); @@ -186,7 +192,7 @@ CallManager::hangUp(CallHangUp::Reason reason) } bool -CallManager::onActiveCall() +CallManager::onActiveCall() const { return session_.state() != webrtc::State::DISCONNECTED; } @@ -252,6 +258,9 @@ CallManager::handleEvent(const RoomEvent<CallInvite> &callInviteEvent) std::vector<RoomMember> members(cache::getMembers(callInviteEvent.room_id)); const RoomMember &caller = members.front().user_id == utils::localUser() ? members.back() : members.front(); + callPartyName_ = caller.display_name.isEmpty() ? caller.user_id : caller.display_name; + callPartyAvatarUrl_ = QString::fromStdString(roomInfo.avatar_url); + emit newCallParty(); auto dialog = new dialogs::AcceptCall(caller.user_id, caller.display_name, QString::fromStdString(roomInfo.name), @@ -364,6 +373,8 @@ void CallManager::clear() { roomid_.clear(); + callPartyName_.clear(); + callPartyAvatarUrl_.clear(); callid_.clear(); remoteICECandidates_.clear(); } diff --git a/src/CallManager.h b/src/CallManager.h index 1de8d2ae..640230a4 100644 --- a/src/CallManager.h +++ b/src/CallManager.h @@ -29,7 +29,9 @@ public: void sendInvite(const QString &roomid); void hangUp( mtx::events::msg::CallHangUp::Reason = mtx::events::msg::CallHangUp::Reason::User); - bool onActiveCall(); + bool onActiveCall() const; + QString callPartyName() const { return callPartyName_; } + QString callPartyAvatarUrl() const { return callPartyAvatarUrl_; } void refreshTurnServer(); public slots: @@ -40,6 +42,7 @@ signals: 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 newCallParty(); void turnServerRetrieved(const mtx::responses::TurnServer &); private slots: @@ -48,6 +51,8 @@ private slots: private: WebRTCSession &session_; QString roomid_; + QString callPartyName_; + QString callPartyAvatarUrl_; std::string callid_; const uint32_t timeoutms_ = 120000; std::vector<mtx::events::msg::CallCandidates::Candidate> remoteICECandidates_; diff --git a/src/WebRTCSession.cpp b/src/WebRTCSession.cpp index b4eaadab..14f17030 100644 --- a/src/WebRTCSession.cpp +++ b/src/WebRTCSession.cpp @@ -636,7 +636,20 @@ WebRTCSession::createPipeline(int opusPayloadType) } bool -WebRTCSession::toggleMuteAudioSource() +WebRTCSession::isMicMuted() const +{ + if (state_ < State::INITIATED) + return false; + + GstElement *srclevel = gst_bin_get_by_name(GST_BIN(pipe_), "srclevel"); + gboolean muted; + g_object_get(srclevel, "mute", &muted, nullptr); + gst_object_unref(srclevel); + return muted; +} + +bool +WebRTCSession::toggleMicMute() { if (state_ < State::INITIATED) return false; diff --git a/src/WebRTCSession.h b/src/WebRTCSession.h index 9593def9..83cabf5c 100644 --- a/src/WebRTCSession.h +++ b/src/WebRTCSession.h @@ -47,7 +47,8 @@ public: bool acceptAnswer(const std::string &sdp); void acceptICECandidates(const std::vector<mtx::events::msg::CallCandidates::Candidate> &); - bool toggleMuteAudioSource(); + bool isMicMuted() const; + bool toggleMicMute(); void end(); void setStunServer(const std::string &stunServer) { stunServer_ = stunServer; } diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index 09ab8cf8..2b453e56 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -7,7 +7,6 @@ #include <QString> #include "BlurhashProvider.h" -#include "CallManager.h" #include "ChatPage.h" #include "ColorImageProvider.h" #include "DelegateChooser.h" @@ -145,6 +144,8 @@ TimelineViewManager::TimelineViewManager(QSharedPointer<UserSettings> userSettin &WebRTCSession::stateChanged, this, &TimelineViewManager::callStateChanged); + connect( + callManager_, &CallManager::newCallParty, this, &TimelineViewManager::callPartyChanged); } void @@ -217,6 +218,13 @@ TimelineViewManager::escapeEmoji(QString str) const } void +TimelineViewManager::toggleMicMute() +{ + WebRTCSession::instance().toggleMicMute(); + emit micMuteChanged(); +} + +void TimelineViewManager::openImageOverlay(QString mxcUrl, QString eventId) const { QQuickImageResponse *imgResponse = diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h index 243927ef..9ff9adac 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h @@ -10,6 +10,7 @@ #include <mtx/responses.hpp> #include "Cache.h" +#include "CallManager.h" #include "Logging.h" #include "TimelineModel.h" #include "Utils.h" @@ -19,7 +20,6 @@ class MxcImageProvider; class BlurhashProvider; -class CallManager; class ColorImageProvider; class UserSettings; class ChatPage; @@ -35,6 +35,9 @@ class TimelineViewManager : public QObject Q_PROPERTY( bool isNarrowView MEMBER isNarrowView_ READ isNarrowView NOTIFY narrowViewChanged) Q_PROPERTY(webrtc::State callState READ callState NOTIFY callStateChanged) + Q_PROPERTY(QString callPartyName READ callPartyName NOTIFY callPartyChanged) + Q_PROPERTY(QString callPartyAvatarUrl READ callPartyAvatarUrl NOTIFY callPartyChanged) + Q_PROPERTY(bool isMicMuted READ isMicMuted NOTIFY micMuteChanged) public: TimelineViewManager(QSharedPointer<UserSettings> userSettings, @@ -51,10 +54,10 @@ public: Q_INVOKABLE bool isInitialSync() const { return isInitialSync_; } bool isNarrowView() const { return isNarrowView_; } webrtc::State callState() const { return WebRTCSession::instance().state(); } - Q_INVOKABLE bool toggleMuteAudioSource() - { - return WebRTCSession::instance().toggleMuteAudioSource(); - } + QString callPartyName() const { return callManager_->callPartyName(); } + QString callPartyAvatarUrl() const { return callManager_->callPartyAvatarUrl(); } + bool isMicMuted() const { return WebRTCSession::instance().isMicMuted(); } + Q_INVOKABLE void toggleMicMute(); Q_INVOKABLE void openImageOverlay(QString mxcUrl, QString eventId) const; Q_INVOKABLE QColor userColor(QString id, QColor background); Q_INVOKABLE QString escapeEmoji(QString str) const; @@ -80,6 +83,8 @@ signals: void showRoomList(); void narrowViewChanged(); void callStateChanged(webrtc::State); + void callPartyChanged(); + void micMuteChanged(); public slots: void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids); |