From 473293b6a5d06e670065dd4d35af0e456621e9e6 Mon Sep 17 00:00:00 2001 From: trilene Date: Sat, 22 Aug 2020 08:18:42 -0400 Subject: Under GStreamer >= 1.17 gather all candidates before sending offer/answer --- src/WebRTCSession.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/WebRTCSession.cpp') diff --git a/src/WebRTCSession.cpp b/src/WebRTCSession.cpp index 2248fb1a..b4e7eeb3 100644 --- a/src/WebRTCSession.cpp +++ b/src/WebRTCSession.cpp @@ -223,18 +223,19 @@ addLocalICECandidate(GstElement *webrtc G_GNUC_UNUSED, { 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) { emit WebRTCSession::instance().newICECandidate( {"audio", (uint16_t)mlineIndex, candidate}); return; } - localcandidates_.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. Fixed in v1.17. // Use a 100ms timeout in the meantime -#if !GST_CHECK_VERSION(1, 17, 0) static guint timerid = 0; if (timerid) g_source_remove(timerid); @@ -447,6 +448,7 @@ WebRTCSession::startPipeline(int opusPayloadType) g_object_set(webrtc_, "stun-server", stunServer_.c_str(), nullptr); } + for (const auto &uri : turnServers_) { nhlog::ui()->info("WebRTC: setting TURN server: {}", uri); gboolean udata; -- cgit 1.5.1 From 67a6ab401b90445169ae35a4107a9973474f8073 Mon Sep 17 00:00:00 2001 From: trilene Date: Fri, 28 Aug 2020 10:49:39 -0400 Subject: Link GStreamer elements before syncing state --- src/WebRTCSession.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/WebRTCSession.cpp') diff --git a/src/WebRTCSession.cpp b/src/WebRTCSession.cpp index b4e7eeb3..f5dc49d8 100644 --- a/src/WebRTCSession.cpp +++ b/src/WebRTCSession.cpp @@ -283,11 +283,11 @@ linkNewPad(GstElement *decodebin G_GNUC_UNUSED, GstPad *newpad, GstElement *pipe GstElement *resample = gst_element_factory_make("audioresample", nullptr); GstElement *sink = gst_element_factory_make("autoaudiosink", nullptr); gst_bin_add_many(GST_BIN(pipe), queue, convert, resample, sink, nullptr); + gst_element_link_many(queue, convert, resample, sink, nullptr); gst_element_sync_state_with_parent(queue); gst_element_sync_state_with_parent(convert); gst_element_sync_state_with_parent(resample); gst_element_sync_state_with_parent(sink); - gst_element_link_many(queue, convert, resample, sink, nullptr); queuepad = gst_element_get_static_pad(queue, "sink"); } @@ -448,7 +448,6 @@ WebRTCSession::startPipeline(int opusPayloadType) g_object_set(webrtc_, "stun-server", stunServer_.c_str(), nullptr); } - for (const auto &uri : turnServers_) { nhlog::ui()->info("WebRTC: setting TURN server: {}", uri); gboolean udata; -- cgit 1.5.1 From 7d2844b2b0d3776e3c9e153122fc30861b9ea694 Mon Sep 17 00:00:00 2001 From: trilene Date: Thu, 10 Sep 2020 14:29:25 -0400 Subject: Fix earlier commit when GStreamer < v1.17 --- src/WebRTCSession.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/WebRTCSession.cpp') diff --git a/src/WebRTCSession.cpp b/src/WebRTCSession.cpp index f5dc49d8..96fd8f07 100644 --- a/src/WebRTCSession.cpp +++ b/src/WebRTCSession.cpp @@ -233,6 +233,8 @@ addLocalICECandidate(GstElement *webrtc G_GNUC_UNUSED, return; } + localcandidates_.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. Fixed in v1.17. // Use a 100ms timeout in the meantime -- cgit 1.5.1 From b6563d9ffe36fff46b72c0d0da2104a6aeccadab Mon Sep 17 00:00:00 2001 From: trilene Date: Thu, 10 Sep 2020 14:34:10 -0400 Subject: GStreamer v1.18.0 released --- src/WebRTCSession.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/WebRTCSession.cpp') diff --git a/src/WebRTCSession.cpp b/src/WebRTCSession.cpp index 96fd8f07..1c1d008d 100644 --- a/src/WebRTCSession.cpp +++ b/src/WebRTCSession.cpp @@ -176,7 +176,7 @@ createAnswer(GstPromise *promise, gpointer webrtc) g_signal_emit_by_name(webrtc, "create-answer", nullptr, promise); } -#if GST_CHECK_VERSION(1, 17, 0) +#if GST_CHECK_VERSION(1, 18, 0) void iceGatheringStateChanged(GstElement *webrtc, GParamSpec *pspec G_GNUC_UNUSED, @@ -223,7 +223,7 @@ addLocalICECandidate(GstElement *webrtc G_GNUC_UNUSED, { nhlog::ui()->debug("WebRTC: local candidate: (m-line:{}):{}", mlineIndex, candidate); -#if GST_CHECK_VERSION(1, 17, 0) +#if GST_CHECK_VERSION(1, 18, 0) localcandidates_.push_back({"audio", (uint16_t)mlineIndex, candidate}); return; #else @@ -236,7 +236,7 @@ addLocalICECandidate(GstElement *webrtc G_GNUC_UNUSED, localcandidates_.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. Fixed in v1.17. + // GST_WEBRTC_ICE_GATHERING_STATE_COMPLETE too early. Fixed in v1.18. // Use a 100ms timeout in the meantime static guint timerid = 0; if (timerid) @@ -474,7 +474,7 @@ WebRTCSession::startPipeline(int opusPayloadType) gst_element_set_state(pipe_, GST_STATE_READY); g_signal_connect(webrtc_, "pad-added", G_CALLBACK(addDecodeBin), pipe_); -#if GST_CHECK_VERSION(1, 17, 0) +#if GST_CHECK_VERSION(1, 18, 0) // capture ICE gathering completion g_signal_connect( webrtc_, "notify::ice-gathering-state", G_CALLBACK(iceGatheringStateChanged), nullptr); -- cgit 1.5.1 From 124952a11cdcb5953bca272fd340660ac664909c Mon Sep 17 00:00:00 2001 From: trilene Date: Sun, 13 Sep 2020 10:21:29 -0400 Subject: Ignore empty remote ICE candidates --- src/WebRTCSession.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/WebRTCSession.cpp') diff --git a/src/WebRTCSession.cpp b/src/WebRTCSession.cpp index 1c1d008d..e9822f7d 100644 --- a/src/WebRTCSession.cpp +++ b/src/WebRTCSession.cpp @@ -426,8 +426,12 @@ WebRTCSession::acceptICECandidates( for (const auto &c : candidates) { nhlog::ui()->debug( "WebRTC: remote candidate: (m-line:{}):{}", c.sdpMLineIndex, c.candidate); - g_signal_emit_by_name( - webrtc_, "add-ice-candidate", c.sdpMLineIndex, c.candidate.c_str()); + if (!c.candidate.empty()) { + g_signal_emit_by_name(webrtc_, + "add-ice-candidate", + c.sdpMLineIndex, + c.candidate.c_str()); + } } } } -- cgit 1.5.1