Under GStreamer >= 1.17 gather all candidates before sending offer/answer

This commit is contained in:
trilene 2020-08-22 08:18:42 -04:00
parent 1402732b5f
commit 473293b6a5

View file

@ -223,18 +223,19 @@ addLocalICECandidate(GstElement *webrtc G_GNUC_UNUSED,
{ {
nhlog::ui()->debug("WebRTC: local candidate: (m-line:{}):{}", mlineIndex, candidate); nhlog::ui()->debug("WebRTC: local candidate: (m-line:{}):{}", mlineIndex, candidate);
#if GST_CHECK_VERSION(1, 17, 0)
localcandidates_.push_back({"audio", (uint16_t)mlineIndex, candidate});
return;
#else
if (WebRTCSession::instance().state() >= WebRTCSession::State::OFFERSENT) { if (WebRTCSession::instance().state() >= WebRTCSession::State::OFFERSENT) {
emit WebRTCSession::instance().newICECandidate( emit WebRTCSession::instance().newICECandidate(
{"audio", (uint16_t)mlineIndex, candidate}); {"audio", (uint16_t)mlineIndex, candidate});
return; return;
} }
localcandidates_.push_back({"audio", (uint16_t)mlineIndex, candidate});
// GStreamer v1.16: webrtcbin's notify::ice-gathering-state triggers // GStreamer v1.16: webrtcbin's notify::ice-gathering-state triggers
// GST_WEBRTC_ICE_GATHERING_STATE_COMPLETE too early. Fixed in v1.17. // GST_WEBRTC_ICE_GATHERING_STATE_COMPLETE too early. Fixed in v1.17.
// Use a 100ms timeout in the meantime // Use a 100ms timeout in the meantime
#if !GST_CHECK_VERSION(1, 17, 0)
static guint timerid = 0; static guint timerid = 0;
if (timerid) if (timerid)
g_source_remove(timerid); g_source_remove(timerid);
@ -447,6 +448,7 @@ WebRTCSession::startPipeline(int opusPayloadType)
g_object_set(webrtc_, "stun-server", stunServer_.c_str(), nullptr); g_object_set(webrtc_, "stun-server", stunServer_.c_str(), nullptr);
} }
for (const auto &uri : turnServers_) { for (const auto &uri : turnServers_) {
nhlog::ui()->info("WebRTC: setting TURN server: {}", uri); nhlog::ui()->info("WebRTC: setting TURN server: {}", uri);
gboolean udata; gboolean udata;