webrtc icon indicating copy to clipboard operation
webrtc copied to clipboard

Implement ICECandidatePoolSize (gathering before SetLocalDescription/SetRemoteDescription)

Open om26er opened this issue 1 year ago • 4 comments

Here is the code

	// Prepare the configuration
	config := webrtc.Configuration{
		ICEServers:           r.iceServers,
		ICECandidatePoolSize: 10,
	}

	// Create a new RTCPeerConnection
	connection, err := webrtc.NewPeerConnection(config)
	if err != nil {
		panic(err)
	}

	connection.OnICECandidate(func(candidate *webrtc.ICECandidate) {
		log.Println(candidate)
	})

It doesn't do anything unless description is set

om26er avatar Aug 29 '24 13:08 om26er

What I expect is the candidates gathering to start even before setting the description.

om26er avatar Aug 29 '24 13:08 om26er

I'm not sure if Pion has a special mode for your expectation. But your expectation is certainly not true for browser implementations. The reason is that before you set any description the implementation doesn't know for how many streams it needs to provide ICE candidates and if bundle is going to be used or not.

I think the more reasonable expectation would be to say that with pools activated there should be a lot less delay in gathering candidates after setting a description, compared to without using an ICE candidate pool.

nils-ohlmeier avatar Aug 29 '24 19:08 nils-ohlmeier

This could be a great optimization! All for adding this @nils-ohlmeier @om26er

To keep things simple we could treate ICECandidatePoolSize as a bool. If != 0 then gather before signaling.

Great first issue for someone to work on!

Sean-Der avatar Oct 07 '24 15:10 Sean-Der

I didn't realize that Pion doesn't have support for ICE candidate pool yet.

Yes having the default pool size be 0 and meaning no gathering before set(Local|Remote)Description makes perfect sense to me. And then an API to set it to some positive number if pooling is desired.

nils-ohlmeier avatar Oct 07 '24 16:10 nils-ohlmeier