diff --git a/src/call/callmanager.cpp b/src/call/callmanager.cpp index 80347d3c9..dcf3d2248 100644 --- a/src/call/callmanager.cpp +++ b/src/call/callmanager.cpp @@ -254,7 +254,6 @@ void CallManager::handleHangup(NeoChatRoom *room, const Quotient::CallHangupEven if (m_session) { m_session->end(); delete m_session; - m_session = nullptr; } setGlobalState(IDLE); Q_EMIT callEnded(); @@ -279,14 +278,14 @@ void CallManager::acceptCall() m_session = CallSession::acceptCall(m_incomingSdp, m_incomingCandidates, m_cachedTurnUris, m_remoteUser->id(), this); m_participants->clear(); - connect(m_session, &CallSession::stateChanged, this, [this] { + connect(m_session.data(), &CallSession::stateChanged, this, [this] { Q_EMIT stateChanged(); if (state() == CallSession::ICEFAILED) { Q_EMIT callEnded(); } }); // TODO refactor away? m_incomingCandidates.clear(); - connectSingleShot(m_session, &CallSession::answerCreated, this, [this](const QString &_sdp, const QVector &candidates) { + connectSingleShot(m_session.data(), &CallSession::answerCreated, this, [this](const QString &_sdp, const QVector &candidates) { const auto &[uuids, sdp] = mangleSdp(_sdp); QVector> msidToPurpose; for (const auto &uuid : uuids) { @@ -361,7 +360,7 @@ void CallManager::startCall(NeoChatRoom *room) return; } - auto missingPlugins = m_session->missingPlugins(); + auto missingPlugins = CallSession::missingPlugins(); if (!missingPlugins.isEmpty()) { qCCritical(voip) << "Missing GStreamer plugins:" << missingPlugins; Q_EMIT Controller::instance().errorOccured("Missing GStreamer plugins."); @@ -377,6 +376,7 @@ void CallManager::startCall(NeoChatRoom *room) setCallId(generateCallId()); setPartyId(generatePartyId()); + m_participants->clear(); for (const auto &user : m_room->users()) { auto participant = new CallParticipant(m_session); participant->m_user = dynamic_cast(user); @@ -392,7 +392,7 @@ void CallManager::startCall(NeoChatRoom *room) } }); - connectSingleShot(m_session, &CallSession::offerCreated, this, [this](const QString &_sdp, const QVector &candidates) { + connectSingleShot(m_session.data(), &CallSession::offerCreated, this, [this](const QString &_sdp, const QVector &candidates) { const auto &[uuids, sdp] = mangleSdp(_sdp); QVector> msidToPurpose; for (const auto &uuid : uuids) { diff --git a/src/call/callmanager.h b/src/call/callmanager.h index ba1ddfcee..664276d82 100644 --- a/src/call/callmanager.h +++ b/src/call/callmanager.h @@ -134,7 +134,7 @@ private: bool init(); bool m_initialised = false; - CallSession *m_session = nullptr; + QPointer m_session = nullptr; void setLifetime(int lifetime); void setRoom(NeoChatRoom *room); diff --git a/src/call/callsession.cpp b/src/call/callsession.cpp index b8143ca08..139b3395e 100644 --- a/src/call/callsession.cpp +++ b/src/call/callsession.cpp @@ -247,6 +247,7 @@ void onGetStats(GstPromise *promise, gpointer) } } +// TODO port to QTimer? gboolean testPacketLoss(gpointer) { if (!keyFrameRequestData.pipe) { @@ -408,7 +409,6 @@ void iceGatheringStateChanged(GstElement *webrtc, GParamSpec *pspec, gpointer us GstWebRTCICEGatheringState newState; g_object_get(webrtc, "ice-gathering-state", &newState, nullptr); - qWarning() << "ICEGATHERINSTCHANGED" << newState; if (newState == GST_WEBRTC_ICE_GATHERING_STATE_COMPLETE) { qCWarning(voip) << "GstWebRTCICEGatheringState -> Complete"; if (instance->m_isOffering) { @@ -618,10 +618,10 @@ void CallSession::end() { qCDebug(voip) << "Ending Call"; if (m_pipe) { - // TODO: This seems to block forever; I don't see significant problem with not doing it... - // gst_element_set_state(m_pipe, GST_STATE_NULL); + gst_element_set_state(m_pipe, GST_STATE_NULL); gst_object_unref(m_pipe); m_pipe = nullptr; + keyFrameRequestData.pipe = nullptr; if (m_busWatchId) { g_source_remove(m_busWatchId); m_busWatchId = 0; @@ -822,7 +822,7 @@ void CallSession::acceptCandidates(const QVector &candidates) } } -QStringList CallSession::missingPlugins() const +QStringList CallSession::missingPlugins() { GstRegistry *registry = gst_registry_get(); static const QVector videoPlugins = { diff --git a/src/call/callsession.h b/src/call/callsession.h index 621fe5c3c..b407fe534 100644 --- a/src/call/callsession.h +++ b/src/call/callsession.h @@ -65,7 +65,7 @@ public: void renegotiateOffer(const QString &offer, const QString &userId); void setTurnServers(QStringList servers); - QStringList missingPlugins() const; + static QStringList missingPlugins(); CallSession::State state() const; diff --git a/src/qml/Component/Timeline/CallInviteDelegate.qml b/src/qml/Component/Timeline/CallInviteDelegate.qml index 61c94c47c..c67a6e12a 100644 --- a/src/qml/Component/Timeline/CallInviteDelegate.qml +++ b/src/qml/Component/Timeline/CallInviteDelegate.qml @@ -9,6 +9,8 @@ import org.kde.kirigami 2.15 as Kirigami import org.kde.neochat 1.0 TimelineContainer { + id: root + width: ListView.view.width innerObject: QQC2.Control { @@ -16,7 +18,7 @@ TimelineContainer { padding: Kirigami.Units.gridUnit*2 contentItem: QQC2.Label { - text: model.author.isLocalUser ? i18n("Outgoing Call") : i18n("Incoming Call") + text: root.author.isLocalUser ? i18n("Outgoing Call") : i18n("Incoming Call") } } }