How do I indicate the end of remote candidates?
Asked Answered
C

1

7

For an WebRTC application, I want to signal, that there are no more remote candidates while using Trickle ICE. The W3C WebRTC spec says:

This method can also be used to indicate the end of remote candidates when called with an empty string for the candidate member

and

This can be indicated by calling addIceCandidate with a candidate value whose candidate property is set to an empty string

and

If candidate.candidate is an empty string, process candidate as an end-of-candidates indication

and

If this RTCIceCandidate represents an end-of-candidates indication, candidate is an empty string.

Thus, I tried different methods in Chrome 67, but non of them works:

pc.addIceCandidate('');

TypeError: Failed to execute 'addIceCandidate' on 'RTCPeerConnection': The provided value is not of type '(RTCIceCandidateInit or RTCIceCandidate)'

pc.addIceCandidate({candidate:''});

TypeError: Candidate missing values for both sdpMid and sdpMLineIndex

pc.addIceCandidate(new IceCandidate());

Failed to construct 'RTCIceCandidate': 1 argument required, but only 0 present.

pc.addIceCandidate(new IceCandidate(''));

Failed to construct 'RTCIceCandidate': parameter 1 ('candidateInitDict') is not an object.

pc.addIceCandidate(new IceCandidate({}));

DOMException: Failed to construct 'RTCIceCandidate': The 'candidate' property is not a string, or is empty.

pc.addIceCandidate(new IceCandidate({candidate:''}));

DOMException: Failed to construct 'RTCIceCandidate': The 'candidate' property is not a string, or is empty.

Question: How do I indicate the end of remote candidates?

[EDIT]:

In 2016/2017, it was just null:

The working group decided to keep this special "all gathering is done" null candidate for backwards compatibility"

It seems, that it does not work anymore:

pc.addIceCandidate(null);

TypeError: Candidate missing values for both sdpMid and sdpMLineIndex

pc.addIceCandidate({candidate: null});

TypeError: Candidate missing values for both sdpMid and sdpMLineIndex

Collate answered 1/8, 2018 at 19:43 Comment(0)
M
1

No browser implements the spec and the spec changed opinion a couple of times. https://github.com/webrtc/adapter will ignore addIceCandidate(null) -- which is mostly required in Microsoft Edge.

Mchenry answered 1/8, 2018 at 20:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.