Send ICE candidates gathered after timeout

This commit is contained in:
trilene 2020-07-23 17:58:22 -04:00
parent 7377215d28
commit d508e3abd6
3 changed files with 17 additions and 2 deletions

View file

@ -15,6 +15,7 @@
#include "dialogs/AcceptCall.h"
Q_DECLARE_METATYPE(std::vector<mtx::events::msg::CallCandidates::Candidate>)
Q_DECLARE_METATYPE(mtx::events::msg::CallCandidates::Candidate)
Q_DECLARE_METATYPE(mtx::responses::TurnServer)
using namespace mtx::events;
@ -30,11 +31,12 @@ CallManager::CallManager(QSharedPointer<UserSettings> userSettings)
settings_(userSettings)
{
qRegisterMetaType<std::vector<mtx::events::msg::CallCandidates::Candidate>>();
qRegisterMetaType<mtx::events::msg::CallCandidates::Candidate>();
qRegisterMetaType<mtx::responses::TurnServer>();
connect(&session_, &WebRTCSession::offerCreated, this,
[this](const std::string &sdp,
const std::vector<mtx::events::msg::CallCandidates::Candidate>& candidates)
const std::vector<CallCandidates::Candidate> &candidates)
{
nhlog::ui()->debug("Offer created with callid_ and roomid_: {} {}", callid_, roomid_.toStdString());
emit newMessage(roomid_, CallInvite{callid_, sdp, 0, timeoutms_});
@ -43,13 +45,20 @@ CallManager::CallManager(QSharedPointer<UserSettings> userSettings)
connect(&session_, &WebRTCSession::answerCreated, this,
[this](const std::string &sdp,
const std::vector<mtx::events::msg::CallCandidates::Candidate>& candidates)
const std::vector<CallCandidates::Candidate> &candidates)
{
nhlog::ui()->debug("Answer created with callid_ and roomid_: {} {}", callid_, roomid_.toStdString());
emit newMessage(roomid_, CallAnswer{callid_, sdp, 0});
emit newMessage(roomid_, CallCandidates{callid_, candidates, 0});
});
connect(&session_, &WebRTCSession::newICECandidate, this,
[this](const CallCandidates::Candidate &candidate)
{
nhlog::ui()->debug("New ICE candidate created with callid_ and roomid_: {} {}", callid_, roomid_.toStdString());
emit newMessage(roomid_, CallCandidates{callid_, {candidate}, 0});
});
connect(&turnServerTimer_, &QTimer::timeout, this, &CallManager::retrieveTurnServer);
turnServerTimer_.start(2000);

View file

@ -358,6 +358,11 @@ setLocalDescription(GstPromise *promise, gpointer webrtc)
void
addLocalICECandidate(GstElement *webrtc G_GNUC_UNUSED, guint mlineIndex, gchar *candidate, gpointer G_GNUC_UNUSED)
{
if (WebRTCSession::instance().state() == WebRTCSession::State::CONNECTED) {
emit WebRTCSession::instance().newICECandidate({"audio", (uint16_t)mlineIndex, candidate});
return;
}
gcandidates.push_back({"audio", (uint16_t)mlineIndex, candidate});
// GStreamer v1.16: webrtcbin's notify::ice-gathering-state triggers GST_WEBRTC_ICE_GATHERING_STATE_COMPLETE too early

View file

@ -46,6 +46,7 @@ public:
signals:
void offerCreated(const std::string &sdp, const std::vector<mtx::events::msg::CallCandidates::Candidate>&);
void answerCreated(const std::string &sdp, const std::vector<mtx::events::msg::CallCandidates::Candidate>&);
void newICECandidate(const mtx::events::msg::CallCandidates::Candidate&);
void stateChanged(WebRTCSession::State); // explicit qualifier necessary for Qt
private slots: