Skip to content

Commit

Permalink
removing premature ending of gathering, now that FF has its gathering…
Browse files Browse the repository at this point in the history
… act together
  • Loading branch information
z-dule committed Oct 10, 2024
1 parent f7bcf71 commit 028e0be
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 48 deletions.
32 changes: 24 additions & 8 deletions src/peerflow/peerflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -1275,7 +1290,7 @@ class AvsPeerConnectionObserver : public webrtc::PeerConnectionObserver {
"no local SDP\n", pf_);
return;
}
#endif
}
}

Expand Down Expand Up @@ -2492,6 +2507,7 @@ int peerflow_handle_offer(struct iflow *iflow,
std::unique_ptr<webrtc::SessionDescriptionInterface> 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",
Expand Down
40 changes: 0 additions & 40 deletions wasm/src/avs_pc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ interface PeerConnection {
call_type: number;
sending_video: boolean;
muted: boolean;
cands: any[];
stats: LocalStats;
users: any;
iva: Uint8Array;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 028e0be

Please sign in to comment.