From c461c0aac03d2ee658ad0b449b0da46c929d4401 Mon Sep 17 00:00:00 2001 From: trilene Date: Sat, 20 Feb 2021 17:14:22 -0500 Subject: [PATCH] Require GStreamer 1.18 for voip support --- CMakeLists.txt | 4 +-- resources/qml/MessageInput.qml | 1 - resources/qml/voip/CallInviteBar.qml | 1 - src/CallDevices.cpp | 44 -------------------------- src/CallDevices.h | 1 - src/CallManager.cpp | 1 - src/CallManager.h | 1 - src/UserSettingsPage.cpp | 1 - src/WebRTCSession.cpp | 46 +--------------------------- 9 files changed, 3 insertions(+), 97 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 72190947..7f695bc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -446,11 +446,11 @@ else() endif() include(FindPkgConfig) -pkg_check_modules(GSTREAMER IMPORTED_TARGET gstreamer-sdp-1.0>=1.16 gstreamer-webrtc-1.0>=1.16) +pkg_check_modules(GSTREAMER IMPORTED_TARGET gstreamer-sdp-1.0>=1.18 gstreamer-webrtc-1.0>=1.18) if (TARGET PkgConfig::GSTREAMER) add_feature_info(voip ON "GStreamer found. Call support is enabled automatically.") else() - add_feature_info(voip OFF "GStreamer could not be found on your system. As a consequence call support has been disabled. If you don't want that, make sure gstreamer-sdp-1.0>=1.16 gstreamer-webrtc-1.0>=1.16 can be found via pkgconfig.") + add_feature_info(voip OFF "GStreamer could not be found on your system. As a consequence call support has been disabled. If you don't want that, make sure gstreamer-sdp-1.0>=1.18 gstreamer-webrtc-1.0>=1.18 can be found via pkgconfig.") endif() # single instance functionality diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml index b5c96660..863b09f7 100644 --- a/resources/qml/MessageInput.qml +++ b/resources/qml/MessageInput.qml @@ -44,7 +44,6 @@ Rectangle { } else if (CallManager.isOnCall) { CallManager.hangUp(); } else { - CallManager.refreshDevices(); var dialog = placeCallDialog.createObject(timelineRoot); dialog.open(); } diff --git a/resources/qml/voip/CallInviteBar.qml b/resources/qml/voip/CallInviteBar.qml index bf630e9e..7fc8cd05 100644 --- a/resources/qml/voip/CallInviteBar.qml +++ b/resources/qml/voip/CallInviteBar.qml @@ -75,7 +75,6 @@ Rectangle { ToolTip.visible: hovered ToolTip.text: qsTr("Devices") onClicked: { - CallManager.refreshDevices(); var dialog = devicesDialog.createObject(timelineRoot); dialog.open(); } diff --git a/src/CallDevices.cpp b/src/CallDevices.cpp index 0b9809e5..f182c133 100644 --- a/src/CallDevices.cpp +++ b/src/CallDevices.cpp @@ -152,7 +152,6 @@ addDevice(GstDevice *device) setDefaultDevice(true); } -#if GST_CHECK_VERSION(1, 18, 0) template bool removeDevice(T &sources, GstDevice *device, bool changed) @@ -212,7 +211,6 @@ newBusMessage(GstBus *bus G_GNUC_UNUSED, GstMessage *msg, gpointer user_data G_G } return TRUE; } -#endif template std::vector @@ -257,7 +255,6 @@ tokenise(std::string_view str, char delim) void CallDevices::init() { -#if GST_CHECK_VERSION(1, 18, 0) static GstDeviceMonitor *monitor = nullptr; if (!monitor) { monitor = gst_device_monitor_new(); @@ -278,43 +275,6 @@ CallDevices::init() return; } } -#endif -} - -void -CallDevices::refresh() -{ -#if !GST_CHECK_VERSION(1, 18, 0) - - static GstDeviceMonitor *monitor = nullptr; - if (!monitor) { - monitor = gst_device_monitor_new(); - GstCaps *caps = gst_caps_new_empty_simple("audio/x-raw"); - gst_device_monitor_add_filter(monitor, "Audio/Source", caps); - gst_device_monitor_add_filter(monitor, "Audio/Duplex", caps); - gst_caps_unref(caps); - caps = gst_caps_new_empty_simple("video/x-raw"); - gst_device_monitor_add_filter(monitor, "Video/Source", caps); - gst_device_monitor_add_filter(monitor, "Video/Duplex", caps); - gst_caps_unref(caps); - } - - auto clearDevices = [](auto &sources) { - std::for_each( - sources.begin(), sources.end(), [](auto &s) { gst_object_unref(s.device); }); - sources.clear(); - }; - clearDevices(audioSources_); - clearDevices(videoSources_); - - GList *devices = gst_device_monitor_get_devices(monitor); - if (devices) { - for (GList *l = devices; l != nullptr; l = l->next) - addDevice(GST_DEVICE_CAST(l->data)); - g_list_free(devices); - } - emit devicesChanged(); -#endif } bool @@ -400,10 +360,6 @@ CallDevices::videoDevice(std::pair &resolution, std::pair &f #else -void -CallDevices::refresh() -{} - bool CallDevices::haveMic() const { diff --git a/src/CallDevices.h b/src/CallDevices.h index 2b4129f1..6d9e18c6 100644 --- a/src/CallDevices.h +++ b/src/CallDevices.h @@ -19,7 +19,6 @@ public: return instance; } - void refresh(); bool haveMic() const; bool haveCamera() const; std::vector names(bool isVideo, const std::string &defaultDevice) const; diff --git a/src/CallManager.cpp b/src/CallManager.cpp index 51bb7b33..b920cfed 100644 --- a/src/CallManager.cpp +++ b/src/CallManager.cpp @@ -290,7 +290,6 @@ CallManager::handleEvent(const RoomEvent &callInviteEvent) haveCallInvite_ = true; callType_ = isVideo ? CallType::VIDEO : CallType::VOICE; inviteSDP_ = callInviteEvent.content.sdp; - CallDevices::instance().refresh(); emit newInviteState(); } diff --git a/src/CallManager.h b/src/CallManager.h index ed745b5b..cfc50481 100644 --- a/src/CallManager.h +++ b/src/CallManager.h @@ -59,7 +59,6 @@ public: public slots: void sendInvite(const QString &roomid, webrtc::CallType); void syncEvent(const mtx::events::collections::TimelineEvents &event); - void refreshDevices() { CallDevices::instance().refresh(); } void toggleMicMute(); void toggleCameraView() { session_.toggleCameraView(); } void acceptInvite(); diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index 1dcf9f63..7410e35b 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -1288,7 +1288,6 @@ UserSettingsPage::showEvent(QShowEvent *) timelineMaxWidthSpin_->setValue(settings_->timelineMaxWidth()); privacyScreenTimeout_->setValue(settings_->privacyScreenTimeout()); - CallDevices::instance().refresh(); auto mics = CallDevices::instance().names(false, settings_->microphone().toStdString()); microphoneCombo_->clear(); for (const auto &m : mics) diff --git a/src/WebRTCSession.cpp b/src/WebRTCSession.cpp index 2281145b..c3a28117 100644 --- a/src/WebRTCSession.cpp +++ b/src/WebRTCSession.cpp @@ -174,7 +174,6 @@ createAnswer(GstPromise *promise, gpointer webrtc) g_signal_emit_by_name(webrtc, "create-answer", nullptr, promise); } -#if GST_CHECK_VERSION(1, 18, 0) void iceGatheringStateChanged(GstElement *webrtc, GParamSpec *pspec G_GNUC_UNUSED, @@ -194,23 +193,6 @@ iceGatheringStateChanged(GstElement *webrtc, } } -#else - -gboolean -onICEGatheringCompletion(gpointer timerid) -{ - *(guint *)(timerid) = 0; - if (WebRTCSession::instance().isOffering()) { - emit WebRTCSession::instance().offerCreated(localsdp_, localcandidates_); - emit WebRTCSession::instance().stateChanged(State::OFFERSENT); - } else { - emit WebRTCSession::instance().answerCreated(localsdp_, localcandidates_); - emit WebRTCSession::instance().stateChanged(State::ANSWERSENT); - } - return FALSE; -} -#endif - void addLocalICECandidate(GstElement *webrtc G_GNUC_UNUSED, guint mlineIndex, @@ -218,28 +200,7 @@ addLocalICECandidate(GstElement *webrtc G_GNUC_UNUSED, gpointer G_GNUC_UNUSED) { nhlog::ui()->debug("WebRTC: local candidate: (m-line:{}):{}", mlineIndex, candidate); - -#if GST_CHECK_VERSION(1, 18, 0) localcandidates_.push_back({std::string() /*max-bundle*/, (uint16_t)mlineIndex, candidate}); - return; -#else - if (WebRTCSession::instance().state() >= State::OFFERSENT) { - emit WebRTCSession::instance().newICECandidate( - {std::string() /*max-bundle*/, (uint16_t)mlineIndex, candidate}); - return; - } - - localcandidates_.push_back({std::string() /*max-bundle*/, (uint16_t)mlineIndex, candidate}); - - // GStreamer v1.16: webrtcbin's notify::ice-gathering-state triggers - // GST_WEBRTC_ICE_GATHERING_STATE_COMPLETE too early. Fixed in v1.18. - // Use a 1s timeout in the meantime - static guint timerid = 0; - if (timerid) - g_source_remove(timerid); - - timerid = g_timeout_add(1000, onICEGatheringCompletion, &timerid); -#endif } void @@ -328,7 +289,6 @@ testPacketLoss(gpointer G_GNUC_UNUSED) return FALSE; } -#if GST_CHECK_VERSION(1, 18, 0) void setWaitForKeyFrame(GstBin *decodebin G_GNUC_UNUSED, GstElement *element, gpointer G_GNUC_UNUSED) { @@ -337,7 +297,6 @@ setWaitForKeyFrame(GstBin *decodebin G_GNUC_UNUSED, GstElement *element, gpointe "rtpvp8depay")) g_object_set(element, "wait-for-keyframe", TRUE, nullptr); } -#endif GstElement * newAudioSinkChain(GstElement *pipe) @@ -537,9 +496,7 @@ addDecodeBin(GstElement *webrtc G_GNUC_UNUSED, GstPad *newpad, GstElement *pipe) // hardware decoding needs investigation; eg rendering fails if vaapi plugin installed g_object_set(decodebin, "force-sw-decoders", TRUE, nullptr); g_signal_connect(decodebin, "pad-added", G_CALLBACK(linkNewPad), pipe); -#if GST_CHECK_VERSION(1, 18, 0) g_signal_connect(decodebin, "element-added", G_CALLBACK(setWaitForKeyFrame), nullptr); -#endif gst_bin_add(GST_BIN(pipe), decodebin); gst_element_sync_state_with_parent(decodebin); GstPad *sinkpad = gst_element_get_static_pad(decodebin, "sink"); @@ -810,11 +767,10 @@ WebRTCSession::startPipeline(int opusPayloadType, int vp8PayloadType) gst_element_set_state(pipe_, GST_STATE_READY); g_signal_connect(webrtc_, "pad-added", G_CALLBACK(addDecodeBin), pipe_); -#if GST_CHECK_VERSION(1, 18, 0) // capture ICE gathering completion g_signal_connect( webrtc_, "notify::ice-gathering-state", G_CALLBACK(iceGatheringStateChanged), nullptr); -#endif + // webrtcbin lifetime is the same as that of the pipeline gst_object_unref(webrtc_);