From 028e0beb1b130a583ebfd79b21c86b8c83839606 Mon Sep 17 00:00:00 2001 From: Dusan Stevanovic Date: Thu, 10 Oct 2024 13:45:44 +0200 Subject: [PATCH] removing premature ending of gathering, now that FF has its gathering act together --- src/peerflow/peerflow.cpp | 32 +++++++++++++++++++++++-------- wasm/src/avs_pc.ts | 40 --------------------------------------- 2 files changed, 24 insertions(+), 48 deletions(-) diff --git a/src/peerflow/peerflow.cpp b/src/peerflow/peerflow.cpp index 5c6956443..91f6f9496 100644 --- a/src/peerflow/peerflow.cpp +++ b/src/peerflow/peerflow.cpp @@ -1253,19 +1253,34 @@ class AvsPeerConnectionObserver : public webrtc::PeerConnectionObserver { virtual void OnIceCandidate(const webrtc::IceCandidateInterface* icand) { std::string cand_str; - const cricket::Candidate& cand = icand->candidate(); + if (!icand) { + const webrtc::SessionDescriptionInterface *isdp; + + info("pf(%p): OnIceCandidate: end-of-candidates\n", pf_); + pf_->gathered = true; + isdp = pf_->peerConn->local_description(); + if (isdp) + invoke_gather(pf_, isdp); + else { + warning("pf(%p): ice candidate " + "no local SDP\n", pf_); + } + return; + } + + const cricket::Candidate& cand = icand->candidate(); + icand->ToString(&cand_str); - info("pf(%p): OnIceCandidate: %s has %d candidates\n", - pf_, cand_str.c_str(), pf_->ncands); + info("pf(%p): OnIceCandidate: %s url=%s has %d candidates\n", + pf_, cand_str.c_str(), icand->server_url().c_str(), pf_->ncands); ++pf_->ncands; - if (!pf_->gathered && cand.type() == std::string("relay")) { - const webrtc::SessionDescriptionInterface *isdp; + if (cand.type() == std::string("relay")) { - info("pf(%p): received first RELAY candidate\n", pf_); - + info("pf(%p): received RELAY candidate\n", pf_); +#if 0 pf_->gathered = true; isdp = pf_->peerConn->local_description(); if (isdp) @@ -1275,7 +1290,7 @@ class AvsPeerConnectionObserver : public webrtc::PeerConnectionObserver { "no local SDP\n", pf_); return; } - +#endif } } @@ -2492,6 +2507,7 @@ int peerflow_handle_offer(struct iflow *iflow, std::unique_ptr sdp = webrtc::CreateSessionDescription(webrtc::SdpType::kOffer, sdp_str, &parse_err); + if (sdp == nullptr) { warning("peerflow_handle_offer: failed to parse SDP: " "line=%s reason=%s\n", diff --git a/wasm/src/avs_pc.ts b/wasm/src/avs_pc.ts index 84b7201f7..5f05a311b 100644 --- a/wasm/src/avs_pc.ts +++ b/wasm/src/avs_pc.ts @@ -68,7 +68,6 @@ interface PeerConnection { call_type: number; sending_video: boolean; muted: boolean; - cands: any[]; stats: LocalStats; users: any; iva: Uint8Array; @@ -1202,44 +1201,6 @@ function candidateHandler(pc: PeerConnection, cand: RTCIceCandidate | null) { return; } - - if (pc_env === ENV_FIREFOX) { - if (mindex != null) { - const cmid = pc.cands[mindex]; - if (!cmid) { - pc_log(LOG_LEVEL_INFO, `candidateHandler: adding mindex=${mindex}`); - pc.cands[mindex] = { - mindex: mindex, - hasRelay: false - } - } - } - } - - if (cand.type === 'relay') { - const sdp = pc.rtc.localDescription; - if (!sdp) { - return; - } - - if (pc_env == ENV_FIREFOX) { - if (mindex != null) { - const rmid = pc.cands[mindex]; - if (rmid) - rmid.hasRelay = true; - } - - for (const cc of pc.cands) { - if (cc && !cc.hasRelay) { - pc_log(LOG_LEVEL_INFO, `candidateHandler: mindex=${cc.mindex} still missing relay`); - return; - } - } - } - - pc_log(LOG_LEVEL_INFO, 'candidateHandler: relay(s) found, finished gathering'); - ccallGatheringHandler(pc, sdp.type.toString(), sdp.sdp.toString()); - } } function connectionHandler(pc: PeerConnection) { @@ -1321,7 +1282,6 @@ function pc_New(self: number, convidPtr: number, call_type: CALL_TYPE_NORMAL, conv_type: CONV_TYPE_ONEONONE, muted: false, - cands: [null, null, null], users: {}, iva: iva8, ivv: ivv8,