From 97681ccf648e68d85aea39de22684ff52e9470c8 Mon Sep 17 00:00:00 2001 From: trilene Date: Wed, 29 Jul 2020 18:16:52 -0400 Subject: [PATCH] Remove references to video calls --- src/ActiveCallBar.cpp | 5 +++-- src/CallManager.cpp | 17 +++++++++++++++-- src/ChatPage.cpp | 3 --- src/WebRTCSession.cpp | 18 +++--------------- src/dialogs/PlaceCall.cpp | 6 ------ src/dialogs/PlaceCall.h | 2 -- 6 files changed, 21 insertions(+), 30 deletions(-) diff --git a/src/ActiveCallBar.cpp b/src/ActiveCallBar.cpp index e55b2e8..7f07982 100644 --- a/src/ActiveCallBar.cpp +++ b/src/ActiveCallBar.cpp @@ -110,7 +110,7 @@ ActiveCallBar::setCallParty( const QString &avatarUrl) { callPartyLabel_->setText(" " + - (displayName.isEmpty() ? userid : displayName) + " -"); + (displayName.isEmpty() ? userid : displayName) + " "); if (!avatarUrl.isEmpty()) avatar_->setImage(avatarUrl); @@ -142,7 +142,8 @@ ActiveCallBar::update(WebRTCSession::State state) show(); callStartTime_ = QDateTime::currentSecsSinceEpoch(); timer_->start(1000); - stateLabel_->setText("Voice call:"); + stateLabel_->setPixmap(QIcon(":/icons/icons/ui/place-call.png"). + pixmap(QSize(buttonSize_, buttonSize_))); durationLabel_->setText("00:00"); durationLabel_->show(); break; diff --git a/src/CallManager.cpp b/src/CallManager.cpp index b57ef1b..3ddcc22 100644 --- a/src/CallManager.cpp +++ b/src/CallManager.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -198,12 +199,24 @@ CallManager::handleEvent_(const mtx::events::collections::TimelineEvents &event) void CallManager::handleEvent(const RoomEvent &callInviteEvent) { - nhlog::ui()->debug("WebRTC: call id: {} - incoming CallInvite from {}", - callInviteEvent.content.call_id, callInviteEvent.sender); + const char video[] = "m=video"; + const std::string &sdp = callInviteEvent.content.sdp; + bool isVideo = std::search(sdp.cbegin(), sdp.cend(), std::cbegin(video), std::cend(video) - 1, + [](unsigned char c1, unsigned char c2) {return std::tolower(c1) == std::tolower(c2);}) + != sdp.cend(); + + nhlog::ui()->debug(std::string("WebRTC: call id: {} - incoming ") + (isVideo ? "video" : "voice") + + " CallInvite from {}", callInviteEvent.content.call_id, callInviteEvent.sender); if (callInviteEvent.content.call_id.empty()) return; + if (isVideo) { + emit newMessage(QString::fromStdString(callInviteEvent.room_id), + CallHangUp{callInviteEvent.content.call_id, 0, CallHangUp::Reason::InviteTimeOut}); + return; + } + auto roomInfo = cache::singleRoomInfo(callInviteEvent.room_id); if (onActiveCall() || roomInfo.member_count != 2) { emit newMessage(QString::fromStdString(callInviteEvent.room_id), diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp index b53a576..620c977 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp @@ -479,9 +479,6 @@ ChatPage::ChatPage(QSharedPointer userSettings, QWidget *parent) connect(dialog, &dialogs::PlaceCall::voice, this, [this]() { callManager_.sendInvite(current_room_); }); - /*connect(dialog, &dialogs::PlaceCall::video, this, [this]() { - showNotification("Video calls not yet implemented."); - });*/ utils::centerWidget(dialog, MainWindow::instance()); dialog->show(); } diff --git a/src/WebRTCSession.cpp b/src/WebRTCSession.cpp index 95a9041..9f3b2f7 100644 --- a/src/WebRTCSession.cpp +++ b/src/WebRTCSession.cpp @@ -64,13 +64,13 @@ WebRTCSession::init(std::string *errorMessage) // GStreamer Plugins: // Base: audioconvert, audioresample, opus, playback, volume - // Good: autodetect, rtpmanager, vpx + // Good: autodetect, rtpmanager // Bad: dtls, srtp, webrtc // libnice [GLib]: nice initialised_ = true; std::string strError = gstVersion + ": Missing plugins: "; const gchar *needed[] = {"audioconvert", "audioresample", "autodetect", "dtls", "nice", - "opus", "playback", "rtpmanager", "srtp", "vpx", "volume", "webrtc", nullptr}; + "opus", "playback", "rtpmanager", "srtp", "volume", "webrtc", nullptr}; GstRegistry *registry = gst_registry_get(); for (guint i = 0; i < g_strv_length((gchar**)needed); i++) { GstPlugin *plugin = gst_registry_find_plugin(registry, needed[i]); @@ -462,10 +462,9 @@ linkNewPad(GstElement *decodebin G_GNUC_UNUSED, GstPad *newpad, GstElement *pipe gst_caps_unref(caps); GstPad *queuepad = nullptr; - GstElement *queue = gst_element_factory_make("queue", nullptr); - if (g_str_has_prefix(name, "audio")) { nhlog::ui()->debug("WebRTC: received incoming audio stream"); + GstElement *queue = gst_element_factory_make("queue", nullptr); GstElement *convert = gst_element_factory_make("audioconvert", nullptr); GstElement *resample = gst_element_factory_make("audioresample", nullptr); GstElement *sink = gst_element_factory_make("autoaudiosink", nullptr); @@ -477,17 +476,6 @@ linkNewPad(GstElement *decodebin G_GNUC_UNUSED, GstPad *newpad, GstElement *pipe gst_element_link_many(queue, convert, resample, sink, nullptr); queuepad = gst_element_get_static_pad(queue, "sink"); } - else if (g_str_has_prefix(name, "video")) { - nhlog::ui()->debug("WebRTC: received incoming video stream"); - GstElement *convert = gst_element_factory_make("videoconvert", nullptr); - GstElement *sink = gst_element_factory_make("autovideosink", nullptr); - gst_bin_add_many(GST_BIN(pipe), queue, convert, sink, nullptr); - gst_element_sync_state_with_parent(queue); - gst_element_sync_state_with_parent(convert); - gst_element_sync_state_with_parent(sink); - gst_element_link_many(queue, convert, sink, nullptr); - queuepad = gst_element_get_static_pad(queue, "sink"); - } if (queuepad) { if (GST_PAD_LINK_FAILED(gst_pad_link(newpad, queuepad))) diff --git a/src/dialogs/PlaceCall.cpp b/src/dialogs/PlaceCall.cpp index 9ad1638..81dd85d 100644 --- a/src/dialogs/PlaceCall.cpp +++ b/src/dialogs/PlaceCall.cpp @@ -40,13 +40,11 @@ PlaceCall::PlaceCall( voiceBtn_ = new QPushButton(tr("Voice Call"), this); voiceBtn_->setDefault(true); - //videoBtn_ = new QPushButton(tr("Video Call"), this); cancelBtn_ = new QPushButton(tr("Cancel"), this); buttonLayout->addStretch(1); buttonLayout->addWidget(avatar); buttonLayout->addWidget(voiceBtn_); - //buttonLayout->addWidget(videoBtn_); buttonLayout->addWidget(cancelBtn_); QString name = displayName.isEmpty() ? callee : displayName; @@ -59,10 +57,6 @@ PlaceCall::PlaceCall( emit voice(); emit close(); }); - /*connect(videoBtn_, &QPushButton::clicked, this, [this]() { - emit video(); - emit close(); - });*/ connect(cancelBtn_, &QPushButton::clicked, this, [this]() { emit cancel(); emit close(); diff --git a/src/dialogs/PlaceCall.h b/src/dialogs/PlaceCall.h index 1c157b7..ed6fb75 100644 --- a/src/dialogs/PlaceCall.h +++ b/src/dialogs/PlaceCall.h @@ -21,12 +21,10 @@ public: signals: void voice(); -// void video(); void cancel(); private: QPushButton *voiceBtn_; -// QPushButton *videoBtn_; QPushButton *cancelBtn_; };